use of net.minecraft.util.ChatComponentTranslation in project Galacticraft by micdoodle8.
the class NEIServerUtils method setGamemode.
public static void setGamemode(EntityPlayerMP player, int mode) {
if (mode < 0 || mode >= NEIActions.gameModes.length || NEIActions.nameActionMap.containsKey(NEIActions.gameModes[mode]) && !NEIServerConfig.canPlayerPerformAction(player.getName(), NEIActions.gameModes[mode])) {
return;
}
// creative+
NEIServerConfig.forPlayer(player.getName()).enableAction("creative+", mode == 2);
if (// open the container immediately for the client
mode == 2 && !(player.openContainer instanceof ContainerCreativeInv)) {
NEISPH.processCreativeInv(player, true);
}
// change it on the server
player.theItemInWorldManager.setGameType(getGameType(mode));
// tell the client to change it
new PacketCustom(NEISPH.channel, 14).writeByte(mode).sendToPlayer(player);
player.addChatMessage(new ChatComponentTranslation("nei.chat.gamemode." + mode));
}
use of net.minecraft.util.ChatComponentTranslation in project Armourers-Workshop by RiskyKen.
the class BlockSkinnable method sleepInBed.
private boolean sleepInBed(World world, int x, int y, int z, EntityPlayer player, Skin skin, ForgeDirection direction, TileEntitySkinnable tileEntity) {
if (world.isRemote) {
return true;
}
Point3D point = null;
if (skin.getParts().get(0).getMarkerCount() > 0) {
point = skin.getParts().get(0).getMarker(0);
} else {
point = new Point3D(0, 0, 16);
}
int xBlockOffset = MathHelper.floor_double(((double) point.getX() + 8) / 16D);
int zBlockOffset = MathHelper.floor_double(((double) point.getZ() + 8) / 16D);
int xOffset = (point.getX() + 8) - x * 16;
int zOffset = (point.getY() + 8) - y * 16;
x -= xBlockOffset * direction.offsetZ + zBlockOffset * direction.offsetX;
;
z -= zBlockOffset * direction.offsetZ + xBlockOffset * direction.offsetX;
float scale = 1F / 16F;
EntityPlayer.EnumStatus enumstatus = player.sleepInBedAt(x, y, z);
if (enumstatus == EntityPlayer.EnumStatus.OK) {
tileEntity.setBedOccupied(true);
ModLogger.log("sleeping!");
player.field_71079_bU = 0.0F;
player.field_71089_bV = 0.0F;
player.setPosition(x + 10, y - 0.5F, z + 1);
player.playerLocation = new ChunkCoordinates(x, y, z);
world.updateAllPlayersSleepingFlag();
return true;
} else {
if (enumstatus == EntityPlayer.EnumStatus.NOT_POSSIBLE_NOW) {
player.addChatComponentMessage(new ChatComponentTranslation("tile.bed.noSleep", new Object[0]));
} else if (enumstatus == EntityPlayer.EnumStatus.NOT_SAFE) {
player.addChatComponentMessage(new ChatComponentTranslation("tile.bed.notSafe", new Object[0]));
}
return true;
}
}
use of net.minecraft.util.ChatComponentTranslation in project PneumaticCraft by MineMaarten.
the class RenderItemPneumaticHelmet method render.
public void render() {
if (helmetModel == null) {
helmetModel = AdvancedModelLoader.loadModel(Models.PNEUMATIC_HELMET);
eyesModel = AdvancedModelLoader.loadModel(Models.PNEUMATIC_HELMET_EYES);
faceModel = AdvancedModelLoader.loadModel(Models.PNEUMATIC_HELMET_FACE);
if (!Config.useHelmetModel) {
PneumaticCraft.proxy.getPlayer().addChatComponentMessage(new ChatComponentTranslation("message.date.ironman"));
}
}
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glColor4d(1, 0.2, 0.2, 1);
helmetModel.renderAll();
GL11.glColor4d(1, 1, 0.7, 1);
faceModel.renderAll();
GL11.glColor4d(1, 1, 1, 1);
GL11.glDisable(GL11.GL_CULL_FACE);
eyesModel.renderAll();
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
use of net.minecraft.util.ChatComponentTranslation in project PneumaticCraft by MineMaarten.
the class EntityDrone method onDeath.
@Override
public void onDeath(DamageSource par1DamageSource) {
for (int i = 0; i < inventory.getSizeInventory(); i++) {
if (inventory.getStackInSlot(i) != null) {
entityDropItem(inventory.getStackInSlot(i), 0);
inventory.setInventorySlotContents(i, null);
}
}
if (naturallySpawned) {
} else {
ItemStack drone = getDroppedStack();
if (hasCustomNameTag())
drone.setStackDisplayName(getCustomNameTag());
entityDropItem(drone, 0);
if (!worldObj.isRemote) {
EntityPlayer owner = getOwner();
if (owner != null) {
int x = (int) Math.floor(posX);
int y = (int) Math.floor(posY);
int z = (int) Math.floor(posZ);
if (hasCustomNameTag()) {
owner.addChatComponentMessage(new ChatComponentTranslation("death.drone.named", getCustomNameTag(), x, y, z));
} else {
owner.addChatComponentMessage(new ChatComponentTranslation("death.drone", x, y, z));
}
}
}
}
if (!worldObj.isRemote)
((FakePlayerItemInWorldManager) getFakePlayer().theItemInWorldManager).cancelDigging();
super.onDeath(par1DamageSource);
}
use of net.minecraft.util.ChatComponentTranslation in project PneumaticCraft by MineMaarten.
the class CommandAmazonDelivery method processCommand.
@Override
public void processCommand(ICommandSender sender, String[] args) {
if (args.length < 2)
throw new WrongUsageException("command.deliverAmazon.args");
int x, y, z;
int curArg;
String regex = "-?\\d+";
if (args[0].matches(regex)) {
if (args.length < 4)
throw new WrongUsageException("command.deliverAmazon.args");
if (!args[1].matches(regex) || !args[2].matches(regex))
throw new WrongUsageException("command.deliverAmazon.coords");
x = Integer.parseInt(args[0]);
y = Integer.parseInt(args[1]);
z = Integer.parseInt(args[2]);
curArg = 3;
} else {
EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(args[0]);
if (player != null) {
x = (int) Math.floor(player.posX);
y = (int) Math.floor(player.posY) + 1;
z = (int) Math.floor(player.posZ);
curArg = 1;
} else {
throw new WrongUsageException("command.deliverAmazon.playerName");
}
}
if (args.length < curArg + 3)
throw new WrongUsageException("command.deliverAmazon.args");
if (!args[curArg].matches(regex) || !args[curArg + 1].matches(regex) || !args[curArg + 2].matches(regex))
throw new WrongUsageException("command.deliverAmazon.coords");
TileEntity te = sender.getEntityWorld().getTileEntity(Integer.parseInt(args[curArg]), Integer.parseInt(args[curArg + 1]), Integer.parseInt(args[curArg + 2]));
IInventory inv = IOHelper.getInventoryForTE(te);
if (inv != null) {
List<ItemStack> deliveredStacks = new ArrayList<ItemStack>();
for (int i = 0; i < inv.getSizeInventory() && deliveredStacks.size() < 65; i++) {
if (inv.getStackInSlot(i) != null)
deliveredStacks.add(inv.getStackInSlot(i));
}
if (deliveredStacks.size() > 0) {
PneumaticRegistry.getInstance().deliverItemsAmazonStyle(sender.getEntityWorld(), x, y, z, deliveredStacks.toArray(new ItemStack[deliveredStacks.size()]));
sender.addChatMessage(new ChatComponentTranslation("command.deliverAmazon.success"));
} else {
sender.addChatMessage(new ChatComponentTranslation("command.deliverAmazon.noItems"));
}
} else {
throw new WrongUsageException("command.deliverAmazon.noInventory");
}
}
Aggregations