Jump to content

TLHPoE

Members
  • Posts

    638
  • Joined

  • Last visited

Everything posted by TLHPoE

  1. I'm sending this from a GUI package enderstorage.gui; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import enderstorage.EnderStorage; import enderstorage.container.ContainerExpEnderChest; import enderstorage.network.PacketRequestChangeExp; import enderstorage.network.PacketRequestRefresh; import enderstorage.tileentity.TileEntityExpEnderChest; //854, 480 @SideOnly(Side.CLIENT) public class GuiExpEnderChest extends GuiContainer { private static final ResourceLocation texture = new ResourceLocation("enderstorage:textures/gui/expEnderChest.png"); private EntityPlayer player; public GuiExpEnderChest(TileEntityExpEnderChest chest, EntityPlayer player) { super(new ContainerExpEnderChest(chest)); this.ySize = 88; this.player = player; } public void initGui() { super.initGui(); this.buttonList.add(new GuiButton(0, this.width / 2 - 83, this.height / 2 - 10, 20, 20, I18n.format("<<<", new Object[0]))); this.buttonList.add(new GuiButton(1, this.width / 2 - 63, this.height / 2 - 10, 20, 20, I18n.format("<<", new Object[0]))); this.buttonList.add(new GuiButton(2, this.width / 2 - 43, this.height / 2 - 10, 20, 20, I18n.format("<", new Object[0]))); this.buttonList.add(new GuiButton(3, this.width / 2 + 63, this.height / 2 - 10, 20, 20, I18n.format(">>>", new Object[0]))); this.buttonList.add(new GuiButton(4, this.width / 2 + 43, this.height / 2 - 10, 20, 20, I18n.format(">>", new Object[0]))); this.buttonList.add(new GuiButton(5, this.width / 2 + 23, this.height / 2 - 10, 20, 20, I18n.format(">", new Object[0]))); EnderStorage.packetHandler.sendToServer(new PacketRequestRefresh()); } protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { String s = I18n.format("container.expEnderChest", new Object[0]); this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752); s = I18n.format("container.expEnderChest.stored", new Object[0]); this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 35, 4210752); s = "" + EnderStorage.currentStored; int x = this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2; int y = 45; this.fontRendererObj.drawString(s, x + 1, y, 0); this.fontRendererObj.drawString(s, x - 1, y, 0); this.fontRendererObj.drawString(s, x, y + 1, 0); this.fontRendererObj.drawString(s, x, y - 1, 0); this.fontRendererObj.drawString(s, x, y, 8453920); } protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(texture); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); } protected void actionPerformed(GuiButton b) { switch(b.id) { case (0): EnderStorage.packetHandler.sendToServer(new PacketRequestChangeExp().setExp(-10)); break; case (1): EnderStorage.packetHandler.sendToServer(new PacketRequestChangeExp().setExp(-5)); break; case (2): EnderStorage.packetHandler.sendToServer(new PacketRequestChangeExp().setExp(-1)); break; case (3): EnderStorage.packetHandler.sendToServer(new PacketRequestChangeExp().setExp(10)); break; case (4): EnderStorage.packetHandler.sendToServer(new PacketRequestChangeExp().setExp(5)); break; case (5): EnderStorage.packetHandler.sendToServer(new PacketRequestChangeExp().setExp(1)); break; } } } I'm not using the exp field because I'm just testing with it. Also the PacketRefreshExp is sent to the client so it'll display it on their gui.
  2. Hmm, it seems that writing to the persisted nbt tag compount doesn't work. :I
  3. The exp field isn't used in anything right now. It returns itself so I can do this: packetHandler.setToServer(new PacketRequestChangeExp().setExp(10));
  4. You could remove all recipes for the block/item and reroute them to your block/item. Or use a core mod.
  5. This is the code I use for spawning a mob. I believe you need to set their angles for them to function properly. World world = player.worldObj; EntityZombie zombie = new EntityZombie(world); zombie.setLocationAndAngles(player.posX, player.posY, player.posZ, MathHelper.wrapAngleTo180_float(w.rand.nextFloat() * 360.0F), 0.0F); zombie.rotationYawHead = zombie.rotationYaw; zombie.renderYawOffset = zombie.rotationYaw; world.spawnEntityInWorld(zombie); zombie.playLivingSound();
  6. I'm currently messing around with the persisted NBT tag in the player, and the integer won't save: NBTTagCompound nbt = player.getEntityData().getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); nbt.setInteger("EnderStorageExp", nbt.getInteger("EnderStorageExp") + 1); I have this code inside of a packet that gets called pretty frequently. Here's the full class: package enderstorage.network; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import enderstorage.EnderStorage; public class PacketRequestChangeExp extends AbstractPacket { public int exp = 0; public PacketRequestChangeExp setExp(int exp) { this.exp = exp; return this; } @Override public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { buffer.writeInt(exp); } @Override public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { exp = buffer.readInt(); } @Override public void handleClientSide(EntityPlayer player) { } @Override public void handleServerSide(EntityPlayer player) { NBTTagCompound nbt = player.getEntityData().getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); nbt.setInteger("EnderStorageExp", nbt.getInteger("EnderStorageExp") + 1); EnderStorage.packetHandler.sendTo(new PacketRefreshExp().setExp(nbt.getInteger("EnderStorageExp")), (EntityPlayerMP) player); } } The default value of the tag is 0. When it's 0 and the code it called, it goes up to 1. If it's 1, it just keeps setting itself to 1.
  7. Hello, I would like to suggest an event where when the server is copying the dead player's data (ender chest, etc.) to the new, respawned player. The event should also have the dead player and the new player. This event would really be helpful for making data persist through player death. You might say, "You could easily store the data in a map when the player dies and apply them when they respawn!" That works, but not when the player dies and the server restarts. Another way is to create a file inside the world folder, but it seems a bit over kill.
  8. It doesn't persist through death. :I I've looked at coolAlias's tutorial on IExtendedEntityProperties but it does something similar to what I'm doing.
  9. Is there any way to save an inventory to the player? Even through death? I know of one way, but it wouldn't work if the player died and then the server restarted. First, I wrote my slot contents to the player if they opened the inventory. Then, if they died, their data would be stored in a HashMap with their name. Finally, when they respawn, it gets rewritten to them.
  10. I'm not sure if you have a method to write an array of bytes, but here's a way to convert a String to a byte array: new String("Hello World!").getBytes();
  11. Is there an event that is called whenever a plant is grown? Like a tree, wheat, right clicking grass with bone meal, etc.
  12. You're missing a space here: GameRegistry.addRecipe(new ItemStack(DiamondMandarineAxe, 1), new Object[]{ "DD", //<------ Right here "DS "," D ",'D',FoodLol.DiamondMandarine,'S',Item.stick }); Could you post the FoodLol class?
  13. For your own recipes, just make your own crafting manager. And for the time, you'll need to add that yourself.
  14. If the itemstack's damage is 99 or 1, it returns and doesn't set it to 99.
  15. I'm clueless on how to do this, but you could create your own ItemBlock class and redirect the Item.getItemFromBlock to it.
  16. Look into what RenderLivingEntity does in its doRender method. Additionally, you could look into how the Enchantment Table does.
  17. I have this class: package tlhpoe.fs.item; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ItemHermesRing extends Item { public ItemHermesRing() { super(); setMaxStackSize(1); setMaxDamage(100); } @Override public void onUpdate(ItemStack is, World world, Entity entity, int par4, boolean par5) { if(!world.isRemote) if(entity instanceof EntityPlayer) { //EntityPlayer player = (EntityPlayer) entity; int dmg = is.getItemDamage(); switch(dmg) { case (99): // return; case (1): // return; } System.err.println("SETTING TO 99"); is.setItemDamage(99); } } @Override public ItemStack onItemRightClick(ItemStack is, World w, EntityPlayer player) { if(!w.isRemote) { int dmg = is.getItemDamage(); switch(dmg) { case (99): is.setItemDamage(1); return is; case (1): is.setItemDamage(99); return is; } } return is; } } For some reason, at this part: @Override public ItemStack onItemRightClick(ItemStack is, World w, EntityPlayer player) { if(!w.isRemote) { int dmg = is.getItemDamage(); switch(dmg) { case (99): is.setItemDamage(1); return is; case (1): is.setItemDamage(99); return is; } } return is; } Everytime I right click, it goes directly to case (99). Am I doing something wrong with setting the itemstack's damage?
  18. Ok, instead I've used the ItemTossEvent to get the dropped item, then I used my own EntityItem class that detects if it's on the ground.
  19. I'm currently trying to implement a kind of drop item into block to get something, but I can't find the right event. I've tried the ItemTossEvent, but it's only called when the entityitem is put into the world. I also tried the LivingFallEvent, but of course, it's only for living entities. So is there an event that's called when an EntityItem drops?
  20. Did you ever call the readFromNBT method?
  21. Did you register your event handler? Could you show your ModelCrown class?
  22. Change en_US.txt to en_US.lang. Also, you need to set the item's unlocalized name.
  23. Here's how I wrote key bindings: https://github.com/TheSlayerMC/RPG/blob/master/net/rpg/handler/KeyHandler.java
  24. This is how I would do it: 1. Make a proxy for client 2. Register an event for RenderPlayerEvent 3. In the event, draw stuff You don't need any server-side stuff because all you're doing is rendering client-side.
  25. Use Draco's, I'm dumb. package tlhpoe.fs.item; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBow; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ItemTest extends ItemBow { private boolean fired; @Override public ItemStack onItemRightClick(ItemStack is, World w, EntityPlayer player) { if(!w.isRemote) { if(!fired) { fired = true; } } return is; } @Override public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) { fired = false; } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.