net.minecraft.entity.player.PlayerEntity Java Examples

The following examples show how to use net.minecraft.entity.player.PlayerEntity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LogCommand.java    From fabric-carpet with MIT License 6 votes vote down vote up
private static int subscribePlayer(ServerCommandSource source, String player_name, String logname, String option)
{
    PlayerEntity player = source.getMinecraftServer().getPlayerManager().getPlayer(player_name);
    if (player == null)
    {
        Messenger.m(source, "r No player specified");
        return 0;
    }
    if (LoggerRegistry.getLogger(logname) == null)
    {
        Messenger.m(source, "r Unknown logger: ","rb "+logname);
        return 0;
    }
    LoggerRegistry.subscribePlayer(player_name, logname, option);
    if (option!=null)
    {
        Messenger.m(source, "gi Subscribed to " + logname + "(" + option + ")");
    }
    else
    {
        Messenger.m(source, "gi Subscribed to " + logname);
    }
        return 1;
}
 
Example #2
Source File: RefineryBlock.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
@Override
public void onBreak(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity) {
    super.onBreak(world, blockPos, blockState, playerEntity);

    BlockEntity blockEntity = world.getBlockEntity(blockPos);

    if (blockEntity != null) {
        if (blockEntity instanceof RefineryBlockEntity) {
            RefineryBlockEntity refineryBlockEntity = (RefineryBlockEntity) blockEntity;

            for (int i = 0; i < refineryBlockEntity.getInventory().getSize(); i++) {
                ItemStack itemStack = refineryBlockEntity.getInventory().getStack(i);

                if (itemStack != null) {
                    world.spawnEntity(new ItemEntity(world, blockPos.getX(), blockPos.getY() + 1, blockPos.getZ(), itemStack));
                }
            }
        }
    }
}
 
Example #3
Source File: PlayerEntityMixin_RealTime.java    From Galaxy with GNU Affero General Public License v3.0 6 votes vote down vote up
@Redirect(
    method = "tick",
    at = @At(
        value = "FIELD",
        target = "Lnet/minecraft/entity/player/PlayerEntity;sleepTimer:I",
        opcode = Opcodes.PUTFIELD
    ),
    slice = @Slice(
        from = @At(
            value = "INVOKE",
            target = "Lnet/minecraft/entity/player/PlayerEntity;wakeUp(ZZ)V"
        ),
        to = @At(
            value = "CONSTANT",
            args = "intValue=110"
        )
    )
)
private void realTimeImpl$adjustForRealTimeWakeTimer(final PlayerEntity self, final int modifier) {
    final int ticks = (int) ((RealTimeTrackingBridge) self.getEntityWorld()).realTimeBridge$getRealTimeTicks();
    this.sleepTimer += ticks;
}
 
Example #4
Source File: ColoredPumpkinBlock.java    From the-hallow with MIT License 6 votes vote down vote up
@Override
public ActionResult onUse(BlockState blockState, World world, BlockPos blockPos, PlayerEntity playerEntity, Hand hand, BlockHitResult blockHitResult) {
	ItemStack stack = playerEntity.getStackInHand(hand);

	if (stack.getItem() == Items.SHEARS) {
		if (!world.isClient) {
			Direction side = blockHitResult.getSide();
			Direction facingTowardPlayer = side.getAxis() == Direction.Axis.Y ? playerEntity.getHorizontalFacing().getOpposite() : side;

			world.playSound(null, blockPos, SoundEvents.BLOCK_PUMPKIN_CARVE, SoundCategory.BLOCKS, 1.0F, 1.0F);
			world.setBlockState(blockPos, HallowedBlocks.CARVED_PUMPKIN_COLORS.get(this.color).getDefaultState().with(CarvedPumpkinBlock.FACING, facingTowardPlayer), 11);
			ItemEntity itemEntity = new ItemEntity(world, blockPos.getX() + 0.5D + facingTowardPlayer.getOffsetX() * 0.65D, blockPos.getY() + 0.1D, blockPos.getZ() + 0.5D + facingTowardPlayer.getOffsetZ() * 0.65D, new ItemStack(Items.PUMPKIN_SEEDS, 4));

			itemEntity.setVelocity(0.05D * (double) facingTowardPlayer.getOffsetX() + world.random.nextDouble() * 0.02D, 0.05D, 0.05D * (double) facingTowardPlayer.getOffsetZ() + world.random.nextDouble() * 0.02D);
			world.spawnEntity(itemEntity);
			stack.damage(1, playerEntity, (playerEntityVar) -> {
				playerEntityVar.sendToolBreakStatus(hand);
			});
		}

		return ActionResult.SUCCESS;
	}

	return super.onUse(blockState, world, blockPos, playerEntity, hand, blockHitResult);
}
 
Example #5
Source File: SyncedGuiDescription.java    From LibGui with MIT License 6 votes vote down vote up
/** WILL MODIFY toInsert! Returns true if anything was inserted. */
private boolean insertIntoExisting(ItemStack toInsert, Slot slot, PlayerEntity player) {
	ItemStack curSlotStack = slot.getStack();
	if (!curSlotStack.isEmpty() && canStacksCombine(toInsert, curSlotStack) && slot.canTakeItems(player)) {
		int combinedAmount = curSlotStack.getCount() + toInsert.getCount();
		if (combinedAmount <= toInsert.getMaxCount()) {
			toInsert.setCount(0);
			curSlotStack.setCount(combinedAmount);
			slot.markDirty();
			return true;
		} else if (curSlotStack.getCount() < toInsert.getMaxCount()) {
			toInsert.decrement(toInsert.getMaxCount() - curSlotStack.getCount());
			curSlotStack.setCount(toInsert.getMaxCount());
			slot.markDirty();
			return true;
		}
	}
	return false;
}
 
Example #6
Source File: EnergyStorageModuleBlock.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
@Override
public void onBreak(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity) {
    super.onBreak(world, blockPos, blockState, playerEntity);
    BlockEntity blockEntity = world.getBlockEntity(blockPos);

    if (blockEntity != null) {
        if (blockEntity instanceof EnergyStorageModuleBlockEntity) {
            EnergyStorageModuleBlockEntity be = (EnergyStorageModuleBlockEntity) blockEntity;

            for (int i = 0; i < be.getInventory().getSize(); i++) {
                ItemStack itemStack = be.getInventory().getStack(i);

                if (itemStack != null) {
                    world.spawnEntity(new ItemEntity(world, blockPos.getX(), blockPos.getY() + 1, blockPos.getZ(), itemStack));
                }
            }
        }
    }
}
 
Example #7
Source File: CoalGeneratorScreenHandler.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
public CoalGeneratorScreenHandler(int syncId, PlayerEntity playerEntity, CoalGeneratorBlockEntity generator) {
    super(syncId, playerEntity, generator, GalacticraftScreenHandlerTypes.COAL_GENERATOR_HANDLER);
    Inventory inventory = blockEntity.getInventory().asInventory();
    addProperty(status);
    // Coal Generator fuel slot
    this.addSlot(new ItemSpecificSlot(inventory, 0, 8, 72, fuel));
    this.addSlot(new ChargeSlot(inventory, 1, 8, 8));

    // Player inventory slots
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 9; ++j) {
            this.addSlot(new Slot(playerEntity.inventory, j + i * 9 + 9, 8 + j * 18, 94 + i * 18));
        }
    }

    // Hotbar slots
    for (int i = 0; i < 9; ++i) {
        this.addSlot(new Slot(playerEntity.inventory, i, 8 + i * 18, 152));
    }

}
 
Example #8
Source File: ContainerEnderItemStorage.java    From EnderStorage with MIT License 6 votes vote down vote up
@Override
public ItemStack transferStackInSlot(PlayerEntity par1EntityPlayer, int i) {
    ItemStack itemstack = ItemStack.EMPTY;
    Slot slot = inventorySlots.get(i);

    if (slot != null && slot.getHasStack()) {
        ItemStack itemstack1 = slot.getStack();
        itemstack = itemstack1.copy();

        int chestSlots = EnderItemStorage.sizes[chestInv.getSize()];
        if (i < chestSlots) {
            if (!mergeItemStack(itemstack1, chestSlots, inventorySlots.size(), true)) {
                return ItemStack.EMPTY;
            }
        } else if (!mergeItemStack(itemstack1, 0, chestSlots, false)) {
            return ItemStack.EMPTY;
        }
        if (itemstack1.getCount() == 0) {
            slot.putStack(ItemStack.EMPTY);
        } else {
            slot.onSlotChanged();
        }
    }
    return itemstack;
}
 
Example #9
Source File: OxygenCollectorBlock.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
@Override
public void onBreak(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity) {
    super.onBreak(world, blockPos, blockState, playerEntity);
    BlockEntity blockEntity = world.getBlockEntity(blockPos);

    if (blockEntity != null) {
        if (blockEntity instanceof OxygenCollectorBlockEntity) {
            OxygenCollectorBlockEntity be = (OxygenCollectorBlockEntity) blockEntity;

            for (int i = 0; i < be.getInventory().getSize(); i++) {
                ItemStack itemStack = be.getInventory().getStack(i);

                if (itemStack != null) {
                    world.spawnEntity(new ItemEntity(world, blockPos.getX(), blockPos.getY() + 1, blockPos.getZ(), itemStack));
                }
            }
        }
    }
}
 
Example #10
Source File: ClientNetwork.java    From Better-Sprinting with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void onPacket(LogicalSide side, ByteBuf data, PlayerEntity player){
	if (side == LogicalSide.SERVER){
		PacketPipeline.sendToPlayer(writeLanSettings(), player);
		return;
	}
	
	byte type = data.readByte();
	
	if (type == 0){
		ClientModManager.svSurvivalFlyBoost = data.readBoolean();
		ClientModManager.svRunInAllDirs = data.readBoolean();
	}
	else if (type == 1 && !ClientSettings.disableMod.get()){
		ClientModManager.svDisableMod = true;
		ClientEventHandler.showDisableWarningWhenPossible = true;
	}
	else if (type == 2 && !ClientSettings.disableMod.get()){
		ClientModManager.svDisableMod = false;
		ClientEventHandler.showDisableWarningWhenPossible = true;
	}
}
 
Example #11
Source File: PumpkinPieBlock.java    From the-hallow with MIT License 6 votes vote down vote up
private ActionResult tryEat(IWorld iWorld, BlockPos pos, BlockState state, PlayerEntity player) {
	if (!player.canConsume(false)) {
		return ActionResult.PASS;
	}
	float saturation = 0.1F;
	TrinketComponent trinketPlayer = TrinketsApi.getTrinketComponent(player);
	ItemStack mainHandStack = trinketPlayer.getStack("hand:ring");
	ItemStack offHandStack = trinketPlayer.getStack("offhand:ring");
	if (mainHandStack.getItem().equals(HallowedItems.PUMPKIN_RING) || offHandStack.getItem().equals(HallowedItems.PUMPKIN_RING)) {
		saturation = 0.3F;
	}
	player.getHungerManager().add(2, saturation);
	int bites = state.get(BITES);
	if (bites > 1) {
		iWorld.setBlockState(pos, state.with(BITES, bites - 1), 3);
	} else {
		iWorld.removeBlock(pos, false);
	}
	return ActionResult.SUCCESS;
}
 
Example #12
Source File: FabricCommandSender.java    From spark with GNU General Public License v3.0 5 votes vote down vote up
@Override
public String getName() {
    if (super.delegate instanceof PlayerEntity) {
        return ((PlayerEntity) super.delegate).getGameProfile().getName();
    } else if (super.delegate instanceof DedicatedServer) {
        return "Console";
    } else {
        return "unknown:" + super.delegate.getClass().getSimpleName();
    }
}
 
Example #13
Source File: EntityUtils.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public static void setGlowing(Entity entity, Formatting color, String teamName) {
	Team team = mc.world.getScoreboard().getTeamNames().contains(teamName) ?
			mc.world.getScoreboard().getTeam(teamName) :
			mc.world.getScoreboard().addTeam(teamName);
       
	mc.world.getScoreboard().addPlayerToTeam(
			entity instanceof PlayerEntity ? entity.getEntityName() : entity.getUuidAsString(), team);
	mc.world.getScoreboard().getTeam(teamName).setColor(color);
	
	entity.setGlowing(true);
}
 
Example #14
Source File: UnlitTorchBlock.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
    if (player.getStackInHand(hand).getItem() instanceof FlintAndSteelItem) {
        world.setBlockState(pos, Blocks.TORCH.getDefaultState());
        ItemStack stack = player.getStackInHand(hand).copy();
        stack.damage(1, player, (playerEntity -> {
        }));
        player.setStackInHand(hand, stack);
    }
    return super.onUse(state, world, pos, player, hand, hit);
}
 
Example #15
Source File: PlayerCommand.java    From fabric-carpet with MIT License 5 votes vote down vote up
private static boolean cantManipulate(CommandContext<ServerCommandSource> context)
{
    PlayerEntity player = getPlayer(context);
    if (player == null)
    {
        Messenger.m(context.getSource(), "r Can only manipulate existing players");
        return true;
    }
    PlayerEntity sendingPlayer;
    try
    {
        sendingPlayer = context.getSource().getPlayer();
    }
    catch (CommandSyntaxException e)
    {
        return false;
    }

    if (!context.getSource().getMinecraftServer().getPlayerManager().isOperator(sendingPlayer.getGameProfile()))
    {
        if (sendingPlayer != player && !(player instanceof EntityPlayerMPFake))
        {
            Messenger.m(context.getSource(), "r Non OP players can't control other real players");
            return true;
        }
    }
    return false;
}
 
Example #16
Source File: MixinPlayerEntity.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
@ModifyVariable(method = "addExperienceLevels", at = @At("HEAD"), ordinal = 0)
private int onAddExperienceLevels(int levels) {
	@SuppressWarnings("ConstantConditions")
	PlayerEntity player = (PlayerEntity) (Object) this;

	PlayerXpEvent.LevelChange event = new PlayerXpEvent.LevelChange(player, levels);
	MinecraftForge.EVENT_BUS.post(event);

	// There are no effects from passing in zero levels, so do that if we've been canceled
	return event.isCanceled() ? 0 : event.getLevels();
}
 
Example #17
Source File: GameRendererMixin.java    From the-hallow with MIT License 5 votes vote down vote up
@Inject(at = @At("RETURN"), method = "getViewDistance()F", cancellable = true)
private void getHallowViewDistance(final CallbackInfoReturnable<Float> info) {
	final MinecraftClient client = MinecraftClient.getInstance();
	final World world = client.world;
	
	if (world.getDimension().getType() == HallowedDimensions.THE_HALLOW) {
		final PlayerEntity player = client.player;
		float totalIntensity = 0;
		int count = 0;
		final int radius = HallowedConfig.HallowedFog.fogSmoothingRadius;
		for (int x = 0; x < radius; x++) {
			for (int z = 0; z < radius; z++) {
				final BlockPos pos = player.getBlockPos().add(x - (radius / 2), 0, z - (radius / 2));
				
				if (world.getBiomeAccess().getBiome(pos) instanceof HallowedBiomeInfo) {
					final HallowedBiomeInfo biomeInfo = (HallowedBiomeInfo) world.getBiomeAccess().getBiome(pos);
					totalIntensity += biomeInfo.getFogIntensity();
					count++;
				}
			}
		}
		
		final float distance = totalIntensity / count;
		if(distance < info.getReturnValue())
		{
			info.setReturnValue(distance);
		}
	}
}
 
Example #18
Source File: ElectricCompressorScreenHandler.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
public ElectricCompressorScreenHandler(int syncId, PlayerEntity player, ElectricCompressorBlockEntity blockEntity) {
    super(syncId, player, blockEntity, GalacticraftScreenHandlerTypes.ELECTRIC_COMPRESSOR_HANDLER);
    this.inventory = blockEntity.getInventory().asInventory();
    addProperty(status);
    addProperty(progress);

    // 3x3 comprerssor input grid
    int slot = 0;
    for (int y = 0; y < 3; y++) {
        for (int x = 0; x < 3; x++) {
            this.addSlot(new Slot(this.inventory, slot, x * 18 + 19, y * 18 + 18));
            slot++;
        }
    }

    // Output slot
    this.addSlot(new FurnaceOutputSlot(playerEntity, this.inventory, CompressorBlockEntity.OUTPUT_SLOT, getOutputSlotPos()[0], getOutputSlotPos()[1]));

    // Player inventory slots
    int playerInvYOffset = 117;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 9; ++j) {
            this.addSlot(new Slot(playerEntity.inventory, j + i * 9 + 9, 8 + j * 18, playerInvYOffset + i * 18));
        }
    }

    // Hotbar slots
    for (int i = 0; i < 9; ++i) {
        this.addSlot(new Slot(playerEntity.inventory, i, 8 + i * 18, playerInvYOffset + 58));
    }

    addProperty(energy);
    addSlot(new FurnaceOutputSlot(player, this.inventory, ElectricCompressorBlockEntity.SECOND_OUTPUT_SLOT, getOutputSlotPos()[0], getOutputSlotPos()[1] + 18));
    addSlot(new ChargeSlot(this.inventory, CompressorBlockEntity.FUEL_INPUT_SLOT, 3 * 18 + 1, 75));
}
 
Example #19
Source File: InventoryUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Drops all items from inv using removeStackFromSlot
 */
public static void dropOnClose(PlayerEntity player, IInventory inv) {
    for (int i = 0; i < inv.getSizeInventory(); i++) {
        ItemStack stack = inv.removeStackFromSlot(i);
        if (!stack.isEmpty()) {
            player.dropItem(stack, false);
        }
    }
}
 
Example #20
Source File: MixinEntityType.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Inject(method = SPAWN, at = @At(value = "INVOKE", target = "net/minecraft/world/World.spawnEntity(Lnet/minecraft/entity/Entity;)Z"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
private void hookMobSpawns(World world, @Nullable CompoundTag itemTag, @Nullable Text name, @Nullable PlayerEntity player, BlockPos pos, SpawnType type, boolean alignPosition, boolean bl, CallbackInfoReturnable<Entity> callback, Entity entity) {
	if (!(entity instanceof MobEntity)) {
		return;
	}

	MobEntity mob = (MobEntity) entity;

	if (EntityEvents.doSpecialSpawn(mob, world, pos.getX(), pos.getY(), pos.getZ(), null, type)) {
		callback.setReturnValue(null);
	}
}
 
Example #21
Source File: HorseCam.java    From MineLittlePony with MIT License 5 votes vote down vote up
/**
 * Transforms the client pony's pitch to the corresponding angle for a human character.
 */
public static float transformCameraAngle(float pitch) {

    if (!MineLittlePony.getInstance().getConfig().fillycam.get()) {
        return pitch;
    }

    PlayerEntity player = MinecraftClient.getInstance().player;
    IPony pony = MineLittlePony.getInstance().getManager().getPony(player);

    if (!pony.getRace(false).isHuman()) {
        float factor = pony.getMetadata().getSize().getEyeHeightFactor();
        return rescaleCameraPitch(player.getStandingEyeHeight() / factor, pitch);
    }

    return pitch;
}
 
Example #22
Source File: OxygenGearItem.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
    if (((GCPlayerAccessor) user).getGearInventory().getStack(5).isEmpty()) {
        ((GCPlayerAccessor) user).getGearInventory().setStack(5, user.getStackInHand(hand));
        return new TypedActionResult<>(ActionResult.SUCCESS, ItemStack.EMPTY);
    }
    return super.use(world, user, hand);
}
 
Example #23
Source File: TorchFireEventHandling.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@SubscribeEvent
public void onAttackEntity(AttackEntityEvent ev)
{
    if (!ConfigManager.SERVER.enableTorchFire.get())
        return;

    if (!ev.getTarget().func_230279_az_() && !ev.getTarget().world.isRemote)
    {
        PlayerEntity player = ev.getPlayer();
        ItemStack stack = player.getHeldItem(Hand.MAIN_HAND);
        if (stack.getCount() > 0 && stack.getItem() instanceof BlockItem)
        {
            BlockItem b = (BlockItem) stack.getItem();
            Block bl = b.getBlock();
            if (bl == Blocks.TORCH)
            {
                ev.getTarget().setFire(2);
                if (!ev.getPlayer().isCreative() && rnd.nextFloat() > 0.25)
                {
                    stack.grow(-1);
                    if (stack.getCount() <= 0)
                    {
                        player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
                    }
                }
            }
        }
    }
}
 
Example #24
Source File: BlockRotator.java    From fabric-carpet with MIT License 5 votes vote down vote up
public static boolean flipBlockWithCactus(BlockState state, World world, PlayerEntity player, Hand hand, BlockHitResult hit)
{
    if (!player.abilities.allowModifyWorld || !CarpetSettings.flippinCactus || !player_holds_cactus_mainhand(player))
    {
        return false;
    }
    CarpetSettings.impendingFillSkipUpdates = true;
    boolean retval = flip_block(state, world, player, hand, hit);
    CarpetSettings.impendingFillSkipUpdates = false;
    return retval;
}
 
Example #25
Source File: PlayerEntity_creativeNoClipMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Redirect(method = "updateSize", at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/entity/player/PlayerEntity;isSpectator()Z")
)
private boolean spectatorsDontPose(PlayerEntity playerEntity)
{
    return playerEntity.isSpectator() || (CarpetSettings.creativeNoClip && playerEntity.isCreative() && playerEntity.abilities.flying);
}
 
Example #26
Source File: WitchedPumpkinItem.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
public ItemStack finishUsing(ItemStack stack, World world, LivingEntity entity) {
	if (isFood() && !world.isClient && entity instanceof PlayerEntity) {
		ServerSidePacketRegistry.INSTANCE.sendToPlayer((PlayerEntity) entity, HallowedNetworking.SHOW_FLOATING_ITEM_S2C, HallowedNetworking.createShowFloatingItemPacket(this));
		((PlayerEntity) entity).playSound(SoundEvents.ENTITY_ILLUSIONER_CAST_SPELL, SoundCategory.PLAYERS, 0.5f, 1f);
	}
	
	return super.finishUsing(stack, world, entity);
}
 
Example #27
Source File: HallowedFogColorCalculator.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
@Environment(EnvType.CLIENT)
public Vec3d calculate(float v, float v1) {
	World world = MinecraftClient.getInstance().world;
	PlayerEntity player = MinecraftClient.getInstance().player;
	double totalR = 0;
	double totalG = 0;
	double totalB = 0;
	int count = 0;
	int radius = HallowedConfig.HallowedFog.fogSmoothingRadius;
	
	for (int x = 0; x < radius; x++) {
		for (int z = 0; z < radius; z++) {
			BlockPos pos = player.getBlockPos().add(x - (radius / 2), 0, z - (radius / 2));
			
			if (world.getBiomeAccess().getBiome(pos) instanceof HallowedBiomeInfo) {
				HallowedBiomeInfo biomeInfo = (HallowedBiomeInfo) world.getBiomeAccess().getBiome(pos);
				
				totalR += Math.pow(biomeInfo.getFogColor().x, 2);
				totalG += Math.pow(biomeInfo.getFogColor().y, 2);
				totalB += Math.pow(biomeInfo.getFogColor().z, 2);
			}
			count++;
		}
	}
	
	return new Vec3d(Math.sqrt(totalR / count), Math.sqrt(totalG / count), Math.sqrt(totalB / count));
}
 
Example #28
Source File: ForgeCommandSender.java    From spark with GNU General Public License v3.0 5 votes vote down vote up
@Override
public String getName() {
    if (super.delegate instanceof PlayerEntity) {
        return ((PlayerEntity) super.delegate).getGameProfile().getName();
    } else if (super.delegate instanceof IServer) {
        return "Console";
    } else {
        return "unknown:" + super.delegate.getClass().getSimpleName();
    }
}
 
Example #29
Source File: LoggerRegistry.java    From fabric-carpet with MIT License 5 votes vote down vote up
public static void playerDisconnected(PlayerEntity player)
{
    for(Logger log: loggerRegistry.values() )
    {
        log.onPlayerDisconnect(player);
    }
}
 
Example #30
Source File: LoggerRegistry.java    From fabric-carpet with MIT License 5 votes vote down vote up
public static void playerConnected(PlayerEntity player)
{
    boolean firstTime = false;
    if (!seenPlayers.contains(player.getName().getString()))
    {
        seenPlayers.add(player.getName().getString());
        firstTime = true;
        //subscribe them to the defualt loggers
    }
    for(Logger log: loggerRegistry.values() )
    {
        log.onPlayerConnect(player, firstTime);
    }
}