This commit is contained in:
Taylor Shuler 2014-08-01 11:13:29 +00:00
commit e467ac38e3
14 changed files with 515 additions and 592 deletions

11
.gitattributes vendored Normal file
View File

@ -0,0 +1,11 @@
# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto
# Explicitly declare text files we want to always be normalized and converted to native line endings on checkout.
*.md text
*.info text
*.txt text
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary

23
.gitignore vendored
View File

@ -1,14 +1,19 @@
build/
.classpath
.project
.gradle/
eclipse/
# Ignore Gradle cache files & directories
bin/
repo/
/run/
build/
## Eclipse
eclipse/
.classpath
.gradle/
.project
.settings/
#IDEA files from Gradle
.idea/
## Idea
.idea
/*.iml
/*.ipr
/*.iws
# Ignore OS cache files & directories
*.DS_Store
_MACOSX
Thumbs.db

View File

@ -26,6 +26,7 @@ repositories {
dirs "repo"
}
}
// IronChest uses git tagging to mark major versions. This sets up the project version to that version data
def versionInfo = getGitVersion()
version = "${versionInfo['IronChest.version']}"
@ -38,11 +39,11 @@ archivesBaseName = "ironchest"
// Setup the forge minecraft plugin data. Specify the preferred forge/minecraft version here
minecraft {
version = "1.7.10-10.13.0.1150"
runDir = "eclipse/assets"
}
// This wrangles the resources for the jar files- stuff like textures and languages
processResources
{
processResources {
// we're omitting the .xcf files - they're development only
exclude '**/*.xcf'
// we only want to do search/replace stuff in mcmod.info, nothing else
@ -74,7 +75,6 @@ processResources
jar {
classifier = 'universal'
version = "${project.minecraft.version}-${project.version}"
}
println "FISHBUM ${jar.version}"
@ -165,8 +165,7 @@ uploadArchives {
}
// This is a special task for pulling the version information from git and the environment (for BUILD_NUMBER)
def getGitVersion()
{
def getGitVersion() {
def out = [:]
// call git command.

View File

@ -14,11 +14,10 @@ import static net.minecraftforge.common.util.ForgeDirection.DOWN;
import static net.minecraftforge.common.util.ForgeDirection.UP;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@ -27,6 +26,7 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
@ -34,20 +34,20 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.google.common.collect.Lists;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockIronChest extends BlockContainer {
private Random random;
@SideOnly(Side.CLIENT)
private IIcon[][] icons;
public BlockIronChest()
{
super(Material.iron);
@ -91,8 +91,8 @@ public class BlockIronChest extends BlockContainer {
return IronChestType.makeEntity(metadata);
}
@SideOnly(Side.CLIENT)
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int i, int j)
{
if (j < IronChestType.values().length)
@ -112,27 +112,68 @@ public class BlockIronChest extends BlockContainer {
items.add(stack);
return items;
}
@Override
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int i1, float f1, float f2, float f3)
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_)
{
TileEntity te = world.getTileEntity(i, j, k);
if (te == null || !(te instanceof TileEntityIronChest))
{
return true;
}
if (world.isSideSolid(i, j + 1, k, ForgeDirection.DOWN))
{
return true;
}
if (world.isRemote)
{
return true;
}
else
{
IInventory iinventory = chestInventory(world, i, j, k);
if (iinventory != null)
{
player.openGui(IronChest.instance, ((TileEntityIronChest) world.getTileEntity(i, j, k)).getType().ordinal(), world, i, j, k);
}
return true;
}
}
public IInventory chestInventory(World world, int i, int j, int k)
{
TileEntity chest = (TileEntityIronChest)world.getTileEntity(i, j, k);
if (chest == null
|| world.isSideSolid(i, j + 1, k, DOWN)
|| isOcelotMounted(world, i, j, k)
|| world.getBlock(i - 1, j, k) == this && (world.isSideSolid(i - 1, j + 1, k, DOWN)
|| isOcelotMounted(world, i - 1, j, k))
|| world.getBlock(i + 1, j, k) == this && (world.isSideSolid(i + 1, j + 1, k, DOWN)
|| isOcelotMounted(world, i + 1, j, k))
|| world.getBlock(i, j, k - 1) == this && (world.isSideSolid(i, j + 1, k - 1, DOWN)
|| isOcelotMounted(world, i, j, k - 1))
|| world.getBlock(i, j, k + 1) == this && (world.isSideSolid(i, j + 1, k + 1, DOWN)
|| isOcelotMounted(world, i, j, k + 1)))
{
return null;
}
else
{
return (IInventory)chest;
}
}
private static boolean isOcelotMounted(World world, int i, int j, int k)
{
Iterator iterator = world.getEntitiesWithinAABB(EntityOcelot.class, AxisAlignedBB.getBoundingBox((double)i, (double)(j + 1), (double)k, (double)(i + 1), (double)(j + 2), (double)(k + 1))).iterator();
EntityOcelot entityocelot;
do
{
if (!iterator.hasNext())
{
return false;
}
Entity entity = (Entity)iterator.next();
entityocelot = (EntityOcelot)entity;
}
while (!entityocelot.isSitting());
player.openGui(IronChest.instance, ((TileEntityIronChest) te).getType().ordinal(), world, i, j, k);
return true;
}
@ -228,7 +269,6 @@ public class BlockIronChest extends BlockContainer {
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
{
@ -283,11 +323,10 @@ public class BlockIronChest extends BlockContainer {
}
}
private static final ForgeDirection[] validRotationAxes = new ForgeDirection[] { UP, DOWN };
@Override
public ForgeDirection[] getValidRotations(World worldObj, int x, int y, int z)
{
return validRotationAxes;
return new ForgeDirection[] { UP, DOWN };
}
@Override

View File

@ -10,13 +10,13 @@
******************************************************************************/
package cpw.mods.ironchest;
import invtweaks.api.container.ChestContainer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import invtweaks.api.container.ChestContainer;
@ChestContainer(isLargeChest = true)
public class ContainerIronChest extends Container {
@ -85,13 +85,13 @@ public class ContainerIronChest extends Container {
protected void layoutContainer(IInventory playerInventory, IInventory chestInventory, IronChestType type, int xSize, int ySize)
{
if (type == IronChestType.DIRTCHEST9000) {
addSlotToContainer(type.makeSlot(chestInventory, 0, 12 + 4 * 18, 8 + 2 * 18));
addSlotToContainer(new Slot(chestInventory, 0, 12 + 4 * 18, 8 + 2 * 18));
} else {
for (int chestRow = 0; chestRow < type.getRowCount(); chestRow++)
{
for (int chestCol = 0; chestCol < type.getRowLength(); chestCol++)
{
addSlotToContainer(type.makeSlot(chestInventory, chestCol + chestRow * type.getRowLength(), 12 + chestCol * 18, 8 + chestRow * 18));
addSlotToContainer(new Slot(chestInventory, chestCol + chestRow * type.getRowLength(), 12 + chestCol * 18, 8 + chestRow * 18));
}
}
}

View File

@ -12,14 +12,15 @@ package cpw.mods.ironchest;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import org.apache.logging.log4j.Level;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
@ -27,12 +28,13 @@ import cpw.mods.fml.common.registry.GameRegistry;
@Mod(modid = "IronChest", name = "Iron Chests", dependencies = "required-after:Forge@[10.10,);required-after:FML@[7.2,)")
public class IronChest {
public static BlockIronChest ironChestBlock;
@SidedProxy(clientSide = "cpw.mods.ironchest.client.ClientProxy", serverSide = "cpw.mods.ironchest.CommonProxy")
public static CommonProxy proxy;
@Instance("IronChest")
public static IronChest instance;
public static boolean CACHE_RENDER = true;
public static boolean OCELOTS_SITONCHESTS = true;
@EventHandler
public void preInit(FMLPreInitializationEvent event)
@ -45,7 +47,6 @@ public class IronChest {
cfg.load();
ChestChangerType.buildItems(cfg);
CACHE_RENDER = cfg.get(Configuration.CATEGORY_GENERAL, "cacheRenderingInformation", true).getBoolean(true);
OCELOTS_SITONCHESTS = cfg.get(Configuration.CATEGORY_GENERAL, "ocelotsSitOnChests", true).getBoolean(true);
}
catch (Exception e)
{
@ -73,16 +74,6 @@ public class IronChest {
ChestChangerType.generateRecipes();
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
proxy.registerRenderInformation();
// if (OCELOTS_SITONCHESTS)
// {
// MinecraftForge.EVENT_BUS.register(new OcelotsSitOnChestsHandler());
// }
MinecraftForge.EVENT_BUS.register(this);
}
@EventHandler
public void modsLoaded(FMLPostInitializationEvent evt)
{
}
}

View File

@ -1,22 +0,0 @@
package cpw.mods.ironchest;
import net.minecraft.entity.ai.EntityAIOcelotSit;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.world.World;
public class IronChestAIOcelotSit extends EntityAIOcelotSit {
public IronChestAIOcelotSit(EntityOcelot par1EntityOcelot, float par2)
{
super(par1EntityOcelot, par2);
}
/* @Override
protected boolean func_151486_a(World world, int x, int y, int z)
{
if (world.getBlock(x, y, z) == IronChest.ironChestBlock)
{
return true;
}
return super.func_151486_a(world, x, y, z);
}
*/}

View File

@ -13,11 +13,10 @@ package cpw.mods.ironchest;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagByte;
@ -246,11 +245,6 @@ public enum IronChestType {
private static String[] sideNames = { "top", "front", "side" };
private static int[] sideMapping = { 0, 0, 2, 1, 2, 2, 2 };
public Slot makeSlot(IInventory chestInventory, int index, int x, int y)
{
return new ValidatingSlot(chestInventory, index, x, y, this);
}
public boolean acceptsStack(ItemStack itemstack)
{
return itemFilter == null || itemstack == null || itemstack.getItem() == itemFilter;

View File

@ -1,33 +0,0 @@
package cpw.mods.ironchest;
import net.minecraft.item.ItemStack;
public class MappableItemStackWrapper {
private ItemStack wrap;
public MappableItemStackWrapper(ItemStack toWrap)
{
wrap = toWrap;
}
@Override
public boolean equals(Object obj)
{
if (!(obj instanceof MappableItemStackWrapper)) return false;
MappableItemStackWrapper isw = (MappableItemStackWrapper) obj;
if (wrap.getHasSubtypes())
{
return isw.wrap.isItemEqual(wrap);
}
else
{
return isw.wrap == wrap;
}
}
@Override
public int hashCode()
{
return System.identityHashCode(wrap);
}
}

View File

@ -1,30 +0,0 @@
package cpw.mods.ironchest;
import java.util.List;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.entity.ai.EntityAIOcelotSit;
import net.minecraft.entity.ai.EntityAITasks;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraftforge.event.entity.living.LivingEvent;
public class OcelotsSitOnChestsHandler {
@SubscribeEvent
public void changeSittingTaskForOcelots(LivingEvent.LivingUpdateEvent evt)
{
if (evt.entityLiving.ticksExisted < 5 && evt.entityLiving instanceof EntityOcelot)
{
EntityOcelot ocelot = (EntityOcelot) evt.entityLiving;
@SuppressWarnings("unchecked")
List<EntityAITasks.EntityAITaskEntry> tasks = ocelot.tasks.taskEntries;
for (int i = 0; i < tasks.size(); i++)
{
EntityAITasks.EntityAITaskEntry task = tasks.get(i);
if (task.priority == 6 && (task.action instanceof EntityAIOcelotSit) && !(task.action instanceof IronChestAIOcelotSit))
{
task.action = new IronChestAIOcelotSit(ocelot, 0.4F);
}
}
}
}
}

View File

@ -1,21 +0,0 @@
package cpw.mods.ironchest;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ValidatingSlot extends Slot {
private IronChestType type;
public ValidatingSlot(IInventory par1iInventory, int par2, int par3, int par4, IronChestType type)
{
super(par1iInventory, par2, par3, par4);
this.type = type;
}
@Override
public boolean isItemValid(ItemStack par1ItemStack)
{
return type.acceptsStack(par1ItemStack);
}
}

View File

@ -9,12 +9,7 @@ package cpw.mods.ironchest;
import java.util.Properties;
public class Version {
private static String major;
private static String minor;
private static String rev;
private static String build;
@SuppressWarnings("unused")
private static String mcversion;
private static String major, minor, rev, build, mcversion;
static void init(Properties properties)
{

View File

@ -18,11 +18,11 @@ import static org.lwjgl.opengl.GL11.glPushMatrix;
import static org.lwjgl.opengl.GL11.glRotatef;
import static org.lwjgl.opengl.GL11.glScalef;
import static org.lwjgl.opengl.GL11.glTranslatef;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import net.minecraft.client.model.ModelChest;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
@ -30,18 +30,19 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.primitives.SignedBytes;
import cpw.mods.ironchest.IronChestType;
import cpw.mods.ironchest.MappableItemStackWrapper;
import cpw.mods.ironchest.TileEntityIronChest;
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
@SuppressWarnings("unused")
private static Map<MappableItemStackWrapper, Integer> renderList = new HashMap<MappableItemStackWrapper, Integer>();
private ModelChest model;
private static Map<IronChestType, ResourceLocation> locations;
static {
Builder<IronChestType, ResourceLocation> builder = ImmutableMap.<IronChestType,ResourceLocation>builder();
for (IronChestType typ : IronChestType.values()) {
@ -49,11 +50,8 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
}
locations = builder.build();
}
private Random random;
@SuppressWarnings("unused")
private RenderBlocks renderBlocks;
private RenderItem itemRenderer;
private static float[][] shifts = { { 0.3F, 0.45F, 0.3F }, { 0.7F, 0.45F, 0.3F }, { 0.3F, 0.45F, 0.7F }, { 0.7F, 0.45F, 0.7F }, { 0.3F, 0.1F, 0.3F },
@ -63,7 +61,6 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
{
model = new ModelChest();
random = new Random();
renderBlocks = new RenderBlocks();
itemRenderer = new RenderItem() {
@Override
public byte getMiniBlockCount(ItemStack stack, byte original) {
@ -176,6 +173,4 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
{
render((TileEntityIronChest) tileentity, x, y, z, partialTick);
}
private ModelChest model;
}