Merge 3d340acdca into 2628cbd41e
This commit is contained in:
commit
e467ac38e3
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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,28 +112,69 @@ 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 (world.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
IInventory iinventory = chestInventory(world, i, j, k);
|
||||
|
||||
if (te == null || !(te instanceof TileEntityIronChest))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (iinventory != null)
|
||||
{
|
||||
player.openGui(IronChest.instance, ((TileEntityIronChest) world.getTileEntity(i, j, k)).getType().ordinal(), world, i, j, k);
|
||||
}
|
||||
|
||||
if (world.isSideSolid(i, j + 1, k, ForgeDirection.DOWN))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (world.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public IInventory chestInventory(World world, int i, int j, int k)
|
||||
{
|
||||
TileEntity chest = (TileEntityIronChest)world.getTileEntity(i, j, k);
|
||||
|
||||
player.openGui(IronChest.instance, ((TileEntityIronChest) te).getType().ordinal(), world, i, j, k);
|
||||
return true;
|
||||
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());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
*/}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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,152 +30,147 @@ 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()) {
|
||||
builder.put(typ, new ResourceLocation("ironchest","textures/model/"+typ.getModelTexture()));
|
||||
}
|
||||
locations = builder.build();
|
||||
}
|
||||
private Random random;
|
||||
private static Map<IronChestType, ResourceLocation> locations;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private RenderBlocks renderBlocks;
|
||||
static {
|
||||
Builder<IronChestType, ResourceLocation> builder = ImmutableMap.<IronChestType,ResourceLocation>builder();
|
||||
for (IronChestType typ : IronChestType.values()) {
|
||||
builder.put(typ, new ResourceLocation("ironchest","textures/model/"+typ.getModelTexture()));
|
||||
}
|
||||
locations = builder.build();
|
||||
}
|
||||
|
||||
private RenderItem itemRenderer;
|
||||
private Random random;
|
||||
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 },
|
||||
{ 0.7F, 0.1F, 0.3F }, { 0.3F, 0.1F, 0.7F }, { 0.7F, 0.1F, 0.7F }, { 0.5F, 0.32F, 0.5F }, };
|
||||
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 },
|
||||
{ 0.7F, 0.1F, 0.3F }, { 0.3F, 0.1F, 0.7F }, { 0.7F, 0.1F, 0.7F }, { 0.5F, 0.32F, 0.5F }, };
|
||||
|
||||
public TileEntityIronChestRenderer()
|
||||
{
|
||||
model = new ModelChest();
|
||||
random = new Random();
|
||||
renderBlocks = new RenderBlocks();
|
||||
itemRenderer = new RenderItem() {
|
||||
@Override
|
||||
public byte getMiniBlockCount(ItemStack stack, byte original) {
|
||||
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 15) + 1);
|
||||
}
|
||||
@Override
|
||||
public byte getMiniItemCount(ItemStack stack, byte original) {
|
||||
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 7) + 1);
|
||||
}
|
||||
@Override
|
||||
public boolean shouldBob() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean shouldSpreadItems() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
itemRenderer.setRenderManager(RenderManager.instance);
|
||||
}
|
||||
public TileEntityIronChestRenderer()
|
||||
{
|
||||
model = new ModelChest();
|
||||
random = new Random();
|
||||
itemRenderer = new RenderItem() {
|
||||
@Override
|
||||
public byte getMiniBlockCount(ItemStack stack, byte original) {
|
||||
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 15) + 1);
|
||||
}
|
||||
@Override
|
||||
public byte getMiniItemCount(ItemStack stack, byte original) {
|
||||
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 7) + 1);
|
||||
}
|
||||
@Override
|
||||
public boolean shouldBob() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean shouldSpreadItems() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
itemRenderer.setRenderManager(RenderManager.instance);
|
||||
}
|
||||
|
||||
public void render(TileEntityIronChest tile, double x, double y, double z, float partialTick) {
|
||||
if (tile == null) {
|
||||
return;
|
||||
}
|
||||
int facing = 3;
|
||||
IronChestType type = tile.getType();
|
||||
if (tile != null && tile.hasWorldObj()) {
|
||||
facing = tile.getFacing();
|
||||
type = tile.getType();
|
||||
int typ = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
type = IronChestType.values()[typ];
|
||||
}
|
||||
bindTexture(locations.get(type));
|
||||
glPushMatrix();
|
||||
glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
|
||||
glScalef(1.0F, -1F, -1F);
|
||||
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;
|
||||
}
|
||||
glRotatef(k, 0.0F, 1.0F, 0.0F);
|
||||
glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
float lidangle = tile.prevLidAngle + (tile.lidAngle - tile.prevLidAngle) * partialTick;
|
||||
lidangle = 1.0F - lidangle;
|
||||
lidangle = 1.0F - lidangle * lidangle * lidangle;
|
||||
model.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F);
|
||||
// Render the chest itself
|
||||
model.renderAll();
|
||||
glDisable(32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||
glPopMatrix();
|
||||
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
if (type.isTransparent() && tile.getDistanceFrom(this.field_147501_a.field_147560_j, this.field_147501_a.field_147561_k, this.field_147501_a.field_147558_l) < 128d) {
|
||||
random.setSeed(254L);
|
||||
float shiftX;
|
||||
float shiftY;
|
||||
float shiftZ;
|
||||
int shift = 0;
|
||||
float blockScale = 0.70F;
|
||||
float timeD = (float) (360.0 * (double) (System.currentTimeMillis() & 0x3FFFL) / (double) 0x3FFFL);
|
||||
if (tile.getTopItemStacks()[1] == null) {
|
||||
shift = 8;
|
||||
blockScale = 0.85F;
|
||||
}
|
||||
glPushMatrix();
|
||||
glDisable(2896 /* GL_LIGHTING */);
|
||||
glTranslatef((float) x, (float) y, (float) z);
|
||||
EntityItem customitem = new EntityItem(field_147501_a.field_147550_f);
|
||||
customitem.hoverStart = 0f;
|
||||
for (ItemStack item : tile.getTopItemStacks()) {
|
||||
if (shift > shifts.length) {
|
||||
break;
|
||||
}
|
||||
if (item == null) {
|
||||
shift++;
|
||||
continue;
|
||||
}
|
||||
shiftX = shifts[shift][0];
|
||||
shiftY = shifts[shift][1];
|
||||
shiftZ = shifts[shift][2];
|
||||
shift++;
|
||||
glPushMatrix();
|
||||
glTranslatef(shiftX, shiftY, shiftZ);
|
||||
glRotatef(timeD, 0.0F, 1.0F, 0.0F);
|
||||
glScalef(blockScale, blockScale, blockScale);
|
||||
customitem.setEntityItemStack(item);
|
||||
itemRenderer.doRender(customitem, 0, 0, 0, 0, 0);
|
||||
glPopMatrix();
|
||||
}
|
||||
glEnable(2896 /* GL_LIGHTING */);
|
||||
glPopMatrix();
|
||||
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
public void render(TileEntityIronChest tile, double x, double y, double z, float partialTick) {
|
||||
if (tile == null) {
|
||||
return;
|
||||
}
|
||||
int facing = 3;
|
||||
IronChestType type = tile.getType();
|
||||
if (tile != null && tile.hasWorldObj()) {
|
||||
facing = tile.getFacing();
|
||||
type = tile.getType();
|
||||
int typ = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
type = IronChestType.values()[typ];
|
||||
}
|
||||
bindTexture(locations.get(type));
|
||||
glPushMatrix();
|
||||
glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
|
||||
glScalef(1.0F, -1F, -1F);
|
||||
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;
|
||||
}
|
||||
glRotatef(k, 0.0F, 1.0F, 0.0F);
|
||||
glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
float lidangle = tile.prevLidAngle + (tile.lidAngle - tile.prevLidAngle) * partialTick;
|
||||
lidangle = 1.0F - lidangle;
|
||||
lidangle = 1.0F - lidangle * lidangle * lidangle;
|
||||
model.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F);
|
||||
// Render the chest itself
|
||||
model.renderAll();
|
||||
glDisable(32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||
glPopMatrix();
|
||||
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
if (type.isTransparent() && tile.getDistanceFrom(this.field_147501_a.field_147560_j, this.field_147501_a.field_147561_k, this.field_147501_a.field_147558_l) < 128d) {
|
||||
random.setSeed(254L);
|
||||
float shiftX;
|
||||
float shiftY;
|
||||
float shiftZ;
|
||||
int shift = 0;
|
||||
float blockScale = 0.70F;
|
||||
float timeD = (float) (360.0 * (double) (System.currentTimeMillis() & 0x3FFFL) / (double) 0x3FFFL);
|
||||
if (tile.getTopItemStacks()[1] == null) {
|
||||
shift = 8;
|
||||
blockScale = 0.85F;
|
||||
}
|
||||
glPushMatrix();
|
||||
glDisable(2896 /* GL_LIGHTING */);
|
||||
glTranslatef((float) x, (float) y, (float) z);
|
||||
EntityItem customitem = new EntityItem(field_147501_a.field_147550_f);
|
||||
customitem.hoverStart = 0f;
|
||||
for (ItemStack item : tile.getTopItemStacks()) {
|
||||
if (shift > shifts.length) {
|
||||
break;
|
||||
}
|
||||
if (item == null) {
|
||||
shift++;
|
||||
continue;
|
||||
}
|
||||
shiftX = shifts[shift][0];
|
||||
shiftY = shifts[shift][1];
|
||||
shiftZ = shifts[shift][2];
|
||||
shift++;
|
||||
glPushMatrix();
|
||||
glTranslatef(shiftX, shiftY, shiftZ);
|
||||
glRotatef(timeD, 0.0F, 1.0F, 0.0F);
|
||||
glScalef(blockScale, blockScale, blockScale);
|
||||
customitem.setEntityItemStack(item);
|
||||
itemRenderer.doRender(customitem, 0, 0, 0, 0, 0);
|
||||
glPopMatrix();
|
||||
}
|
||||
glEnable(2896 /* GL_LIGHTING */);
|
||||
glPopMatrix();
|
||||
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTick)
|
||||
{
|
||||
render((TileEntityIronChest) tileentity, x, y, z, partialTick);
|
||||
}
|
||||
|
||||
private ModelChest model;
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTick)
|
||||
{
|
||||
render((TileEntityIronChest) tileentity, x, y, z, partialTick);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue