Jump to content

[1.10.2] Custom slab issues


Erfurt

Recommended Posts

Hey I managed to figure this out. 100% working slabs

 

Unlike the answer above I actually use a custom ItemSlab  which gets rid of VARIANT bs.

 

I also gave a 100% working slabs example!

There is no need to use ItemSlab and those VARIANTS are no "bs".

Stop giving people bad advice and please stop being stubborn.

We have seen from his other post that he has a very strict view on how Minecraft should've been made and what current systems are "bs". Just let him be. He'll have to live with it.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Yeah dude . But we're not discussing my views are we. My slabs are 100% and I was providing assistance. Feel free to also use my code .

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

Link to comment
Share on other sites

Hey guys,

 

So I have some small problems with my custom slabs, the first problem is that my double slab doesn't drop it's single slab counterpart, don't know how to fix that. The second problem is that the blockstate .json files seems to need some funky variants, and I'm not sure why that is. It's not something I think is really important to fix, as they work fine texture-wise, but it would be lovely if someone could see why, and maybe help me change it so that it would be more like the vanilla .json files.

 

Here's my Slab class

 

 

 

 

public abstract class EadoreSlab extends BlockSlab
{
private static final PropertyBool VARIANT = PropertyBool.create("variant");

public EadoreSlab(Material mat, String name)
{
	super(mat);
	this.setUnlocalizedName(name);
	this.setRegistryName(name);
	this.useNeighborBrightness = !this.isDouble(); 
	setHardness(2);
	if(mat == Material.WOOD)
	{
		Blocks.FIRE.setFireInfo(this, 5, 5);
	}

	if (!this.isDouble())
	{
            setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
        }

	IBlockState blockState = this.blockState.getBaseState();
        blockState = blockState.withProperty(VARIANT, false);
        if (!this.isDouble())
        {
            blockState.withProperty(HALF, EnumBlockHalf.BOTTOM);
        }
        
        setDefaultState(blockState);
}

public String getUnlocalizedName(int meta)
{
	return this.getUnlocalizedName();
}

@Override
public Comparable<?> getTypeForItem(ItemStack stack)
{
	return false;
}

@Override
public IProperty<?> getVariantProperty()
{
	return VARIANT;
}

@Override
public int damageDropped(IBlockState state)
{
	return 0;
}

@Override
public final IBlockState getStateFromMeta(final int meta) {
	IBlockState blockState = this.getDefaultState();
        blockState = blockState.withProperty(VARIANT, false);
        if (!this.isDouble()) {
            EnumBlockHalf value = EnumBlockHalf.BOTTOM;
            if ((meta &  != 0) {
                value = EnumBlockHalf.TOP;
            }

            blockState = blockState.withProperty(HALF, value);
        }

	return blockState;
}

@Override
public final int getMetaFromState(final IBlockState state) {
        if (this.isDouble()) {
           return 0;
        }

        if ((EnumBlockHalf) state.getValue(HALF) == EnumBlockHalf.TOP) {
            return 8;
        } else {
            return 0;
        }
}

@Override
protected final BlockStateContainer createBlockState() {
        if (this.isDouble()) {
            return new BlockStateContainer(this, new IProperty[] {VARIANT});
        } else {
            return new BlockStateContainer(this, new IProperty[] {VARIANT, HALF});
        }
}
}

 

 

 

Here's my Single/Double slab class

 

 

public class EadoreHalfSlab extends EadoreSlab
{

public EadoreHalfSlab(Material mat, String name)
{
	super(mat, name);
}

@Override
public boolean isDouble()
{
	//Double slab class returns true
	return false;
}

}

 

 

 

Here's the ItemSlab class

 

 

package erfurt.eadore.items;

import erfurt.eadore.blocks.EadoreDoubleSlab;
import erfurt.eadore.blocks.EadoreHalfSlab;
import net.minecraft.block.Block;
import net.minecraft.item.ItemSlab;

public class EadoreItemSlab extends ItemSlab
{

public EadoreItemSlab(Block block, EadoreHalfSlab singleSlab, EadoreDoubleSlab doubleSlab, Boolean stacked)
{
	super(block, singleSlab, doubleSlab);
}

}

 

 

 

Here's how I register my slab

 

 

public class BlockRegistry
{
public static Block planks_maple;

public static Block slab_half_maple;
public static Block slab_double_maple;


public static void init()
{
	planks_maple = new EadorePlanks("planks_maple");

	slab_half_maple = new EadoreHalfSlab(Material.WOOD, "slab_half_maple");
	slab_double_maple = new EadoreDoubleSlab(Material.WOOD, "slab_double_maple");
}

public static void register()
{
	registerBlock(planks_maple);

	registerSlab(slab_half_maple, slab_half_maple, slab_double_maple, false);
	registerSlab(slab_double_maple, slab_half_maple, slab_double_maple, false);
}

public static void registerRenders()
{
	registerRender(planks_maple);

	registerRender(slab_half_maple);
	registerRender(slab_double_maple);
}

public static void registerBlock(Block block)
{
	GameRegistry.register(block);
	GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
}

public static void registerSlab(Block block, Block singleSlab, Block doubleSlab, Boolean stacked)
{
	GameRegistry.register(block);
	GameRegistry.register(new EadoreItemSlab(block, (EadoreHalfSlab)singleSlab, (EadoreDoubleSlab)doubleSlab, stacked).setRegistryName(block.getRegistryName()));
}

public static void registerRender(Block block)
{
	Item item = Item.getItemFromBlock(block);
	ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(block.getRegistryName(), "normal"));
}
}

 

 

 

Here's the blockstate .json files.

 

 

slab_half_maple

{
    "variants": {
        "half=bottom,variant=false": { "model": "em:slab_half_maple" },
        "half=top,variant=false": { "model": "em:slab_upper_maple" },
        "half=bottom,variant=true": { "model": "em:slab_half_maple" },
        "half=top,variant=true": { "model": "em:slab_upper_maple" }
    }
}

slab_double_maple

{
    "variants": {
        "variant=false": { "model": "em:planks_maple" }
    }
}

 

 

 

I you take a look at Biomes o plenty code on GIT they have working stack-able slabs and give the right item back. yu can take a look at how they got the methods done.

Link to comment
Share on other sites

^ BOP is best resource to learn about Sapling, tree generation, world gen, Slab, stairs , Biome and Biome decorator and there is a BOP for almost all versions of Minecraft since 1.7

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

Link to comment
Share on other sites

Just wanted to say thank you, I used trollworkout's code to get slabs up and running.  I tried for few days to get it working on my own so I could at least understand it but I think the ItemSlab was where I couldn't put it all together, so I finally gave in and tried his, and got it working, the itemslab saves the day.  Just a few notes though incase someone else comes across this thread, I did have to tinker a little with the code, as the slab was showing up 3 times in the creative tabs as the item, the half and the double slab, and for all intensive purposes you only want the itemslab to show up because it's the key to the blocks logic, so I added this bit of code onto the SlabBlock code

 

 

    /**
     * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
     */
    @SideOnly(Side.CLIENT)
    @Override
    public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
    {
    	if(itemIn == ModItems.slab_cherry){
        list.add(new ItemStack(itemIn));
    	}
    }

 

 

and also need to add in that breaking the block will return the Item and not the block, not sure how you made it work completely on your end troll as I didn't want to go reading all your code :) but just wanted to throw my 2 cents in in case anyone is having trouble because, these slabs are, I feel unnecessarily difficult.  Thanks

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



×
×
  • Create New...

Important Information

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