Version 2.5 - fix IC display on SMP, fix crystal chests on SMP
This commit is contained in:
parent
5ec981acb8
commit
6d505961a3
|
@ -13,7 +13,7 @@
|
|||
</description>
|
||||
|
||||
<property name="modname" value="mod_ironchests" />
|
||||
<property name="version" value="2.4.1" />
|
||||
<property name="version" value="2.5" />
|
||||
<property name="mcp.home" location="/home/cpw/minecraft1dev/forge1.3.3.12" />
|
||||
<property name="mcp.obfoutput" location="${mcp.home}/reobf" />
|
||||
<property name="client.mcp.obfoutput" location="${mcp.obfoutput}/minecraft" />
|
||||
|
|
|
@ -11,6 +11,8 @@ import net.minecraft.src.GuiScreen;
|
|||
import net.minecraft.src.ModLoader;
|
||||
import net.minecraft.src.ModLoaderMp;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.Packet;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.forge.MinecraftForgeClient;
|
||||
import cpw.mods.ironchest.ChestChangerType;
|
||||
import cpw.mods.ironchest.IProxy;
|
||||
|
@ -21,8 +23,8 @@ public class ClientProxy extends BaseModMp implements IProxy {
|
|||
@Override
|
||||
public void registerRenderInformation() {
|
||||
ChestItemRenderHelper.instance=new IronChestRenderHelper();
|
||||
MinecraftForgeClient.preloadTexture("cpw/mods/ironchest/sprites/block_textures.png");
|
||||
MinecraftForgeClient.preloadTexture("cpw/mods/ironchest/sprites/item_textures.png");
|
||||
MinecraftForgeClient.preloadTexture("/cpw/mods/ironchest/sprites/block_textures.png");
|
||||
MinecraftForgeClient.preloadTexture("/cpw/mods/ironchest/sprites/item_textures.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,4 +86,29 @@ public class ClientProxy extends BaseModMp implements IProxy {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleTileEntityPacket(int x, int y, int z, int type, int[] intData, float[] floatData, String[] stringData) {
|
||||
TileEntity te=ModLoader.getMinecraftInstance().theWorld.getBlockTileEntity(x, y, z);
|
||||
if (te!=null && te instanceof TileEntityIronChest) {
|
||||
TileEntityIronChest icte=(TileEntityIronChest)te;
|
||||
icte.handlePacketData(type,intData,floatData,stringData);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket(TileEntityIronChest tile) {
|
||||
// NOOP on client
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTileEntityUpdate(TileEntityIronChest tile) {
|
||||
// NOOP on client
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRemote() {
|
||||
return ModLoader.getMinecraftInstance().theWorld.isRemote;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import net.minecraft.src.NBTTagCompound;
|
|||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.src.mod_IronChest;
|
||||
import net.minecraft.src.forge.IMultipassRender;
|
||||
import net.minecraft.src.forge.ITextureProvider;
|
||||
|
||||
public class BlockIronChest extends BlockContainer implements ITextureProvider {
|
||||
|
@ -182,9 +181,4 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public boolean canRenderInPass(int n) {
|
||||
return n==0;
|
||||
}*/
|
||||
}
|
|
@ -5,6 +5,7 @@ import java.io.File;
|
|||
import net.minecraft.src.EntityItem;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.Packet;
|
||||
|
||||
public interface IProxy {
|
||||
|
||||
|
@ -22,4 +23,11 @@ public interface IProxy {
|
|||
|
||||
public abstract void registerGUI(int guiId);
|
||||
|
||||
public abstract void handleTileEntityPacket(int x, int y, int z, int type, int[] intData, float[] floatData, String[] stringData);
|
||||
|
||||
public abstract Packet getDescriptionPacket(TileEntityIronChest tile);
|
||||
|
||||
public abstract void sendTileEntityUpdate(TileEntityIronChest tile);
|
||||
|
||||
public abstract boolean isRemote();
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import net.minecraft.src.Item;
|
|||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.src.mod_IronChest;
|
||||
import net.minecraft.src.forge.ITextureProvider;
|
||||
|
||||
public class ItemChestChanger extends Item implements ITextureProvider {
|
||||
|
@ -32,6 +33,7 @@ public class ItemChestChanger extends Item implements ITextureProvider {
|
|||
world.setBlockMetadataWithNotify(X, Y, Z, newchest.getType().ordinal());
|
||||
world.notifyBlocksOfNeighborChange(X, Y, Z, world.getBlockId(X, Y, Z));
|
||||
stack.stackSize=0;
|
||||
mod_IronChest.proxy.sendTileEntityUpdate(newchest);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.src.IInventory;
|
|||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.NBTTagList;
|
||||
import net.minecraft.src.Packet;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.mod_IronChest;
|
||||
|
||||
|
@ -21,6 +22,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
|
|||
private ItemStack[] topStacks;
|
||||
private byte facing;
|
||||
private boolean inventoryTouched;
|
||||
private boolean hadStuff;
|
||||
|
||||
public TileEntityIronChest() {
|
||||
this(IronChestType.IRON);
|
||||
|
@ -66,7 +68,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
|
|||
}
|
||||
|
||||
protected void sortTopStacks() {
|
||||
if (!type.isTransparent()) {
|
||||
if (!type.isTransparent() || mod_IronChest.proxy.isRemote()) {
|
||||
return;
|
||||
}
|
||||
ItemStack[] tempCopy=new ItemStack[getSizeInventory()];
|
||||
|
@ -85,12 +87,15 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
|
|||
hasStuff=true;
|
||||
}
|
||||
}
|
||||
if (!hasStuff) {
|
||||
if (!hasStuff && hadStuff) {
|
||||
hadStuff=false;
|
||||
for (int i=0; i<topStacks.length; i++) {
|
||||
topStacks[i]=null;
|
||||
}
|
||||
mod_IronChest.proxy.sendTileEntityUpdate(this);
|
||||
return;
|
||||
}
|
||||
hadStuff=true;
|
||||
Arrays.sort(tempCopy, new Comparator<ItemStack>() {
|
||||
@Override
|
||||
public int compare(ItemStack o1, ItemStack o2) {
|
||||
|
@ -115,7 +120,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
|
|||
for (int i=p; i<topStacks.length; i++) {
|
||||
topStacks[i]=null;
|
||||
}
|
||||
|
||||
mod_IronChest.proxy.sendTileEntityUpdate(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -293,6 +298,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
|
|||
BlockIronChest block=mod_IronChest.ironChestBlock;
|
||||
block.dropContent(newSize,this,this.worldObj);
|
||||
newEntity.setFacing(facing);
|
||||
newEntity.sortTopStacks();
|
||||
return newEntity;
|
||||
}
|
||||
|
||||
|
@ -309,4 +315,50 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
|
|||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Packet getDescriptionPacket() {
|
||||
return mod_IronChest.proxy.getDescriptionPacket(this);
|
||||
}
|
||||
|
||||
public void handlePacketData(int typeData, int[] intData, float[] floatData, String[] stringData) {
|
||||
TileEntityIronChest chest=this;
|
||||
if (this.type.ordinal()!=typeData) {
|
||||
chest=updateFromMetadata(typeData);
|
||||
}
|
||||
if (IronChestType.values()[typeData].isTransparent() && intData!=null) {
|
||||
int pos=0;
|
||||
if (intData.length<chest.topStacks.length*3) {
|
||||
return;
|
||||
}
|
||||
for (int i=0; i<chest.topStacks.length; i++) {
|
||||
if (intData[pos+2]!=0) {
|
||||
ItemStack is=new ItemStack(intData[pos],intData[pos+2],intData[pos+1]);
|
||||
chest.topStacks[i]=is;
|
||||
} else {
|
||||
chest.topStacks[i]=null;
|
||||
}
|
||||
pos+=3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int[] buildIntDataList() {
|
||||
if (type.isTransparent()) {
|
||||
int[] sortList=new int[topStacks.length*3];
|
||||
int pos=0;
|
||||
for (ItemStack is : topStacks) {
|
||||
if (is!=null) {
|
||||
sortList[pos++]=is.itemID;
|
||||
sortList[pos++]=is.getItemDamage();
|
||||
sortList[pos++]=is.stackSize;
|
||||
} else {
|
||||
sortList[pos++]=0;
|
||||
sortList[pos++]=0;
|
||||
sortList[pos++]=0;
|
||||
}
|
||||
}
|
||||
return sortList;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,12 +23,12 @@ public class mod_IronChest extends BaseModMp {
|
|||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return "2.4";
|
||||
return "2.5";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
MinecraftForge.versionDetect("IronChest", 1, 3, 0);
|
||||
MinecraftForge.versionDetect("IronChest", 1, 3, 3);
|
||||
proxy = ServerClientProxy.getProxy();
|
||||
File cfgFile = new File(proxy.getMinecraftDir(), "config/IronChest.cfg");
|
||||
Configuration cfg = new Configuration(cfgFile);
|
||||
|
@ -97,4 +97,8 @@ public class mod_IronChest extends BaseModMp {
|
|||
public static void openGUI(EntityPlayer player, TileEntityIronChest te) {
|
||||
proxy.showGUI(te,player);
|
||||
}
|
||||
|
||||
public void HandleTileEntityPacket(int x, int y, int z, int type, int[] intData, float[] floatData, String[] stringData) {
|
||||
proxy.handleTileEntityPacket(x,y,z,type,intData,floatData,stringData);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,13 @@ package cpw.mods.ironchest.server;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraft.src.BaseModMp;
|
||||
import net.minecraft.src.EntityItem;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.ModLoader;
|
||||
import net.minecraft.src.ModLoaderMp;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.Packet;
|
||||
import net.minecraft.src.mod_IronChest;
|
||||
import cpw.mods.ironchest.ContainerIronChestBase;
|
||||
import cpw.mods.ironchest.IProxy;
|
||||
|
@ -51,4 +54,24 @@ public class ServerProxy implements IProxy {
|
|||
// NOOP on server
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleTileEntityPacket(int x, int y, int z, int type, int[] intData, float[] floatData, String[] stringData) {
|
||||
// NOOP on server
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket(TileEntityIronChest tile) {
|
||||
return ModLoaderMp.GetTileEntityPacket(ModLoaderMp.GetModInstance(mod_IronChest.class), tile.xCoord, tile.yCoord, tile.zCoord, tile.getType().ordinal(), tile.buildIntDataList(),null,null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTileEntityUpdate(TileEntityIronChest tile) {
|
||||
ModLoaderMp.SendTileEntityPacket(tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRemote() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue