public void runCommand(ItemStack itemStack, World world, EntityPlayer entityPlayer) { if (itemStack != null || NBTHelper.getBoolean(itemStack, "isSet")) { switch (NBTHelper.getInt(itemStack, "commandID")) { case 0: // toggleDownFall toggleDownfall(); break; case 1: // give Random giveItem(entityPlayer); break; case 2: // kill Entity // EntityLivingBase entity = (EntityLivingBase) getEntityLookingAt(world, entityPlayer); break; case 3: // time set day setTime(world, entityPlayer, "day"); break; case 4: // time set night setTime(world, entityPlayer, "night"); break; default: LogHelper.error("Error running command in ItemCommandScroll"); LogHelper.error("Case index out of bounds:" + NBTHelper.getInt(itemStack, "commandID")); break; } } }
public void onGuiTextfieldUpdate(int id, String text) { if (id == 0) { name = text; markDirty(); } else if (id == 1) { message = text; markDirty(); } else { LogHelper.error("Invalid TextField id in TileEntityChatBox: " + id); } }
private void setTime(World world, EntityPlayer entityPlayer, String timeStr) { long time; if (timeStr == "day") { time = 1000; } else if (timeStr == "night") { time = 13000; } else { time = 0; LogHelper.error("Improper setTime call in ItemCommandScroll"); } for (int j = 0; j < MinecraftServer.getServer().worldServers.length; ++j) { MinecraftServer.getServer().worldServers[j].setWorldTime(time); } }