Jump to content

[1.19/1.18.2] Fire Block Burns Forever


Noxxous

Recommended Posts

Hello, I have set it to Setblock Fire and I have tried copying from Flint and Steel and I have changed it to no. 3 flag, but it still burns forever and unloads when you go somewhere else


    @SubscribeEvent
    public static void Mine (LeftClickBlock event) {
        BlockPos bPos = event.getPos();
        BlockPos DebugPos = bPos;
        if ((event.getEntity().getMainHandItem().getItem() == itemInit.lightsaber_on.get() || event.getEntity().getMainHandItem().getItem() == itemInit.lightsaber_off.get())/* && !event.getLevel().isClientSide*/){
            if (event.getFace() == Direction.UP || event.getFace() == Direction.DOWN) {
                for (int i = 1; i > -2; i--) {
                    for (int j = 1; j > -2; j--) {
                        bPos = new BlockPos(DebugPos.getX() + i, DebugPos.getY(), DebugPos.getZ() + j);
                        Minecraft.getInstance().level.setBlock(bPos, BaseFireBlock.getState(Minecraft.getInstance().level, bPos), 3);
                        event.getLevel().gameEvent(event.getEntity(), GameEvent.BLOCK_PLACE, bPos);
                        Minecraft.getInstance().level.setBlock(DebugPos, BaseFireBlock.getState(Minecraft.getInstance().level, DebugPos), 3);
                        event.getLevel().gameEvent(event.getEntity(), GameEvent.BLOCK_PLACE, DebugPos);
                    }
                }
            }
            if (event.getFace() == Direction.NORTH || event.getFace() == Direction.SOUTH) {
                for (int i = 1; i > -2; i--) {
                    for (int j = 1; j > -2; j--) {
                        bPos = new BlockPos(DebugPos.getX() + i, DebugPos.getY() + j, DebugPos.getZ());
                        Minecraft.getInstance().level.setBlock(bPos, BaseFireBlock.getState(Minecraft.getInstance().level, bPos), 3);
                        event.getLevel().gameEvent(event.getEntity(), GameEvent.BLOCK_PLACE, bPos);
                        Minecraft.getInstance().level.setBlock(DebugPos, BaseFireBlock.getState(Minecraft.getInstance().level, DebugPos), 3);
                        event.getLevel().gameEvent(event.getEntity(), GameEvent.BLOCK_PLACE, DebugPos);
                    }
                }
            }
            if (event.getFace() == Direction.EAST || event.getFace() == Direction.WEST) {
                for (int i = 1; i > -2; i--) {
                    for (int j = 1; j > -2; j--) {
                        bPos = new BlockPos(DebugPos.getX(), DebugPos.getY() + i, DebugPos.getZ() + j);
                        Minecraft.getInstance().level.setBlock(bPos, BaseFireBlock.getState(Minecraft.getInstance().level, bPos), 3);
                        event.getLevel().gameEvent(event.getEntity(), GameEvent.BLOCK_PLACE, bPos);
                        Minecraft.getInstance().level.setBlock(DebugPos, BaseFireBlock.getState(Minecraft.getInstance().level, DebugPos), 3);
                        event.getLevel().gameEvent(event.getEntity(), GameEvent.BLOCK_PLACE, DebugPos);
                    }
                }
            }
            Minecraft.getInstance().player.playSound(SoundEvents.GENERIC_DRINK, 1.0f, 1.0f);
            event.setCanceled(true);
        }
    }
 

Edited by Noxxous
Added the version
Link to comment
Share on other sites

  • Noxxous changed the title to [1.19/1.18.2] Fire Block Burns Forever

You are using that event in the wrong way and you are only doing things on the client side which means nothing gets persisted or seen by other players.

You should be coding this in your useOn() method for your item like the flint and steel and pay attention to the use of sidedSuccess()

https://forge.gemwire.uk/wiki/Sides

https://forge.gemwire.uk/wiki/Block_Interaction

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

This is how I got your requirements to work:

@Mod.EventBusSubscriber(modid = ExampleMod.MODID)
public class Events {
    @SubscribeEvent
    public static void startFires(LeftClickBlock event) {
        var itemStack = event.getItemStack();
        if (itemStack.is(ExampleMod.MY_SWORD.get())) {
            var minecraft = Minecraft.getInstance();
            BlockHitResult blockhitresult = (BlockHitResult) minecraft.hitResult;
            minecraft.gameMode.useItemOn(minecraft.player, minecraft.level, event.getHand(), blockhitresult);
            event.setCanceled(true);
        }
    }
}

Then I just copied the flint and steel useOn() code into my sword item.

 

I still think this is kind of an abuse of that event though.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

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