Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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.

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

  • Author

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!

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.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.