Make players mobs too !
This commit is contained in:
+7
-4
@@ -4,6 +4,7 @@ import { LocalPlayer } from "./entity/local_player.ts";
|
||||
import { RemotePlayer } from "./entity/remote_player.ts";
|
||||
import { ItemEntity } from "./entity/item_entity.ts";
|
||||
import { RemoteEntity } from "./entity/remote_entity.ts";
|
||||
import type { Entity } from "./entity/entity.ts";
|
||||
import { Camera } from "./camera.ts";
|
||||
import { Options } from "./options.ts";
|
||||
import { MultiPlayerGameMode } from "./game_mode.ts";
|
||||
@@ -46,8 +47,8 @@ export class Client {
|
||||
screens: GuiScreen[] = [];
|
||||
// what the player is looking at, updated every frame
|
||||
hit_result: BlockHitResult | undefined;
|
||||
// the entity being looked at, closer than any block. hit_result is undefined then
|
||||
entity_hit: RemoteEntity | undefined;
|
||||
// the entity or other player being looked at, closer than any block. hit_result is undefined then
|
||||
entity_hit: Entity | undefined;
|
||||
debugging = false;
|
||||
|
||||
// seconds of game time not ticked yet
|
||||
@@ -255,7 +256,9 @@ export class Client {
|
||||
player.yaw,
|
||||
player.pitch,
|
||||
ENTITY_REACH,
|
||||
(entity) => entity instanceof RemoteEntity && !entity.dead && is_hittable(entity),
|
||||
(entity) =>
|
||||
entity instanceof RemotePlayer ||
|
||||
(entity instanceof RemoteEntity && !entity.dead && is_hittable(entity)),
|
||||
);
|
||||
// a block in front of the entity hides it
|
||||
this.hit_result = this.level.pick(
|
||||
@@ -266,7 +269,7 @@ export class Client {
|
||||
player.pitch,
|
||||
picked?.distance ?? BLOCK_REACH,
|
||||
);
|
||||
this.entity_hit = picked && !this.hit_result ? picked.entity as RemoteEntity : undefined;
|
||||
this.entity_hit = picked && !this.hit_result ? picked.entity : undefined;
|
||||
}
|
||||
|
||||
// clicks happen right away, holding to break advances in tick()
|
||||
|
||||
Reference in New Issue
Block a user