Iron chests can now be placed (with hackery)
This commit is contained in:
parent
5ee76dbe22
commit
a015481d3d
|
@ -58,6 +58,9 @@ func_177775_a - addObject
|
||||||
func_174889_b - openInventory
|
func_174889_b - openInventory
|
||||||
func_174886_c - closeInventory
|
func_174886_c - closeInventory
|
||||||
|
|
||||||
|
—RenderItem—
|
||||||
|
func_180451_a - renderEffect
|
||||||
|
|
||||||
——————————
|
——————————
|
||||||
ESTIMATES
|
ESTIMATES
|
||||||
——————————
|
——————————
|
||||||
|
@ -164,6 +167,11 @@ field_177992_a - ORIGIN
|
||||||
—IStringSerializable—
|
—IStringSerializable—
|
||||||
func_176610_l - getID
|
func_176610_l - getID
|
||||||
|
|
||||||
|
—ModelBakery—
|
||||||
|
func_177580_d - getModelLocation
|
||||||
|
func_177584_b - getBlockStateLocation
|
||||||
|
func_177586_a - getModelBlockDefinition
|
||||||
|
|
||||||
——————————
|
——————————
|
||||||
FIXES
|
FIXES
|
||||||
——————————
|
——————————
|
||||||
|
@ -174,3 +182,49 @@ FIXES
|
||||||
ResourceLocation key = new ResourceLocation(modId + ":" + name);
|
ResourceLocation key = new ResourceLocation(modId + ":" + name);
|
||||||
return getMain().iBlockRegistry.containsKey(key) ? getMain().iBlockRegistry.getObject(key) : null;
|
return getMain().iBlockRegistry.containsKey(key) ? getMain().iBlockRegistry.getObject(key) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int registerBlock(Block block, String name, int idHint)
|
||||||
|
{
|
||||||
|
// handle ItemBlock-before-Block registrations
|
||||||
|
ItemBlock itemBlock = null;
|
||||||
|
|
||||||
|
for (Item item : iItemRegistry.typeSafeIterable()) // find matching ItemBlock
|
||||||
|
{
|
||||||
|
if (item instanceof ItemBlock && ((ItemBlock) item).blockInstance == block)
|
||||||
|
{
|
||||||
|
itemBlock = (ItemBlock) item;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemBlock != null) // has ItemBlock, adjust id and clear the slot already occupied by the corresponding item
|
||||||
|
{
|
||||||
|
idHint = iItemRegistry.getId(itemBlock);
|
||||||
|
FMLLog.fine("Found matching ItemBlock %s for Block %s at id %d", itemBlock, block, idHint);
|
||||||
|
freeSlot(idHint, block); // temporarily free the slot occupied by the Item for the block registration
|
||||||
|
}
|
||||||
|
|
||||||
|
// add
|
||||||
|
int blockId = iBlockRegistry.add(idHint, name, block, availabilityMap);
|
||||||
|
|
||||||
|
if (itemBlock != null) // verify
|
||||||
|
{
|
||||||
|
if (blockId != idHint) throw new IllegalStateException(String.format("Block at itemblock id %d insertion failed, got id %d.", idHint, blockId));
|
||||||
|
verifyItemBlockName(itemBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Hackery added by me which probably shouldn't be done
|
||||||
|
Iterator iterator1 = block.getBlockState().getValidStates().iterator();
|
||||||
|
|
||||||
|
while (iterator1.hasNext())
|
||||||
|
{
|
||||||
|
IBlockState iblockstate = (IBlockState)iterator1.next();
|
||||||
|
int i = blockRegistry.getIDForObject(block) << 4 | block.getMetaFromBlockState(iblockstate);
|
||||||
|
Block.field_176229_d.func_148746_a(iblockstate, i);
|
||||||
|
}
|
||||||
|
//End hackery
|
||||||
|
|
||||||
|
useSlot(blockId);
|
||||||
|
((RegistryDelegate.Delegate<Block>) block.delegate).setName(name);
|
||||||
|
return blockId;
|
||||||
|
}
|
|
@ -10,6 +10,7 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package cpw.mods.ironchest;
|
package cpw.mods.ironchest;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -19,24 +20,26 @@ import net.minecraft.block.properties.PropertyEnum;
|
||||||
import net.minecraft.block.state.BlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class BlockIronChest extends /*BlockContainer*/Block
|
public class BlockIronChest extends /*BlockContainer*/Block
|
||||||
{
|
{
|
||||||
public static final PropertyEnum VARIANT_PROP = PropertyEnum.func_177709_a("variant", IronChestType.class);
|
public static final PropertyEnum VARIANT_PROP = PropertyEnum.func_177709_a("variant", IronChestType.class);
|
||||||
|
|
||||||
private Random random;
|
|
||||||
|
|
||||||
public BlockIronChest()
|
public BlockIronChest()
|
||||||
{
|
{
|
||||||
super(Material.iron);
|
super(Material.iron);
|
||||||
|
|
||||||
this.setDefaultBlockState(this.blockState.getBaseState().setProperty(VARIANT_PROP, IronChestType.IRON));
|
this.setDefaultBlockState(this.blockState.getBaseState().setProperty(VARIANT_PROP, IronChestType.IRON));
|
||||||
|
|
||||||
setUnlocalizedName("IronChest");
|
//this.setBlockBounds(0.0625F, 0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
|
||||||
setHardness(3.0F);
|
this.setHardness(3.0F);
|
||||||
setBlockBounds(0.0625F, 0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
|
this.setUnlocalizedName("IronChest");
|
||||||
random = new Random();
|
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||||
setCreativeTab(CreativeTabs.tabDecorations);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,6 +54,19 @@ public class BlockIronChest extends /*BlockContainer*/Block
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void getSubBlocks(Item itemIn, CreativeTabs tab, List list)
|
||||||
|
{
|
||||||
|
for (IronChestType type : IronChestType.values())
|
||||||
|
{
|
||||||
|
if (type.isValidForCreativeMode())
|
||||||
|
{
|
||||||
|
list.add(new ItemStack(this, 1, type.ordinal()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockState getBlockStateFromMeta(int meta)
|
public IBlockState getBlockStateFromMeta(int meta)
|
||||||
{
|
{
|
||||||
|
@ -206,20 +222,6 @@ public class BlockIronChest extends /*BlockContainer*/Block
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
/*@Override
|
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
|
|
||||||
{
|
|
||||||
for (IronChestType type : IronChestType.values())
|
|
||||||
{
|
|
||||||
if (type.isValidForCreativeMode())
|
|
||||||
{
|
|
||||||
par3List.add(new ItemStack(this, 1, type.ordinal()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*@Override
|
/*@Override
|
||||||
public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
|
public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package cpw.mods.ironchest;
|
package cpw.mods.ironchest;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||||
import net.minecraftforge.fml.common.Mod.Instance;
|
import net.minecraftforge.fml.common.Mod.Instance;
|
||||||
|
@ -53,7 +55,7 @@ public class IronChest {
|
||||||
cfg.save();
|
cfg.save();
|
||||||
}*/
|
}*/
|
||||||
ironChestBlock = new BlockIronChest();
|
ironChestBlock = new BlockIronChest();
|
||||||
GameRegistry.registerBlock(ironChestBlock,/* ItemIronChest.class,*/ "BlockIronChest");
|
GameRegistry.registerBlock(ironChestBlock, ItemIronChest.class, "BlockIronChest");
|
||||||
//PacketHandler.INSTANCE.ordinal();
|
//PacketHandler.INSTANCE.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,23 +14,25 @@ import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class ItemIronChest extends ItemBlock {
|
public class ItemIronChest extends ItemBlock
|
||||||
|
{
|
||||||
public ItemIronChest(Block block)
|
public ItemIronChest(Block block)
|
||||||
{
|
{
|
||||||
super(block);
|
super(block);
|
||||||
setHasSubtypes(true);
|
|
||||||
|
this.setMaxDurability(0);
|
||||||
|
this.setHasSubtypes(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetadata(int i)
|
public int getMetadata(int meta)
|
||||||
{
|
{
|
||||||
return IronChestType.validateMeta(i);
|
return IronChestType.validateMeta(meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUnlocalizedName(ItemStack itemstack)
|
public String getUnlocalizedName(ItemStack itemstack)
|
||||||
{
|
{
|
||||||
return "tile.ironchest:"+IronChestType.values()[itemstack.getMetadata()].name();
|
return "tile.ironchest:" + IronChestType.values()[itemstack.getMetadata()].name();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"normal": { "model": "ironchest:BlockIronChest" }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "block/cube_all",
|
||||||
|
"textures": {
|
||||||
|
"all": "blocks/clay"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"parent": "ironchest:block/BlockIronChest",
|
||||||
|
"display": {
|
||||||
|
"thirdperson": {
|
||||||
|
"rotation": [ 10, -45, 170 ],
|
||||||
|
"translation": [ 0, 1.5, -2.75 ],
|
||||||
|
"scale": [ 0.375, 0.375, 0.375 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue