Finished blockDimWall

This commit is contained in:
Michael Zanga 2016-06-28 09:52:21 -04:00
parent 8e6626e46a
commit 201e7d46b7
15 changed files with 42 additions and 114 deletions

View file

@ -14,10 +14,11 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import com.zixiken.dimdoors.client.PrivatePocketRender;
import net.minecraftforge.fml.relauncher.Side;
@ -52,17 +53,17 @@ public class BlockDimWall extends Block {
protected BlockState createBlockState() {return new BlockState(this, TYPE);}
@Override
public float getBlockHardness(World world, int x, int y, int z) {
if (world.getBlockMetadata(x, y, z) != 1) return this.blockHardness;
public float getBlockHardness(World world, BlockPos pos) {
if (world.getBlockState(pos).getValue(TYPE) != 1) return this.blockHardness;
else return SUPER_HIGH_HARDNESS;
}
@Override
public float getExplosionResistance(Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) {
if (world.getBlockMetadata(x, y, z) != 1)
return super.getExplosionResistance(entity, world, x, y, z, explosionX, explosionY, explosionZ);
else return SUPER_EXPLOSION_RESISTANCE;
}
public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion) {
if(world.getBlockState(pos).getValue(TYPE) != 1)
return super.getExplosionResistance(world, pos, exploder, explosion);
else return SUPER_EXPLOSION_RESISTANCE;
}
public int getRenderType()
{
@ -99,36 +100,22 @@ public class BlockDimWall extends Block {
{
return 0;
}
/**
* replaces the block clicked with the held block, instead of placing the block on top of it. Shift click to disable.
*/
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) {
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) {
//Check if the metadata value is 0 -- we don't want the user to replace Ancient Fabric
if (entityPlayer.getCurrentEquippedItem() != null && world.getBlockMetadata(x, y, z) != 1)
{
Item playerEquip = entityPlayer.getCurrentEquippedItem().getItem();
if (playerEquip instanceof ItemBlock)
{
// SenseiKiwi: Using getBlockID() rather than the raw itemID is critical.
// Some mods may override that function and use item IDs outside the range
// of the block list.
ItemBlock playerEquipItemBlock = (ItemBlock)playerEquip;
Block block = playerEquipItemBlock.field_150939_a;
if (!block.isNormalCube(world, x, y, z) || block instanceof BlockContainer || block == this)
{
ItemStack playerEquip = player.getCurrentEquippedItem();
if (playerEquip != null && state.getValue(TYPE) != 1) {
Block block = Block.getBlockFromItem(playerEquip.getItem());
if (block != null) {
if (!block.isNormalCube(world, pos) || block instanceof BlockContainer || block == this)
return false;
}
if (!world.isRemote)
{
if (!entityPlayer.capabilities.isCreativeMode)
{
entityPlayer.getCurrentEquippedItem().stackSize--;
}
world.setBlock(x, y, z, block, playerEquipItemBlock.getMetadata(entityPlayer.getCurrentEquippedItem().getItemDamage()), 0);
if (!world.isRemote) {
if (!player.capabilities.isCreativeMode) playerEquip.stackSize--;
world.setBlockState(pos, block.getStateFromMeta(playerEquip.getItemDamage()));
}
return true;
}

View file

@ -6,7 +6,7 @@ import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBlockDimWall extends ItemBlock {
private final static String[] subNames = {"", "Perm" , "Personal"};
private final static String[] subNames = {"", "Ancient" , "Altered"};
public ItemBlockDimWall(Block block) {
super(block);

View file

@ -13,15 +13,15 @@ public class BlockRenderManager {
public static void registerBlockRenderers() {
register(DimDoors.blockDimWall);
register(DimDoors.blockDimWall, 1, "Perm");
register(DimDoors.blockDimWall, 2, "Personal");
register(DimDoors.blockDimWall, 1, "Ancient");
register(DimDoors.blockDimWall, 2, "Altered");
}
public static void addModelVariants() {
ModelBakery.registerItemVariants(Item.getItemFromBlock(DimDoors.blockDimWall),
new ResourceLocation(ID + ":blockDimWall"),
new ResourceLocation(ID + ":blockDimWallPerm"),
new ResourceLocation(ID + ":blockDimWallPersonal"));
new ResourceLocation(ID + ":blockDimWallAncient"),
new ResourceLocation(ID + ":blockDimWallAltered"));
}
private static void register(Block block) {

View file

@ -1,7 +1,7 @@
{
"variants": {
"type=0": { "model": "dimdoors:blockDimWall" },
"type=1": { "model": "dimdoors:blockDimWallPerm" },
"type=2": { "model": "dimdoors:blockDimWallPersonal" }
"type=1": { "model": "dimdoors:blockDimWallAncient" },
"type=2": { "model": "dimdoors:blockDimWallAltered" }
}
}

View file

@ -5,8 +5,8 @@ tile.dimDoorGold.name=Golden Dimensional Door
tile.doorQuartz.name=Quartz Door
tile.dimDoorPersonal.name=Personal Dimensional Door
tile.blockDimWall.name=Fabric of Reality
tile.blockAlteredWall.name=Altered Fabric
tile.blockAncientWall.name=Ancient Fabric
tile.blockDimWallAltered.name=Altered Fabric
tile.blockDimWallAncient.name=Ancient Fabric
tile.blockDimWallPerm.name=Eternal Fabric
tile.dimDoorWarp.name=Warp Door
tile.rift.name=Rift

View file

@ -0,0 +1,4 @@
{
"parent": "block/cube_all",
"textures": { "all": "dimdoors:blocks/blockDimWallAltered" }
}

View file

@ -0,0 +1,4 @@
{
"parent": "block/cube_all",
"textures": { "all": "dimdoors:blocks/blockDimWallAncient" }
}

View file

@ -1,4 +0,0 @@
{
"parent": "block/cube_all",
"textures": { "all": "dimdoors:blocks/blockDimWallPerm" }
}

View file

@ -1,4 +0,0 @@
{
"parent": "block/cube_all",
"textures": { "all": "dimdoors:blocks/blockDimWallPersonal" }
}

View file

@ -1,5 +1,5 @@
{
"parent": "dimdoors:block/blockDimWallPerm",
"parent": "dimdoors:block/blockDimWallAltered",
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],

View file

@ -1,5 +1,5 @@
{
"parent": "dimdoors:block/blockDimWallPersonal",
"parent": "dimdoors:block/blockDimWallAncient",
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],

View file

@ -0,0 +1,3 @@
{
"animation": { "frametime": 2 }
}

View file

@ -1,62 +0,0 @@
{
"animation":
{
"frametime": 2,
"frames":
[
0
,1
,2
,3
,4
,5
,6
,7
,8
,9
,10
,11
,13
,14
,15
,16
,17
,18
,19
,20
,21
,22
,23
,24
,25
,16
,17
,28
,29
,30
,31
,32
,33
,34
,35
,36
,37
,38
,39
,40
,41
,42
,43
,44
,45
,46
,47
,48
,49
]
}
}