Jump to content

VapourDrive

Members
  • Posts

    11
  • Joined

  • Last visited

Everything posted by VapourDrive

  1. Sorry, after a long time staring at this my ability to communicate had begun to deteriorate I guess. I know that tools can't stack. I put a full stack of sticks in the bottom and middle slot, and likewise iron in the top three slots and then shift clicked the output, filling my inventory with crafted tools. The console contained log information that said some of the tools were supposed to be enchanted but non of them were. (I tried things like relogging and throwing all of the items onto the ground to see if it was a desync, no luck)
  2. The results I had were with stacks of tools, and I could see from the log that the block of code was being run multiple numbers of times. I just have no idea why it isn't actually changing the itemstack.
  3. So I'm using the ItemCraftedEvent for something sortof non-conventional; random chance stuff and it's been working as planned until I noticed an issue. If I just click and drag items out of the craft slot, one in a random number ends up being enchanted. If I shift click the item out of the slot, they are never enchanted even though my logging says it runs through the code block. My event is subscribed properly etc. public class CraftingEventHandler { @SubscribeEvent public void craftingTableEvent(PlayerEvent.ItemCraftedEvent event){ Random rand = new Random(); int chance = rand.nextInt(10); if(chance > 7){ event.crafting.addEnchantment(Enchantment.getEnchantmentByLocation("efficiency"), 2); Element.log.log(Level.INFO, "Added Enchantment"); } } } Any ideas what I may be doing wrong? (also, it's been a *long* time since I've tinkered with any of this, sorry if it's something stupid)
  4. Hopefully this isn't too much of a necropost but what do you mean by changing the main class? I have the same problem, not natives folder in the generated build folder
  5. Are there limits to the priority, is is actually 0-10? What would actually happen if I give it a weight of 10000?
  6. The problem lies in that if you don't register a structure properly, for all you know the game will end up throwing your generated "thing" in randomly and it can interfere with other legit structures, such as overlap a stronghold for example. As for the rooms and hallways, a room generates initially, then there is a chance for another room to generate and if it does, a connecting hallway gets generated immediately after. The process always goes: roomA -> roomB -> hallwayAB, if roomB calls another room then the process is repeated as roomB -> roomC -> hallwayBC Generating the rooms first allowed me to make all of the sides solid and then the hallways force openings into the room. Getting the size of the rooms variable took a lot of fiddling around because they needed to be generated at different distances apart from each other. It was all pretty fun but "organizing" the world was hard with structures so big. Something like a vanilla dungeon doesn't matter because it never exceeds the bounds of its chunk (afaik).
  7. You also have to make sure that you actually reference the looting level stored in the event, not just your level, which is just initiated at 0. so you would have something like Random rand = new Random(); // since there is none supplied if(rand.nextInt(20) == 0 && event.lootingLevel > 0) { event.entityLiving.dropItem(My_Items.SuperRareEgg, event.lootingLevel); }
  8. Just generating things is really easy... see this: https://github.com/VapourDrive/ExpandedWorld Trying to register things as structures seems to be such a massive pain in the ass that I abandoned all hope and moved on to a different project. I had a dungeon based off of spherical rooms that had a chance to recursively generate another room in a row with connecting hallways and it looked quite nice. The issue ran into the size of the structure, without actually registering it as a structure the game doesn't care about where it generates and things can get really messy. I'll keep watching this thread for any updates....
  9. Thanks very much for your help Ernio. I will readily admit that I am incapable of modding at very advanced levels so the client-server ticker would be beyond me. I did manage to get it to work though. I tested other ways I could go about just preventing the block from dropping and came across the BreakSpeed event in PlayerEvent. Not only can I make the player punch much slower but it also continuously fires as well as gives me access to EntityPlayer. I haven't really touched the logic yet but here is the event: @SubscribeEvent(priority = EventPriority.HIGHEST) public void playerBlockDropCheck(PlayerEvent.BreakSpeed event) { EntityPlayer player = event.entityPlayer; Block block = event.block; Material material = block.getMaterial(); ItemStack itemstack = player.getCurrentEquippedItem(); if (itemstack == null || !itemstack.getItem().isItemTool(itemstack)) { if (material == Material.wood || material == Material.anvil || material == Material.rock || material == Material.iron) { player.attackEntityFrom(DamageSource.magic, 2.0F); event.newSpeed = 0.1F; } } }
  10. Currently the player takes the damage specified once at the beginning of attempting to harvest the block. If you continue to hold the mouse button you can continue to harvest the block with no further negative effects. I figured out that there are harvest events in the playerevent class that I could subscribe to that would produce the same end goal however I still think continuous damage while punching a block with a bare hand would be the most realistic.
  11. I have been looking through the events that forge and fml add and I noticed an event that gets called every tick that the player is using an item but I didn't find one that gets called every tick the player is attempting to break a block. If you subscribe to PlayerInteractEvent it gets called once at the initial interaction. I also tried cancelling the interaction so that the player fails at attempting to harvest the block right away. If anyone has any ideas for how-else I would damage the player if he tries to harvest a block without a tool in his hand? code: @SubscribeEvent(priority = EventPriority.HIGHEST) public void playerBlockPunch(PlayerInteractEvent event) { if (event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) { System.out.println("check"); EntityPlayer player = event.entityPlayer; int x = event.x; int y = event.y; int z = event.z; Block block = event.world.getBlock(x, y, z); Material material = block.getMaterial(); ItemStack itemstack = player.getCurrentEquippedItem(); if (itemstack == null || itemstack.getItem().isItemTool(itemstack)) { if (material == Material.wood || material == Material.anvil || material == Material.rock || material == Material.iron) { player.attackEntityFrom(DamageSource.magic, 2.0F); } } } } Also I apologize if I didn't follow any proper convention, first post
×
×
  • Create New...

Important Information

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