Basic chests into and out of world again
This commit is contained in:
parent
1afe4d8e61
commit
54baabba1e
|
@ -5,6 +5,7 @@ import java.io.File;
|
||||||
import cpw.mods.ironchest.BlockIronChest;
|
import cpw.mods.ironchest.BlockIronChest;
|
||||||
import cpw.mods.ironchest.IronChestType;
|
import cpw.mods.ironchest.IronChestType;
|
||||||
import cpw.mods.ironchest.ItemIronChest;
|
import cpw.mods.ironchest.ItemIronChest;
|
||||||
|
import cpw.mods.ironchest.client.TileEntityIronChestRenderer;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.src.forge.Configuration;
|
import net.minecraft.src.forge.Configuration;
|
||||||
import net.minecraft.src.forge.MinecraftForgeClient;
|
import net.minecraft.src.forge.MinecraftForgeClient;
|
||||||
|
@ -41,9 +42,11 @@ public class mod_IronChest extends BaseModMp {
|
||||||
}
|
}
|
||||||
|
|
||||||
ModLoader.RegisterBlock(ironChestBlock, ItemIronChest.class);
|
ModLoader.RegisterBlock(ironChestBlock, ItemIronChest.class);
|
||||||
IronChestType.registerTileEntities();
|
IronChestType.registerTranslations();
|
||||||
|
IronChestType.registerTileEntities(TileEntityIronChestRenderer.class);
|
||||||
IronChestType.registerRecipes(ironChestBlock);
|
IronChestType.registerRecipes(ironChestBlock);
|
||||||
|
|
||||||
|
System.out.printf("Item : %s\n", Item.itemsList[ironChestBlock.blockID]);
|
||||||
MinecraftForgeClient.preloadTexture("ic2/sprites/ironchest_block_tex.png");
|
MinecraftForgeClient.preloadTexture("ic2/sprites/ironchest_block_tex.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package cpw.mods.ironchest;
|
package cpw.mods.ironchest;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.src.BlockContainer;
|
import net.minecraft.src.BlockContainer;
|
||||||
import net.minecraft.src.EntityLiving;
|
import net.minecraft.src.EntityLiving;
|
||||||
import net.minecraft.src.IBlockAccess;
|
import net.minecraft.src.IBlockAccess;
|
||||||
|
@ -13,6 +15,7 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider {
|
||||||
|
|
||||||
public BlockIronChest(int id) {
|
public BlockIronChest(int id) {
|
||||||
super(id, Material.iron);
|
super(id, Material.iron);
|
||||||
|
setBlockName("IronChest");
|
||||||
setHardness(3.0F);
|
setHardness(3.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +56,7 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
return typ.getTextureRow()*16+1;
|
return typ.getTextureRow()*16+1;
|
||||||
case 2:
|
case 3:
|
||||||
return typ.getTextureRow()*16+2;
|
return typ.getTextureRow()*16+2;
|
||||||
default:
|
default:
|
||||||
return typ.getTextureRow()*16;
|
return typ.getTextureRow()*16;
|
||||||
|
@ -89,4 +92,8 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider {
|
||||||
world.markBlockNeedsUpdate(i, j, k);
|
world.markBlockNeedsUpdate(i, j, k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
protected int damageDropped(int i) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import net.minecraft.src.Item;
|
||||||
import net.minecraft.src.ItemStack;
|
import net.minecraft.src.ItemStack;
|
||||||
import net.minecraft.src.ModLoader;
|
import net.minecraft.src.ModLoader;
|
||||||
import net.minecraft.src.TileEntity;
|
import net.minecraft.src.TileEntity;
|
||||||
|
import net.minecraft.src.TileEntitySpecialRenderer;
|
||||||
import net.minecraft.src.mod_IronChest;
|
import net.minecraft.src.mod_IronChest;
|
||||||
|
|
||||||
public enum IronChestType {
|
public enum IronChestType {
|
||||||
|
@ -24,7 +25,7 @@ public enum IronChestType {
|
||||||
IronChestType(int size, String friendlyName, String modelTexture, int textureRow, Item mat, Class<? extends TileEntityIronChest> clazz, String... recipes) {
|
IronChestType(int size, String friendlyName, String modelTexture, int textureRow, Item mat, Class<? extends TileEntityIronChest> clazz, String... recipes) {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.friendlyName = friendlyName;
|
this.friendlyName = friendlyName;
|
||||||
this.modelTexture = modelTexture;
|
this.modelTexture = "ic2/sprites/"+modelTexture;
|
||||||
this.textureRow = textureRow;
|
this.textureRow = textureRow;
|
||||||
this.clazz = clazz;
|
this.clazz = clazz;
|
||||||
this.mat = mat;
|
this.mat = mat;
|
||||||
|
@ -64,24 +65,40 @@ public enum IronChestType {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerTileEntities() {
|
public static void registerTileEntities(Class<? extends TileEntitySpecialRenderer> renderer) {
|
||||||
for (IronChestType typ : values()) {
|
for (IronChestType typ : values()) {
|
||||||
System.out.printf("Registering %s\n",typ.friendlyName);
|
try {
|
||||||
ModLoader.RegisterTileEntity(typ.clazz, typ.friendlyName);
|
if (renderer!=null) {
|
||||||
|
ModLoader.RegisterTileEntity(typ.clazz, typ.name(),renderer.newInstance());
|
||||||
|
} else {
|
||||||
|
ModLoader.RegisterTileEntity(typ.clazz, typ.name());
|
||||||
|
}
|
||||||
|
} catch (InstantiationException e) {
|
||||||
|
// unpossible
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
// unpossible
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void registerTranslations() {
|
||||||
|
for (IronChestType typ : values()) {
|
||||||
|
ModLoader.AddLocalization(typ.name()+".name", typ.friendlyName);
|
||||||
|
}
|
||||||
|
}
|
||||||
public static void registerRecipes(BlockIronChest blockResult) {
|
public static void registerRecipes(BlockIronChest blockResult) {
|
||||||
ItemStack previous=new ItemStack(Block.chest);
|
ItemStack previous=new ItemStack(Block.chest);
|
||||||
for (IronChestType typ : values()) {
|
for (IronChestType typ : values()) {
|
||||||
for (String recipe : typ.recipes) {
|
for (String recipe : typ.recipes) {
|
||||||
addRecipe(new ItemStack(blockResult, typ.ordinal()), recipe, 'm', typ.mat, 'P', previous, 'G', Block.glass, 'C', Block.chest);
|
String[] recipeSplit=new String[] { recipe.substring(0,3),recipe.substring(3,6), recipe.substring(6,9) };
|
||||||
|
addRecipe(new ItemStack(blockResult, 1, typ.ordinal()), recipeSplit, 'm', typ.mat, 'P', previous, 'G', Block.glass, 'C', Block.chest);
|
||||||
}
|
}
|
||||||
previous=new ItemStack(blockResult,typ.ordinal());
|
previous=new ItemStack(blockResult,1,typ.ordinal());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static void addRecipe(ItemStack is, Object... parts) {
|
private static void addRecipe(ItemStack is, Object... parts) {
|
||||||
System.out.printf("Recipe : %s\n",Arrays.asList(parts));
|
|
||||||
ModLoader.AddRecipe(is, parts);
|
ModLoader.AddRecipe(is, parts);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,7 +13,7 @@ public class ItemIronChest extends ItemBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetadata(int i) {
|
public int getMetadata(int i) {
|
||||||
if (i<=IronChestType.values().length) {
|
if (i<IronChestType.values().length) {
|
||||||
return i;
|
return i;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -21,6 +21,6 @@ public class ItemIronChest extends ItemBlock {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String getItemNameIS(ItemStack itemstack) {
|
public String getItemNameIS(ItemStack itemstack) {
|
||||||
return IronChestType.values()[itemstack.getItemDamage()].friendlyName;
|
return IronChestType.values()[itemstack.getItemDamage()].name();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String getInvName() {
|
public String getInvName() {
|
||||||
return type.friendlyName;
|
return type.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IronChestType getType() {
|
public IronChestType getType() {
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
Loading…
Reference in New Issue