Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Custom fire block won't burn entities, works fine on blocks.


WolfAmaril
 Share

Recommended Posts

After some research, experimenting, and playing around with mods that are made by people vastly more skilled in Java than I, I have determined one thing.

 

This is probably one of the hardest things to attempt to do with a mod.

That is to say, make a custom fire block that goes out when hit.

Also, I am tired, it's the start of (my) weekend, so I'm just gonna sleep on it for a bit.

Link to comment
Share on other sites

Oh come on dont make it sound so impossible. I happen to have a custom fire block im my mod that also dose not go out when you left click it (Thats the way i want it) It took me 2 minutes to achieve what you are trying to do using PlayerInteractEvent.

 

Here is part of what i came up with.

@SubscribeEvent
public void playerInteract(PlayerInteractEvent event){
if (event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK){
	if (event.world.getBlock(event.x, event.y + 1, event.z) == "Your fire block"){
		event.world.setBlockToAir(event.x, event.y + 1, event.z);
	}
}
}

That will extinguish the fire if you click the block under it. However it will not work if the fire is on the side of a block i will let you figure that part out for yourself but i have done most of the work for you.

 

Hint: ForgeDirection will be a big help.

 

I am the author of Draconic Evolution

Link to comment
Share on other sites

Oh come on dont make it sound so impossible. I happen to have a custom fire block im my mod that also dose not go out when you left click it (Thats the way i want it) It took me 2 minutes to achieve what you are trying to do using PlayerInteractEvent.

 

Here is part of what i came up with.

@SubscribeEvent
public void playerInteract(PlayerInteractEvent event){
if (event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK){
	if (event.world.getBlock(event.x, event.y + 1, event.z) == "Your fire block"){
		event.world.setBlockToAir(event.x, event.y + 1, event.z);
	}
}
}

That will extinguish the fire if you click the block under it. However it will not work if the fire is on the side of a block i will let you figure that part out for yourself but i have done most of the work for you.

 

Hint: ForgeDirection will be a big help.

 

 

Just spent a few hours trying to get this to work and, while I understand the theory behind it, I can't seem to get the Subscribe event so work right, and my EventHandler class is just kinda meh.

Link to comment
Share on other sites

Link to comment
Share on other sites

Hmm... That all looks correct try adding a System.out to the event handler to to check that it is actually getting called. Also maby rename your event handler class because there are a lot of classes called EventHandler.

 

Edit: Have you done anything to your block to make it possible to actually hit it? When you try to hit fire (including my custom fire block) you actually hit the block under/behind it because fire has no selection bounding box. The way the code i gave you works is it detects when a player left clicks a block (any block) and checks if the block above that block is your fire block if so it sets the block above the block you clicked to air.

 

Edit2: Looking at your code it looks like FireColoredBase is your base block and all of the actual blocks that exist in world extend that? If that is true

event.world.getBlock(event.x, event.y + 1, event.z) == ModBlocks.FireColoredBase

will never return true because FireColoredBase dosnt actually exist in world. To fix that use instanceof FireColoredBase instead of == ModBlocks.FireColoredBase

 

Edit3: Assuming that BlockFireColoredBase is a base class that you dont want to exist in game you should not have an instance of it in your ModBlocks class the isBurning override should be in the class itself and it should not be registered. (But thats assuming you dont want it registered in game)

One last thing... Look into java naming convention http://www.oracle.com/technetwork/java/codeconventions-135099.html

I am the author of Draconic Evolution

Link to comment
Share on other sites

IT WORKS IT WORKS THANK YOU IT WORKS!

 

I'd registered FireColoredBase to try and make instanceof works, but turns out that was wrong, so now it's not registered, so that's fixed.

 

Will probably just give my fire block a normal full block bounding box to make it easier to click and not have to add lots of code. That shouldn't make it solid form what I've seen.

 

What part of the naming convention did I screw up? My Java prof taught about 4 different naming conventions (none of which I'm actually convinced are the right one).

Link to comment
Share on other sites

I'm not sure about which one you messed up, but naming something EventHandler, when you need to import an EventHandler class will really screw with the compiler unless you specify with the fully qualified name for the class you are wanting to use.

 

For example:

com.yourname.class.EventHandler would be a fully qualified name to determine which event handler class it should be using.

Link to comment
Share on other sites

I was referring to the way you named your block instances in your ModBlocks class  e.g. "FireColoredBlack" should be "fireColoredBlack" Also giving your fire block a bounding box would make things simpler but i think fire with a bounding box would be a bit weird. It wont take much to get the code i gave you yo work properly.

 

Here is another really big hint

ForgeDirection face = ForgeDirection.getOrientation(event.face);
int x = event.x + face.offsetX;
int y = event.y + face.offsetY;
int z = event.z + face.offsetZ;
System.out.println(event.world.getBlock(x, y, z));

I am the author of Draconic Evolution

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
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.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • How can i make the transparency of an block work just like the SlimeBlock, as shown in the image:
    • [11:22:34] [main/INFO]: ModLauncher running: args [--username, Amaru782, --version, forge-36.2.19, --gameDir, C:\Users\usuario\curseforge\minecraft\Instances\Better Minecraft [FORGE] - 1.16.5, --assetsDir, C:\Users\usuario\curseforge\minecraft\Install\assets, --assetIndex, 1.16, --uuid, dc27f25f4a0349eca32fbd0abdd36c7c, --accessToken, ????????, --userType, msa, --versionType, release, --width, 1366, --height, 768, --launchTarget, fmlclient, --fml.forgeVersion, 36.2.19, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20210115.111550] [11:22:34] [main/INFO]: ModLauncher 8.0.9+86+master.3cf110c starting: java version 1.8.0_51 by Oracle Corporation [11:22:35] [main/WARN]: LEGACY JDK DETECTED, SECURED JAR HANDLING DISABLED [11:22:36] [main/INFO]: Added Lets Encrypt root certificates as additional trust [11:22:36] [main/INFO]: SpongePowered MIXIN Subsystem Version=0.8.4 Source=file:/C:/Users/usuario/curseforge/minecraft/Install/libraries/org/spongepowered/mixin/0.8.4/mixin-0.8.4.jar Service=ModLauncher Env=CLIENT [11:22:36] [main/WARN]: Configuration file C:\Users\usuario\curseforge\minecraft\Instances\Better Minecraft [FORGE] - 1.16.5\config\fml.toml is not correct. Correcting [11:22:36] [main/WARN]: Incorrect key [defaultConfigPath] was corrected from null to defaultconfigs [11:22:37] [main/FATAL]: Failed to find Minecraft resource version 1.16.5-20210115.111550 at C:\Users\usuario\curseforge\minecraft\Install\libraries\net\minecraftforge\forge\1.16.5-36.2.19\forge-1.16.5-36.2.19-client.jar [11:22:37] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]: java.lang.RuntimeException: Missing minecraft resource! [11:22:37] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.minecraftforge.fml.loading.FMLCommonLaunchHandler.lambda$validatePaths$4(FMLCommonLaunchHandler.java:124) [11:22:37] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.minecraftforge.fml.loading.FMLCommonLaunchHandler$$Lambda$170/292641216.accept(Unknown Source) [11:22:37] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:     at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) [11:22:37] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:     at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580) [11:22:37] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.minecraftforge.fml.loading.FMLCommonLaunchHandler.validatePaths(FMLCommonLaunchHandler.java:121) [11:22:37] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.minecraftforge.fml.loading.FMLLoader.setupLaunchHandler(FMLLoader.java:202) [11:22:37] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.minecraftforge.fml.loading.FMLServiceProvider.initialize(FMLServiceProvider.java:94) [11:22:37] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.TransformationServiceDecorator.onInitialize(TransformationServiceDecorator.java:68) [11:22:37] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.TransformationServicesHandler.lambda$initialiseTransformationServices$7(TransformationServicesHandler.java:107) [11:22:37] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.TransformationServicesHandler$$Lambda$92/30578394.accept(Unknown Source) [11:22:37] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:     at java.util.HashMap$Values.forEach(HashMap.java:972) [11:22:37] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.TransformationServicesHandler.initialiseTransformationServices(TransformationServicesHandler.java:107) [11:22:37] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.TransformationServicesHandler.initializeTransformationServices(TransformationServicesHandler.java:59) [11:22:37] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.Launcher.run(Launcher.java:76) [11:22:37] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.Launcher.main(Launcher.java:66)  
    • excuse my idiocy where do i find the debug.log  
    • [1.17]Hey bro,i want to load a texture that can appear on the screen(like ui) when i hold some itmes,so i make a: package com.xiaomi.derby.screen; import com.mojang.blaze3d.vertex.PoseStack; import com.xiaomi.derby.item.ModItems; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionHand; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import static net.minecraftforge.fmlclient.gui.GuiUtils.drawTexturedModalRect; public class UIRenderer { private static final ResourceLocation TEXTURE = new ResourceLocation("derby","textures/gui/speed_bar"); @SubscribeEvent public void onRenderGui(RenderGameOverlayEvent.Post event) { LocalPlayer player = Minecraft.getInstance().player; if(RenderGameOverlayEvent.ElementType.ALL.equals(event.getType())){ assert player != null; if(player.getItemInHand(InteractionHand.MAIN_HAND).is(ModItems.HORSE_WHIP.get())) { Minecraft.getInstance().textureManager.bindForSetup(TEXTURE); drawTexturedModalRect(new PoseStack(), 50, 50, 80, 41, 80, 41, 0); } } } } But when i entered the game , i found there was not the texture which i set,it was a black rectangle.Can you tell me how can i solve this problem?THANKS A LOT!  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.