Finished blockDimWall
This commit is contained in:
parent
8e6626e46a
commit
201e7d46b7
15 changed files with 42 additions and 114 deletions
|
@ -14,10 +14,11 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemBlock;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.BlockPos;
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
|
import net.minecraft.world.Explosion;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import com.zixiken.dimdoors.client.PrivatePocketRender;
|
import com.zixiken.dimdoors.client.PrivatePocketRender;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
@ -52,17 +53,17 @@ public class BlockDimWall extends Block {
|
||||||
protected BlockState createBlockState() {return new BlockState(this, TYPE);}
|
protected BlockState createBlockState() {return new BlockState(this, TYPE);}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getBlockHardness(World world, int x, int y, int z) {
|
public float getBlockHardness(World world, BlockPos pos) {
|
||||||
if (world.getBlockMetadata(x, y, z) != 1) return this.blockHardness;
|
if (world.getBlockState(pos).getValue(TYPE) != 1) return this.blockHardness;
|
||||||
else return SUPER_HIGH_HARDNESS;
|
else return SUPER_HIGH_HARDNESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getExplosionResistance(Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) {
|
public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion) {
|
||||||
if (world.getBlockMetadata(x, y, z) != 1)
|
if(world.getBlockState(pos).getValue(TYPE) != 1)
|
||||||
return super.getExplosionResistance(entity, world, x, y, z, explosionX, explosionY, explosionZ);
|
return super.getExplosionResistance(world, pos, exploder, explosion);
|
||||||
else return SUPER_EXPLOSION_RESISTANCE;
|
else return SUPER_EXPLOSION_RESISTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRenderType()
|
public int getRenderType()
|
||||||
{
|
{
|
||||||
|
@ -99,36 +100,22 @@ public class BlockDimWall extends Block {
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* replaces the block clicked with the held block, instead of placing the block on top of it. Shift click to disable.
|
* replaces the block clicked with the held block, instead of placing the block on top of it. Shift click to disable.
|
||||||
*/
|
*/
|
||||||
@Override
|
@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
|
//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)
|
ItemStack playerEquip = player.getCurrentEquippedItem();
|
||||||
{
|
if (playerEquip != null && state.getValue(TYPE) != 1) {
|
||||||
Item playerEquip = entityPlayer.getCurrentEquippedItem().getItem();
|
Block block = Block.getBlockFromItem(playerEquip.getItem());
|
||||||
|
if (block != null) {
|
||||||
if (playerEquip instanceof ItemBlock)
|
if (!block.isNormalCube(world, pos) || block instanceof BlockContainer || block == this)
|
||||||
{
|
|
||||||
// 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)
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
if (!world.isRemote) {
|
||||||
if (!world.isRemote)
|
if (!player.capabilities.isCreativeMode) playerEquip.stackSize--;
|
||||||
{
|
world.setBlockState(pos, block.getStateFromMeta(playerEquip.getItemDamage()));
|
||||||
if (!entityPlayer.capabilities.isCreativeMode)
|
|
||||||
{
|
|
||||||
entityPlayer.getCurrentEquippedItem().stackSize--;
|
|
||||||
}
|
|
||||||
world.setBlock(x, y, z, block, playerEquipItemBlock.getMetadata(entityPlayer.getCurrentEquippedItem().getItemDamage()), 0);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class ItemBlockDimWall extends ItemBlock {
|
public class ItemBlockDimWall extends ItemBlock {
|
||||||
private final static String[] subNames = {"", "Perm" , "Personal"};
|
private final static String[] subNames = {"", "Ancient" , "Altered"};
|
||||||
|
|
||||||
public ItemBlockDimWall(Block block) {
|
public ItemBlockDimWall(Block block) {
|
||||||
super(block);
|
super(block);
|
||||||
|
|
|
@ -13,15 +13,15 @@ public class BlockRenderManager {
|
||||||
|
|
||||||
public static void registerBlockRenderers() {
|
public static void registerBlockRenderers() {
|
||||||
register(DimDoors.blockDimWall);
|
register(DimDoors.blockDimWall);
|
||||||
register(DimDoors.blockDimWall, 1, "Perm");
|
register(DimDoors.blockDimWall, 1, "Ancient");
|
||||||
register(DimDoors.blockDimWall, 2, "Personal");
|
register(DimDoors.blockDimWall, 2, "Altered");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addModelVariants() {
|
public static void addModelVariants() {
|
||||||
ModelBakery.registerItemVariants(Item.getItemFromBlock(DimDoors.blockDimWall),
|
ModelBakery.registerItemVariants(Item.getItemFromBlock(DimDoors.blockDimWall),
|
||||||
new ResourceLocation(ID + ":blockDimWall"),
|
new ResourceLocation(ID + ":blockDimWall"),
|
||||||
new ResourceLocation(ID + ":blockDimWallPerm"),
|
new ResourceLocation(ID + ":blockDimWallAncient"),
|
||||||
new ResourceLocation(ID + ":blockDimWallPersonal"));
|
new ResourceLocation(ID + ":blockDimWallAltered"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void register(Block block) {
|
private static void register(Block block) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"variants": {
|
"variants": {
|
||||||
"type=0": { "model": "dimdoors:blockDimWall" },
|
"type=0": { "model": "dimdoors:blockDimWall" },
|
||||||
"type=1": { "model": "dimdoors:blockDimWallPerm" },
|
"type=1": { "model": "dimdoors:blockDimWallAncient" },
|
||||||
"type=2": { "model": "dimdoors:blockDimWallPersonal" }
|
"type=2": { "model": "dimdoors:blockDimWallAltered" }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,8 +5,8 @@ tile.dimDoorGold.name=Golden Dimensional Door
|
||||||
tile.doorQuartz.name=Quartz Door
|
tile.doorQuartz.name=Quartz Door
|
||||||
tile.dimDoorPersonal.name=Personal Dimensional Door
|
tile.dimDoorPersonal.name=Personal Dimensional Door
|
||||||
tile.blockDimWall.name=Fabric of Reality
|
tile.blockDimWall.name=Fabric of Reality
|
||||||
tile.blockAlteredWall.name=Altered Fabric
|
tile.blockDimWallAltered.name=Altered Fabric
|
||||||
tile.blockAncientWall.name=Ancient Fabric
|
tile.blockDimWallAncient.name=Ancient Fabric
|
||||||
tile.blockDimWallPerm.name=Eternal Fabric
|
tile.blockDimWallPerm.name=Eternal Fabric
|
||||||
tile.dimDoorWarp.name=Warp Door
|
tile.dimDoorWarp.name=Warp Door
|
||||||
tile.rift.name=Rift
|
tile.rift.name=Rift
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"parent": "block/cube_all",
|
||||||
|
"textures": { "all": "dimdoors:blocks/blockDimWallAltered" }
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"parent": "block/cube_all",
|
||||||
|
"textures": { "all": "dimdoors:blocks/blockDimWallAncient" }
|
||||||
|
}
|
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "block/cube_all",
|
|
||||||
"textures": { "all": "dimdoors:blocks/blockDimWallPerm" }
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "block/cube_all",
|
|
||||||
"textures": { "all": "dimdoors:blocks/blockDimWallPersonal" }
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"parent": "dimdoors:block/blockDimWallPerm",
|
"parent": "dimdoors:block/blockDimWallAltered",
|
||||||
"display": {
|
"display": {
|
||||||
"thirdperson": {
|
"thirdperson": {
|
||||||
"rotation": [ 10, -45, 170 ],
|
"rotation": [ 10, -45, 170 ],
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"parent": "dimdoors:block/blockDimWallPersonal",
|
"parent": "dimdoors:block/blockDimWallAncient",
|
||||||
"display": {
|
"display": {
|
||||||
"thirdperson": {
|
"thirdperson": {
|
||||||
"rotation": [ 10, -45, 170 ],
|
"rotation": [ 10, -45, 170 ],
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"animation": { "frametime": 2 }
|
||||||
|
}
|
|
@ -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
|
|
||||||
|
|
||||||
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue