Fix #72, Chests now work while as a spectator.
This commit is contained in:
parent
5d607a0d15
commit
bb8cb4ff98
|
@ -33,7 +33,7 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
deobfCompile "mezz.jei:jei_1.9.4:3.4.0.202"
|
deobfCompile "mezz.jei:jei_1.9.4:3.5.0.209"
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is our group. I'm cpw.mods
|
// This is our group. I'm cpw.mods
|
||||||
|
@ -43,8 +43,8 @@ archivesBaseName = "ironchest"
|
||||||
|
|
||||||
// Setup the forge minecraft plugin data. Specify the preferred forge/minecraft version here
|
// Setup the forge minecraft plugin data. Specify the preferred forge/minecraft version here
|
||||||
minecraft {
|
minecraft {
|
||||||
version = "1.9.4-12.17.0.1909-1.9.4"
|
version = "1.9.4-12.17.0.1954"
|
||||||
mappings = "snapshot_20160519"
|
mappings = "snapshot_20160607"
|
||||||
runDir = "run"
|
runDir = "run"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A marker for containers that have a chest-like persistant storage component. Enables the Inventroy Tweaks sorting buttons for this container.
|
* A marker for containers that have a chest-like persistent storage component. Enables the Inventory Tweaks sorting buttons for this container.
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
|
@ -26,7 +26,7 @@ public @interface ChestContainer
|
||||||
// Signature int func()
|
// Signature int func()
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
public @interface RowSizeCallback
|
@interface RowSizeCallback
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ public @interface ChestContainer
|
||||||
// Signature int func()
|
// Signature int func()
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
public @interface IsLargeCallback
|
@interface IsLargeCallback
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -28,15 +28,15 @@ import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||||
public enum IronChestType implements IStringSerializable
|
public enum IronChestType implements IStringSerializable
|
||||||
{
|
{
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
IRON(54, 9, true, "ironchest.png", Arrays.asList("ingotIron", "ingotRefinedIron"), TileEntityIronChest.class, "mmmmPmmmm", "mGmG3GmGm"),
|
IRON(54, 9, true, "ironchest.png", Arrays.asList("ingotIron", "ingotRefinedIron"), TileEntityIronChest.class, 184, 202, "mmmmPmmmm", "mGmG3GmGm"),
|
||||||
GOLD(81, 9, true, "goldchest.png", Collections.singleton("ingotGold"), TileEntityGoldChest.class, "mmmmPmmmm", "mGmG4GmGm"),
|
GOLD(81, 9, true, "goldchest.png", Collections.singleton("ingotGold"), TileEntityGoldChest.class, 184, 256, "mmmmPmmmm", "mGmG4GmGm"),
|
||||||
DIAMOND(108, 12, true, "diamondchest.png", Collections.singleton("gemDiamond"), TileEntityDiamondChest.class, "GGGmPmGGG", "GGGG4Gmmm"),
|
DIAMOND(108, 12, true, "diamondchest.png", Collections.singleton("gemDiamond"), TileEntityDiamondChest.class, 184, 256, "GGGmPmGGG", "GGGG4Gmmm"),
|
||||||
COPPER(45, 9, false, "copperchest.png", Collections.singleton("ingotCopper"), TileEntityCopperChest.class, "mmmmCmmmm"),
|
COPPER(45, 9, false, "copperchest.png", Collections.singleton("ingotCopper"), TileEntityCopperChest.class, 184, 184, "mmmmCmmmm"),
|
||||||
SILVER(72, 9, false, "silverchest.png", Collections.singleton("ingotSilver"), TileEntitySilverChest.class, "mmmm3mmmm", "mGmG0GmGm"),
|
SILVER(72, 9, false, "silverchest.png", Collections.singleton("ingotSilver"), TileEntitySilverChest.class, 184, 238, "mmmm3mmmm", "mGmG0GmGm"),
|
||||||
CRYSTAL(108, 12, true, "crystalchest.png", Collections.singleton("blockGlass"), TileEntityCrystalChest.class, "GGGGPGGGG"),
|
CRYSTAL(108, 12, true, "crystalchest.png", Collections.singleton("blockGlass"), TileEntityCrystalChest.class, 238, 256, "GGGGPGGGG"),
|
||||||
OBSIDIAN(108, 12, false, "obsidianchest.png", Collections.singleton("obsidian"), TileEntityObsidianChest.class, "mmmm2mmmm"),
|
OBSIDIAN(108, 12, false, "obsidianchest.png", Collections.singleton("obsidian"), TileEntityObsidianChest.class, 238, 256, "mmmm2mmmm"),
|
||||||
DIRTCHEST9000(1, 1, false, "dirtchest.png", Collections.singleton("dirt"), TileEntityDirtChest.class, "mmmmCmmmm"),
|
DIRTCHEST9000(1, 1, false, "dirtchest.png", Collections.singleton("dirt"), TileEntityDirtChest.class, 184, 184, "mmmmCmmmm"),
|
||||||
WOOD(0, 0, false, "", Collections.singleton("plankWood"), null);
|
WOOD(0, 0, false, "", Collections.singleton("plankWood"), null, 0, 0);
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
|
|
||||||
public static final IronChestType VALUES[] = values();
|
public static final IronChestType VALUES[] = values();
|
||||||
|
@ -50,9 +50,11 @@ public enum IronChestType implements IStringSerializable
|
||||||
public final Class<? extends TileEntityIronChest> clazz;
|
public final Class<? extends TileEntityIronChest> clazz;
|
||||||
public final Collection<String> recipes;
|
public final Collection<String> recipes;
|
||||||
public final Collection<String> matList;
|
public final Collection<String> matList;
|
||||||
|
public final int xSize;
|
||||||
|
public final int ySize;
|
||||||
|
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
IronChestType(int size, int rowLength, boolean tieredChest, String modelTexture, Collection<String> mats, Class<? extends TileEntityIronChest> clazz, String... recipes)
|
IronChestType(int size, int rowLength, boolean tieredChest, String modelTexture, Collection<String> mats, Class<? extends TileEntityIronChest> clazz, int xSize, int ySize, String... recipes)
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
{
|
{
|
||||||
this.name = this.name().toLowerCase();
|
this.name = this.name().toLowerCase();
|
||||||
|
@ -63,6 +65,8 @@ public enum IronChestType implements IStringSerializable
|
||||||
this.matList = Collections.unmodifiableCollection(mats);
|
this.matList = Collections.unmodifiableCollection(mats);
|
||||||
this.clazz = clazz;
|
this.clazz = clazz;
|
||||||
this.recipes = Collections.unmodifiableCollection(Arrays.asList(recipes));
|
this.recipes = Collections.unmodifiableCollection(Arrays.asList(recipes));
|
||||||
|
this.xSize = xSize;
|
||||||
|
this.ySize = ySize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBreakTexture()
|
public String getBreakTexture()
|
||||||
|
|
|
@ -46,6 +46,7 @@ public class TileEntityIronChest extends TileEntityLockable implements ITickable
|
||||||
private boolean inventoryTouched;
|
private boolean inventoryTouched;
|
||||||
private boolean hadStuff;
|
private boolean hadStuff;
|
||||||
private String customName;
|
private String customName;
|
||||||
|
private IronChestType chestType;
|
||||||
|
|
||||||
public TileEntityIronChest()
|
public TileEntityIronChest()
|
||||||
{
|
{
|
||||||
|
@ -55,6 +56,7 @@ public class TileEntityIronChest extends TileEntityLockable implements ITickable
|
||||||
protected TileEntityIronChest(IronChestType type)
|
protected TileEntityIronChest(IronChestType type)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
this.chestType = type;
|
||||||
this.chestContents = new ItemStack[type.size];
|
this.chestContents = new ItemStack[type.size];
|
||||||
this.topStacks = new ItemStack[8];
|
this.topStacks = new ItemStack[8];
|
||||||
this.facing = EnumFacing.NORTH;
|
this.facing = EnumFacing.NORTH;
|
||||||
|
@ -477,19 +479,29 @@ public class TileEntityIronChest extends TileEntityLockable implements ITickable
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void openInventory(EntityPlayer player)
|
public void openInventory(EntityPlayer player)
|
||||||
|
{
|
||||||
|
if (!player.isSpectator())
|
||||||
{
|
{
|
||||||
if (this.worldObj == null)
|
if (this.worldObj == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.numPlayersUsing < 0)
|
||||||
|
{
|
||||||
|
this.numPlayersUsing = 0;
|
||||||
|
}
|
||||||
|
|
||||||
this.numPlayersUsing++;
|
this.numPlayersUsing++;
|
||||||
|
|
||||||
this.worldObj.addBlockEvent(this.pos, IronChest.ironChestBlock, 1, this.numPlayersUsing);
|
this.worldObj.addBlockEvent(this.pos, IronChest.ironChestBlock, 1, this.numPlayersUsing);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void closeInventory(EntityPlayer player)
|
public void closeInventory(EntityPlayer player)
|
||||||
|
{
|
||||||
|
if (!player.isSpectator())
|
||||||
{
|
{
|
||||||
if (this.worldObj == null)
|
if (this.worldObj == null)
|
||||||
{
|
{
|
||||||
|
@ -500,6 +512,7 @@ public class TileEntityIronChest extends TileEntityLockable implements ITickable
|
||||||
|
|
||||||
this.worldObj.addBlockEvent(this.pos, IronChest.ironChestBlock, 1, this.numPlayersUsing);
|
this.worldObj.addBlockEvent(this.pos, IronChest.ironChestBlock, 1, this.numPlayersUsing);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setFacing(EnumFacing facing)
|
public void setFacing(EnumFacing facing)
|
||||||
{
|
{
|
||||||
|
@ -674,7 +687,7 @@ public class TileEntityIronChest extends TileEntityLockable implements ITickable
|
||||||
@Override
|
@Override
|
||||||
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
|
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
|
||||||
{
|
{
|
||||||
return null;
|
return new ContainerIronChest(playerInventory, this, this.chestType, this.chestType.xSize, this.chestType.ySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -692,6 +705,6 @@ public class TileEntityIronChest extends TileEntityLockable implements ITickable
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound getUpdateTag()
|
public NBTTagCompound getUpdateTag()
|
||||||
{
|
{
|
||||||
return writeToNBT(new NBTTagCompound());
|
return this.writeToNBT(new NBTTagCompound());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue