use of net.minecraft.entity.player.ServerPlayerEntity in project Bookshelf by Darkhax-Minecraft.
the class CommandHand method hand.
private int hand(CommandContext<CommandSource> context) throws CommandSyntaxException {
final OutputType type = context.getArgument("type", OutputType.class);
final ServerPlayerEntity player = context.getSource().getPlayerOrException();
final String outputText = type.converter.apply(player.getMainHandItem());
final ITextComponent component = TextComponentUtils.wrapInSquareBrackets(new StringTextComponent(outputText).withStyle((style) -> {
return style.withColor(TextFormatting.GREEN).withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, outputText)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslationTextComponent("chat.copy.click"))).withInsertion(outputText);
}));
context.getSource().sendSuccess(component, false);
return 0;
}
use of net.minecraft.entity.player.ServerPlayerEntity in project NetherEx by LogicTechCorp.
the class PlayerHandler method onPlayerRespawn.
@SubscribeEvent
public static void onPlayerRespawn(PlayerEvent.PlayerRespawnEvent event) {
World world = event.getPlayer().getEntityWorld();
PlayerEntity player = event.getPlayer();
PlayerInventory playerInventory = player.inventory;
if (!world.isRemote) {
ItemStack mirrorStack = ItemStack.EMPTY;
for (int i = 0; i < playerInventory.getSizeInventory(); i++) {
ItemStack stack = playerInventory.getStackInSlot(i);
if (stack.getItem() == NetherExItems.DULL_MIRROR.get()) {
mirrorStack = stack;
break;
}
}
if (!mirrorStack.isEmpty()) {
if (mirrorStack.getDamage() < mirrorStack.getMaxDamage() - 1) {
CompoundNBT compound = NBTHelper.ensureTagExists(mirrorStack);
if (compound.contains("SpawnDimension") && compound.contains("SpawnPoint")) {
DimensionType spawnDimension = DimensionType.byName(new ResourceLocation(compound.getString("SpawnDimension")));
if (spawnDimension != null && player.dimension != spawnDimension) {
MinecraftServer server = world.getServer();
if (server != null) {
BlockPos spawnPoint = NBTUtil.readBlockPos(compound.getCompound("SpawnPoint"));
((ServerPlayerEntity) player).teleport(server.getWorld(spawnDimension), spawnPoint.getX() + 0.5D, spawnPoint.getY(), spawnPoint.getZ() + 0.5D, player.rotationYaw, player.rotationPitch);
}
}
}
}
}
}
}
Aggregations