More stuff, starting to work in a test world. Nice...
This commit is contained in:
parent
c640fd5e63
commit
1afe4d8e61
|
@ -68,7 +68,7 @@
|
||||||
<property name="jarname" value="${modname}-${side}-${version}" />
|
<property name="jarname" value="${modname}-${side}-${version}" />
|
||||||
<jar destfile="${basedir}/${jarname}.zip">
|
<jar destfile="${basedir}/${jarname}.zip">
|
||||||
<fileset dir="${output}" includes="**/*.class" />
|
<fileset dir="${output}" includes="**/*.class" />
|
||||||
<fileset dir="${resource.dir}" />
|
<fileset dir="${resource.dir}" includes="**/*.png"/>
|
||||||
</jar>
|
</jar>
|
||||||
</target>
|
</target>
|
||||||
<target name="build" depends="merge-client,merge-server,build-client,build-server" />
|
<target name="build" depends="merge-client,merge-server,build-client,build-server" />
|
||||||
|
@ -114,8 +114,9 @@
|
||||||
<exec executable="${mcp.home}/reobfuscate.sh" dir="${mcp.home}" />
|
<exec executable="${mcp.home}/reobfuscate.sh" dir="${mcp.home}" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="deploy" depends="init,build">
|
<target name="deploy" depends="init,build-client">
|
||||||
<move file="${deploy.dir}/${output}.zip" tofile="${deploy.dir}/${output}.zip.${timestamp}" failonerror="false" verbose="true" />
|
<property name="jarname" value="${modname}-client-${version}" />
|
||||||
<copy file="${basedir}/${output}.zip" todir="${deploy.dir}" verbose="true" />
|
<move file="${deploy.dir}/${jarname}.zip" tofile="${deploy.dir}/${jarname}.zip.${timestamp}" failonerror="false" verbose="true" />
|
||||||
|
<copy file="${basedir}/${jarname}.zip" todir="${deploy.dir}" verbose="true" />
|
||||||
</target>
|
</target>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -3,13 +3,16 @@ package net.minecraft.src;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import cpw.mods.ironchest.BlockIronChest;
|
import cpw.mods.ironchest.BlockIronChest;
|
||||||
|
import cpw.mods.ironchest.IronChestType;
|
||||||
|
import cpw.mods.ironchest.ItemIronChest;
|
||||||
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;
|
||||||
|
|
||||||
public class mod_IronChest extends BaseModMp {
|
public class mod_IronChest extends BaseModMp {
|
||||||
|
|
||||||
public static BlockIronChest ironChestBlock;
|
public static BlockIronChest ironChestBlock;
|
||||||
|
public static boolean compatibilityMode;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
|
@ -18,10 +21,17 @@ public class mod_IronChest extends BaseModMp {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
Configuration cfg=new Configuration(new File(Minecraft.getMinecraftDir(),"config/IronChest.cfg"));
|
File cfgFile = new File(Minecraft.getMinecraftDir(), "config/IronChest.cfg");
|
||||||
|
// If our config file exists
|
||||||
|
boolean defaultCompatibility = cfgFile.exists();
|
||||||
|
Configuration cfg = new Configuration(cfgFile);
|
||||||
try {
|
try {
|
||||||
cfg.load();
|
cfg.load();
|
||||||
ironChestBlock=new BlockIronChest(Integer.parseInt(cfg.getOrCreateBlockIdProperty("blockVeryLargeChest", 181).value));
|
// But doesn't have the compatibilityMode flag, enable compatibility
|
||||||
|
// mode
|
||||||
|
compatibilityMode = Boolean.parseBoolean(cfg.getOrCreateBooleanProperty("compatibilityMode", Configuration.GENERAL_PROPERTY,
|
||||||
|
defaultCompatibility).value);
|
||||||
|
ironChestBlock = new BlockIronChest(Integer.parseInt(cfg.getOrCreateBlockIdProperty("blockVeryLargeChest", 181).value));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ModLoader.getLogger().severe("IronChest was unable to load it's configuration successfully");
|
ModLoader.getLogger().severe("IronChest was unable to load it's configuration successfully");
|
||||||
e.printStackTrace(System.err);
|
e.printStackTrace(System.err);
|
||||||
|
@ -29,6 +39,12 @@ public class mod_IronChest extends BaseModMp {
|
||||||
} finally {
|
} finally {
|
||||||
cfg.save();
|
cfg.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ModLoader.RegisterBlock(ironChestBlock, ItemIronChest.class);
|
||||||
|
IronChestType.registerTileEntities();
|
||||||
|
IronChestType.registerRecipes(ironChestBlock);
|
||||||
|
|
||||||
|
MinecraftForgeClient.preloadTexture("ic2/sprites/ironchest_block_tex.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileEntity getBlockEntity(int metadata) {
|
public TileEntity getBlockEntity(int metadata) {
|
||||||
return TileEntityIronChest.makeEntity(metadata);
|
return IronChestType.makeEntity(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBlockTexture(IBlockAccess worldAccess, int i, int j, int k, int l) {
|
public int getBlockTexture(IBlockAccess worldAccess, int i, int j, int k, int l) {
|
||||||
|
@ -36,34 +36,38 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider {
|
||||||
if (te != null && te instanceof TileEntityIronChest) {
|
if (te != null && te instanceof TileEntityIronChest) {
|
||||||
TileEntityIronChest icte=(TileEntityIronChest) te;
|
TileEntityIronChest icte=(TileEntityIronChest) te;
|
||||||
if (l==0 || l==1) { // Top and Bottom
|
if (l==0 || l==1) { // Top and Bottom
|
||||||
return icte.getType().getTextureRow()*16;
|
|
||||||
} else if (l==getTextureFace(icte.getFacing())) { // Front
|
|
||||||
return icte.getType().getTextureRow()*16+1;
|
return icte.getType().getTextureRow()*16+1;
|
||||||
} else { // Back and Sides
|
} else if (l==icte.getFacing()) { // Front
|
||||||
return icte.getType().getTextureRow()*16+2;
|
return icte.getType().getTextureRow()*16+2;
|
||||||
|
} else { // Back and Sides
|
||||||
|
return icte.getType().getTextureRow()*16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte getTextureFace(byte facing) {
|
@Override
|
||||||
switch (facing) {
|
public int getBlockTextureFromSideAndMetadata(int i, int j) {
|
||||||
|
IronChestType typ=IronChestType.values()[j];
|
||||||
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
return 3;
|
|
||||||
case 1:
|
case 1:
|
||||||
return 4;
|
return typ.getTextureRow()*16+1;
|
||||||
case 2:
|
case 2:
|
||||||
return 2;
|
return typ.getTextureRow()*16+2;
|
||||||
case 3:
|
|
||||||
return 5;
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return typ.getTextureRow()*16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockAdded(World world, int i, int j, int k) {
|
||||||
|
super.onBlockAdded(world, i, j, k);
|
||||||
|
world.markBlockNeedsUpdate(i, j, k);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving) {
|
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving) {
|
||||||
super.onBlockPlacedBy(world, i, j, k, entityliving);
|
|
||||||
byte chestFacing = 0;
|
byte chestFacing = 0;
|
||||||
int facing = MathHelper.floor_double((double) ((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
|
int facing = MathHelper.floor_double((double) ((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
|
||||||
if (facing == 0) {
|
if (facing == 0) {
|
||||||
|
@ -78,9 +82,11 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider {
|
||||||
if (facing == 3) {
|
if (facing == 3) {
|
||||||
chestFacing = 4;
|
chestFacing = 4;
|
||||||
}
|
}
|
||||||
|
System.out.printf("Facing %d %d\n", facing,chestFacing);
|
||||||
TileEntity te = world.getBlockTileEntity(i, j, k);
|
TileEntity te = world.getBlockTileEntity(i, j, k);
|
||||||
if (te != null && te instanceof TileEntityIronChest) {
|
if (te != null && te instanceof TileEntityIronChest) {
|
||||||
((TileEntityIronChest) te).setFacing(chestFacing);
|
((TileEntityIronChest) te).setFacing(chestFacing);
|
||||||
|
world.markBlockNeedsUpdate(i, j, k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
package cpw.mods.ironchest;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import net.minecraft.src.Block;
|
||||||
|
import net.minecraft.src.Item;
|
||||||
|
import net.minecraft.src.ItemStack;
|
||||||
|
import net.minecraft.src.ModLoader;
|
||||||
|
import net.minecraft.src.TileEntity;
|
||||||
|
import net.minecraft.src.mod_IronChest;
|
||||||
|
|
||||||
|
public enum IronChestType {
|
||||||
|
IRON(54, "IronChest", "ironchest.png", 0, Item.ingotIron, TileEntityIronChest.class, "mmmmPmmmm"),
|
||||||
|
GOLD(81, "GoldChest", "goldchest.png", 1, Item.ingotGold, TileEntityGoldChest.class, "mmmmPmmmm");
|
||||||
|
// DIAMOND(108,"DiamondChest","diamondchest.png",2);
|
||||||
|
int size;
|
||||||
|
String friendlyName;
|
||||||
|
private String modelTexture;
|
||||||
|
private int textureRow;
|
||||||
|
private Class<? extends TileEntityIronChest> clazz;
|
||||||
|
private Item mat;
|
||||||
|
private String[] recipes;
|
||||||
|
|
||||||
|
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.textureRow = textureRow;
|
||||||
|
this.clazz = clazz;
|
||||||
|
this.mat = mat;
|
||||||
|
this.recipes=recipes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModelTexture() {
|
||||||
|
return modelTexture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTextureRow() {
|
||||||
|
return textureRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TileEntity makeEntity(int metadata) {
|
||||||
|
//Compatibility
|
||||||
|
int chesttype=metadata;
|
||||||
|
int facing=0;
|
||||||
|
|
||||||
|
if (metadata>2) {
|
||||||
|
chesttype=metadata<<2;
|
||||||
|
facing=metadata&3;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
TileEntityIronChest te=values()[chesttype].clazz.newInstance();
|
||||||
|
if (mod_IronChest.compatibilityMode) {
|
||||||
|
te.setFacing((byte)facing);
|
||||||
|
}
|
||||||
|
return te;
|
||||||
|
} catch (InstantiationException e) {
|
||||||
|
// unpossible
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
// unpossible
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void registerTileEntities() {
|
||||||
|
for (IronChestType typ : values()) {
|
||||||
|
System.out.printf("Registering %s\n",typ.friendlyName);
|
||||||
|
ModLoader.RegisterTileEntity(typ.clazz, 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);
|
||||||
|
}
|
||||||
|
previous=new ItemStack(blockResult,typ.ordinal());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static void addRecipe(ItemStack is, Object... parts) {
|
||||||
|
System.out.printf("Recipe : %s\n",Arrays.asList(parts));
|
||||||
|
ModLoader.AddRecipe(is, parts);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package cpw.mods.ironchest;
|
||||||
|
|
||||||
|
import net.minecraft.src.ItemBlock;
|
||||||
|
import net.minecraft.src.ItemStack;
|
||||||
|
|
||||||
|
public class ItemIronChest extends ItemBlock {
|
||||||
|
|
||||||
|
public ItemIronChest(int id) {
|
||||||
|
super(id);
|
||||||
|
setMaxDamage(0);
|
||||||
|
setHasSubtypes(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetadata(int i) {
|
||||||
|
if (i<=IronChestType.values().length) {
|
||||||
|
return i;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getItemNameIS(ItemStack itemstack) {
|
||||||
|
return IronChestType.values()[itemstack.getItemDamage()].friendlyName;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package cpw.mods.ironchest;
|
||||||
|
|
||||||
|
public class TileEntityGoldChest extends TileEntityIronChest {
|
||||||
|
|
||||||
|
public TileEntityGoldChest() {
|
||||||
|
super(IronChestType.GOLD);
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,41 +8,21 @@ import net.minecraft.src.NBTTagList;
|
||||||
import net.minecraft.src.TileEntity;
|
import net.minecraft.src.TileEntity;
|
||||||
|
|
||||||
public class TileEntityIronChest extends TileEntity implements IInventory {
|
public class TileEntityIronChest extends TileEntity implements IInventory {
|
||||||
public enum Type {
|
|
||||||
IRON(54,"IronChest","ironchest.png",0),
|
|
||||||
GOLD(81,"GoldChest","goldchest.png",1),
|
|
||||||
DIAMOND(108,"DiamondChest","diamondchest.png",2);
|
|
||||||
private int size;
|
|
||||||
private String friendlyName;
|
|
||||||
private String modelTexture;
|
|
||||||
private int textureRow;
|
|
||||||
|
|
||||||
Type(int size, String friendlyName, String modelTexture, int textureRow) {
|
|
||||||
this.size=size;
|
|
||||||
this.friendlyName=friendlyName;
|
|
||||||
this.modelTexture=modelTexture;
|
|
||||||
this.textureRow=textureRow;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getModelTexture() {
|
|
||||||
return modelTexture;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTextureRow() {
|
|
||||||
return textureRow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private int ticksSinceSync;
|
private int ticksSinceSync;
|
||||||
public float prevLidAngle;
|
public float prevLidAngle;
|
||||||
public float lidAngle;
|
public float lidAngle;
|
||||||
private int numUsingPlayers;
|
private int numUsingPlayers;
|
||||||
private Type type;
|
private IronChestType type;
|
||||||
public ItemStack[] chestContents;
|
public ItemStack[] chestContents;
|
||||||
private byte facing;
|
private byte facing;
|
||||||
|
|
||||||
public TileEntityIronChest(Type type, byte facing) {
|
public TileEntityIronChest() {
|
||||||
|
this(IronChestType.IRON);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TileEntityIronChest(IronChestType type) {
|
||||||
|
super();
|
||||||
this.type=type;
|
this.type=type;
|
||||||
this.facing=facing;
|
|
||||||
this.chestContents=new ItemStack[getSizeInventory()];
|
this.chestContents=new ItemStack[getSizeInventory()];
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,25 +38,47 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
|
||||||
return type.friendlyName;
|
return type.friendlyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getType() {
|
public IronChestType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStackInSlot(int i) {
|
public ItemStack getStackInSlot(int i) {
|
||||||
// TODO Auto-generated method stub
|
return chestContents[i];
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack decrStackSize(int i, int j) {
|
public ItemStack decrStackSize(int i, int j) {
|
||||||
// TODO Auto-generated method stub
|
if (chestContents[i] != null)
|
||||||
return null;
|
{
|
||||||
|
if (chestContents[i].stackSize <= j)
|
||||||
|
{
|
||||||
|
ItemStack itemstack = chestContents[i];
|
||||||
|
chestContents[i] = null;
|
||||||
|
onInventoryChanged();
|
||||||
|
return itemstack;
|
||||||
|
}
|
||||||
|
ItemStack itemstack1 = chestContents[i].splitStack(j);
|
||||||
|
if (chestContents[i].stackSize == 0)
|
||||||
|
{
|
||||||
|
chestContents[i] = null;
|
||||||
|
}
|
||||||
|
onInventoryChanged();
|
||||||
|
return itemstack1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||||
// TODO Auto-generated method stub
|
chestContents[i] = itemstack;
|
||||||
|
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit())
|
||||||
|
{
|
||||||
|
itemstack.stackSize = getInventoryStackLimit();
|
||||||
|
}
|
||||||
|
onInventoryChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -94,6 +96,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
|
||||||
chestContents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
|
chestContents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
facing=nbttagcompound.getByte("facing");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -113,6 +116,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
|
||||||
}
|
}
|
||||||
|
|
||||||
nbttagcompound.setTag("Items", nbttaglist);
|
nbttagcompound.setTag("Items", nbttaglist);
|
||||||
|
nbttagcompound.setByte("facing", facing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -170,6 +174,8 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
|
||||||
if (i == 1)
|
if (i == 1)
|
||||||
{
|
{
|
||||||
numUsingPlayers = j;
|
numUsingPlayers = j;
|
||||||
|
} else if (i == 2) {
|
||||||
|
facing = (byte)j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,19 +191,11 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
|
||||||
worldObj.playNoteAt(xCoord, yCoord, zCoord, 1, numUsingPlayers);
|
worldObj.playNoteAt(xCoord, yCoord, zCoord, 1, numUsingPlayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static TileEntity makeEntity(int metadata) {
|
|
||||||
//Compatibility
|
|
||||||
int chesttype=metadata;
|
|
||||||
int facing=0;
|
|
||||||
|
|
||||||
if (metadata>2) {
|
|
||||||
chesttype=metadata<<2;
|
|
||||||
facing=metadata&3;
|
|
||||||
}
|
|
||||||
return new TileEntityIronChest(Type.values()[chesttype],(byte)facing);
|
|
||||||
}
|
|
||||||
public void setFacing(byte chestFacing) {
|
public void setFacing(byte chestFacing) {
|
||||||
this.facing=chestFacing;
|
this.facing=chestFacing;
|
||||||
|
if (worldObj!=null) {
|
||||||
|
worldObj.playNoteAt(xCoord, yCoord, zCoord, 2, facing);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
Binary file not shown.
Loading…
Reference in New Issue