Initial work on pillars - needs some serious bug fixing!
This commit is contained in:
parent
bafbd0b076
commit
d52240813e
|
@ -0,0 +1,58 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.block.base.BlockStringPillar;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
|
||||
public class BlockDemonPillar extends BlockStringPillar implements IVariantProvider
|
||||
{
|
||||
public static final String[] names = new String[] { "raw", "corrosive" };
|
||||
|
||||
public BlockDemonPillar(String baseName, Material materialIn)
|
||||
{
|
||||
super(materialIn, names);
|
||||
|
||||
setUnlocalizedName(Constants.Mod.MODID + "." + baseName + ".");
|
||||
setCreativeTab(BloodMagic.tabBloodMagic);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setSoundType(SoundType.STONE);
|
||||
setHarvestLevel("pickaxe", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
// for (int i = 0; i < 3; i++)
|
||||
// {
|
||||
// ret.add(new ImmutablePair<Integer, String>(i, "axis=" + EnumFacing.Axis.values()[i]));
|
||||
// }
|
||||
//
|
||||
// for (int i = 0; i < names.length; i++)
|
||||
// {
|
||||
// ret.add(new ImmutablePair<Integer, String>(i + 3, "type=" + names[i]));
|
||||
// }
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
for (int j = 0; j < names.length; j++)
|
||||
{
|
||||
ret.add(new ImmutablePair<Integer, String>(j * 3 + i, "axis=" + EnumFacing.Axis.values()[i] + ",type=" + names[j]));
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -99,7 +99,7 @@ public class BlockString extends Block
|
|||
list.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
|
||||
private void setupStates()
|
||||
protected void setupStates()
|
||||
{
|
||||
this.setDefaultState(getExtendedBlockState().withProperty(unlistedStringProp, values.get(0)).withProperty(stringProp, values.get(0)));
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public class BlockString extends Block
|
|||
return (IExtendedBlockState) this.getBaseExtendedState().getBaseState();
|
||||
}
|
||||
|
||||
private BlockStateContainer createRealBlockState()
|
||||
protected BlockStateContainer createRealBlockState()
|
||||
{
|
||||
return new ExtendedBlockState(this, new IProperty[] { stringProp }, new IUnlistedProperty[] { unlistedStringProp });
|
||||
}
|
||||
|
|
|
@ -0,0 +1,156 @@
|
|||
package WayofTime.bloodmagic.block.base;
|
||||
|
||||
import net.minecraft.block.BlockRotatedPillar;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
public class BlockStringPillar extends BlockString
|
||||
{
|
||||
public BlockStringPillar(Material material, String[] values, String propName)
|
||||
{
|
||||
super(material, values, propName);
|
||||
}
|
||||
|
||||
public BlockStringPillar(Material material, String[] values)
|
||||
{
|
||||
this(material, values, "type");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
// System.out.println(state);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given metadata into a BlockState for this Block
|
||||
*/
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
IBlockState iblockstate = this.getDefaultState().withProperty(this.getStringProp(), this.getValues().get((meta & 3) % 4));
|
||||
|
||||
switch (meta & 12)
|
||||
{
|
||||
case 0:
|
||||
iblockstate = iblockstate.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Y);
|
||||
break;
|
||||
case 4:
|
||||
iblockstate = iblockstate.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.X);
|
||||
break;
|
||||
case 8:
|
||||
iblockstate = iblockstate.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Z);
|
||||
break;
|
||||
default:
|
||||
iblockstate.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Y);
|
||||
break;
|
||||
}
|
||||
|
||||
// System.out.println(iblockstate);
|
||||
|
||||
return iblockstate;
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
int i = 0;
|
||||
i = i | this.getValues().indexOf(String.valueOf(state.getValue(this.getStringProp())));
|
||||
|
||||
switch ((EnumFacing.Axis) state.getValue(BlockRotatedPillar.AXIS))
|
||||
{
|
||||
case X:
|
||||
i |= 4;
|
||||
break;
|
||||
case Z:
|
||||
i |= 8;
|
||||
break;
|
||||
// case NONE:
|
||||
// i |= 12;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rotateBlock(net.minecraft.world.World world, BlockPos pos, EnumFacing axis)
|
||||
{
|
||||
net.minecraft.block.state.IBlockState state = world.getBlockState(pos);
|
||||
for (net.minecraft.block.properties.IProperty<?> prop : state.getProperties().keySet())
|
||||
{
|
||||
if (prop == BlockRotatedPillar.AXIS)
|
||||
{
|
||||
world.setBlockState(pos, state.cycleProperty(prop));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState withRotation(IBlockState state, Rotation rot)
|
||||
{
|
||||
switch (rot)
|
||||
{
|
||||
case COUNTERCLOCKWISE_90:
|
||||
case CLOCKWISE_90:
|
||||
switch (state.getValue(BlockRotatedPillar.AXIS))
|
||||
{
|
||||
case X:
|
||||
return state.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Z);
|
||||
case Z:
|
||||
return state.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.X);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupStates()
|
||||
{
|
||||
this.setDefaultState(getExtendedBlockState().withProperty(this.getUnlistedStringProp(), this.getValues().get(0)).withProperty(this.getStringProp(), this.getValues().get(0)).withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Y));
|
||||
}
|
||||
|
||||
// @Override
|
||||
// protected BlockStateContainer createBlockState()
|
||||
// {
|
||||
// return new BlockStateContainer(this, new IProperty[] { this.getStringProp(), BlockRotatedPillar.AXIS });
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createRealBlockState()
|
||||
{
|
||||
return new ExtendedBlockState(this, new IProperty[] { BlockRotatedPillar.AXIS, this.getStringProp() }, new IUnlistedProperty[] { this.getUnlistedStringProp() });
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack createStackedBlock(IBlockState state)
|
||||
{
|
||||
return new ItemStack(Item.getItemFromBlock(this), 1, this.getValues().indexOf(String.valueOf(state.getValue(this.getStringProp()))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||
{
|
||||
return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(BlockRotatedPillar.AXIS, facing.getAxis());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package WayofTime.bloodmagic.item.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import WayofTime.bloodmagic.block.BlockDemonPillar;
|
||||
|
||||
public class ItemBlockDemonPillarBase extends ItemBlock
|
||||
{
|
||||
// public final BlockDemonBase demonBlock;
|
||||
|
||||
public ItemBlockDemonPillarBase(Block block)
|
||||
{
|
||||
super(block);
|
||||
setHasSubtypes(true);
|
||||
// demonBlock = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
return super.getUnlocalizedName(stack) + BlockDemonPillar.names[stack.getItemDamage() % BlockDemonPillar.names.length];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int meta)
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package WayofTime.bloodmagic.registry;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
@ -22,6 +23,7 @@ import WayofTime.bloodmagic.block.BlockDemonBase;
|
|||
import WayofTime.bloodmagic.block.BlockDemonCrucible;
|
||||
import WayofTime.bloodmagic.block.BlockDemonCrystal;
|
||||
import WayofTime.bloodmagic.block.BlockDemonCrystallizer;
|
||||
import WayofTime.bloodmagic.block.BlockDemonPillar;
|
||||
import WayofTime.bloodmagic.block.BlockDemonPylon;
|
||||
import WayofTime.bloodmagic.block.BlockDimensionalPortal;
|
||||
import WayofTime.bloodmagic.block.BlockIncenseAltar;
|
||||
|
@ -46,6 +48,7 @@ import WayofTime.bloodmagic.item.block.ItemBlockBloodTank;
|
|||
import WayofTime.bloodmagic.item.block.ItemBlockCrystal;
|
||||
import WayofTime.bloodmagic.item.block.ItemBlockDemonBase;
|
||||
import WayofTime.bloodmagic.item.block.ItemBlockDemonCrystal;
|
||||
import WayofTime.bloodmagic.item.block.ItemBlockDemonPillarBase;
|
||||
import WayofTime.bloodmagic.item.block.ItemBlockMimic;
|
||||
import WayofTime.bloodmagic.item.block.ItemBlockPath;
|
||||
import WayofTime.bloodmagic.item.block.ItemBlockPedestal;
|
||||
|
@ -117,6 +120,7 @@ public class ModBlocks
|
|||
|
||||
public static Block demonBrick1;
|
||||
public static Block demonBrick2;
|
||||
public static Block demonPillar1;
|
||||
|
||||
public static void init()
|
||||
{
|
||||
|
@ -157,7 +161,7 @@ public class ModBlocks
|
|||
|
||||
demonBrick1 = registerBlock(new ItemBlockDemonBase(new BlockDemonBase("bricks1", new String[] { "brick1_raw", "brick1_corrosive", "brick1_destructive", "brick1_vengeful", "brick1_steadfast", "brick2_raw", "brick2_corrosive", "brick2_destructive", "brick2_vengeful", "brick2_steadfast", "brick3_raw", "brick3_corrosive", "brick3_destructive", "brick3_vengeful", "brick3_steadfast" })), Constants.BloodMagicBlock.DEMON_BRICK_1.getRegName());
|
||||
demonBrick2 = registerBlock(new ItemBlockDemonBase(new BlockDemonBase("bricks2", new String[] { "smallbrick_raw", "smallbrick_corrosive", "smallbrick_destructive", "smallbrick_vengeful", "smallbrick_steadfast", "tile_raw", "tile_corrosive", "tile_destructive", "tile_vengeful", "tile_steadfast", "tilespecial_raw", "tilespecial_corrosive", "tilespecial_destructive", "tilespecial_vengeful", "tilespecial_steadfast" })), Constants.BloodMagicBlock.DEMON_BRICK_2.getRegName());
|
||||
|
||||
demonPillar1 = registerBlock(new ItemBlockDemonPillarBase(new BlockDemonPillar("pillar1", Material.ROCK)), "BlockPillar1");
|
||||
// testSpellBlock = registerBlock(new BlockTestSpellBlock());
|
||||
|
||||
BloodMagicAPI.addToTeleposerBlacklist(inputRoutingNode);
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
"forge_marker": 1,
|
||||
"defaults": {
|
||||
"model": "minecraft:cube_bottom_top",
|
||||
"textures": {
|
||||
"bottom": "bloodmagic:blocks/dungeon/dungeon_pillarheart",
|
||||
"top": "bloodmagic:blocks/dungeon/dungeon_pillarheart",
|
||||
"side": "bloodmagic:blocks/dungeon/dungeon_pillar"
|
||||
}
|
||||
},
|
||||
"variants": {
|
||||
"axis": {
|
||||
"x": {
|
||||
"transform": {
|
||||
"rotation": {"z": -90}
|
||||
}
|
||||
},
|
||||
"y": {
|
||||
|
||||
},
|
||||
"z": {
|
||||
"transform": {
|
||||
"rotation": {"x": 90}
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": {
|
||||
"raw": {
|
||||
|
||||
},
|
||||
"corrosive": {
|
||||
"textures": {
|
||||
"bottom": "bloodmagic:blocks/dungeon/dungeon_pillarheart_c",
|
||||
"top": "bloodmagic:blocks/dungeon/dungeon_pillarheart_c",
|
||||
"side": "bloodmagic:blocks/dungeon/dungeon_pillar_c"
|
||||
}
|
||||
}
|
||||
},
|
||||
"inventory": [{
|
||||
"variants": {
|
||||
"raw": {
|
||||
|
||||
},
|
||||
"corrosive": {
|
||||
"textures": {
|
||||
"bottom": "bloodmagic:blocks/dungeon/dungeon_pillarheart_c",
|
||||
"top": "bloodmagic:blocks/dungeon/dungeon_pillarheart_c",
|
||||
"side": "bloodmagic:blocks/dungeon/dungeon_pillar_c"
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue