Updated Calclavia Core

This commit is contained in:
Calclavia 2014-03-08 13:10:03 -08:00
parent 148152fc71
commit b94e8aaf17
4 changed files with 68 additions and 64 deletions

View file

@ -1,24 +0,0 @@
package resonantinduction.archaic.engineering;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.tileentity.TileEntity;
import resonantinduction.core.render.RenderItemOverlayTile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderEngineeringTable extends RenderItemOverlayTile
{
private final RenderBlocks renderBlocks = new RenderBlocks();
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
{
if (tileEntity instanceof TileEngineeringTable)
{
TileEngineeringTable tile = (TileEngineeringTable) tileEntity;
renderItemOnSides(tileEntity, tile.getStackInSlot(9), x, y, z);
renderTopOverlay(tileEntity, tile.craftingMatrix, tile.getDirection(), x, y - 0.1, z);
}
}
}

View file

@ -1,6 +1,5 @@
package resonantinduction.archaic.engineering;
import java.util.Random;
import java.util.Set;
import net.minecraft.block.material.Material;
@ -18,17 +17,18 @@ import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.packet.Packet;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import org.apache.commons.lang3.ArrayUtils;
import org.lwjgl.opengl.GL11;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.Settings;
import resonantinduction.core.prefab.imprint.ItemImprint;
import resonantinduction.core.render.RenderItemOverlayTile;
import universalelectricity.api.vector.Vector2;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.content.module.TileBlock;
import calclavia.lib.content.module.TileRender;
import calclavia.lib.content.module.prefab.TileInventory;
import calclavia.lib.gui.ContainerDummy;
import calclavia.lib.network.IPacketReceiver;
@ -39,8 +39,8 @@ import calclavia.lib.prefab.tile.IRotatable;
import calclavia.lib.prefab.vector.Cuboid;
import calclavia.lib.utility.WorldUtility;
import calclavia.lib.utility.inventory.AutoCraftingManager;
import calclavia.lib.utility.inventory.InventoryUtility;
import calclavia.lib.utility.inventory.AutoCraftingManager.IAutoCrafter;
import calclavia.lib.utility.inventory.InventoryUtility;
import codechicken.multipart.ControlKeyModifer;
import com.builtbroken.common.Pair;
@ -80,9 +80,7 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv
private int[] playerSlots;
@SideOnly(Side.CLIENT)
private Icon iconTop;
@SideOnly(Side.CLIENT)
private Icon iconFront;
private static Icon iconTop, iconFront, iconSide;
public TileEngineeringTable()
{
@ -97,16 +95,16 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int meta)
{
return side == 1 ? iconTop : (side == meta ? iconFront : icon);
return side == 1 ? iconTop : (side == meta ? iconFront : iconSide);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
iconTop = iconRegister.registerIcon(this.getTextureName() + "_top");
iconFront = iconRegister.registerIcon(this.getTextureName() + "_front");
icon = iconRegister.registerIcon(this.getTextureName() + "_side");
iconTop = iconRegister.registerIcon(getTextureName() + "_top");
iconFront = iconRegister.registerIcon(getTextureName() + "_front");
iconSide = iconRegister.registerIcon(getTextureName() + "_side");
}
@Override
@ -154,7 +152,7 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv
Vector3 hitVector = new Vector3(hit.x, 0, hit.z);
final double regionLength = 1d / 3d;
// Rotate the hit vector baed on direction of the tile.
// Rotate the hit vector based on direction of the tile.
hitVector.translate(new Vector3(-0.5, 0, -0.5));
hitVector.rotate(WorldUtility.getAngleFromForgeDirection(getDirection()), Vector3.UP());
hitVector.translate(new Vector3(0.5, 0, 0.5));
@ -221,20 +219,25 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv
}
@Override
protected boolean configure(EntityPlayer player, int hitSide, Vector3 hit)
protected boolean configure(EntityPlayer player, int side, Vector3 hit)
{
searchInventories = !searchInventories;
if (!world().isRemote)
if (player.isSneaking())
{
if (searchInventories)
player.addChatMessage("Engineering table will now search for nearby inventories for resources.");
else
player.addChatMessage("Engineering table will not search for nearby inventories for resources.");
searchInventories = !searchInventories;
if (!world().isRemote)
{
if (searchInventories)
player.addChatMessage("Engineering table will now search for nearby inventories for resources.");
else
player.addChatMessage("Engineering table will not search for nearby inventories for resources.");
}
markUpdate();
return true;
}
markUpdate();
return true;
return super.configure(player, side, hit);
}
@Override
@ -305,7 +308,7 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv
{
try
{
this.readFromNBT(PacketHandler.readNBTTagCompound(data));
readFromNBT(PacketHandler.readNBTTagCompound(data));
}
catch (Exception e)
{
@ -753,4 +756,26 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv
return slots;
}
@Override
@SideOnly(Side.CLIENT)
protected TileRender newRenderer()
{
return new TileRender()
{
@Override
public boolean renderDynamic(Vector3 position, boolean isItem, float frame)
{
if (!isItem)
{
GL11.glPushMatrix();
RenderItemOverlayTile.renderItemOnSides(TileEngineeringTable.this, getStackInSlot(9), position.x, position.y, position.z);
RenderItemOverlayTile.renderTopOverlay(TileEngineeringTable.this, craftingMatrix, getDirection(), position.x, position.y - 0.1, position.z);
GL11.glPopMatrix();
}
return false;
}
};
}
}

View file

@ -9,7 +9,7 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
@ -19,7 +19,6 @@ import org.lwjgl.opengl.GL11;
import resonantinduction.api.IFilterable;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.prefab.imprint.ItemImprint;
import universalelectricity.api.UniversalElectricity;
import universalelectricity.api.vector.Vector3;
@ -136,7 +135,7 @@ public class TileSorter extends TileInventory
}
@SideOnly(Side.CLIENT)
protected TileRender renderer()
protected TileRender newRenderer()
{
return new TileRender()
{
@ -144,35 +143,39 @@ public class TileSorter extends TileInventory
final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "sorter.png");
@Override
public void renderDynamic(Vector3 position, float frame)
public boolean renderDynamic(Vector3 position, boolean isItem, float frame)
{
GL11.glPushMatrix();
RenderUtility.enableBlending();
GL11.glTranslated(position.x + 0.5, position.y + 0.5, position.z + 0.5);
RenderUtility.bind(TEXTURE);
for (int i = 0; i < TileSorter.this.getSizeInventory(); i++)
if (!isItem)
{
if (TileSorter.this.getStackInSlot(i) != null)
for (int i = 0; i < TileSorter.this.getSizeInventory(); i++)
{
ForgeDirection dir = ForgeDirection.getOrientation(i);
GL11.glPushMatrix();
if (TileSorter.this.getStackInSlot(i) != null)
{
ForgeDirection dir = ForgeDirection.getOrientation(i);
GL11.glPushMatrix();
if (dir.ordinal() == 0)
GL11.glRotatef(-90, 0, 0, 1);
if (dir.ordinal() == 0)
GL11.glRotatef(-90, 0, 0, 1);
if (dir.ordinal() == 1)
GL11.glRotatef(90, 0, 0, 1);
if (dir.ordinal() == 1)
GL11.glRotatef(90, 0, 0, 1);
RenderUtility.rotateBlockBasedOnDirection(dir);
MODEL.renderOnly("port");
GL11.glPopMatrix();
RenderUtility.rotateBlockBasedOnDirection(dir);
MODEL.renderOnly("port");
GL11.glPopMatrix();
}
}
}
MODEL.renderAllExcept("port");
RenderUtility.disableBlending();
GL11.glPopMatrix();
return true;
}
};

View file

@ -39,7 +39,7 @@ public abstract class RenderItemOverlayTile extends TileEntitySpecialRenderer
renderBlocks = new RenderBlocks();
}
public void renderTopOverlay(TileEntity tileEntity, ItemStack[] inventory, ForgeDirection dir, double x, double y, double z)
public static void renderTopOverlay(TileEntity tileEntity, ItemStack[] inventory, ForgeDirection dir, double x, double y, double z)
{
renderTopOverlay(tileEntity, inventory, dir, 3, 3, x, y, z, 0.7f);
}