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

Block events in forge? (BlockBreak, BlockPlace, Explosions etc)


epicsquare
 Share

Recommended Posts

Hi,

 

How would I get these events in Forge. Coming from bukkit, I would like to port over some of my mods, and I need those events(Block Break, Block Place, Entity Explode). Surprisingly, I have not been able to find any kind of information online about server only mods for forge. Does anyone have any information on this too?

 

Thanks a lot!

Link to comment
Share on other sites

keepcalm has a small api for this:

 

https://github.com/keepcalm/BlockBreak

 

Now I have been trying it myself but I can not get it working due to the methods not existing that are shown in the readme, Give that a try and let me know how you get on because I need to use it myself aswell.

Now as for adding blocks etc..I dont know :(

 

Anyone else that can help would be great.

Link to comment
Share on other sites

Yeah, I found his little api too, but that covers only but a third of what I need. I'll take a look at it later, but hopefully there is a more universal solution to this. Thanks anyway!

 

EDIT: I got his API to build and all, but it doesn't seem to actually work. I'm not fully sure if I'm using it properly though, as in I'm not sure how to integrate it into the source. I just kind of tossed his folder into <mcproot>/src/minecraft and then registered a container class on the event bus which was:

 

public class EventHookContainerClass {

 

@ForgeSubscribe

public void BlockBreak(PlayerBreakBlockEvent e)

{

System.out.println("Break!");

}

}

 

However this was not called when block were broken.

 

Link to comment
Share on other sites

Did you initialize it?

 

MinecraftForge.EVENT_BUS.register(new ForgeEventHandler())

 

Again this is what he says to do on github, but for me again there is no ForgeEventHandler??

 

Edit:

 

Sorry I think I just realised im supposed to create that ForgeEventHandler class?? As you said you registered your own class on the even bus

Link to comment
Share on other sites

That's right, but you need to ensure FML is loading the coremod. Ninjar (for the coremods folder) coming soon ;)

Protip: try and find answers yourself before asking on the forum.

It's pretty likely that there is an answer.

 

Was I helpful? Give me a thank you!

 

 

width=635 height=903http://bit.ly/HZ03zy[/img]

 

 

Tired of waiting for mods to port to bukkit?

use BukkitForge! (now with a working version of WorldEdit!)

Link to comment
Share on other sites

So now that ive changed the code to look like this:

 

@ForgeSubscribe

public void onBlockBreak(PlayerBreakBlockEvent ev) {

    System.out.println("Break!:" );

}

 

@Init

public void init(FMLInitializationEvent ev) {

 

MinecraftForge.EVENT_BUS.register(this);

}

 

Then I can see that the server does indeed go there but when I break a block I get no output from it, am I still missing something?

Link to comment
Share on other sites

That's right, but you need to ensure FML is loading the coremod. Ninjar (for the coremods folder) coming soon ;)

 

Oh you mean this? "Version 1.4.5-0: https://github.com/downloads/keepcalm/BlockBreak/blockbreak-1.4.5-0.jar for Minecraft 1.4.4 or 1.4.5, and MinecraftForge." (From your thread). I see. Are you planning on making a block place too? And what about if a block is broken by explosion?

 

Thanks

Link to comment
Share on other sites

Nope. I put that jar into coremods and now I get:

 

[embed=425,349]---- Minecraft Crash Report ----

// Ouch. That hurt :(

 

Time: 1/6/13 12:01 PM

Description: Exception in server tick loop

 

cpw.mods.fml.common.DuplicateModsFoundException

at cpw.mods.fml.common.Loader.identifyDuplicates(Loader.java:374)

at cpw.mods.fml.common.Loader.identifyMods(Loader.java:335)

at cpw.mods.fml.common.Loader.loadMods(Loader.java:457)

at cpw.mods.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:86)

at cpw.mods.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:345)

at net.minecraft.server.dedicated.DedicatedServer.startServer(DedicatedServer.java:64)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:458)

at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- System Details --

Details:

Minecraft Version: 1.4.6

Operating System: Windows 7 (x86) version 6.1

Java Version: 1.7.0_09, Oracle Corporation

Java VM Version: Java HotSpot Client VM (mixed mode), Oracle Corporation

Memory: 964726120 bytes (920 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

Suspicious classes: FML and Forge are installed

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP v7.25 FML v4.6.12.511 Minecraft Forge 6.5.0.467 6 mods loaded, 0 mods active

mcp [Minecraft Coder Pack] (minecraft.jar)

FML [Forge Mod Loader] (coremods)

Forge [Minecraft Forge] (coremods)

BlockBreak [block Break Event] (bin)

epicsquare_Tutorial [Tutorial] (bin)

BlockBreak [block Break Event] (blockbreak-1.4.5-0.jar)

Profiler Position: N/A (disabled)

Is Modded: Definitely; Server brand changed to 'fml'

Type: Dedicated Server (map_server.txt)

[/embed]

 

Again, not sure how to actually properly integrate that block break api. Kinda noob at this  :-\

Link to comment
Share on other sites

Not my classes, its because of that jar in the coremods.

 

Game gives this error:

 

...

You have mod sources that are duplicate within your system

 

Mod Id : File name

 

BlockBreak : bin

BlockBreak : blockbreak-1.4.5-0.jar

 

Edit:

 

I removed the block break sources and added the jar as a reference. Now I get:

 

[sEVERE] [ForgeModLoader] Found a duplicate mod BlockBreak at [C:\...\Coding\mcp725\jars\coremods\blockbreak-1.4.5-0.jar, C:\....\Coding\mcp725\jars\coremods\blockbreak-1.4.5-0.jar]

 

What am I doing wrong?  :(

Link to comment
Share on other sites

Ok, I updated and released my API (link in signature). To create events, have a class that extends Event and use MinecraftForge.EVENT_BUS.post(event) when you want to call it.

Protip: try and find answers yourself before asking on the forum.

It's pretty likely that there is an answer.

 

Was I helpful? Give me a thank you!

 

 

width=635 height=903http://bit.ly/HZ03zy[/img]

 

 

Tired of waiting for mods to port to bukkit?

use BukkitForge! (now with a working version of WorldEdit!)

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



×
×
  • Create New...

Important Information

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