Initial checkin. Build script works nicely. Some basic code in place.

This commit is contained in:
Christian Weeks 2012-01-26 17:37:39 -05:00
commit c640fd5e63
9 changed files with 546 additions and 0 deletions

9
IronChests2/.classpath Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="client"/>
<classpathentry kind="src" path="common"/>
<classpathentry kind="src" path="server"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry combineaccessrules="false" kind="src" path="/minecraft1.1-client"/>
<classpathentry kind="output" path="bin"/>
</classpath>

2
IronChests2/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/mod_ironchests-client-2.0.zip
/mod_ironchests-server-2.0.zip

17
IronChests2/.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>IronChests2</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,12 @@
#Wed Jan 25 17:13:27 EST 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

121
IronChests2/build.xml Normal file
View File

@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- ======================================================================
mod_IronChest
Bigger chests
cpw
====================================================================== -->
<project name="mod_IronChests" default="build">
<description>
Iron Chests
</description>
<property name="modname" value="mod_ironchests" />
<property name="version" value="2.0" />
<property name="mcp.home" location="/home/cpw/minecraft1dev/forge1.31" />
<property name="mcp.obfoutput" location="${mcp.home}/reobf" />
<property name="client.mcp.obfoutput" location="${mcp.obfoutput}/minecraft" />
<property name="server.mcp.obfoutput" location="${mcp.obfoutput}/minecraft_server" />
<property name="mcp.srcdir" location="${mcp.home}/src" />
<property name="client.mcp.srcdir" location="${mcp.srcdir}/minecraft" />
<property name="server.mcp.srcdir" location="${mcp.srcdir}/minecraft_server" />
<property name="deploy.dir" location="${user.home}/.minecraft/mods" />
<property name="common.src.dir" location="${basedir}/common" />
<property name="client.src.dir" location="${basedir}/client" />
<property name="server.src.dir" location="${basedir}/server" />
<property name="resource.dir" location="${basedir}/resources" />
<macrodef name="side">
<attribute name="prop"/>
<attribute name="src"/>
<attribute name="side"/>
<sequential>
<property name="@{prop}" value="${@{side}.@{src}}"/>
</sequential>
</macrodef>
<target name="init">
<tstamp>
<format pattern="yyMMddHHmmss" property="timestamp" />
</tstamp>
</target>
<target name="clean">
<antcall target="clean-source">
<param name="side" value="client" />
</antcall>
<antcall target="clean-source">
<param name="side" value="server" />
</antcall>
<exec executable="${mcp.home}/updatemd5.sh" dir="${mcp.home}" />
</target>
<target name="build-client" depends="init,clean,merge-client,buildandreobfmcp">
<antcall target="extract-built-jar">
<param name="side" value="client" />
</antcall>
</target>
<target name="build-server" depends="init,clean,merge-server,buildandreobfmcp">
<antcall target="extract-built-jar">
<param name="side" value="server" />
</antcall>
</target>
<target name="extract-built-jar">
<side prop="output" src="mcp.obfoutput" side="${side}"/>
<property name="jarname" value="${modname}-${side}-${version}" />
<jar destfile="${basedir}/${jarname}.zip">
<fileset dir="${output}" includes="**/*.class" />
<fileset dir="${resource.dir}" />
</jar>
</target>
<target name="build" depends="merge-client,merge-server,build-client,build-server" />
<!-- antcall target to merge source to a side -->
<target name="clean-source">
<side prop="delete-targ" src="mcp.srcdir" side="${side}"/>
<side prop="side-from" src="src.dir" side="${side}"/>
<delete verbose="true">
<fileset dir="${delete-targ}">
<present present="both" targetdir="${side-from}" />
</fileset>
<fileset dir="${delete-targ}">
<present present="both" targetdir="${common.src.dir}" />
</fileset>
</delete>
</target>
<target name="merge-source">
<side prop="merge-to" src="mcp.srcdir" side="${side}"/>
<side prop="side-from" src="src.dir" side="${side}"/>
<copy todir="${merge-to}" overwrite="true" verbose="true">
<fileset dir="${side-from}" includes="**/*.java" />
<fileset dir="${common.src.dir}" includes="**/*.java" />
</copy>
</target>
<target name="merge-client" depends="init,clean">
<antcall target="merge-source">
<param name="side" value="client" />
</antcall>
</target>
<target name="merge-server" depends="init,clean">
<antcall target="merge-source">
<param name="side" value="server" />
</antcall>
</target>
<target name="buildandreobfmcp" depends="init">
<exec executable="${mcp.home}/recompile.sh" dir="${mcp.home}" />
<exec executable="${mcp.home}/reobfuscate.sh" dir="${mcp.home}" />
</target>
<target name="deploy" depends="init,build">
<move file="${deploy.dir}/${output}.zip" tofile="${deploy.dir}/${output}.zip.${timestamp}" failonerror="false" verbose="true" />
<copy file="${basedir}/${output}.zip" todir="${deploy.dir}" verbose="true" />
</target>
</project>

View File

@ -0,0 +1,62 @@
package cpw.mods.ironchest.client;
import org.lwjgl.opengl.GL11;
import cpw.mods.ironchest.TileEntityIronChest;
import net.minecraft.src.ModelChest;
import net.minecraft.src.TileEntity;
import net.minecraft.src.TileEntitySpecialRenderer;
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
public TileEntityIronChestRenderer() {
model = new ModelChest();
}
public void render(TileEntityIronChest tile, double d, double d1, double d2, float f) {
int facing = 3;
int metatype = 0;
if (tile != null && tile.worldObj != null) {
metatype = tile.getBlockMetadata();
facing = tile.getFacing();
}
bindTextureByName(tile.getType().getModelTexture());
GL11.glPushMatrix();
GL11.glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glTranslatef((float) d, (float) d1 + 1.0F, (float) d2 + 1.0F);
GL11.glScalef(1.0F, -1F, -1F);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
int k = 0;
if (facing == 2) {
k = 180;
}
if (facing == 3) {
k = 0;
}
if (facing == 4) {
k = 90;
}
if (facing == 5) {
k = -90;
}
GL11.glRotatef(k, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
float f1 = tile.prevLidAngle + (tile.lidAngle - tile.prevLidAngle) * f;
f1 = 1.0F - f1;
f1 = 1.0F - f1 * f1 * f1;
model.chestLid.rotateAngleX = -((f1 * 3.141593F) / 2.0F);
model.func_35402_a();
GL11.glDisable(32826 /* GL_RESCALE_NORMAL_EXT */);
GL11.glPopMatrix();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2, float f) {
render((TileEntityIronChest) tileentity, d, d1, d2, f);
}
private ModelChest model;
}

View File

@ -0,0 +1,34 @@
package net.minecraft.src;
import java.io.File;
import cpw.mods.ironchest.BlockIronChest;
import net.minecraft.client.Minecraft;
import net.minecraft.src.forge.Configuration;
public class mod_IronChest extends BaseModMp {
public static BlockIronChest ironChestBlock;
@Override
public String getVersion() {
return "2.0";
}
@Override
public void load() {
Configuration cfg=new Configuration(new File(Minecraft.getMinecraftDir(),"config/IronChest.cfg"));
try {
cfg.load();
ironChestBlock=new BlockIronChest(Integer.parseInt(cfg.getOrCreateBlockIdProperty("blockVeryLargeChest", 181).value));
} catch (Exception e) {
ModLoader.getLogger().severe("IronChest was unable to load it's configuration successfully");
e.printStackTrace(System.err);
throw new RuntimeException(e);
} finally {
cfg.save();
}
}
}

View File

@ -0,0 +1,86 @@
package cpw.mods.ironchest;
import net.minecraft.src.BlockContainer;
import net.minecraft.src.EntityLiving;
import net.minecraft.src.IBlockAccess;
import net.minecraft.src.Material;
import net.minecraft.src.MathHelper;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import net.minecraft.src.forge.ITextureProvider;
public class BlockIronChest extends BlockContainer implements ITextureProvider {
public BlockIronChest(int id) {
super(id, Material.iron);
setHardness(3.0F);
}
@Override
public TileEntity getBlockEntity() {
return null;
}
@Override
public String getTextureFile() {
return "ic2/sprites/ironchest_block_tex.png";
}
@Override
public TileEntity getBlockEntity(int metadata) {
return TileEntityIronChest.makeEntity(metadata);
}
public int getBlockTexture(IBlockAccess worldAccess, int i, int j, int k, int l) {
TileEntity te = worldAccess.getBlockTileEntity(i, j, k);
if (te != null && te instanceof TileEntityIronChest) {
TileEntityIronChest icte=(TileEntityIronChest) te;
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;
} else { // Back and Sides
return icte.getType().getTextureRow()*16+2;
}
}
return 0;
}
public byte getTextureFace(byte facing) {
switch (facing) {
case 0:
return 3;
case 1:
return 4;
case 2:
return 2;
case 3:
return 5;
default:
return 0;
}
}
@Override
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving) {
super.onBlockPlacedBy(world, i, j, k, entityliving);
byte chestFacing = 0;
int facing = MathHelper.floor_double((double) ((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
if (facing == 0) {
chestFacing = 2;
}
if (facing == 1) {
chestFacing = 5;
}
if (facing == 2) {
chestFacing = 3;
}
if (facing == 3) {
chestFacing = 4;
}
TileEntity te = world.getBlockTileEntity(i, j, k);
if (te != null && te instanceof TileEntityIronChest) {
((TileEntityIronChest) te).setFacing(chestFacing);
}
}
}

View File

@ -0,0 +1,203 @@
package cpw.mods.ironchest;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IInventory;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.NBTTagList;
import net.minecraft.src.TileEntity;
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;
public float prevLidAngle;
public float lidAngle;
private int numUsingPlayers;
private Type type;
public ItemStack[] chestContents;
private byte facing;
public TileEntityIronChest(Type type, byte facing) {
this.type=type;
this.facing=facing;
this.chestContents=new ItemStack[getSizeInventory()];
}
@Override
public int getSizeInventory() {
return type.size;
}
public byte getFacing() {
return this.facing;
}
@Override
public String getInvName() {
return type.friendlyName;
}
public Type getType() {
return type;
}
@Override
public ItemStack getStackInSlot(int i) {
// TODO Auto-generated method stub
return null;
}
@Override
public ItemStack decrStackSize(int i, int j) {
// TODO Auto-generated method stub
return null;
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack) {
// TODO Auto-generated method stub
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound)
{
super.readFromNBT(nbttagcompound);
NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
chestContents = new ItemStack[getSizeInventory()];
for (int i = 0; i < nbttaglist.tagCount(); i++)
{
NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
int j = nbttagcompound1.getByte("Slot") & 0xff;
if (j >= 0 && j < chestContents.length)
{
chestContents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
}
}
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound)
{
super.writeToNBT(nbttagcompound);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < chestContents.length; i++)
{
if (chestContents[i] != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte)i);
chestContents[i].writeToNBT(nbttagcompound1);
nbttaglist.setTag(nbttagcompound1);
}
}
nbttagcompound.setTag("Items", nbttaglist);
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
if (worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this) {
return false;
}
return entityplayer.getDistanceSq((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D;
}
@Override
public void updateEntity() {
super.updateEntity();
// Resynchronize clients with the server state
if ((++ticksSinceSync % 20) * 4 == 0) {
worldObj.playNoteAt(xCoord, yCoord, zCoord, 1, numUsingPlayers);
}
prevLidAngle = lidAngle;
float f = 0.1F;
if (numUsingPlayers > 0 && lidAngle == 0.0F) {
double d = (double) xCoord + 0.5D;
double d1 = (double) zCoord + 0.5D;
worldObj.playSoundEffect(d, (double) yCoord + 0.5D, d1, "random.chestopen", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
}
if (numUsingPlayers == 0 && lidAngle > 0.0F || numUsingPlayers > 0 && lidAngle < 1.0F) {
float f1 = lidAngle;
if (numUsingPlayers > 0) {
lidAngle += f;
} else {
lidAngle -= f;
}
if (lidAngle > 1.0F) {
lidAngle = 1.0F;
}
float f2 = 0.5F;
if (lidAngle < f2 && f1 >= f2) {
double d2 = (double) xCoord + 0.5D;
double d3 = (double) zCoord + 0.5D;
worldObj.playSoundEffect(d2, (double) yCoord + 0.5D, d3, "random.chestclosed", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
}
if (lidAngle < 0.0F) {
lidAngle = 0.0F;
}
}
}
@Override
public void onTileEntityPowered(int i, int j)
{
if (i == 1)
{
numUsingPlayers = j;
}
}
@Override
public void openChest() {
numUsingPlayers++;
worldObj.playNoteAt(xCoord, yCoord, zCoord, 1, numUsingPlayers);
}
@Override
public void closeChest() {
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) {
this.facing=chestFacing;
}
}