Jump to content

Mistram

Members
  • Posts

    35
  • Joined

  • Last visited

Everything posted by Mistram

  1. I created a Networkchannel, that is working just fine, and a IMessage and its Handler. I am triing to send an integer over the channel, shorts are working no problem. The message is registered, but if I try to send it I get a strange exception. Message and Handler class public class ActualEnergyMessage implements IMessage{ private int actualEnergy; public ActualEnergyMessage() { } public ActualEnergyMessage(int actualEnergy) { this.actualEnergy = actualEnergy; } @Override public void fromBytes(ByteBuf buf) { actualEnergy = ByteBufUtils.readVarInt(buf, 16); } @Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeVarInt(buf, actualEnergy, 16); } public static class Handler implements IMessageHandler<ActualEnergyMessage, IMessage> { @Override public IMessage onMessage(ActualEnergyMessage message, MessageContext ctx) { ((ExtendedPlayer)(Minecraft.getMinecraft().thePlayer.getExtendedProperties(ExtendedPlayer.EXT_PROP_NAME))).setActualEnergy(message.actualEnergy); return null; } } }
  2. I guess I need to specify my question. Is entityjoinworld ALWAYS called after the entity gots constructed? If yes when would it be better to use the one or the other event
  3. Hello everyone, I have been studiing events, and right now I am really confused what the difference between EntityConstrcuting and EntityJoinWorld is and when to use which. Can anyone help? Greetz Mistram
  4. I need to think about your idea and try a little bit. And yes it is called after breaking the block. Even if Im doing nothing. And the mined block is getting replaced for some seconds. I have NO idea why. I think if that issue is fixxed I can finish my work
  5. I got some code that breaks a whole tree when u mine one log from it. Now I wanna realize that it takes longer to break the bigger the tree is. Right now I am triing to safe a value when a player starts to harvest a tree. Everytime BreakSpeed is called I get that value from the hasmap and use it. Problem right now: After breaking a log the BreakSpeed wont stop getting called. private static HashMap<String, Float> map = new HashMap<String, Float>(); @SubscribeEvent public void breakSpeed(BreakSpeed speed) { System.out.println("call"); if (!speed.entityPlayer.worldObj.isRemote &&speed.state.getBlock() instanceof BlockLog) { speed.newSpeed = map.get(speed.entityPlayer.getName()); System.out.println(speed.newSpeed); } } @SubscribeEvent public void interact(PlayerInteractEvent event) { if (!event.world.isRemote) { if (event.world.getBlockState(event.pos).getBlock() instanceof BlockLog) { map.put(event.entityPlayer.getName(), 0.1F); } } }
  6. Actually I need to change my problem. How can I make that the event is called only ONCE, when the player starts to interact with the tree. Because otherway I would kill minecraft with calculating if the mined thing is a tree every call..
  7. 3 times yes. I was using this with a syso and it was firing like insane
  8. Hello everyone, I am triing of making a mod that'll is working with Logs and Trees. To implement full functionality I wanted to change the time a player needs to break a log if the log is part of a tree. I tried like so @SubscribeEvent public void breakSpeed(BreakSpeed speed) { if (speed.state.getBlock() instanceof BlockLog && isATree(speed.state.getBlock)) { speed.newSpeed=100F; } } But it seems like my code isnt affecting the breakSpeed of the block.. Any Ideas why?
  9. You need to define every age of the corn in a separate json file or it wont work. I can only link u a german tutorial dont found a english one yet
  10. I am triing to make a chest that can contain stacks with more then 64 Items. My problem is that it seems that it wont accept if I let getInventoryStackLimit return more then 64. Any way to get around that? Heres my code public class TileEntityInfiniteChest extends TileEntity implements IInventory{ private ItemStack[] items; @Override public void writeToNBT(NBTTagCompound compound) { // TODO Auto-generated method stub super.writeToNBT(compound); NBTTagList items = new NBTTagList(); for (int i=0; i<getSizeInventory(); i++) { ItemStack stack = getStackInSlot(i); if (stack!=null) { NBTTagCompound item = new NBTTagCompound(); item.setByte("Slot", (byte) i); stack.writeToNBT(item); items.appendTag(item); } } compound.setTag("Items", items); } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); NBTTagList items = (NBTTagList) compound.getTag("Items"); if (items==null) { return; } for (int i = 0; i <items.tagCount(); i++) { NBTTagCompound item = items.getCompoundTagAt(i); byte slot = item.getByte("Slot"); setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(item)); } } public TileEntityInfiniteChest() { items = new ItemStack[3]; } @Override public String getName() { return null; } @Override public boolean hasCustomName() { return false; } @Override public IChatComponent getDisplayName() { return null; } @Override public int getSizeInventory() { return items.length; } @Override public ItemStack getStackInSlot(int index) { return items[index]; } @Override public ItemStack decrStackSize(int index, int count) { ItemStack itemstack = getStackInSlot(index); if (itemstack!=null) { if (itemstack.stackSize <=count) { setInventorySlotContents(index, null); } else { itemstack= itemstack.splitStack(count); markDirty(); } } return itemstack; } @Override public ItemStack getStackInSlotOnClosing(int index) { ItemStack item = getStackInSlot(index); setInventorySlotContents(index, null); return item; } @Override public void setInventorySlotContents(int index, ItemStack stack) { items[index] = stack; } @Override public int getInventoryStackLimit() { return 128; } @Override public boolean isUseableByPlayer(EntityPlayer player) { return player.getDistanceSqToCenter(pos)<=64; } @Override public void openInventory(EntityPlayer player) { // TODO Auto-generated method stub } @Override public void closeInventory(EntityPlayer player) { // TODO Auto-generated method stub } @Override public boolean isItemValidForSlot(int index, ItemStack stack) { // TODO Auto-generated method stub return true; } @Override public int getField(int id) { // TODO Auto-generated method stub return 0; } @Override public void setField(int id, int value) { // TODO Auto-generated method stub } @Override public int getFieldCount() { // TODO Auto-generated method stub return 0; } @Override public void clear() { // TODO Auto-generated method stub } }
×
×
  • Create New...

Important Information

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