Jump to content

Taimander

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by Taimander

  1. Nvm, its actually easy, just use context.get(LootParameters.THIS_ENTITY) Thank you again!
  2. Thank you very much for the GLMs! I didn't know they existed haha. As you said, it will be a bit of a headache to figure out who the player is, but you definitely helped me to get a path to take! Thank you.
  3. Hello, I am trying to make that when a player breaks a block, it doesn't drop the block. I don't want to cancel the event, the block must break, as if nothing really changed, except that it doesn't drop anything. If possible, I want to know what were the drops that the player would've had. I'm looking for something like this: ItemStack[] drops = event.getDrops(); event.setDrops(new ItemStack[0]); Thanks in advance
  4. That is normal, the downloads are executable jars. Just open it as if it was a .exe
  5. How can I change the light level spawn conditions?
  6. Hello, I want to modify the spawn conditions of monsters so that instead of spawning at night, they spawn at daytime. I looked for a way to do this, but what I found is an answer from 2013 about an EntityRegistry, but I can't find it, so I think it may have been renamed, changed or removed. (Or I am just dumb and missed it) How can I do this right now? (I want to do this with vanilla mobs, not custom mobs.)
  7. @diesieben07 Oh thank you very much. I didn't know tags existed haha. I was overcomplicating everything, this is much easier.
  8. Hello, I am looking to change the behavior of water and lava blocks, basically I want to make so that the lava doesn't burn the player and that water burns the player. I found that the line that handles lava burning is in the onEntityCollision method on the FlowingFluidBlock class: public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { if (this.fluid.isIn(FluidTags.LAVA)) { entityIn.setInLava(); } } the method checks if the fluid is lava, so I tought that I could create a class that extends this one and modify only that method. But I can't seem to be able to re-define the lava and water blocks on the Blocks class. (I am using reflection to do that, since the fields are final). Field lavafield = Blocks.class.getDeclaredField("LAVA"); // LAVA field from Blocks (THIS IS WHERE THE EXCEPTION OCCURS) Field waterfield = Blocks.class.getDeclaredField("WATER"); // WATER field from Blocks Field modifiersField = Field.class.getDeclaredField("modifiers"); // modifiers of a field modifiersField.setAccessible(true); // make modifiers public modifiersField.setInt(lavafield, lavafield.getModifiers() & ~Modifier.FINAL); // set LAVA public modifiersField.setInt(waterfield, waterfield.getModifiers() & ~Modifier.FINAL); // set WATER public lavafield.set(null, register("lava", new PatchedFlowingFluidBlock(Fluids.LAVA, Block.Properties.create(Material.LAVA).doesNotBlockMovement().tickRandomly().hardnessAndResistance(100.0F).lightValue(15).noDrops()))); // Redefine the block with the "patched" FlowingFluidBlock that checks for water to burn. waterfield.set(null, register("water", new PatchedFlowingFluidBlock(Fluids.WATER, Block.Properties.create(Material.WATER).doesNotBlockMovement().hardnessAndResistance(100.0F).noDrops()))); // The same as the line before This is my new onEntityCollision: @Override public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { if (this.getFluid().isIn(FluidTags.WATER)) { entityIn.setInLava(); } } This approach doesn't work (It gives a NoSuchFieldException in the first line, idk why) and also I believe it is very hacky because is uses reflection, modifying final fields and using deprecated methods. Is there a better/easier way to do this?
×
×
  • Create New...

Important Information

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