Jump to content

DosMike

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by DosMike

  1. file and fileCopy hurt me, they should both be invalid pathnames starting with a colon... if you want to write in the game directory you should be able to just use a relative path (new File("words.txt"), or new File(".", "words.txt") if you want to explicitly mention a directory) besides that copying a file twice to append a line seems highly inefficient, instead try using a FileWriter: new BufferedWriter(new FileWriter("words.txt", true)); The second argument is the append flag, for more information google it. Also please don't forget to .flush() any output stream before closing it to prevent data loss
  2. Ah thank you very much, that did the trick
  3. So I basically want to be able to put stuff on a block and take it back off (changing it's state). Since I want to partially require different items/tools for that I'm using the onBlockActivated-Method: @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (!facing.equals(EnumFacing.UP)) return false; ItemStack item = playerIn.getHeldItem(hand); if (item == null || item.isEmpty()) return false; Type type = state.getValue(VARIANT); if (item.getItem().getToolClasses(item).contains("shovel")) { if (type.equals(Type.CLEAN)) return false; // clean up cleaned if (type.equals(Type.HAYED)) { //take back clean wheat if (!worldIn.isRemote) { worldIn.setBlockState(pos, getStateFromMeta(Type.CLEAN.getMeta())); Renergy.l("Dropping Wheat"); EntityItem recycle = new EntityItem(worldIn, hitX, hitY + 0.1, hitZ, new ItemStack(Items.WHEAT)); recycle.setDefaultPickupDelay(); worldIn.spawnEntity(recycle); worldIn.playSound(playerIn, hitX, hitY, hitZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.BLOCKS, 1f, 1f); } return true; } //More cases.... Now changing the BlockState and decreasing the item in hand (placing something on the block) works without any problems. Taking the item back from the block (with a shovel in this case) however only changes the BlockState. The item wont spawn, the sound wont play and what frustrates me the most is that there is absolutely no StackTrace whatsoever. There seems to be a similar topic from about a year ago that sadly never got resolved, so I'm opening this topic. I'm currently building against forge 2619
×
×
  • Create New...

Important Information

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