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.IronChestType;
|
||||
import cpw.mods.ironchest.ItemIronChest;
|
||||
import cpw.mods.ironchest.client.TileEntityIronChestRenderer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.forge.Configuration;
|
||||
import net.minecraft.src.forge.MinecraftForgeClient;
|
||||
|
@ -41,9 +42,11 @@ public class mod_IronChest extends BaseModMp {
|
|||
}
|
||||
|
||||
ModLoader.RegisterBlock(ironChestBlock, ItemIronChest.class);
|
||||
IronChestType.registerTileEntities();
|
||||
IronChestType.registerTranslations();
|
||||
IronChestType.registerTileEntities(TileEntityIronChestRenderer.class);
|
||||
IronChestType.registerRecipes(ironChestBlock);
|
||||
|
||||
System.out.printf("Item : %s\n", Item.itemsList[ironChestBlock.blockID]);
|
||||
MinecraftForgeClient.preloadTexture("ic2/sprites/ironchest_block_tex.png");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package cpw.mods.ironchest;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.src.BlockContainer;
|
||||
import net.minecraft.src.EntityLiving;
|
||||
import net.minecraft.src.IBlockAccess;
|
||||
|
@ -13,6 +15,7 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider {
|
|||
|
||||
public BlockIronChest(int id) {
|
||||
super(id, Material.iron);
|
||||
setBlockName("IronChest");
|
||||
setHardness(3.0F);
|
||||
}
|
||||
|
||||
|
@ -53,7 +56,7 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider {
|
|||
case 0:
|
||||
case 1:
|
||||
return typ.getTextureRow()*16+1;
|
||||
case 2:
|
||||
case 3:
|
||||
return typ.getTextureRow()*16+2;
|
||||
default:
|
||||
return typ.getTextureRow()*16;
|
||||
|
@ -89,4 +92,8 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider {
|
|||
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.ModLoader;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.TileEntitySpecialRenderer;
|
||||
import net.minecraft.src.mod_IronChest;
|
||||
|
||||
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) {
|
||||
this.size = size;
|
||||
this.friendlyName = friendlyName;
|
||||
this.modelTexture = modelTexture;
|
||||
this.modelTexture = "ic2/sprites/"+modelTexture;
|
||||
this.textureRow = textureRow;
|
||||
this.clazz = clazz;
|
||||
this.mat = mat;
|
||||
|
@ -64,24 +65,40 @@ public enum IronChestType {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static void registerTileEntities() {
|
||||
public static void registerTileEntities(Class<? extends TileEntitySpecialRenderer> renderer) {
|
||||
for (IronChestType typ : values()) {
|
||||
System.out.printf("Registering %s\n",typ.friendlyName);
|
||||
ModLoader.RegisterTileEntity(typ.clazz, typ.friendlyName);
|
||||
try {
|
||||
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) {
|
||||
ItemStack previous=new ItemStack(Block.chest);
|
||||
for (IronChestType typ : values()) {
|
||||
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) {
|
||||
System.out.printf("Recipe : %s\n",Arrays.asList(parts));
|
||||
ModLoader.AddRecipe(is, parts);
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@ public class ItemIronChest extends ItemBlock {
|
|||
|
||||
@Override
|
||||
public int getMetadata(int i) {
|
||||
if (i<=IronChestType.values().length) {
|
||||
if (i<IronChestType.values().length) {
|
||||
return i;
|
||||
} else {
|
||||
return 0;
|
||||
|
@ -21,6 +21,6 @@ public class ItemIronChest extends ItemBlock {
|
|||
}
|
||||
@Override
|
||||
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
|
||||
public String getInvName() {
|
||||
return type.friendlyName;
|
||||
return type.name();
|
||||
}
|
||||
|
||||
public IronChestType getType() {
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
Loading…
Reference in New Issue