Created the proper rendering for the crystal clusters while in hand
This commit is contained in:
parent
19fec96bfd
commit
ea24e7edd8
15 changed files with 261 additions and 7 deletions
|
@ -1,7 +1,9 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
|
@ -11,6 +13,7 @@ import net.minecraft.block.state.BlockState;
|
|||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -23,17 +26,20 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.item.ItemComponent;
|
||||
import WayofTime.bloodmagic.tile.TileAltar;
|
||||
import WayofTime.bloodmagic.tile.TileDemonCrystal;
|
||||
|
||||
public class BlockDemonCrystal extends BlockContainer
|
||||
{
|
||||
public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 6);
|
||||
public static final PropertyEnum<EnumDemonWillType> TYPE = PropertyEnum.<EnumDemonWillType>create("type", EnumDemonWillType.class);
|
||||
public static final PropertyEnum<EnumFacing> ATTACHED = PropertyEnum.<EnumFacing>create("attached", EnumFacing.class);
|
||||
|
||||
public BlockDemonCrystal()
|
||||
{
|
||||
super(Material.rock);
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, EnumDemonWillType.DEFAULT));
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, EnumDemonWillType.DEFAULT).withProperty(ATTACHED, EnumFacing.UP));
|
||||
|
||||
setUnlocalizedName(Constants.Mod.MODID + ".demonCrystal");
|
||||
setRegistryName(Constants.BloodMagicBlock.DEMON_CRYSTAL.getRegName());
|
||||
|
@ -43,11 +49,36 @@ public class BlockDemonCrystal extends BlockContainer
|
|||
setHarvestLevel("pickaxe", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockOnSide(World world, BlockPos pos, EnumFacing side)
|
||||
{
|
||||
BlockPos offsetPos = pos.offset(side.getOpposite());
|
||||
IBlockState offsetState = world.getBlockState(offsetPos);
|
||||
Block offsetBlock = offsetState.getBlock();
|
||||
|
||||
return offsetBlock.isSideSolid(world, offsetPos, side) && this.canPlaceBlockAt(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock)
|
||||
{
|
||||
TileDemonCrystal tile = (TileDemonCrystal) world.getTileEntity(pos);
|
||||
EnumFacing placement = tile.getPlacement();
|
||||
BlockPos offsetPos = pos.offset(placement.getOpposite());
|
||||
IBlockState offsetState = world.getBlockState(offsetPos);
|
||||
Block offsetBlock = offsetState.getBlock();
|
||||
|
||||
if (!offsetBlock.isSideSolid(world, offsetPos, placement))
|
||||
{
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
TileDemonCrystal tile = (TileDemonCrystal) world.getTileEntity(pos);
|
||||
return state.withProperty(AGE, tile.getCrystalCountForRender());
|
||||
return state.withProperty(AGE, tile.getCrystalCountForRender()).withProperty(ATTACHED, tile.getPlacement());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,7 +124,6 @@ public class BlockDemonCrystal extends BlockContainer
|
|||
@Override
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
System.out.println("Meta: " + meta + ", " + EnumDemonWillType.values()[meta]);
|
||||
return this.getDefaultState().withProperty(TYPE, EnumDemonWillType.values()[meta]);
|
||||
}
|
||||
|
||||
|
@ -109,7 +139,7 @@ public class BlockDemonCrystal extends BlockContainer
|
|||
@Override
|
||||
protected BlockState createBlockState()
|
||||
{
|
||||
return new BlockState(this, new IProperty[] { TYPE, AGE });
|
||||
return new BlockState(this, new IProperty[] { TYPE, AGE, ATTACHED });
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,6 +148,49 @@ public class BlockDemonCrystal extends BlockContainer
|
|||
return new TileDemonCrystal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos pos, IBlockState state)
|
||||
{
|
||||
TileDemonCrystal tile = (TileDemonCrystal) world.getTileEntity(pos);
|
||||
EnumDemonWillType type = state.getValue(TYPE);
|
||||
int number = tile.getCrystalCount();
|
||||
|
||||
spawnAsEntity(world, pos, getItemStackDropped(type, number));
|
||||
world.removeTileEntity(pos);
|
||||
}
|
||||
|
||||
private ItemStack getItemStackDropped(EnumDemonWillType type, int crystalNumber)
|
||||
{
|
||||
ItemStack stack = null;
|
||||
switch (type)
|
||||
{
|
||||
case CORROSIVE:
|
||||
stack = ItemComponent.getStack(ItemComponent.CRYSTAL_CORROSIVE);
|
||||
break;
|
||||
case DEFAULT:
|
||||
stack = ItemComponent.getStack(ItemComponent.CRYSTAL_DEFAULT);
|
||||
break;
|
||||
case DESTRUCTIVE:
|
||||
stack = ItemComponent.getStack(ItemComponent.CRYSTAL_DESTRUCTIVE);
|
||||
break;
|
||||
case STEADFAST:
|
||||
stack = ItemComponent.getStack(ItemComponent.CRYSTAL_STEADFAST);
|
||||
break;
|
||||
case VENGEFUL:
|
||||
stack = ItemComponent.getStack(ItemComponent.CRYSTAL_VENGEFUL);
|
||||
break;
|
||||
}
|
||||
|
||||
stack.stackSize = crystalNumber;
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random random)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
|
|
|
@ -3,6 +3,9 @@ package WayofTime.bloodmagic.block;
|
|||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
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;
|
||||
|
@ -24,6 +27,12 @@ public class BlockDemonCrystallizer extends BlockContainer
|
|||
// setBlockBounds(0.3F, 0F, 0.3F, 0.72F, 1F, 0.72F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideSolid(IBlockAccess world, BlockPos pos, EnumFacing side)
|
||||
{
|
||||
return side == EnumFacing.UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue