Java源码示例:net.minecraft.client.world.ClientWorld

示例1
@Override
public void onUpdate()
{
	PlayerEntity player = MC.player;
	ClientWorld world = MC.world;
	
	players.clear();
	Stream<AbstractClientPlayerEntity> stream = world.getPlayers()
		.parallelStream().filter(e -> !e.removed && e.getHealth() > 0)
		.filter(e -> e != player)
		.filter(e -> !(e instanceof FakePlayerEntity))
		.filter(e -> Math.abs(e.getY() - MC.player.getY()) <= 1e6);
	
	if(filterSleeping.isChecked())
		stream = stream.filter(e -> !e.isSleeping());
	
	if(filterInvisible.isChecked())
		stream = stream.filter(e -> !e.isInvisible());
	
	players.addAll(stream.collect(Collectors.toList()));
}
 
示例2
private static Entity changeEntityType(Entity entity, EntityType<?> newType) {
    ClientWorld world = (ClientWorld) entity.world;
    Entity destEntity = newType.create(world);
    if (destEntity == null) {
        return entity;
    }

    // copy the entity
    destEntity.fromTag(entity.toTag(new CompoundTag()));
    destEntity.trackedX = entity.trackedX;
    destEntity.trackedY = entity.trackedY;
    destEntity.trackedZ = entity.trackedZ;

    // replace entity in world and exchange entity id
    int entityId = entity.getEntityId();
    world.removeEntity(entityId);
    destEntity.setEntityId(entityId);
    world.addEntity(entityId, destEntity);

    // exchange data tracker (this may be part of a series of data tracker updates, need the same data tracker instance)
    DataTrackerManager.transferDataTracker(entity, destEntity);
    return destEntity;
}
 
示例3
public DrippingFuelParticle(ClientWorld world, double x, double y, double z, double velX, double velY, double velZ) {
    super(world, x, y, z, velX, velY, velZ);
    setSprite(MinecraftClient.getInstance().getItemRenderer().getModels().getSprite(Blocks.ACACIA_LOG.asItem()));
    this.scale *= 0.25f;
    this.velocityX = 0.0f;
    this.velocityY = -0.6f;
    this.velocityZ = 0.0f;
    this.colorRed = 146f / 255f;
    this.colorGreen = 140f / 255f;
    this.colorBlue = 74f / 255f;
    this.colorAlpha = 213f / 255f;
    this.maxAge = (int) (64.0D / (Math.random() * 0.8D + 0.2D));
}
 
示例4
public DrippingCrudeOilParticle(ClientWorld world, double x, double y, double z, double velX, double velY, double velZ) {
    super(world, x, y, z, velX, velY, velZ);
    setSprite(MinecraftClient.getInstance().getItemRenderer().getModels().getSprite(Blocks.ACACIA_LOG.asItem()));
    this.scale *= 0.25f;
    this.velocityX = 0.0f;
    this.velocityY = -0.6f;
    this.velocityZ = 0.0f;
    this.colorRed = 42f / 255f;
    this.colorGreen = 42f / 255f;
    this.colorBlue = 42f / 255f;
    this.colorAlpha = 229f / 255f;
    this.maxAge = (int) (64.0D / (Math.random() * 0.8D + 0.2D));
}
 
示例5
@Redirect(method = "joinWorld(Lnet/minecraft/client/world/ClientWorld;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;reset(Lnet/minecraft/client/gui/screen/Screen;)V", ordinal = 0))
private void redirectReset_joinWorld(MinecraftClient client, Screen screen, ClientWorld world) {
	if (world.getDimension().getType() == HallowedDimensions.THE_HALLOW) {
		reset(new HallowedLoadingScreen());
	} else {
		reset(screen);
	}
}
 
示例6
@Override
public void onUpdate()
{
	ClientPlayerEntity player = MC.player;
	ClientWorld world = MC.world;
	
	entities.clear();
	Stream<Entity> stream =
		StreamSupport.stream(world.getEntities().spliterator(), true)
			.filter(e -> !e.removed && e != player)
			.filter(e -> !(e instanceof FakePlayerEntity))
			.filter(e -> e instanceof LivingEntity)
			.filter(e -> ((LivingEntity)e).getHealth() > 0);
	
	if(filterPlayers.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity));
	
	if(filterSleeping.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity
			&& ((PlayerEntity)e).isSleeping()));
	
	if(filterMonsters.isChecked())
		stream = stream.filter(e -> !(e instanceof Monster));
	
	if(filterAnimals.isChecked())
		stream = stream.filter(
			e -> !(e instanceof AnimalEntity || e instanceof AmbientEntity
				|| e instanceof WaterCreatureEntity));
	
	if(filterInvisible.isChecked())
		stream = stream.filter(e -> !e.isInvisible());
	
	entities.addAll(stream.collect(Collectors.toList()));
}
 
示例7
private FootprintParticle(TextureManager textureManager, ClientWorld world, double x, double y, double z) {
    super(world, x, y, z, 0, 0, 0);
    this.textureManager = textureManager;
    this.velocityX = 0;
    this.velocityY = 0;
    this.velocityZ = 0;
}
 
示例8
@Inject(method = "setBlockStateWithoutNeighborUpdates", at = @At("HEAD"), cancellable = true)
private void onSetBlockWithoutNeighborUpdates(BlockPos pos, BlockState state, CallbackInfo ci) {
    if (ConnectionInfo.protocolVersion <= Protocols.V1_12_2) {
        ((ClientWorld) (Object) this).setBlockState(pos, state);
        ci.cancel();
    }
}
 
示例9
public static void handle(SpawnEntity msg, PacketContext context) {
	PatchworkNetworking.enqueueWork(context.getTaskQueue(), () -> {
		EntityType<?> type = Registry.ENTITY_TYPE.get(msg.typeId);

		if (type.equals(Registry.ENTITY_TYPE.get(Registry.ENTITY_TYPE.getDefaultId()))) {
			throw new RuntimeException(String.format("Could not spawn entity (id %d) with unknown type at (%f, %f, %f)", msg.entityId, msg.posX, msg.posY, msg.posZ));
		}

		ClientWorld world = MinecraftClient.getInstance().world;

		Entity entity = ((ClientEntitySpawner<?>) type).customClientSpawn(msg, world);

		if (entity == null) {
			return;
		}

		entity.updateTrackedPosition(msg.posX, msg.posY, msg.posZ);
		entity.updatePositionAndAngles(msg.posX, msg.posY, msg.posZ, (msg.yaw * 360) / 256.0F, (msg.pitch * 360) / 256.0F);
		entity.setHeadYaw((msg.headYaw * 360) / 256.0F);
		entity.setYaw((msg.headYaw * 360) / 256.0F);

		entity.setEntityId(msg.entityId);
		entity.setUuid(msg.uuid);
		world.addEntity(msg.entityId, entity);
		entity.setVelocity(msg.velX / 8000.0, msg.velY / 8000.0, msg.velZ / 8000.0);

		if (entity instanceof IEntityAdditionalSpawnData) {
			((IEntityAdditionalSpawnData) entity).readSpawnData(msg.buf);
		}
	});
}
 
示例10
private void handleTilePacket(ClientWorld world, PacketCustom packet, BlockPos pos) {
    TileEntity tile = world.getTileEntity(pos);

    if (tile instanceof TileFrequencyOwner) {
        ((TileFrequencyOwner) tile).readFromPacket(packet);
    }
}
 
示例11
private boolean isCorrectEntity(Entity entity)
{
	ClientPlayerEntity player = MC.player;
	ClientWorld world = MC.world;
	
	double rangeSq = Math.pow(range.getValue(), 2);
	Stream<LivingEntity> stream = Stream.of(entity)
		.filter(e -> e instanceof LivingEntity).map(e -> (LivingEntity)e)
		.filter(e -> !e.removed && e.getHealth() > 0)
		.filter(e -> player.squaredDistanceTo(e) <= rangeSq)
		.filter(e -> e != player)
		.filter(e -> !(e instanceof FakePlayerEntity))
		.filter(e -> !WURST.getFriends().contains(e.getEntityName()));
	
	if(filterPlayers.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity));
	
	if(filterSleeping.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity
			&& ((PlayerEntity)e).isSleeping()));
	
	if(filterFlying.getValue() > 0)
		stream = stream.filter(e -> {
			
			if(!(e instanceof PlayerEntity))
				return true;
			
			Box box = e.getBoundingBox();
			box = box.union(box.offset(0, -filterFlying.getValue(), 0));
			return world.doesNotCollide(box);
		});
	
	if(filterMonsters.isChecked())
		stream = stream.filter(e -> !(e instanceof Monster));
	
	if(filterPigmen.isChecked())
		stream = stream.filter(e -> !(e instanceof ZombifiedPiglinEntity));
	
	if(filterEndermen.isChecked())
		stream = stream.filter(e -> !(e instanceof EndermanEntity));
	
	if(filterAnimals.isChecked())
		stream = stream.filter(
			e -> !(e instanceof AnimalEntity || e instanceof AmbientEntity
				|| e instanceof WaterCreatureEntity));
	
	if(filterBabies.isChecked())
		stream = stream.filter(e -> !(e instanceof PassiveEntity
			&& ((PassiveEntity)e).isBaby()));
	
	if(filterPets.isChecked())
		stream = stream
			.filter(e -> !(e instanceof TameableEntity
				&& ((TameableEntity)e).isTamed()))
			.filter(e -> !(e instanceof HorseBaseEntity
				&& ((HorseBaseEntity)e).isTame()));
	
	if(filterVillagers.isChecked())
		stream = stream.filter(e -> !(e instanceof VillagerEntity));
	
	if(filterGolems.isChecked())
		stream = stream.filter(e -> !(e instanceof GolemEntity));
	
	if(filterInvisible.isChecked())
		stream = stream.filter(e -> !e.isInvisible());
	
	return stream.findFirst().isPresent();
}
 
示例12
private void scan()
{
	int minX = chunk.getPos().getStartX();
	int minY = 0;
	int minZ = chunk.getPos().getStartZ();
	int maxX = chunk.getPos().getEndX();
	int maxY = 255;
	int maxZ = chunk.getPos().getEndZ();
	
	ClientWorld world = MC.world;
	ArrayList<BlockPos> blocks = new ArrayList<>();
	
	for(int x = minX; x <= maxX; x++)
		for(int y = minY; y <= maxY; y++)
			for(int z = minZ; z <= maxZ; z++)
			{
				BlockPos pos = new BlockPos(x, y, z);
				BlockState state = world.getBlockState(pos);
				
				if(state.getMaterial().blocksMovement())
					continue;
				if(!state.getFluidState().isEmpty())
					continue;
				
				BlockState stateDown = world.getBlockState(pos.down());
				if(!stateDown.allowsSpawning(world, pos.down(),
					EntityType.ZOMBIE))
					continue;
				
				blocks.add(pos);
			}
		
	if(Thread.interrupted())
		return;
	
	red.addAll(blocks.stream()
		.filter(pos -> world.getLightLevel(LightType.BLOCK, pos) < 8)
		.filter(pos -> world.getLightLevel(LightType.SKY, pos) < 8)
		.collect(Collectors.toList()));
	
	if(Thread.interrupted())
		return;
	
	yellow.addAll(blocks.stream().filter(pos -> !red.contains(pos))
		.filter(pos -> world.getLightLevel(LightType.BLOCK, pos) < 8)
		.collect(Collectors.toList()));
	doneScanning = true;
}
 
示例13
private void attack()
{
	// set entity
	ClientPlayerEntity player = MC.player;
	ClientWorld world = MC.world;
	
	if(player.getAttackCooldownProgress(0) < 1)
		return;
	
	double rangeSq = Math.pow(range.getValue(), 2);
	Stream<LivingEntity> stream = StreamSupport
		.stream(MC.world.getEntities().spliterator(), true)
		.filter(e -> e instanceof LivingEntity).map(e -> (LivingEntity)e)
		.filter(e -> !e.removed && e.getHealth() > 0)
		.filter(e -> player.squaredDistanceTo(e) <= rangeSq)
		.filter(e -> e != player)
		.filter(e -> !(e instanceof FakePlayerEntity))
		.filter(e -> !WURST.getFriends().contains(e.getEntityName()));
	
	if(filterPlayers.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity));
	
	if(filterSleeping.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity
			&& ((PlayerEntity)e).isSleeping()));
	
	if(filterFlying.getValue() > 0)
		stream = stream.filter(e -> {
			
			if(!(e instanceof PlayerEntity))
				return true;
			
			Box box = e.getBoundingBox();
			box = box.union(box.offset(0, -filterFlying.getValue(), 0));
			return world.doesNotCollide(box);
		});
	
	if(filterMonsters.isChecked())
		stream = stream.filter(e -> !(e instanceof Monster));
	
	if(filterPigmen.isChecked())
		stream = stream.filter(e -> !(e instanceof ZombifiedPiglinEntity));
	
	if(filterEndermen.isChecked())
		stream = stream.filter(e -> !(e instanceof EndermanEntity));
	
	if(filterAnimals.isChecked())
		stream = stream.filter(
			e -> !(e instanceof AnimalEntity || e instanceof AmbientEntity
				|| e instanceof WaterCreatureEntity));
	
	if(filterBabies.isChecked())
		stream = stream.filter(e -> !(e instanceof PassiveEntity
			&& ((PassiveEntity)e).isBaby()));
	
	if(filterPets.isChecked())
		stream = stream
			.filter(e -> !(e instanceof TameableEntity
				&& ((TameableEntity)e).isTamed()))
			.filter(e -> !(e instanceof HorseBaseEntity
				&& ((HorseBaseEntity)e).isTame()));
	
	if(filterVillagers.isChecked())
		stream = stream.filter(e -> !(e instanceof VillagerEntity));
	
	if(filterGolems.isChecked())
		stream = stream.filter(e -> !(e instanceof GolemEntity));
	
	if(filterInvisible.isChecked())
		stream = stream.filter(e -> !e.isInvisible());
	
	LivingEntity target =
		stream.min(priority.getSelected().comparator).orElse(null);
	if(target == null)
		return;
	
	WURST.getHax().autoSwordHack.setSlot();
	
	// face entity
	Rotation rotation = RotationUtils
		.getNeededRotations(target.getBoundingBox().getCenter());
	PlayerMoveC2SPacket.LookOnly packet = new PlayerMoveC2SPacket.LookOnly(
		rotation.getYaw(), rotation.getPitch(), MC.player.isOnGround());
	MC.player.networkHandler.sendPacket(packet);
	
	// attack entity
	MC.interactionManager.attackEntity(player, target);
	player.swingHand(Hand.MAIN_HAND);
}
 
示例14
@Override
public void onUpdate()
{
	ClientPlayerEntity player = MC.player;
	ClientWorld world = MC.world;
	
	if(player.getAttackCooldownProgress(0) < 1)
		return;
	
	double rangeSq = Math.pow(range.getValue(), 2);
	Stream<LivingEntity> stream = StreamSupport
		.stream(MC.world.getEntities().spliterator(), true)
		.filter(e -> e instanceof LivingEntity).map(e -> (LivingEntity)e)
		.filter(e -> !e.removed && e.getHealth() > 0)
		.filter(e -> player.squaredDistanceTo(e) <= rangeSq)
		.filter(e -> e != player)
		.filter(e -> !(e instanceof FakePlayerEntity))
		.filter(e -> !WURST.getFriends().contains(e.getEntityName()));
	
	if(filterPlayers.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity));
	
	if(filterSleeping.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity
			&& ((PlayerEntity)e).isSleeping()));
	
	if(filterFlying.getValue() > 0)
		stream = stream.filter(e -> {
			
			if(!(e instanceof PlayerEntity))
				return true;
			
			Box box = e.getBoundingBox();
			box = box.union(box.offset(0, -filterFlying.getValue(), 0));
			return world.doesNotCollide(box);
		});
	
	if(filterMonsters.isChecked())
		stream = stream.filter(e -> !(e instanceof Monster));
	
	if(filterPigmen.isChecked())
		stream = stream.filter(e -> !(e instanceof ZombifiedPiglinEntity));
	
	if(filterEndermen.isChecked())
		stream = stream.filter(e -> !(e instanceof EndermanEntity));
	
	if(filterAnimals.isChecked())
		stream = stream.filter(
			e -> !(e instanceof AnimalEntity || e instanceof AmbientEntity
				|| e instanceof WaterCreatureEntity));
	
	if(filterBabies.isChecked())
		stream = stream.filter(e -> !(e instanceof PassiveEntity
			&& ((PassiveEntity)e).isBaby()));
	
	if(filterPets.isChecked())
		stream = stream
			.filter(e -> !(e instanceof TameableEntity
				&& ((TameableEntity)e).isTamed()))
			.filter(e -> !(e instanceof HorseBaseEntity
				&& ((HorseBaseEntity)e).isTame()));
	
	if(filterVillagers.isChecked())
		stream = stream.filter(e -> !(e instanceof VillagerEntity));
	
	if(filterGolems.isChecked())
		stream = stream.filter(e -> !(e instanceof GolemEntity));
	
	if(filterInvisible.isChecked())
		stream = stream.filter(e -> !e.isInvisible());
	
	target = stream.min(priority.getSelected().comparator).orElse(null);
	if(target == null)
		return;
	
	WURST.getHax().autoSwordHack.setSlot();
	
	// face entity
	if(!faceEntityClient(target))
		return;
	
	// attack entity
	MC.interactionManager.attackEntity(player, target);
	player.swingHand(Hand.MAIN_HAND);
}
 
示例15
@Override
public void onUpdate()
{
	ClientPlayerEntity player = MC.player;
	ClientWorld world = MC.world;
	
	if(player.getAttackCooldownProgress(0) < 1)
		return;
	
	double rangeSq = Math.pow(range.getValue(), 2);
	Stream<LivingEntity> stream = StreamSupport
		.stream(MC.world.getEntities().spliterator(), true)
		.filter(e -> e instanceof LivingEntity).map(e -> (LivingEntity)e)
		.filter(e -> !e.removed && e.getHealth() > 0)
		.filter(e -> player.squaredDistanceTo(e) <= rangeSq)
		.filter(e -> e != player)
		.filter(e -> !(e instanceof FakePlayerEntity))
		.filter(e -> !WURST.getFriends().contains(e.getEntityName()));
	
	if(filterPlayers.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity));
	
	if(filterSleeping.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity
			&& ((PlayerEntity)e).isSleeping()));
	
	if(filterFlying.getValue() > 0)
		stream = stream.filter(e -> {
			
			if(!(e instanceof PlayerEntity))
				return true;
			
			Box box = e.getBoundingBox();
			box = box.union(box.offset(0, -filterFlying.getValue(), 0));
			return world.doesNotCollide(box);
		});
	
	if(filterMonsters.isChecked())
		stream = stream.filter(e -> !(e instanceof Monster));
	
	if(filterPigmen.isChecked())
		stream = stream.filter(e -> !(e instanceof ZombifiedPiglinEntity));
	
	if(filterEndermen.isChecked())
		stream = stream.filter(e -> !(e instanceof EndermanEntity));
	
	if(filterAnimals.isChecked())
		stream = stream.filter(
			e -> !(e instanceof AnimalEntity || e instanceof AmbientEntity
				|| e instanceof WaterCreatureEntity));
	
	if(filterBabies.isChecked())
		stream = stream.filter(e -> !(e instanceof PassiveEntity
			&& ((PassiveEntity)e).isBaby()));
	
	if(filterPets.isChecked())
		stream = stream
			.filter(e -> !(e instanceof TameableEntity
				&& ((TameableEntity)e).isTamed()))
			.filter(e -> !(e instanceof HorseBaseEntity
				&& ((HorseBaseEntity)e).isTame()));
	
	if(filterVillagers.isChecked())
		stream = stream.filter(e -> !(e instanceof VillagerEntity));
	
	if(filterGolems.isChecked())
		stream = stream.filter(e -> !(e instanceof GolemEntity));
	
	if(filterInvisible.isChecked())
		stream = stream.filter(e -> !e.isInvisible());
	
	target = stream.min(priority.getSelected().comparator).orElse(null);
	renderTarget = target;
	if(target == null)
		return;
	
	WURST.getHax().autoSwordHack.setSlot();
	
	WURST.getRotationFaker()
		.faceVectorPacket(target.getBoundingBox().getCenter());
}
 
示例16
@Shadow
public abstract ActionResult interactBlock(
	ClientPlayerEntity clientPlayerEntity_1, ClientWorld clientWorld_1,
	Hand hand_1, BlockHitResult blockHitResult_1);
 
示例17
public ClientPlayerEntityMixin(WurstClient wurst, ClientWorld clientWorld_1,
	GameProfile gameProfile_1)
{
	super(clientWorld_1, gameProfile_1);
}
 
示例18
public MixinOtherClientPlayerEntity(ClientWorld world, GameProfile gameProfile) {
    super(world, gameProfile);
}
 
示例19
@Override
public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
    SuspendParticle particle = SuspendParticleAccessor.constructor(world, x, y, z, xSpeed, ySpeed, zSpeed);
    particle.setSprite(sprite);
    return particle;
}
 
示例20
@Override
public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
    return CrackParticleAccessor.constructor(world, x, y, z, xSpeed, ySpeed, zSpeed, new ItemStack(Blocks.SNOW_BLOCK));
}
 
示例21
@Override
public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
    return new FootprintParticle(MinecraftClient.getInstance().getTextureManager(), world, x, y, z);
}
 
示例22
public OldBlockDustParticle(ClientWorld world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, BlockState state) {
    super(world, x, y, z, xSpeed, ySpeed, zSpeed, state);
    velocityX = xSpeed;
    velocityY = ySpeed;
    velocityZ = zSpeed;
}
 
示例23
@Override
public Particle createParticle(BlockStateParticleEffect type, ClientWorld world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
    return new OldBlockDustParticle(world, x, y, z, xSpeed, ySpeed, zSpeed, type.getBlockState());
}
 
示例24
@Invoker("<init>")
static CrackParticle constructor(ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ, ItemStack stack) {
    return MixinHelper.fakeInstance();
}
 
示例25
@Invoker("<init>")
static SuspendParticle constructor(ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) {
    return MixinHelper.fakeInstance();
}
 
示例26
@Inject(method = "<init>", at = @At(value = "TAIL"))
private void postConstruct(CallbackInfo info) {
	WorldEvents.onWorldLoad((ClientWorld) (Object) this);
}
 
示例27
public ClientPlayerEntityMixin(ClientWorld clientWorld_1, GameProfile gameProfile_1) {
    super(clientWorld_1, gameProfile_1);
}
 
示例28
private void handleTankTilePacket(ClientWorld world, BlockPos pos, PacketCustom packet) {
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileEnderTank) {
        ((TileEnderTank) tile).sync(packet);
    }
}