Updated ocelot handling
This commit is contained in:
parent
a36beb09c8
commit
6bb69755ab
|
|
@ -26,6 +26,7 @@ repositories {
|
||||||
dirs "repo"
|
dirs "repo"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// IronChest uses git tagging to mark major versions. This sets up the project version to that version data
|
// IronChest uses git tagging to mark major versions. This sets up the project version to that version data
|
||||||
def versionInfo = getGitVersion()
|
def versionInfo = getGitVersion()
|
||||||
version = "${versionInfo['IronChest.version']}"
|
version = "${versionInfo['IronChest.version']}"
|
||||||
|
|
@ -38,11 +39,11 @@ 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.7.10-10.13.0.1150"
|
version = "1.7.10-10.13.0.1150"
|
||||||
|
runDir = "eclipse/assets"
|
||||||
}
|
}
|
||||||
|
|
||||||
// This wrangles the resources for the jar files- stuff like textures and languages
|
// 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
|
// we're omitting the .xcf files - they're development only
|
||||||
exclude '**/*.xcf'
|
exclude '**/*.xcf'
|
||||||
// we only want to do search/replace stuff in mcmod.info, nothing else
|
// we only want to do search/replace stuff in mcmod.info, nothing else
|
||||||
|
|
@ -74,7 +75,6 @@ processResources
|
||||||
jar {
|
jar {
|
||||||
classifier = 'universal'
|
classifier = 'universal'
|
||||||
version = "${project.minecraft.version}-${project.version}"
|
version = "${project.minecraft.version}-${project.version}"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
println "FISHBUM ${jar.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)
|
// This is a special task for pulling the version information from git and the environment (for BUILD_NUMBER)
|
||||||
def getGitVersion()
|
def getGitVersion() {
|
||||||
{
|
|
||||||
def out = [:]
|
def out = [:]
|
||||||
|
|
||||||
// call git command.
|
// call git command.
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,10 @@ import static net.minecraftforge.common.util.ForgeDirection.DOWN;
|
||||||
import static net.minecraftforge.common.util.ForgeDirection.UP;
|
import static net.minecraftforge.common.util.ForgeDirection.UP;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockContainer;
|
import net.minecraft.block.BlockContainer;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
|
@ -27,6 +26,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
|
import net.minecraft.entity.passive.EntityOcelot;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
|
|
@ -34,20 +34,20 @@ import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class BlockIronChest extends BlockContainer {
|
public class BlockIronChest extends BlockContainer {
|
||||||
|
|
||||||
private Random random;
|
private Random random;
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
private IIcon[][] icons;
|
|
||||||
|
|
||||||
public BlockIronChest()
|
public BlockIronChest()
|
||||||
{
|
{
|
||||||
super(Material.iron);
|
super(Material.iron);
|
||||||
|
|
@ -91,8 +91,8 @@ public class BlockIronChest extends BlockContainer {
|
||||||
return IronChestType.makeEntity(metadata);
|
return IronChestType.makeEntity(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@Override
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
public IIcon getIcon(int i, int j)
|
public IIcon getIcon(int i, int j)
|
||||||
{
|
{
|
||||||
if (j < IronChestType.values().length)
|
if (j < IronChestType.values().length)
|
||||||
|
|
@ -112,28 +112,69 @@ public class BlockIronChest extends BlockContainer {
|
||||||
items.add(stack);
|
items.add(stack);
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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))
|
if (iinventory != null)
|
||||||
{
|
{
|
||||||
return true;
|
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)
|
public IInventory chestInventory(World world, int i, int j, int k)
|
||||||
{
|
{
|
||||||
return true;
|
TileEntity chest = (TileEntityIronChest)world.getTileEntity(i, j, k);
|
||||||
}
|
|
||||||
|
|
||||||
player.openGui(IronChest.instance, ((TileEntityIronChest) te).getType().ordinal(), world, i, j, k);
|
if (chest == null
|
||||||
return true;
|
|| 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
|
@Override
|
||||||
|
|
@ -228,7 +269,6 @@ public class BlockIronChest extends BlockContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
|
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||||
{
|
{
|
||||||
|
|
@ -274,11 +314,10 @@ public class BlockIronChest extends BlockContainer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final ForgeDirection[] validRotationAxes = new ForgeDirection[] { UP, DOWN };
|
|
||||||
@Override
|
@Override
|
||||||
public ForgeDirection[] getValidRotations(World worldObj, int x, int y, int z)
|
public ForgeDirection[] getValidRotations(World worldObj, int x, int y, int z)
|
||||||
{
|
{
|
||||||
return validRotationAxes;
|
return new ForgeDirection[] { UP, DOWN };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,15 @@ package cpw.mods.ironchest;
|
||||||
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
|
|
||||||
import cpw.mods.fml.common.FMLLog;
|
import cpw.mods.fml.common.FMLLog;
|
||||||
import cpw.mods.fml.common.Mod;
|
import cpw.mods.fml.common.Mod;
|
||||||
import cpw.mods.fml.common.Mod.EventHandler;
|
import cpw.mods.fml.common.Mod.EventHandler;
|
||||||
import cpw.mods.fml.common.Mod.Instance;
|
import cpw.mods.fml.common.Mod.Instance;
|
||||||
import cpw.mods.fml.common.SidedProxy;
|
import cpw.mods.fml.common.SidedProxy;
|
||||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
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.event.FMLPreInitializationEvent;
|
||||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
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,)")
|
@Mod(modid = "IronChest", name = "Iron Chests", dependencies = "required-after:Forge@[10.10,);required-after:FML@[7.2,)")
|
||||||
public class IronChest {
|
public class IronChest {
|
||||||
public static BlockIronChest ironChestBlock;
|
public static BlockIronChest ironChestBlock;
|
||||||
|
|
||||||
@SidedProxy(clientSide = "cpw.mods.ironchest.client.ClientProxy", serverSide = "cpw.mods.ironchest.CommonProxy")
|
@SidedProxy(clientSide = "cpw.mods.ironchest.client.ClientProxy", serverSide = "cpw.mods.ironchest.CommonProxy")
|
||||||
public static CommonProxy proxy;
|
public static CommonProxy proxy;
|
||||||
|
|
||||||
@Instance("IronChest")
|
@Instance("IronChest")
|
||||||
public static IronChest instance;
|
public static IronChest instance;
|
||||||
public static boolean CACHE_RENDER = true;
|
public static boolean CACHE_RENDER = true;
|
||||||
public static boolean OCELOTS_SITONCHESTS = true;
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void preInit(FMLPreInitializationEvent event)
|
public void preInit(FMLPreInitializationEvent event)
|
||||||
|
|
@ -45,7 +47,6 @@ public class IronChest {
|
||||||
cfg.load();
|
cfg.load();
|
||||||
ChestChangerType.buildItems(cfg);
|
ChestChangerType.buildItems(cfg);
|
||||||
CACHE_RENDER = cfg.get(Configuration.CATEGORY_GENERAL, "cacheRenderingInformation", true).getBoolean(true);
|
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)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
@ -73,16 +74,6 @@ public class IronChest {
|
||||||
ChestChangerType.generateRecipes();
|
ChestChangerType.generateRecipes();
|
||||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
|
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
|
||||||
proxy.registerRenderInformation();
|
proxy.registerRenderInformation();
|
||||||
// if (OCELOTS_SITONCHESTS)
|
|
||||||
// {
|
|
||||||
// MinecraftForge.EVENT_BUS.register(new OcelotsSitOnChestsHandler());
|
|
||||||
// }
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
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);
|
|
||||||
}
|
|
||||||
*/}
|
|
||||||
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -9,12 +9,7 @@ package cpw.mods.ironchest;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
public class Version {
|
public class Version {
|
||||||
private static String major;
|
private static String major, minor, rev, build, mcversion;
|
||||||
private static String minor;
|
|
||||||
private static String rev;
|
|
||||||
private static String build;
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private static String mcversion;
|
|
||||||
|
|
||||||
static void init(Properties properties)
|
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.glRotatef;
|
||||||
import static org.lwjgl.opengl.GL11.glScalef;
|
import static org.lwjgl.opengl.GL11.glScalef;
|
||||||
import static org.lwjgl.opengl.GL11.glTranslatef;
|
import static org.lwjgl.opengl.GL11.glTranslatef;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.client.model.ModelChest;
|
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.RenderItem;
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
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.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableMap.Builder;
|
import com.google.common.collect.ImmutableMap.Builder;
|
||||||
import com.google.common.primitives.SignedBytes;
|
import com.google.common.primitives.SignedBytes;
|
||||||
|
|
||||||
import cpw.mods.ironchest.IronChestType;
|
import cpw.mods.ironchest.IronChestType;
|
||||||
import cpw.mods.ironchest.MappableItemStackWrapper;
|
|
||||||
import cpw.mods.ironchest.TileEntityIronChest;
|
import cpw.mods.ironchest.TileEntityIronChest;
|
||||||
|
|
||||||
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
||||||
@SuppressWarnings("unused")
|
private ModelChest model;
|
||||||
private static Map<MappableItemStackWrapper, Integer> renderList = new HashMap<MappableItemStackWrapper, Integer>();
|
|
||||||
|
|
||||||
private static Map<IronChestType, ResourceLocation> locations;
|
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;
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
static {
|
||||||
private RenderBlocks renderBlocks;
|
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 },
|
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 }, };
|
{ 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()
|
public TileEntityIronChestRenderer()
|
||||||
{
|
{
|
||||||
model = new ModelChest();
|
model = new ModelChest();
|
||||||
random = new Random();
|
random = new Random();
|
||||||
renderBlocks = new RenderBlocks();
|
itemRenderer = new RenderItem() {
|
||||||
itemRenderer = new RenderItem() {
|
@Override
|
||||||
@Override
|
public byte getMiniBlockCount(ItemStack stack, byte original) {
|
||||||
public byte getMiniBlockCount(ItemStack stack, byte original) {
|
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 15) + 1);
|
||||||
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 15) + 1);
|
}
|
||||||
}
|
@Override
|
||||||
@Override
|
public byte getMiniItemCount(ItemStack stack, byte original) {
|
||||||
public byte getMiniItemCount(ItemStack stack, byte original) {
|
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 7) + 1);
|
||||||
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 7) + 1);
|
}
|
||||||
}
|
@Override
|
||||||
@Override
|
public boolean shouldBob() {
|
||||||
public boolean shouldBob() {
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
@Override
|
||||||
@Override
|
public boolean shouldSpreadItems() {
|
||||||
public boolean shouldSpreadItems() {
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
};
|
||||||
};
|
itemRenderer.setRenderManager(RenderManager.instance);
|
||||||
itemRenderer.setRenderManager(RenderManager.instance);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void render(TileEntityIronChest tile, double x, double y, double z, float partialTick) {
|
public void render(TileEntityIronChest tile, double x, double y, double z, float partialTick) {
|
||||||
if (tile == null) {
|
if (tile == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int facing = 3;
|
int facing = 3;
|
||||||
IronChestType type = tile.getType();
|
IronChestType type = tile.getType();
|
||||||
if (tile != null && tile.hasWorldObj()) {
|
if (tile != null && tile.hasWorldObj()) {
|
||||||
facing = tile.getFacing();
|
facing = tile.getFacing();
|
||||||
type = tile.getType();
|
type = tile.getType();
|
||||||
int typ = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord);
|
int typ = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||||
type = IronChestType.values()[typ];
|
type = IronChestType.values()[typ];
|
||||||
}
|
}
|
||||||
bindTexture(locations.get(type));
|
bindTexture(locations.get(type));
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
|
glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||||
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
|
glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
|
||||||
glScalef(1.0F, -1F, -1F);
|
glScalef(1.0F, -1F, -1F);
|
||||||
glTranslatef(0.5F, 0.5F, 0.5F);
|
glTranslatef(0.5F, 0.5F, 0.5F);
|
||||||
int k = 0;
|
int k = 0;
|
||||||
if (facing == 2) {
|
if (facing == 2) {
|
||||||
k = 180;
|
k = 180;
|
||||||
}
|
}
|
||||||
if (facing == 3) {
|
if (facing == 3) {
|
||||||
k = 0;
|
k = 0;
|
||||||
}
|
}
|
||||||
if (facing == 4) {
|
if (facing == 4) {
|
||||||
k = 90;
|
k = 90;
|
||||||
}
|
}
|
||||||
if (facing == 5) {
|
if (facing == 5) {
|
||||||
k = -90;
|
k = -90;
|
||||||
}
|
}
|
||||||
glRotatef(k, 0.0F, 1.0F, 0.0F);
|
glRotatef(k, 0.0F, 1.0F, 0.0F);
|
||||||
glTranslatef(-0.5F, -0.5F, -0.5F);
|
glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||||
float lidangle = tile.prevLidAngle + (tile.lidAngle - tile.prevLidAngle) * partialTick;
|
float lidangle = tile.prevLidAngle + (tile.lidAngle - tile.prevLidAngle) * partialTick;
|
||||||
lidangle = 1.0F - lidangle;
|
lidangle = 1.0F - lidangle;
|
||||||
lidangle = 1.0F - lidangle * lidangle * lidangle;
|
lidangle = 1.0F - lidangle * lidangle * lidangle;
|
||||||
model.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F);
|
model.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F);
|
||||||
// Render the chest itself
|
// Render the chest itself
|
||||||
model.renderAll();
|
model.renderAll();
|
||||||
glDisable(32826 /* GL_RESCALE_NORMAL_EXT */);
|
glDisable(32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
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) {
|
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);
|
random.setSeed(254L);
|
||||||
float shiftX;
|
float shiftX;
|
||||||
float shiftY;
|
float shiftY;
|
||||||
float shiftZ;
|
float shiftZ;
|
||||||
int shift = 0;
|
int shift = 0;
|
||||||
float blockScale = 0.70F;
|
float blockScale = 0.70F;
|
||||||
float timeD = (float) (360.0 * (double) (System.currentTimeMillis() & 0x3FFFL) / (double) 0x3FFFL);
|
float timeD = (float) (360.0 * (double) (System.currentTimeMillis() & 0x3FFFL) / (double) 0x3FFFL);
|
||||||
if (tile.getTopItemStacks()[1] == null) {
|
if (tile.getTopItemStacks()[1] == null) {
|
||||||
shift = 8;
|
shift = 8;
|
||||||
blockScale = 0.85F;
|
blockScale = 0.85F;
|
||||||
}
|
}
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glDisable(2896 /* GL_LIGHTING */);
|
glDisable(2896 /* GL_LIGHTING */);
|
||||||
glTranslatef((float) x, (float) y, (float) z);
|
glTranslatef((float) x, (float) y, (float) z);
|
||||||
EntityItem customitem = new EntityItem(field_147501_a.field_147550_f);
|
EntityItem customitem = new EntityItem(field_147501_a.field_147550_f);
|
||||||
customitem.hoverStart = 0f;
|
customitem.hoverStart = 0f;
|
||||||
for (ItemStack item : tile.getTopItemStacks()) {
|
for (ItemStack item : tile.getTopItemStacks()) {
|
||||||
if (shift > shifts.length) {
|
if (shift > shifts.length) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
shift++;
|
shift++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
shiftX = shifts[shift][0];
|
shiftX = shifts[shift][0];
|
||||||
shiftY = shifts[shift][1];
|
shiftY = shifts[shift][1];
|
||||||
shiftZ = shifts[shift][2];
|
shiftZ = shifts[shift][2];
|
||||||
shift++;
|
shift++;
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(shiftX, shiftY, shiftZ);
|
glTranslatef(shiftX, shiftY, shiftZ);
|
||||||
glRotatef(timeD, 0.0F, 1.0F, 0.0F);
|
glRotatef(timeD, 0.0F, 1.0F, 0.0F);
|
||||||
glScalef(blockScale, blockScale, blockScale);
|
glScalef(blockScale, blockScale, blockScale);
|
||||||
customitem.setEntityItemStack(item);
|
customitem.setEntityItemStack(item);
|
||||||
itemRenderer.doRender(customitem, 0, 0, 0, 0, 0);
|
itemRenderer.doRender(customitem, 0, 0, 0, 0, 0);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
glEnable(2896 /* GL_LIGHTING */);
|
glEnable(2896 /* GL_LIGHTING */);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTick)
|
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTick)
|
||||||
{
|
{
|
||||||
render((TileEntityIronChest) tileentity, x, y, z, partialTick);
|
render((TileEntityIronChest) tileentity, x, y, z, partialTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ModelChest model;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue