Manic_Cure Posted May 12, 2014 Posted May 12, 2014 I'm writing a mod to create wood fences for all the different types of wood in minecraft, but I want them all to connect to each other. It was easy enough to override the fences' canConnectFenceTo() methods, so now the only one left is the vanilla fence. Is there a way to override or circumvent the vanilla fence's canConnectFenceTo() method so that it connects to the other fences? I have just begun learning mincraft modding, but I know Java pretty well. I'm just used to creating my own projects from scratch, and far less experienced working around someone else's code. Thanks in advance. Quote
jabelar Posted May 12, 2014 Posted May 12, 2014 Firstly, if your fence classes extend the vanilla fence class then the vanilla fence class will consider them fences. Secondly, if there is a cancellable event at the time of interest you can intercept it by subscribing to it and doing your own processing. Like maybe when player places a block you could intercept it. Thirdly you can replace the vanilla block with your own that extends the vanilla block but overrides the methods you want to customize. You can do the replacement by maybe changing the crafting recipe for the fence to output yours instead, or you can look for any instances of fence and simply replace them with yours, and so forth. Not necessarily elegant but possible. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
Manic_Cure Posted May 12, 2014 Author Posted May 12, 2014 Thanks for the reply, jabelar. My fence class does extend the vanilla fence, however, it doesn't seem to recognize a child of the BlockFence class as a Block.fence, and therefore the method mentioned above returns a false boolean. Your second suggestion might solve my problem, but I have yet to look into tapping into subscribing to game events, and am unfamiliar with how minecraft handles player events. I'll check this method out, thanks! Quote
jabelar Posted May 12, 2014 Posted May 12, 2014 Thanks for the reply, jabelar. My fence class does extend the vanilla fence, however, it doesn't seem to recognize a child of the BlockFence class as a Block.fence, and therefore the method mentioned above returns a false boolean. Yeah, the problem is the way it checks if it is a fence. If it had checked the class using isMemberOf then your blocks would be considered fences, but since it is checking specifically against the registered instance then yeah that won't work. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
Recommended Posts
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.