本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.addChatComponentMessage方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.addChatComponentMessage方法的具体用法?Java EntityPlayer.addChatComponentMessage怎么用?Java EntityPlayer.addChatComponentMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.player.EntityPlayer
的用法示例。
在下文中一共展示了EntityPlayer.addChatComponentMessage方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemUse
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos,
EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (!worldIn.isRemote) {
if(!facing.equals(EnumFacing.UP)){
playerIn.addChatComponentMessage(new TextComponentTranslation("chat.tripod.mustup"));
return EnumActionResult.PASS;
}
Entity entity = new EntityTripod(worldIn);
entity.setPositionAndUpdate(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
entity.rotationYaw = playerIn.rotationYaw;
entity.rotationPitch = playerIn.rotationPitch;
worldIn.spawnEntityInWorld(entity);
// worldIn.updateEntities();
stack.stackSize--;
return EnumActionResult.SUCCESS;
}
return EnumActionResult.PASS;
}
示例2: entityInteract
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SubscribeEvent
public void entityInteract(EntityInteract event) {
if (event.getEntityPlayer().getEntityData().hasKey("renderViewCamera")) {
event.setCanceled(true);
if (event.getSide().isClient() && event.getHand().equals(EnumHand.MAIN_HAND)
&& event.getItemStack() == null) {
System.out.println("EntityInteract,HandType=" + event.getHand());
ActiveTripod(Minecraft.getMinecraft().thePlayer.getName(),
((EntityTripod) event.getWorld()
.getEntityByID(event.getEntityPlayer().getEntityData().getInteger("renderViewCamera")))
.getDelay());
}
return;
}
if (event.getTarget() instanceof EntityTripod) {
Entity target = ((PlayerInteractEvent.EntityInteract) event).getTarget();
EntityPlayer player = event.getEntityPlayer();
if (!player.isSneaking()) {
if (player.inventory.armorInventory[3] != null
&& player.inventory.armorInventory[3].getItem() instanceof ItemGlassesHelmet) {
if (player.getEntityWorld().isRemote) {
// System.out.println("123");
Minecraft.getMinecraft().setRenderViewEntity(target);
Minecraft.getMinecraft().ingameGUI.setRecordPlaying(new TextComponentTranslation("chat.tripod.info"), false);
}
player.getEntityData().setInteger("renderViewCamera", target.getEntityId());
}else if(!event.getWorld().isRemote&&event.getHand().equals(EnumHand.MAIN_HAND)){
player.addChatComponentMessage(new TextComponentTranslation("chat.tripod.mustuseglass"));
}
} else {
player.getEntityData().setInteger("usingGui", target.getEntityId());
player.openGui(MineCamera.instance, GuiElementLoader.GUI_TRIPOD_CAMERA, target.getEntityWorld(),
(int) target.posX, (int) target.posY, (int) target.posZ);
}
}
}
示例3: processCommand
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void processCommand(ICommandSender par1ICommandSender,
String[] par2ArrayOfStr) {
EntityPlayer player = (EntityPlayer) par1ICommandSender;
PlayerRoleplayMode props = PlayerRoleplayMode.get(player);
player.addChatComponentMessage(new ChatComponentText("Your roleplay mode is currently: " + props.getRoleplayMode()));
}
示例4: processCommand
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void processCommand(ICommandSender par1ICommandSender,
String[] par2ArrayOfStr) {
EntityPlayer player = (EntityPlayer) par1ICommandSender;
PlayerRoleplayMode props = PlayerRoleplayMode.get(player);
props.setRoleplayMode(!props.getRoleplayMode(), true);
player.addChatComponentMessage(new ChatComponentText("Your nickname is now:"
+ "."));
}
示例5: removedByPlayer
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player,
boolean willHarvest) {
EnumFacing facing = state.getValue(FACING).getOpposite().rotateY();
EnumFacing fatherfacing = facing.getOpposite();
if (player.isSneaking()) {
int width = 1;
int height = 1;
for (int i = 1; i < 50; i++) {
if (world.getBlockState(pos.offset(facing, i)).getBlock() instanceof BlockPictureFrameMultiple) {
width++;
world.setBlockToAir(pos.offset(facing, i));
} else {
break;
}
}
for (int i = 1; i < 50; i++) {
if (world.getBlockState(pos.up(i)).getBlock() instanceof BlockPictureFrameMultiple) {
height++;
world.setBlockToAir(pos.up(i));
} else {
break;
}
}
for (int i = 1; i < width; i++) {
for (int j = 1; j < height; j++) {
if (world.getBlockState(pos.offset(facing, i).up(j))
.getBlock() instanceof BlockPictureFrameMultiple) {
world.setBlockToAir(pos.offset(facing, i).up(j));
}
}
}
}
for (int i = 1; i < 50; i++) {
if (!(world.getBlockState(pos.offset(fatherfacing, i)).getBlock() instanceof BlockPictureFrameMultiple)) {
for (int j = 1; j < 50; j++) {
if (!(world.getBlockState(pos.offset(fatherfacing, i - 1).down(j))
.getBlock() instanceof BlockPictureFrameMultiple)) {
TileEntityPictureFrameMultiple te = (TileEntityPictureFrameMultiple) world
.getTileEntity(pos.offset(fatherfacing, i - 1).down(j - 1));
if (te != null) {
//System.out.println(pos.offset(fatherfacing, i - 1).down(j - 1));
if (!te.imagename.equals("")) {
if (!world.isRemote) {
ItemStack picture = new ItemStack(ItemLoader.itemPicture);
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("pid", te.imagename);
picture.setTagCompound(nbt);
Block.spawnAsEntity(world, pos, picture);
player.addChatComponentMessage(
new TextComponentTranslation("chat.framemultiple.changeanddrowpicture"));
}
te.imagename = "";
te.shouldrender = false;
}
}
break;
}
}
break;
}
}
return super.removedByPlayer(state, world, pos, player, willHarvest);
}
示例6: onBlockActivated
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
if (state.getValue(PART) != BlockBed.EnumPartType.HEAD)
{
pos = pos.offset((EnumFacing)state.getValue(FACING));
state = worldIn.getBlockState(pos);
if (state.getBlock() != this)
{
return true;
}
}
if (worldIn.provider.canRespawnHere() && worldIn.getBiomeGenForCoords(pos) != BiomeGenBase.hell)
{
if (((Boolean)state.getValue(OCCUPIED)).booleanValue())
{
EntityPlayer entityplayer = this.getPlayerInBed(worldIn, pos);
if (entityplayer != null)
{
playerIn.addChatComponentMessage(new ChatComponentTranslation("tile.bed.occupied", new Object[0]));
return true;
}
state = state.withProperty(OCCUPIED, Boolean.valueOf(false));
worldIn.setBlockState(pos, state, 4);
}
EntityPlayer.EnumStatus entityplayer$enumstatus = playerIn.trySleep(pos);
if (entityplayer$enumstatus == EntityPlayer.EnumStatus.OK)
{
state = state.withProperty(OCCUPIED, Boolean.valueOf(true));
worldIn.setBlockState(pos, state, 4);
return true;
}
else
{
if (entityplayer$enumstatus == EntityPlayer.EnumStatus.NOT_POSSIBLE_NOW)
{
playerIn.addChatComponentMessage(new ChatComponentTranslation("tile.bed.noSleep", new Object[0]));
}
else if (entityplayer$enumstatus == EntityPlayer.EnumStatus.NOT_SAFE)
{
playerIn.addChatComponentMessage(new ChatComponentTranslation("tile.bed.notSafe", new Object[0]));
}
return true;
}
}
else
{
worldIn.setBlockToAir(pos);
BlockPos blockpos = pos.offset(((EnumFacing)state.getValue(FACING)).getOpposite());
if (worldIn.getBlockState(blockpos).getBlock() == this)
{
worldIn.setBlockToAir(blockpos);
}
worldIn.newExplosion((Entity)null, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, 5.0F, true, true);
return true;
}
}
}
示例7: handleChangeGameState
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public void handleChangeGameState(S2BPacketChangeGameState packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
EntityPlayer entityplayer = this.gameController.thePlayer;
int i = packetIn.getGameState();
float f = packetIn.func_149137_d();
int j = MathHelper.floor_float(f + 0.5F);
if (i >= 0 && i < S2BPacketChangeGameState.MESSAGE_NAMES.length && S2BPacketChangeGameState.MESSAGE_NAMES[i] != null)
{
entityplayer.addChatComponentMessage(new ChatComponentTranslation(S2BPacketChangeGameState.MESSAGE_NAMES[i], new Object[0]));
}
if (i == 1)
{
this.clientWorldController.getWorldInfo().setRaining(true);
this.clientWorldController.setRainStrength(0.0F);
}
else if (i == 2)
{
this.clientWorldController.getWorldInfo().setRaining(false);
this.clientWorldController.setRainStrength(1.0F);
}
else if (i == 3)
{
this.gameController.playerController.setGameType(WorldSettings.GameType.getByID(j));
}
else if (i == 4)
{
this.gameController.displayGuiScreen(new GuiWinGame());
}
else if (i == 5)
{
GameSettings gamesettings = this.gameController.gameSettings;
if (f == 0.0F)
{
this.gameController.displayGuiScreen(new GuiScreenDemo());
}
else if (f == 101.0F)
{
this.gameController.ingameGUI.getChatGUI().printChatMessage(new ChatComponentTranslation("demo.help.movement", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindForward.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindLeft.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindBack.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindRight.getKeyCode())}));
}
else if (f == 102.0F)
{
this.gameController.ingameGUI.getChatGUI().printChatMessage(new ChatComponentTranslation("demo.help.jump", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindJump.getKeyCode())}));
}
else if (f == 103.0F)
{
this.gameController.ingameGUI.getChatGUI().printChatMessage(new ChatComponentTranslation("demo.help.inventory", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindInventory.getKeyCode())}));
}
}
else if (i == 6)
{
this.clientWorldController.playSound(entityplayer.posX, entityplayer.posY + (double)entityplayer.getEyeHeight(), entityplayer.posZ, "random.successful_hit", 0.18F, 0.45F, false);
}
else if (i == 7)
{
this.clientWorldController.setRainStrength(f);
}
else if (i == 8)
{
this.clientWorldController.setThunderStrength(f);
}
else if (i == 10)
{
this.clientWorldController.spawnParticle(EnumParticleTypes.MOB_APPEARANCE, entityplayer.posX, entityplayer.posY, entityplayer.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
this.clientWorldController.playSound(entityplayer.posX, entityplayer.posY, entityplayer.posZ, "mob.guardian.curse", 1.0F, 1.0F, false);
}
}
示例8: onBlockActivated
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
if (state.getValue(PART) != BlockBed.EnumPartType.HEAD)
{
pos = pos.offset((EnumFacing)state.getValue(FACING));
state = worldIn.getBlockState(pos);
if (state.getBlock() != this)
{
return true;
}
}
if (worldIn.provider.canRespawnHere() && worldIn.getBiome(pos) != Biomes.HELL)
{
if (((Boolean)state.getValue(OCCUPIED)).booleanValue())
{
EntityPlayer entityplayer = this.getPlayerInBed(worldIn, pos);
if (entityplayer != null)
{
playerIn.addChatComponentMessage(new TextComponentTranslation("tile.bed.occupied", new Object[0]));
return true;
}
state = state.withProperty(OCCUPIED, Boolean.valueOf(false));
worldIn.setBlockState(pos, state, 4);
}
EntityPlayer.SleepResult entityplayer$sleepresult = playerIn.trySleep(pos);
if (entityplayer$sleepresult == EntityPlayer.SleepResult.OK)
{
state = state.withProperty(OCCUPIED, Boolean.valueOf(true));
worldIn.setBlockState(pos, state, 4);
return true;
}
else
{
if (entityplayer$sleepresult == EntityPlayer.SleepResult.NOT_POSSIBLE_NOW)
{
playerIn.addChatComponentMessage(new TextComponentTranslation("tile.bed.noSleep", new Object[0]));
}
else if (entityplayer$sleepresult == EntityPlayer.SleepResult.NOT_SAFE)
{
playerIn.addChatComponentMessage(new TextComponentTranslation("tile.bed.notSafe", new Object[0]));
}
return true;
}
}
else
{
worldIn.setBlockToAir(pos);
BlockPos blockpos = pos.offset(((EnumFacing)state.getValue(FACING)).getOpposite());
if (worldIn.getBlockState(blockpos).getBlock() == this)
{
worldIn.setBlockToAir(blockpos);
}
worldIn.newExplosion((Entity)null, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, 5.0F, true, true);
return true;
}
}
}
示例9: sendMissingPropertiesMessage
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public void sendMissingPropertiesMessage(EntityPlayer p) {
p.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED
+ "Properties for player " + EnumChatFormatting.YELLOW
+ p.getCommandSenderName() + EnumChatFormatting.RED
+ " could not be found!"));
}
示例10: handleChangeGameState
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public void handleChangeGameState(SPacketChangeGameState packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
EntityPlayer entityplayer = this.gameController.player;
int i = packetIn.getGameState();
float f = packetIn.getValue();
int j = MathHelper.floor(f + 0.5F);
if (i >= 0 && i < SPacketChangeGameState.MESSAGE_NAMES.length && SPacketChangeGameState.MESSAGE_NAMES[i] != null)
{
entityplayer.addChatComponentMessage(new TextComponentTranslation(SPacketChangeGameState.MESSAGE_NAMES[i], new Object[0]), false);
}
if (i == 1)
{
this.clientWorldController.getWorldInfo().setRaining(true);
this.clientWorldController.setRainStrength(0.0F);
}
else if (i == 2)
{
this.clientWorldController.getWorldInfo().setRaining(false);
this.clientWorldController.setRainStrength(1.0F);
}
else if (i == 3)
{
this.gameController.playerController.setGameType(GameType.getByID(j));
}
else if (i == 4)
{
if (j == 0)
{
this.gameController.player.connection.sendPacket(new CPacketClientStatus(CPacketClientStatus.State.PERFORM_RESPAWN));
this.gameController.displayGuiScreen(new GuiDownloadTerrain(this));
}
else if (j == 1)
{
this.gameController.displayGuiScreen(new GuiWinGame());
}
}
else if (i == 5)
{
GameSettings gamesettings = this.gameController.gameSettings;
if (f == 0.0F)
{
this.gameController.displayGuiScreen(new GuiScreenDemo());
}
else if (f == 101.0F)
{
this.gameController.ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("demo.help.movement", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindForward.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindLeft.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindBack.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindRight.getKeyCode())}));
}
else if (f == 102.0F)
{
this.gameController.ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("demo.help.jump", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindJump.getKeyCode())}));
}
else if (f == 103.0F)
{
this.gameController.ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("demo.help.inventory", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindInventory.getKeyCode())}));
}
}
else if (i == 6)
{
this.clientWorldController.playSound(entityplayer, entityplayer.posX, entityplayer.posY + (double)entityplayer.getEyeHeight(), entityplayer.posZ, SoundEvents.ENTITY_ARROW_HIT_PLAYER, SoundCategory.PLAYERS, 0.18F, 0.45F);
}
else if (i == 7)
{
this.clientWorldController.setRainStrength(f);
}
else if (i == 8)
{
this.clientWorldController.setThunderStrength(f);
}
else if (i == 10)
{
this.clientWorldController.spawnParticle(EnumParticleTypes.MOB_APPEARANCE, entityplayer.posX, entityplayer.posY, entityplayer.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
this.clientWorldController.playSound(entityplayer, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_ELDER_GUARDIAN_CURSE, SoundCategory.HOSTILE, 1.0F, 1.0F);
}
}
示例11: sendInvalidValueMessage
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public void sendInvalidValueMessage(EntityPlayer p, String invalidPlayer) {
p.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED
+ "Nickname " + EnumChatFormatting.YELLOW + invalidPlayer
+ EnumChatFormatting.RED + " is invalid!"));
}
示例12: sendWrongUsageMessage
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public void sendWrongUsageMessage(EntityPlayer p) {
p.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED
+ "Proper " + EnumChatFormatting.RED + "usage: "
+ getCommandUsage(p)));
}
示例13: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
playerIn.addChatComponentMessage(new TextComponentString("Right clicked"));
return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand);
}
示例14: handleChangeGameState
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public void handleChangeGameState(SPacketChangeGameState packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
EntityPlayer entityplayer = this.gameController.thePlayer;
int i = packetIn.getGameState();
float f = packetIn.getValue();
int j = MathHelper.floor_float(f + 0.5F);
if (i >= 0 && i < SPacketChangeGameState.MESSAGE_NAMES.length && SPacketChangeGameState.MESSAGE_NAMES[i] != null)
{
entityplayer.addChatComponentMessage(new TextComponentTranslation(SPacketChangeGameState.MESSAGE_NAMES[i], new Object[0]));
}
if (i == 1)
{
this.clientWorldController.getWorldInfo().setRaining(true);
this.clientWorldController.setRainStrength(0.0F);
}
else if (i == 2)
{
this.clientWorldController.getWorldInfo().setRaining(false);
this.clientWorldController.setRainStrength(1.0F);
}
else if (i == 3)
{
this.gameController.playerController.setGameType(GameType.getByID(j));
}
else if (i == 4)
{
if (j == 0)
{
this.gameController.thePlayer.connection.sendPacket(new CPacketClientStatus(CPacketClientStatus.State.PERFORM_RESPAWN));
this.gameController.displayGuiScreen(new GuiDownloadTerrain(this));
}
else if (j == 1)
{
this.gameController.displayGuiScreen(new GuiWinGame());
}
}
else if (i == 5)
{
GameSettings gamesettings = this.gameController.gameSettings;
if (f == 0.0F)
{
this.gameController.displayGuiScreen(new GuiScreenDemo());
}
else if (f == 101.0F)
{
this.gameController.ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("demo.help.movement", new Object[] {gamesettings.keyBindForward.getDisplayName(), gamesettings.keyBindLeft.getDisplayName(), gamesettings.keyBindBack.getDisplayName(), gamesettings.keyBindRight.getDisplayName()}));
}
else if (f == 102.0F)
{
this.gameController.ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("demo.help.jump", new Object[] {gamesettings.keyBindJump.getDisplayName()}));
}
else if (f == 103.0F)
{
this.gameController.ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("demo.help.inventory", new Object[] {gamesettings.keyBindInventory.getDisplayName()}));
}
}
else if (i == 6)
{
this.clientWorldController.playSound(entityplayer, entityplayer.posX, entityplayer.posY + (double)entityplayer.getEyeHeight(), entityplayer.posZ, SoundEvents.ENTITY_ARROW_HIT_PLAYER, SoundCategory.PLAYERS, 0.18F, 0.45F);
}
else if (i == 7)
{
this.clientWorldController.setRainStrength(f);
}
else if (i == 8)
{
this.clientWorldController.setThunderStrength(f);
}
else if (i == 10)
{
this.clientWorldController.spawnParticle(EnumParticleTypes.MOB_APPEARANCE, entityplayer.posX, entityplayer.posY, entityplayer.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
this.clientWorldController.playSound(entityplayer, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_ELDER_GUARDIAN_CURSE, SoundCategory.HOSTILE, 1.0F, 1.0F);
}
}