Jump to content

Recommended Posts

Posted

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

 

  Reveal hidden contents

 

 

Here's my Single/Double slab class

 

  Reveal hidden contents

 

 

Here's the ItemSlab class

 

  Reveal hidden contents

 

 

Here's how I register my slab

 

  Reveal hidden contents

 

 

Here's the blockstate .json files.

 

  Reveal hidden contents

 

Posted
  On 10/29/2016 at 8:40 PM, larsgerrits said:

In your ItemSlab class.

 

Strange, it doesn't seem like there is a getItem method to Override in my ItemSlab class. Could there be another way to do it?

Posted

If is a generic object I recommend doing a

 

return Item.itemFromBlock(this)

 

this will return the current item from the current block.

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.

Posted
  On 10/29/2016 at 9:08 PM, trollworkout said:

If is a generic object I recommend doing a

 

return Item.itemFromBlock(this)

 

this will return the current item from the current block.

 

Just to clarify, are you talking about using the getItem method in my ItemSlab class aswell, or something else?

Posted

getItem in your custom slab

 

have a look at planks . they use VARIANTS and sub blocks.

 

 

To drop the correct sub-block variant you need to override a bunch of functions

 

getItem

 

getSubBlock

 

getDamagedDropped (or something similar)

 

 

Which is why I NEVER EVER EVER use sub block variants for wood, slabs, planks and the like unless I 100000% need it. Is stupidly complicated. You can just create each individual block separately register each model and simply return itself  done.  You can even use Block to do it don't even need a custom block.

 

Not saying you should do it like me just that I think you will reduce 1 year of your life figuring out the sub block meta bugs and issues.

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.

Posted
  On 10/29/2016 at 9:36 PM, trollworkout said:

getItem in your custom slab

 

have a look at planks . they use VARIANTS and sub blocks.

 

 

To drop the correct sub-block variant you need to override a bunch of functions

 

getItem

 

getSubBlock

 

getDamagedDropped (or something similar)

 

 

Which is why I NEVER EVER EVER use sub block variants for wood, slabs, planks and the like unless I 100000% need it. Is stupidly complicated. You can just create each individual block separately register each model and simply return itself  done.  You can even use Block to do it don't even need a custom block.

 

Not saying you should do it like me just that I think you will reduce 1 year of your life figuring out the sub block meta bugs and issues.

 

I hate using subblocks aswell, can never get it to work :)

But with slabs, you kinda have to, at least to some degree, as far as I know, but I could be wrong.

 

However I think I understand what you want me to do, it's just that I can't seem to get it to work without making them fully subblocks, with an EnumType method and all that. Properly going to take me forever to get this to work, unless there is an easier way, that I just can't see...

 

I believe that this is what you mean, example taking from BlockStoneSlab

 

  Reveal hidden contents

 

 

What I can't seem to get around is BlockStoneSlab.EnumType, which would imply that I need to make a custom EnumType in my Slab class.

 

EDIT: I have tried to replace BlockStoneSlab.EnumType with 0, as that seemed to be  the way to do it, didn't work. Thought I had it then, but I did not :/

Posted

You can make custom enums or custom properties but you need to define them in a separate class.  I can't remember now right now but is online somewhere. Is pretty simple.

 

I know watchu mean that you need to use sub blocks but I think you can get away by doing blockstate logic + bounding box tricks.

 

I'm actualy gonna make my own custom slab and stairs soon so I'll let you know when I succceed.

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.

Posted
  On 10/29/2016 at 10:57 PM, trollworkout said:

You can make custom enums or custom properties but you need to define them in a separate class.  I can't remember now right now but is online somewhere. Is pretty simple.

 

I know watchu mean that you need to use sub blocks but I think you can get away by doing blockstate logic + bounding box tricks.

 

I'm actualy gonna make my own custom slab and stairs soon so I'll let you know when I succceed.

 

Cool, when/if I get mine to work, I'll let you know aswell

Posted

Erfurt I noticed there's a glitch with stairs being too dark when Smooth Lighting is OFF possibly with slabs too? 

 

Placing this.setLightOpacity(0); in the constructor fixes the issue.

 

Also I have successfully created custom stairs . Slabs next in a lil bit.

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.

Posted
  On 10/30/2016 at 12:51 AM, trollworkout said:

Erfurt I noticed there's a glitch with stairs being too dark when Smooth Lighting is OFF possibly with slabs too? 

 

Placing this.setLightOpacity(0); in the constructor fixes the issue.

 

Also I have successfully created custom stairs . Slabs next in a lil bit.

 

Cool mate, I haven't seen any light issues with my slabs tho :)

Posted
  On 10/30/2016 at 12:51 AM, trollworkout said:

Erfurt I noticed there's a glitch with stairs being too dark when Smooth Lighting is OFF possibly with slabs too? 

 

Placing this.setLightOpacity(0); in the constructor fixes the issue.

 

Also I have successfully created custom stairs . Slabs next in a lil bit.

 

setLightOpacity is not what you want, as it is meant how much light you want to let pass through the block.

0 means you let all the light get through. Try it out in the dark place a glowstone block for example on the ground and surround it with your slabs in such a way the glowstone is not visible anymore. You will see light passing through.

 

The darkness *glitch* you see, can be fixed with this:

useNeighborBrightness = true;

In this way the block will use the lightvalue of the block(s) next to it , whatever position that is (left, right, in front, up, etc etc)

 

So when do you use setLightOpacity? For example glass blocks or in your case maybe glass slabs or glass stairs or what ever block that is transparent.

Posted

I also think you do not need itemslab. I have also fully functional slabs.

I have 3 classes for it:

 

- a class that extends BlockSlab (CustomBlockSlab for example)

- a class for halfslabs that extends CustomBlockSlab (CustomHalfSlab)

- a class for doubleslabs that extends CustomBlockSlab (CustomDoubleSlab)

 

the only difference half and double have is this:

@Override
public boolean isDouble() {
	// TODO Auto-generated method stub
	return true;
}

the half has it set to false and the double to true

 

I tried before the pass this boolean variable directly as an argument to CustomBlockSlab, because in this way i would only need 1 file. For some reason this doesn't work and i do not know why. So i used 3 files for each set of slabs.

 

You can define up to 8 different types in your slabs

I'll give you an example of my slabs.

 

BlockChalkstoneBlockSlab.class:

 

  Reveal hidden contents

 

 

BlockChalkstoneHalfSlab.class:

 

  Reveal hidden contents

 

 

BlockChalkstoneDoubleSlab.class:

 

  Reveal hidden contents

 

 

i create it like this:

chalkstoneslab = new BlockChalkstoneHalfSlab(References.temBlocks.CHALKSTONEHALFSLAB.getUnlocalizedName(), References.temBlocks.CHALKSTONEHALFSLAB.getRegistryName());
	chalkstonedoubleslab = new BlockChalkstoneDoubleSlab(References.temBlocks.CHALKSTONEDOUBLESLAB.getUnlocalizedName(), References.temBlocks.CHALKSTONEDOUBLESLAB.getRegistryName());

 

register it like this:

registerBlockSlab(chalkstoneslab, chalkstonedoubleslab);

I have created a special method to register it

it looks like this:

private static void registerBlockSlab(Block slab, Block doubleslab){
	GameRegistry.register(slab);
	GameRegistry.register(doubleslab);
	ItemSlab item = new ItemSlab(slab, (BlockSlab) slab, (BlockSlab) doubleslab);
	item.setRegistryName(slab.getRegistryName());
	GameRegistry.register(item);
}

 

Now try not to copy paste this all. Try to understand how it works.

The way i did it is maybe not the best way at all. I'm not an expert at all, but maybe i can help you!

As far i know it all works fine for me.

You can figure out by yourself how the rendering works. If not we will hear from you soon.

Posted
  On 10/30/2016 at 11:39 AM, winnetrie said:

You can figure out by yourself how the rendering works. If not we will hear from you soon.

 

For the rendering I believe that I have to use this method

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

 

For both singleSlab and doubleSlab, if I'm wrong please do correct me :)

Posted

You can also make multiple types of the same method like this:

 

private static void registerRender(Block block, int meta, String variant){
	ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), meta, new ModelResourceLocation(block.getRegistryName(),variant));	
}
private static void registerRender(Block block, String variant){
	ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(),variant));
	}
private static void registerRender(Block block){
	ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(),"inventory"));
	}

Because this method is used for the same purpose you can keep the same naming for it. That way you don't need to invent multiple names for multiple tasks that slightly differs.

Sometimes you only want to pass a block, sometimes you want meta, sometimes you want to define an exact variant.

 

You only register the render for your halfslab. You still need the blockstate for both.

Posted

Or like how I have things:

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/hardlib/EasyRegistry.java

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/hardlib/client/ClientEasyRegistry.java

 

(Those classes are proxys for a library mod).  I give the methods different names so that I know what's going to happen.  It's a verification that I'm typing out the method that does what I'm thinking I want to happen.  But yes, they could be renamed to all have the same name and just be overloaded.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I'm working on the slab right now . Works until I place it then it crashes saying there's no property "half" 

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.

Posted

Your block class doesn't have a property "half" for some reason.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I managed to make it working by adding the meta and createBlockstate but now it crashes because 

 

Comparable<?> comparable1 = iblockstate.getValue(iproperty);

 

my comparable returns null because I have no VARIANT.

 

I tried to create my own SlabItem but  I'm kinda confused as this complicated stupid MC way of doing things with sub blocks and meta.

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.

Posted

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.

 

Here is my custom SlabBlock  (generic slab block you can use for any slab block base)

 

  Reveal hidden contents

 

 

 

Here is my half slab for WOOD only . This is what I actually use to create the block and half slab (continue reading)

 

  Reveal hidden contents

 

 

This is my double slab (as you can see this returns isDouble true..by default my custom base slab is set to double false which is why in the half slab I don't set this at all)

 

  Reveal hidden contents

 

 

 

Here is my custom ItemSlab (the trick here is I got rid of Comparator<?> and IProperty because that was used for VARIANT. in other words this type of slab is defined one at a time and does not have subtypes or sub blocks or variants)

 

  Reveal hidden contents

 

 

 

This is how I register the item

		public static final ItemBlock SLAB_APPLE = (ItemBlock) new SlabItem(ModBlocks.HALFSLAB_APPLE, (BlockSlab) ModBlocks.HALFSLAB_APPLE, (BlockSlab) ModBlocks.DOUBLESLAB_APPLE).setUnlocalizedName("slabApple").setRegistryName("slabApple").setCreativeTab(ModData.CREATIVE_TAB);

 

The trick is

Blockitem mySlab = new SlabItem( halfSlab, halfSlab, fullSlab)

 

 

This is how I register the block

		public static final Block DOUBLESLAB_APPLE = (new DoubleSlabWoodBlock("doubleSlabApple"));
	public static final Block HALFSLAB_APPLE = (new HalfSlabWoodBlock("halfSlabApple"));	

 

For the json you make your slab item parent to you halfSlab model and your blockstate would be same as regular MC slab . 2 blockstates halfSlab and fulLSlab . halfSlab has 2 HALF properties BOTTOM when to place it lower and UPPER when you place it higher . The BOTTOM model is your normal slab that you also use for item parent.

 

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.

Posted

Here is the link to my project

https://github.com/trollworkout/technorcery/tree/master/src/main/java/com/technorcery

 

knock yourself out

 

Note that the way my project is structured is like this

blocks = unique blocks that need special classes

client = anything that runs on client side

common = anything that runs on both client and server

common/block = generic blocks (here you gonna find the slab, stairs, halfslab..)

common/item = generic item (here you gonna find the custom itemslab)

entity = entities

sever = anything that runs on server

 

 

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.

Posted
  On 10/31/2016 at 12:54 AM, Draco18s said:

Your block class doesn't have a property "half" for some reason.

 

I was missing the getStateFromMeta getMetaFromState and createBlockstate functions so it didn't understand what half=bottom half=upper were

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.

Posted
  On 10/31/2016 at 2:08 AM, trollworkout said:

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.

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.