[1.8.3] Change block hardeness - make another bedrock

Discussion in 'Plugin Development' started by Leny12313, Aug 10, 2017.

Thread Status:
Not open for further replies.
  1. Offline

    Leny12313

    So i try to set f.e glowstone hardeness like bedrock, cuz player can't destroy this block, cuz when i use world guard player can destroy block and another player can knock this player through this block,
    i try to use this:
    CraftMagicNumbers.getBlock(Material.STONE).c(1f);
    but method c() only take String not float ;/
    and try this:
    Field f = Block.class.getDeclaredField("strength");
    f.setAccessible(true);
    f.set(Block.GLOWSTONE, 50.0F); // make sure it's a float
    //import net.minecraft.server.v1_8_R3.Block;
    but Block.GLOWSTONE not exists ;/
     
  2. Offline

    Kermit_23

    have you tried this? https://bukkit.org/threads/change-block-resistance.459728/
     
  3. Kermit_23 likes this.
  4. Offline

    Leny12313

    @AlvinB sory but i don't have server, i make this for my friend only
    @Kermit_23
    Block block = Block.getByName("IRON_DOOR");
    try {
    Field field = Block.class.getDeclaredField("durability");
    field.setAccessible(true);
    field.set(block, 600000.0f);
    } catch (NoSuchFieldException | IllegalAccessException e) {
    e.printStackTrace();
    }
    i try this, but strill iron_door dig as fast as without this code ;/
     
    Last edited: Aug 11, 2017
  5. @Leny12313
    Then go tell him to update. There are incredibly few people who can actually help you considering you're using 1.8 NMS code.
     
  6. Offline

    Zombie_Striker

    @Leny12313
    If you don't want a player to be able to break a door, why not listen to BlockBreakEvent and cancel the event if it is for an iron door? There is no reason to go into NMS.
     
  7. Offline

    MattTheBeast

    Its funny because I just recently made a thread on somewhat the same topic. People dont seem to understand that we are not trying to cancel a block break event, we are trying to avoid a block break and the block cracking altogether. Your problem is the same as mine, you whant to prevent a block break event to happen, not to cancel it.

    @Leny12313
    If you find a fix be sure to pm me about it, and If I find anything il let you know. Iv tryed so many things and I'm losing hope, but whats really bothering me is that i'v seen this done before :/
     
  8. Offline

    Zombie_Striker

    @MattTheBeast
    If that is the case, why not just cancel PlayerInteractEvent if they are left clicking the block?
     
  9. Offline

    MattTheBeast

    @Zombie_Striker PlayerInteractEvent is only called once when you left click a block, if the player holds down they can still break the block. Same goes with the BlockDamageEvent.
     
Thread Status:
Not open for further replies.

Share This Page