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

    • There's a scheme I got into where they promised to trade Bitcoin for me and take a cut as a commission. Seemed like a good idea at the time. But then, things went south real fast. They ended up transferring   $190,000 worth of my Bitcoin. I was devastated and felt completely helpless. That's when I stumbled upon the Wizard Web Recovery Tool. It was like a beacon of hope amid chaos. With this tool, I could finally start digging into what went wrong and hopefully get my Bitcoin back. Using Wizard Web was surprisingly easy. I just had to plug in some details about my Bitcoin account and let it do its thing. It started scanning the internet, looking for any clues about what happened to my Bitcoin. It felt like having a detective on my side, searching for answers. And guess what? Wizard Web found some leads. It uncovered evidence of the scheme's shady dealings and helped me track down the people responsible for losing my Bitcoin. Armed with this information, I took the case to court. After a long and hard-fought legal battle, the court ruled in my favor. The perpetrators were held accountable for their actions and faced criminal charges for their involvement in the scheme. It was a victory not just for me, but for anyone who's been taken advantage of by these kinds of scams. Thanks to Wizard Web Recovery, I was able to get justice and reclaim what was rightfully mine. It showed me that even in the face of adversity, there's always a way to fight back. And with the right tools and determination, anything is possible.   The following is the contact information for Wizard Web Recovery.   Email: wizard web recovery((@))programmer . net
    • Hello, good morning. I know some programming and I'm interested in mod creation. That's why I've decided to follow a tutorial guide on YouTube by TurtyWurty. https://www.youtube.com/watch?v=DhoX9cmAZqA&t=160s&ab_channel=TurtyWurty I've followed the tutorial perfectly. The problem is that when checking the food, the texture doesn't load for me. However, everything seems fine no matter how much I check. I'm sure it's something trivial, the problem is that I can't find it. Could you help me solve it, please? I leave a zip of my file so you can edit it freely. forge-1.20-Civicraft.rar
    • If you have nvidia graphics, it's important that you make sure Minecraft (and anything Minecraft-related) is set to prefer high performance graphics first. If you only update your AMD drivers it might fix the issue but cause severe performance loss vs Vanilla as it'll be running on the integrated graphics instead of dedicated nvidia graphics
    • Update your drivers: https://www.amd.com/en/support/downloads/drivers.html/processors/ryzen/ryzen-5000-series/amd-ryzen-5-5600g.html
  • Topics

×
×
  • Create New...

Important Information

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