Jump to content

[Solved][1.9.4] Updating my custom walls from 1.8 to 1.9.4


Erfurt

Recommended Posts

Hey guys,

 

I'm having some difficulty updating my custom walls, and i was hoping that someone could help me.

 

Here's the code for my base wall class ( this worked in 1.8 ), I use this because I have different types of wall that have different properties, for example some of my walls emits light. I extend my other classes from the base class.

public abstract class BaseBlockWall extends BlockWall
{
public BaseBlockWall(Block block)
{
	super(block);
}

public int damageDropped(int meta)
{
	return meta;
}

public boolean canPlaceTorchOnTop(IBlockAccess world, BlockPos pos)
{
	return true;
}

public boolean canConnectTo(IBlockAccess world, BlockPos pos)
    {
	IBlockState state = world.getBlockState(pos);
        Block block = state.getBlock();
        return block == Blocks.BARRIER ? false : (((block != this && !(block instanceof BlockFenceGate) && !(block instanceof BlockWall))) ? (block.getMaterial(state).isOpaque() && state.isFullCube() ? block.getMaterial(state) != Material.GOURD : false) : true);
    }
}

At first glans everything seems to work. But none of my walls want to connect to each other. It only want to connect to itself. I want to have all of the different classes connecting to eachother. A second thing that isn't working is that I can't place torches on top of the walls.

 

This is the code for my basic walls class.

public class EadoreWall extends BaseBlockWall
{
public EadoreWall(Block block, String name)
{
	super(block);
	this.setUnlocalizedName(name);
	this.setRegistryName(name);
}

@Override
@SideOnly(Side.CLIENT)
    public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list)
    {
        list.add(new ItemStack(item, 1, 0));
    }
}

 

To my knowledge this should work. However it does not, maybe someone can see something I can't.

Link to comment
Share on other sites

Your error is in canConnectTo. You use "block != this", which will limit each wall's connection to itself. You probably want "instanceof BlockWall" (or BaseBlockWall) so all your walls accept every other wall.

 

I also recommend that you optimize that expression, but that's probably my OCD kicking in  ;)

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

Your error is in canConnectTo. You use "block != this", which will limit each wall's connection to itself. You probably want "instanceof BlockWall" (or BaseBlockWall) so all your walls accept every other wall.

 

I also recommend that you optimize that expression, but that's probably my OCD kicking in  ;)

 

I tried that, sadly it didn't make a difference. I have been looking at vanilla code, from 1.8.9 and 1.9.4 and it seems that the vanilla method was changed from public to private, could this be the reason for my problem? If so, can I even fix? How?

Link to comment
Share on other sites

Your error is in canConnectTo. You use "block != this", which will limit each wall's connection to itself. You probably want "instanceof BlockWall" (or BaseBlockWall) so all your walls accept every other wall.

 

I also recommend that you optimize that expression, but that's probably my OCD kicking in  ;)

BTW what do you mean by optimize the expression? Personally I can't see how this can be done otherwise. It's pretty much the same way that vanilla code does it.

Link to comment
Share on other sites

I have fixed the torch thing, the method had been changed a bit from 1.8 to 1.9. Still haven't been able to get my walls to connect, any help would be lovely ☺️

Post your updated BaseBlockWall and EadoreBlockWall.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

I have fixed the torch thing, the method had been changed a bit from 1.8 to 1.9. Still haven't been able to get my walls to connect, any help would be lovely ☺️

Post your updated BaseBlockWall and EadoreBlockWall.

I all did was to change from

public boolean canPlaceTorchOnTop(IBlockAccess world, BlockPos pos)
{
	return true;
}

to

@Override
public boolean canPlaceTorchOnTop(IBlockState state, IBlockAccess world, BlockPos pos)
{
	return true;
}

 

I have otherwise, tried all of your suggestions, regarding the walls not connecting to each other, but without any success, and that was when I noticed that the canConnectTo method inside BlockWall had been changed from public to private, and I don't know if that's why my code from 1.8 doesn't work in 1.9.4, as I mentioned in my original post, I had everything working in 1.8.

Link to comment
Share on other sites

I have fixed the torch thing, the method had been changed a bit from 1.8 to 1.9. Still haven't been able to get my walls to connect, any help would be lovely ☺️

Post your updated BaseBlockWall and EadoreBlockWall.

I all did was to change from

public boolean canPlaceTorchOnTop(IBlockAccess world, BlockPos pos)
{
	return true;
}

to

@Override
public boolean canPlaceTorchOnTop(IBlockState state, IBlockAccess world, BlockPos pos)
{
	return true;
}

 

I have otherwise, tried all of your suggestions, regarding the walls not connecting to each other, but without any success, and that was when I noticed that the canConnectTo method inside BlockWall had been changed from public to private, and I don't know if that's why my code from 1.8 doesn't work in 1.9.4, as I mentioned in my original post, I had everything working in 1.8.

I would prefer to look at the whole class(es) but I think this is your problem.

(((block != this && !(block instanceof BlockFenceGate) && !(block instanceof BlockWall)))
// Instead use
(!(block instanceof BlockWall) || !(block instanceof BlockFenceGate))

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

I fixed it now. Because canConnectTo is a private boolean in the BlockWall class, I need to add and override the IBlockState getActualState, for it to work. So my final class looks like this.

public abstract class BaseBlockWall extends BlockWall
{
public BaseBlockWall(Block block)
{
	super(block);
}

public int damageDropped(int meta)
{
	return meta;
}

@Override
public boolean canPlaceTorchOnTop(IBlockState state, IBlockAccess world, BlockPos pos)
{
	return true;
}

public boolean canConnectTo(IBlockAccess world, BlockPos pos)
    {
	IBlockState state = world.getBlockState(pos);
        Block block = state.getBlock();
        return block == Blocks.BARRIER ? false : (((block != this && !(block instanceof BlockFenceGate) && !(block instanceof BlockWall))) ? (block.getMaterial(state).isOpaque() && state.isFullCube() ? block.getMaterial(state) != Material.GOURD : false) : true);
    }

@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
    {
        boolean flag = this.canConnectTo(worldIn, pos.north());
        boolean flag1 = this.canConnectTo(worldIn, pos.east());
        boolean flag2 = this.canConnectTo(worldIn, pos.south());
        boolean flag3 = this.canConnectTo(worldIn, pos.west());
        boolean flag4 = flag && !flag1 && flag2 && !flag3 || !flag && flag1 && !flag2 && flag3;
        return state.withProperty(UP, Boolean.valueOf(!flag4 || !worldIn.isAirBlock(pos.up()))).withProperty(NORTH, Boolean.valueOf(flag)).withProperty(EAST, Boolean.valueOf(flag1)).withProperty(SOUTH, Boolean.valueOf(flag2)).withProperty(WEST, Boolean.valueOf(flag3));
    }
}

 

And this works. I know that some of the methods I use in the canConnectTo boolean is deprecated, like block.getMaterial(state).isOpaque() and I will see if I can use some updated code for it instead. But at least it works now, thanks for the help guys :)

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • DUTA89 agen slot online terbaik dan sering memberikan kemenangan kepada setiap member yang deposit diatas 50k dengan tidak klaim bonus sepeser pun.   Link daftar : https://heylink.me/DUTA89OFFICIAL/  
    • Hello All! Started a MC Eternal 1.6.2.2 server on Shockbyte hosting. The only other mod I added was betterfarmland v0.0.8BETA. Server is 16GB and Shockbyte wont tell me how many CPU cores i have.  We are having problems now when players log in it seems to crash the server. At other times it seems fine and we can have 3 people playing for hours at a time. Usually always when it does crash it is when someone logs in. Crash Reports Below. To the person who can post the fix I will reward $100 via Paypal.   ---- Minecraft Crash Report ---- // This is a token for 1 free hug. Redeem at your nearest Mojangsta: [~~HUG~~] Time: 2024-09-19 21:04:58 UTC Description: Exception in server tick loop java.lang.StackOverflowError     at net.minecraft.advancements.PlayerAdvancements.hasCompletedChildrenOrSelf(PlayerAdvancements.java:451)     at net.minecraft.advancements.PlayerAdvancements.shouldBeVisible(PlayerAdvancements.java:419)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:385)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.P  
    • It worked the first time but none of my friends and now me either could enter the server. internal exception: io.netty.handler.codec.DecoderException Unknown modifier tconstruct:soulbound
    • It worked the first time but none of my friends and now me either could enter the server. internal exception: io.netty.handler.codec.DecoderException Unknown modifier tconstruct:soulbound
    • It worked the first time but none of my friends and now me either could enter the server. internal exception: io.netty.handler.codec.DecoderException Unknown modifier tconstruct:soulbound
  • Topics

×
×
  • Create New...

Important Information

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