public class railControlBlock extends BlockRail implements ITileEntityProvider {
public static final PropertyEnum SHAPE = PropertyEnum.create("shape", BlockRailBase.EnumRailDirection.class);
public int getMetaFromState(IBlockState state)
{
return ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)).getMetadata();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { SHAPE });
}
public boolean isOpaqueCube()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock()
{
return false;
}
public int getRenderBlockPass()
{
return 1;
}
protected void onNeighborChangedInternal(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
//whenever the blocks around it change
}
}
when it loads a world it looks like a 3 x 3 x 0.2 block, but the collision and hit box are only for the center of it, a link showing the issue is here :
You can't really fix this without using multiblock structures. Its because minecraft will not check for a block collision if the entity bounding box s not in the "maximum" 1x1x1 space of the block. And that is because minecraft assumes that the block can't be bigger than 1x1x1 even thou it is not preventing it.
Edit: this is what is happening
So basically your block is not considered to cause a possible collision
Rollback Post to RevisionRollBack
Not doing mc modding that much anymore because I am making a full blown game that does not have limitations that mc has. (rip Magiology for now)
I may come back if MC fixes it's rendering pipeline.
You can't really fix this without using multiblock structures. Its because minecraft will not check for a block collision if the entity bounding box s not in the "maximum" 1x1x1 space of the block. And that is because minecraft assumes that the block can't be bigger than 1x1x1 even thou it is not preventing it.
Edit: this is what is happening
So basically your block is not considered to cause a possible collision
Make a main block of the structure (or of you want all blocks of the structure to be the same than you need decide/detect what block is going to do the detecting) and with it check for blocks of the structure. And if all blocks match the structure than set the matedata of the blocks to something and with metadata you see if the block is in multiblock and it it is than set the custom rendering and the block bounds.
Rollback Post to RevisionRollBack
Not doing mc modding that much anymore because I am making a full blown game that does not have limitations that mc has. (rip Magiology for now)
I may come back if MC fixes it's rendering pipeline.
Make a main block of the structure (or of you want all blocks of the structure to be the same than you need decide/detect what block is going to do the detecting) and with it check for blocks of the structure. And if all blocks match the structure than set the matedata of the blocks to something and with metadata you see if the block is in multiblock and it it is than set the custom rendering and the block bounds.
ok, how would i work with metadata and custom rendering? I have never had to use metadata before or custom rendering before.
The Meaning of Life, the Universe, and Everything.
Location:
Pennsylvania
Join Date:
7/16/2015
Posts:
99
Location:
Pennsylvania
Minecraft:
UltraTechX
Member Details
the first issue I ran into, is there a way to implement more than 1 piece of metadata? Since I am going to use 1 for the rotation of the tracks and 1 for which part of the multi-block it is.
how would i use a blockstate? the rail directions look like they uses a little of both since the functions IBlockState from meta, getmetafromstate, and others
You have to set the block bounds in the block's constructor before hand.That's all the problem is. If you want to create a multi-block structure like they are talking about, it isn't too difficult. You can copy any vanilla classes' code to fit. I'd suggest using integers to specify the metadata. If you need, I'd be glad to help you through this. It might have sounded confusing.
You have to set the block bounds in the block's constructor before hand.That's all the problem is. If you want to create a multi-block structure like they are talking about, it isn't too difficult. You can copy any vanilla classes' code to fit. I'd suggest using integers to specify the metadata. If you need, I'd be glad to help you through this. It might have sounded confusing.
by putting it in the constructor, do you mean setBlockBounds, or setBlockBoundBasedOnState?
i have this rail code, its a 3 by 3 by 0.2 block, but minecraft thinks it is a normal 1 by 1 by 1 block:
controlRail.json:
{
"__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
"textures": {
"particle": "generic:blocks/railControlBlock",
"0": "generic:blocks/railControlBlock"
},
"elements": [
{
"name": "inner track right",
"from": [ 17.0, 1.0, -16.0 ],
"to": [ 20.0, 2.0, 32.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 10.0, 6.0, 11.0, 7.0 ] },
"east": { "texture": "#0", "uv": [ 5.0, 8.0, 6.0, 9.0 ] },
"south": { "texture": "#0", "uv": [ 5.0, 8.0, 6.0, 9.0 ] },
"west": { "texture": "#0", "uv": [ 5.0, 5.0, 6.0, 6.0 ] },
"up": { "texture": "#0", "uv": [ 5.0, 0.0, 6.0, 16.0 ] },
"down": { "texture": "#0", "uv": [ 5.0, 0.0, 6.0, 16.0 ] }
}
},
{
"name": "outer track right",
"from": [ 26.0, 1.0, -16.0 ],
"to": [ 29.0, 2.0, 32.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 2.0, 6.0, 3.0, 7.0 ] },
"east": { "texture": "#0", "uv": [ 2.0, 7.0, 3.0, 8.0 ] },
"south": { "texture": "#0", "uv": [ 2.0, 5.0, 3.0, 6.0 ] },
"west": { "texture": "#0", "uv": [ 2.0, 0.0, 3.0, 1.0 ] },
"up": { "texture": "#0", "uv": [ 2.0, 0.0, 3.0, 16.0 ] },
"down": { "texture": "#0", "uv": [ 2.0, 0.0, 3.0, 16.0 ] }
}
},
{
"name": "rail bottom",
"from": [ -16.0, 0.0, 13.0 ],
"to": [ 32.0, 1.0, 15.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 11.0, 10.0, 12.0, 11.0 ] },
"east": { "texture": "#0", "uv": [ 11.0, 5.0, 13.0, 6.0 ] },
"south": { "texture": "#0", "uv": [ 12.0, 6.0, 13.0, 5.0 ] },
"west": { "texture": "#0", "uv": [ 13.0, 10.0, 11.0, 11.0 ] },
"up": { "texture": "#0", "uv": [ 11.0, 9.0, 13.0, 10.0 ] },
"down": { "texture": "#0", "uv": [ 11.0, 10.0, 13.0, 11.0 ] }
}
},
{
"name": "inner track left",
"from": [ -4.0, 1.0, -16.0 ],
"to": [ -1.0, 2.0, 32.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 10.0, 6.0, 11.0, 7.0 ] },
"east": { "texture": "#0", "uv": [ 5.0, 8.0, 6.0, 9.0 ] },
"south": { "texture": "#0", "uv": [ 5.0, 8.0, 6.0, 9.0 ] },
"west": { "texture": "#0", "uv": [ 5.0, 5.0, 6.0, 6.0 ] },
"up": { "texture": "#0", "uv": [ 5.0, 0.0, 6.0, 16.0 ] },
"down": { "texture": "#0", "uv": [ 5.0, 0.0, 6.0, 16.0 ] }
}
},
{
"name": "outer track left",
"from": [ -13.0, 1.0, -16.0 ],
"to": [ -10.0, 2.0, 32.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 2.0, 6.0, 3.0, 7.0 ] },
"east": { "texture": "#0", "uv": [ 2.0, 7.0, 3.0, 8.0 ] },
"south": { "texture": "#0", "uv": [ 2.0, 5.0, 3.0, 6.0 ] },
"west": { "texture": "#0", "uv": [ 2.0, 0.0, 3.0, 1.0 ] },
"up": { "texture": "#0", "uv": [ 2.0, 0.0, 3.0, 16.0 ] },
"down": { "texture": "#0", "uv": [ 2.0, 0.0, 3.0, 16.0 ] }
}
},
{
"name": "rail bottom",
"from": [ -16.0, 0.0, 9.0 ],
"to": [ 32.0, 1.0, 11.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 11.0, 10.0, 12.0, 11.0 ] },
"east": { "texture": "#0", "uv": [ 11.0, 5.0, 13.0, 6.0 ] },
"south": { "texture": "#0", "uv": [ 12.0, 6.0, 13.0, 5.0 ] },
"west": { "texture": "#0", "uv": [ 13.0, 10.0, 11.0, 11.0 ] },
"up": { "texture": "#0", "uv": [ 11.0, 9.0, 13.0, 10.0 ] },
"down": { "texture": "#0", "uv": [ 11.0, 10.0, 13.0, 11.0 ] }
}
},
{
"name": "rail bottom",
"from": [ -16.0, 0.0, 5.0 ],
"to": [ 32.0, 1.0, 7.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 11.0, 10.0, 12.0, 11.0 ] },
"east": { "texture": "#0", "uv": [ 11.0, 5.0, 13.0, 6.0 ] },
"south": { "texture": "#0", "uv": [ 12.0, 6.0, 13.0, 5.0 ] },
"west": { "texture": "#0", "uv": [ 13.0, 10.0, 11.0, 11.0 ] },
"up": { "texture": "#0", "uv": [ 11.0, 9.0, 13.0, 10.0 ] },
"down": { "texture": "#0", "uv": [ 11.0, 10.0, 13.0, 11.0 ] }
}
},
{
"name": "rail bottom",
"from": [ -16.0, 0.0, 1.0 ],
"to": [ 32.0, 1.0, 3.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 11.0, 10.0, 12.0, 11.0 ] },
"east": { "texture": "#0", "uv": [ 11.0, 5.0, 13.0, 6.0 ] },
"south": { "texture": "#0", "uv": [ 12.0, 6.0, 13.0, 5.0 ] },
"west": { "texture": "#0", "uv": [ 13.0, 10.0, 11.0, 11.0 ] },
"up": { "texture": "#0", "uv": [ 11.0, 9.0, 13.0, 10.0 ] },
"down": { "texture": "#0", "uv": [ 11.0, 10.0, 13.0, 11.0 ] }
}
},
{
"name": "Center Track",
"from": [ 6.0, 1.0, -16.0 ],
"to": [ 10.0, 2.0, 32.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 13.0, 6.0, 14.0, 7.0 ] },
"east": { "texture": "#0", "uv": [ 2.0, 8.0, 3.0, 9.0 ] },
"south": { "texture": "#0", "uv": [ 2.0, 8.0, 3.0, 9.0 ] },
"west": { "texture": "#0", "uv": [ 2.0, 5.0, 3.0, 6.0 ] },
"up": { "texture": "#0", "uv": [ 2.0, 0.0, 3.0, 16.0 ] },
"down": { "texture": "#0", "uv": [ 2.0, 0.0, 3.0, 16.0 ] }
}
},
{
"name": "rail bottom",
"from": [ -16.0, 0.0, -3.0 ],
"to": [ 32.0, 1.0, -1.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 11.0, 10.0, 12.0, 11.0 ] },
"east": { "texture": "#0", "uv": [ 11.0, 5.0, 13.0, 6.0 ] },
"south": { "texture": "#0", "uv": [ 12.0, 6.0, 13.0, 5.0 ] },
"west": { "texture": "#0", "uv": [ 13.0, 10.0, 11.0, 11.0 ] },
"up": { "texture": "#0", "uv": [ 11.0, 9.0, 13.0, 10.0 ] },
"down": { "texture": "#0", "uv": [ 11.0, 10.0, 13.0, 11.0 ] }
}
},
{
"name": "rail bottom",
"from": [ -16.0, 0.0, -7.0 ],
"to": [ 32.0, 1.0, -5.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 11.0, 10.0, 12.0, 11.0 ] },
"east": { "texture": "#0", "uv": [ 11.0, 5.0, 13.0, 6.0 ] },
"south": { "texture": "#0", "uv": [ 12.0, 6.0, 13.0, 5.0 ] },
"west": { "texture": "#0", "uv": [ 13.0, 10.0, 11.0, 11.0 ] },
"up": { "texture": "#0", "uv": [ 11.0, 9.0, 13.0, 10.0 ] },
"down": { "texture": "#0", "uv": [ 11.0, 10.0, 13.0, 11.0 ] }
}
},
{
"name": "rail bottom",
"from": [ -16.0, 0.0, -11.0 ],
"to": [ 32.0, 1.0, -9.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 11.0, 10.0, 12.0, 11.0 ] },
"east": { "texture": "#0", "uv": [ 11.0, 5.0, 13.0, 6.0 ] },
"south": { "texture": "#0", "uv": [ 12.0, 6.0, 13.0, 5.0 ] },
"west": { "texture": "#0", "uv": [ 13.0, 10.0, 11.0, 11.0 ] },
"up": { "texture": "#0", "uv": [ 11.0, 9.0, 13.0, 10.0 ] },
"down": { "texture": "#0", "uv": [ 11.0, 10.0, 13.0, 11.0 ] }
}
},
{
"name": "rail bottom",
"from": [ -16.0, 0.0, -15.0 ],
"to": [ 32.0, 1.0, -13.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 11.0, 10.0, 12.0, 11.0 ] },
"east": { "texture": "#0", "uv": [ 11.0, 5.0, 13.0, 6.0 ] },
"south": { "texture": "#0", "uv": [ 12.0, 6.0, 13.0, 5.0 ] },
"west": { "texture": "#0", "uv": [ 13.0, 10.0, 11.0, 11.0 ] },
"up": { "texture": "#0", "uv": [ 11.0, 9.0, 13.0, 10.0 ] },
"down": { "texture": "#0", "uv": [ 11.0, 10.0, 13.0, 11.0 ] }
}
},
{
"name": "reail bottom",
"from": [ -16.0, 0.0, 17.0 ],
"to": [ 32.0, 1.0, 19.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 11.0, 10.0, 12.0, 11.0 ] },
"east": { "texture": "#0", "uv": [ 11.0, 5.0, 13.0, 6.0 ] },
"south": { "texture": "#0", "uv": [ 12.0, 6.0, 13.0, 5.0 ] },
"west": { "texture": "#0", "uv": [ 13.0, 10.0, 11.0, 11.0 ] },
"up": { "texture": "#0", "uv": [ 11.0, 9.0, 13.0, 10.0 ] },
"down": { "texture": "#0", "uv": [ 11.0, 10.0, 13.0, 11.0 ] }
}
},
{
"name": "rail bottom",
"from": [ -16.0, 0.0, 21.0 ],
"to": [ 32.0, 1.0, 23.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 11.0, 10.0, 12.0, 11.0 ] },
"east": { "texture": "#0", "uv": [ 11.0, 5.0, 13.0, 6.0 ] },
"south": { "texture": "#0", "uv": [ 12.0, 6.0, 13.0, 5.0 ] },
"west": { "texture": "#0", "uv": [ 13.0, 10.0, 11.0, 11.0 ] },
"up": { "texture": "#0", "uv": [ 11.0, 9.0, 13.0, 10.0 ] },
"down": { "texture": "#0", "uv": [ 11.0, 10.0, 13.0, 11.0 ] }
}
},
{
"name": "rail bottom",
"from": [ -16.0, 0.0, 25.0 ],
"to": [ 32.0, 1.0, 27.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 11.0, 10.0, 12.0, 11.0 ] },
"east": { "texture": "#0", "uv": [ 11.0, 5.0, 13.0, 6.0 ] },
"south": { "texture": "#0", "uv": [ 12.0, 6.0, 13.0, 5.0 ] },
"west": { "texture": "#0", "uv": [ 13.0, 10.0, 11.0, 11.0 ] },
"up": { "texture": "#0", "uv": [ 11.0, 9.0, 13.0, 10.0 ] },
"down": { "texture": "#0", "uv": [ 11.0, 10.0, 13.0, 11.0 ] }
}
},
{
"name": "rail bottom",
"from": [ -16.0, 0.0, 29.0 ],
"to": [ 32.0, 1.0, 31.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 11.0, 10.0, 12.0, 11.0 ] },
"east": { "texture": "#0", "uv": [ 11.0, 5.0, 13.0, 6.0 ] },
"south": { "texture": "#0", "uv": [ 12.0, 6.0, 13.0, 5.0 ] },
"west": { "texture": "#0", "uv": [ 13.0, 10.0, 11.0, 11.0 ] },
"up": { "texture": "#0", "uv": [ 11.0, 9.0, 13.0, 10.0 ] },
"down": { "texture": "#0", "uv": [ 11.0, 10.0, 13.0, 11.0 ] }
}
}
]
}
controlRail.java:
package tutorial.generic;
import net.minecraft.tileentity.TileEntity;
public class railControl extends TileEntity{
public railControl() {
}
}
controlRailBlock.java:
package tutorial.generic;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRail;
import net.minecraft.block.BlockRailBase;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class railControlBlock extends BlockRail implements ITileEntityProvider {
public static final PropertyEnum SHAPE = PropertyEnum.create("shape", BlockRailBase.EnumRailDirection.class);
private static String name = "railControlBlock";
public railControlBlock() {
super();
GameRegistry.registerTileEntity(railControl.class, name);
setDefaultState(this.blockState.getBaseState().withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_SOUTH));
GameRegistry.registerBlock(this, name);
this.setCreativeTab(CreativeTabs.tabMisc);
this.setUnlocalizedName(name);
this.setHardness(2.0f);
this.setResistance(6.0f);
this.setHarvestLevel("pickaxe", 2);
this.isBlockContainer = true;
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
return new railControl();
}
public static String getName(){
return name;
}
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos)
{
setBlockBoundsBasedOnState(worldIn, pos);
return super.getSelectedBoundingBox(worldIn, pos);
}
public IProperty getShapeProperty()
{
return SHAPE;
}
public IBlockState getStateFromMeta(int meta)
{
return getDefaultState().withProperty(SHAPE, BlockRailBase.EnumRailDirection.byMetadata(meta));
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
this.setBlockBounds(-1.0F, 0.0F, -1.0F, 2.0F, 0.125F, 2.0F);
}
public int getMetaFromState(IBlockState state)
{
return ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)).getMetadata();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { SHAPE });
}
public boolean isOpaqueCube()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock()
{
return false;
}
public int getRenderBlockPass()
{
return 1;
}
protected void onNeighborChangedInternal(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
//whenever the blocks around it change
}
}
when it loads a world it looks like a 3 x 3 x 0.2 block, but the collision and hit box are only for the center of it, a link showing the issue is here :
http://imgur.com/a/mDvGR
so I guess the real question is, how can I make a working multi-block block, thank you for your responses!:D
You can't really fix this without using multiblock structures. Its because minecraft will not check for a block collision if the entity bounding box s not in the "maximum" 1x1x1 space of the block. And that is because minecraft assumes that the block can't be bigger than 1x1x1 even thou it is not preventing it.
Edit: this is what is happening
So basically your block is not considered to cause a possible collision
Not doing mc modding that much anymore because I am making a full blown game that does not have limitations that mc has. (rip Magiology for now)
I may come back if MC fixes it's rendering pipeline.
how would I create a multiblock structure?
Make a main block of the structure (or of you want all blocks of the structure to be the same than you need decide/detect what block is going to do the detecting) and with it check for blocks of the structure. And if all blocks match the structure than set the matedata of the blocks to something and with metadata you see if the block is in multiblock and it it is than set the custom rendering and the block bounds.
Not doing mc modding that much anymore because I am making a full blown game that does not have limitations that mc has. (rip Magiology for now)
I may come back if MC fixes it's rendering pipeline.
ok, how would i work with metadata and custom rendering? I have never had to use metadata before or custom rendering before.
Metadata shouldn't be that hard, afaik it's just a number next to the block ID, a sub-block to say so.
It's what rails, torches, furnaces, etc use for orientation, for example
oh ok, ill give it a try in a little bit.
the first issue I ran into, is there a way to implement more than 1 piece of metadata? Since I am going to use 1 for the rotation of the tracks and 1 for which part of the multi-block it is.
nope than use tileentitys
Not doing mc modding that much anymore because I am making a full blown game that does not have limitations that mc has. (rip Magiology for now)
I may come back if MC fixes it's rendering pipeline.
ok, then would it be like make 9 separate blocks and put them all down when the user places the center piece?
What about BlockStates?
Please don't PM me asking for help, I will just redirect you to the appropriate forum, where there are others who are far more skilled than me.
This is not the signature you are looking for.
Banners and such things
how would i use a blockstate? the rail directions look like they uses a little of both since the functions IBlockState from meta, getmetafromstate, and others
I don't think that BlockStates have enough storage for what he is trying to do.
You have 1 boolean that leaves you with 3 bits or 8 combinations and that is short by one
Not doing mc modding that much anymore because I am making a full blown game that does not have limitations that mc has. (rip Magiology for now)
I may come back if MC fixes it's rendering pipeline.
ok then, good thing the block is already a tile entity, but how would I use the tile entity to tell it which block is which of the 9?
Uhhh just use int position; or something like that?
Not doing mc modding that much anymore because I am making a full blown game that does not have limitations that mc has. (rip Magiology for now)
I may come back if MC fixes it's rendering pipeline.
You have to set the block bounds in the block's constructor before hand.That's all the problem is. If you want to create a multi-block structure like they are talking about, it isn't too difficult. You can copy any vanilla classes' code to fit. I'd suggest using integers to specify the metadata. If you need, I'd be glad to help you through this. It might have sounded confusing.
Hello!
by putting it in the constructor, do you mean setBlockBounds, or setBlockBoundBasedOnState?
Look into BlockBed, that should be enough to get you started.
I agree with GotoLink, use setBlockBounds. setBlockBoundsBasedOnState is mostly overridden to set bounds at specific times.
Hello!
ok, so i added this to the blocks constructor :
setBlockBounds(-1.0F, 0.0F, -1.0F, 2.0F, 0.125F, 2.0F);
nothing changed at all
EDIT : I was not able to use some code from the bed successfully