Now with fancy output blocks

This commit is contained in:
WayofTime 2016-01-15 19:36:44 -05:00
parent 07c138710c
commit 2c666a931e
7 changed files with 188 additions and 6 deletions

View file

@ -1,12 +1,19 @@
package WayofTime.bloodmagic.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.BlockFenceGate;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
@ -14,6 +21,13 @@ import WayofTime.bloodmagic.tile.routing.TileOutputRoutingNode;
public class BlockOutputRoutingNode extends BlockContainer
{
public static final PropertyBool UP = PropertyBool.create("up");
public static final PropertyBool DOWN = PropertyBool.create("down");
public static final PropertyBool NORTH = PropertyBool.create("north");
public static final PropertyBool EAST = PropertyBool.create("east");
public static final PropertyBool SOUTH = PropertyBool.create("south");
public static final PropertyBool WEST = PropertyBool.create("west");
public BlockOutputRoutingNode()
{
super(Material.rock);
@ -23,6 +37,63 @@ public class BlockOutputRoutingNode extends BlockContainer
setHardness(2.0F);
setResistance(5.0F);
setHarvestLevel("pickaxe", 2);
this.setDefaultState(this.blockState.getBaseState().withProperty(DOWN, Boolean.valueOf(false)).withProperty(UP, Boolean.valueOf(false)).withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)));
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean isFullCube()
{
return false;
}
@Override
public boolean isVisuallyOpaque()
{
return false;
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState();
}
/**
* Convert the BlockState into the correct metadata value
*/
@Override
public int getMetaFromState(IBlockState state)
{
return 0;
}
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
return state.withProperty(UP, Boolean.valueOf(this.shouldConnect(worldIn, pos.up()))).withProperty(DOWN, Boolean.valueOf(this.shouldConnect(worldIn, pos.down()))).withProperty(NORTH, Boolean.valueOf(this.shouldConnect(worldIn, pos.north()))).withProperty(EAST, Boolean.valueOf(this.shouldConnect(worldIn, pos.east()))).withProperty(SOUTH, Boolean.valueOf(this.shouldConnect(worldIn, pos.south()))).withProperty(WEST, Boolean.valueOf(this.shouldConnect(worldIn, pos.west())));
}
@Override
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { UP, DOWN, NORTH, EAST, WEST, SOUTH });
}
public boolean shouldConnect(IBlockAccess world, BlockPos pos)
{
Block block = world.getBlockState(pos).getBlock();
if (block instanceof BlockOutputRoutingNode)
{
return false;
}
return block == Blocks.barrier ? false : (block != this && !(block instanceof BlockFenceGate) ? (block.getMaterial().isOpaque() && block.isFullCube() ? block.getMaterial() != Material.gourd : false) : true);
}
@Override

View file

@ -143,6 +143,7 @@ public class ModBlocks
renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(spectralBlock));
renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(phantomBlock));
renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(soulForge));
renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(outputRoutingNode));
}
private static Block registerBlock(Block block, Class<? extends ItemBlock> itemBlock, String name)

View file

@ -53,6 +53,7 @@ public class TileRoutingNode extends TileInventory implements IRoutingNode, IIte
public void readFromNBT(NBTTagCompound tag)
{
super.readFromNBT(tag);
connectionList.clear();
NBTTagCompound masterTag = tag.getCompoundTag(Constants.NBT.ROUTING_MASTER);
masterPos = new BlockPos(masterTag.getInteger(Constants.NBT.X_COORD), masterTag.getInteger(Constants.NBT.Y_COORD), masterTag.getInteger(Constants.NBT.Z_COORD));
@ -75,13 +76,15 @@ public class TileRoutingNode extends TileInventory implements IRoutingNode, IIte
}
for (BlockPos testPos : connectionList)
{
this.removeConnection(testPos);
TileEntity tile = worldObj.getTileEntity(testPos);
if (tile instanceof IRoutingNode)
{
((IRoutingNode) tile).removeConnection(pos);
worldObj.markBlockForUpdate(testPos);
}
}
connectionList.clear();
}
@Override
@ -163,8 +166,9 @@ public class TileRoutingNode extends TileInventory implements IRoutingNode, IIte
{
if (connectionList.contains(pos1))
{
worldObj.markBlockForUpdate(this.pos);
connectionList.remove(pos1);
System.out.println("Position: " + pos + ", remaining: " + connectionList.size());
worldObj.markBlockForUpdate(pos);
}
}

View file

@ -1,6 +1,45 @@
{
"variants": {
"normal": { "model": "bloodmagic:BlockOutputRoutingNode" }
}
"forge_marker": 1,
"defaults": {
"model": "bloodmagic:routing/OutputRoutingNodeCore",
"rotation": [
{
"y": 45
},
{
"x": 45
}
],
"textures": {
"core": "blocks/iron_block",
"attachment": "minecraft:blocks/stone"
},
"uvlock": true // This and all other properties of "defaults" will be inherited by simple submodels. They will NOT be inherited by named submodels.
},
"variants": {
"north": {
"true": {"submodel": "bloodmagic:routing/RoutingNodeBase"}, // Simple submodel declaration. You can also specify multiple submodels for a variant.
"false": {}
},
"south": {
"true": {"submodel": "bloodmagic:routing/RoutingNodeBase", "y": 180},
"false": {}
},
"east": {
"true": {"submodel": "bloodmagic:routing/RoutingNodeBase", "y": 90}, // Submodel will be rotated.
"false": {}
},
"west": {
"true": {"submodel": "bloodmagic:routing/RoutingNodeBase", "y": 270},
"false": {}
},
"down": {
"true": {"submodel": "bloodmagic:routing/RoutingNodeBase", "x": 90},
"false": {}
},
"up": {
"true": {"submodel": "bloodmagic:routing/RoutingNodeBase", "x": -90},
"false": {}
} // Must have this in here or the blockstates loader will not know of all the properties and values, and it will create the wrong vanilla state strings.
}
}

View file

@ -0,0 +1,20 @@
{
"textures": {
"particle": "#core"
},
"elements": [
{
"from": [ 6, 6, 6 ],
"to": [ 10, 10, 10 ],
"faces": {
"down": { "uv": [ 6, 6, 10, 10 ], "texture": "#core" },
"up": { "uv": [ 6, 6, 10, 10 ], "texture": "#core" },
"north": { "uv": [ 6, 6, 10, 10 ], "texture": "#core" },
"west": { "uv": [ 6, 6, 10, 10 ], "texture": "#core" },
"east": { "uv": [ 6, 6, 10, 10 ], "texture": "#core" },
"south": { "uv": [ 6, 6, 10, 10 ], "texture": "#core" }
},
"__comment": "core"
}
]
}

View file

@ -0,0 +1,33 @@
{
"textures": {
"particle": "#core"
},
"elements": [
{
"from": [ 4, 4, 0 ],
"to": [ 12, 12, 2 ],
"faces": {
"down": { "uv": [ 4, 11, 5, 16 ], "texture": "#attachment" },
"up": { "uv": [ 4, 0, 5, 5 ], "texture": "#attachment" },
"north": { "uv": [ 11, 6, 12, 12 ], "texture": "#attachment" },
"west": { "uv": [ 0, 6, 5, 12 ], "texture": "#attachment" },
"east": { "uv": [ 11, 6, 16, 12 ], "texture": "#attachment" },
"south": { "uv": [ 4, 6, 5, 12 ], "texture": "#attachment" }
},
"__comment": "part 1"
},
{
"from": [ 6, 6, 2 ],
"to": [ 10, 10, 4 ],
"faces": {
"down": { "uv": [ 4, 11, 5, 16 ], "texture": "#attachment" },
"up": { "uv": [ 4, 0, 5, 5 ], "texture": "#attachment" },
"north": { "uv": [ 11, 6, 12, 12 ], "texture": "#attachment" },
"west": { "uv": [ 0, 6, 5, 12 ], "texture": "#attachment" },
"east": { "uv": [ 11, 6, 16, 12 ], "texture": "#attachment" },
"south": { "uv": [ 4, 6, 5, 12 ], "texture": "#attachment" }
},
"__comment": "part 2"
}
]
}

View file

@ -0,0 +1,14 @@
{
"parent": "bloodmagic:block/routing/OutputRoutingNodeCore",
"textures": {
"core": "blocks/iron_block",
"attachment": "minecraft:blocks/stone"
},
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],
"translation": [ 0, 1.5, -2.75 ],
"scale": [ 0.375, 0.375, 0.375 ]
}
}
}