Fixed sorter render and packets
This commit is contained in:
parent
7f490b260a
commit
eddc09c1cb
2 changed files with 64 additions and 25 deletions
|
@ -90,7 +90,7 @@ public class Mechanical
|
||||||
public static Block blockConveyorBelt;
|
public static Block blockConveyorBelt;
|
||||||
public static Block blockManipulator;
|
public static Block blockManipulator;
|
||||||
public static Block blockDetector;
|
public static Block blockDetector;
|
||||||
public static Block blockRejector;
|
// public static Block blockRejector;
|
||||||
public static Block blockSorter;
|
public static Block blockSorter;
|
||||||
|
|
||||||
// Fluids
|
// Fluids
|
||||||
|
@ -122,8 +122,8 @@ public class Mechanical
|
||||||
blockConveyorBelt = contentRegistry.createTile(BlockConveyorBelt.class, TileConveyorBelt.class);
|
blockConveyorBelt = contentRegistry.createTile(BlockConveyorBelt.class, TileConveyorBelt.class);
|
||||||
blockManipulator = contentRegistry.createTile(BlockManipulator.class, TileManipulator.class);
|
blockManipulator = contentRegistry.createTile(BlockManipulator.class, TileManipulator.class);
|
||||||
blockDetector = contentRegistry.createTile(BlockDetector.class, TileDetector.class);
|
blockDetector = contentRegistry.createTile(BlockDetector.class, TileDetector.class);
|
||||||
//blockRejector = contentRegistry.createTile(BlockRejector.class, TileRejector.class);
|
// blockRejector = contentRegistry.createTile(BlockRejector.class, TileRejector.class);
|
||||||
blockRejector = contentRegistry.newBlock(TileSorter.class);
|
blockSorter = contentRegistry.newBlock(TileSorter.class);
|
||||||
|
|
||||||
blockPump = contentRegistry.createTile(BlockPump.class, TilePump.class);
|
blockPump = contentRegistry.createTile(BlockPump.class, TilePump.class);
|
||||||
|
|
||||||
|
@ -142,6 +142,7 @@ public class Mechanical
|
||||||
|
|
||||||
PacketAnnotation.register(TileWindTurbine.class);
|
PacketAnnotation.register(TileWindTurbine.class);
|
||||||
PacketAnnotation.register(TileWaterTurbine.class);
|
PacketAnnotation.register(TileWaterTurbine.class);
|
||||||
|
PacketAnnotation.register(TileSorter.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -165,7 +166,9 @@ public class Mechanical
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockConveyorBelt, 4), "III", "GGG", 'I', Item.ingotIron, 'G', itemGear));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockConveyorBelt, 4), "III", "GGG", 'I', Item.ingotIron, 'G', itemGear));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockManipulator, "SSS", "SRS", "SCS", 'S', Item.ingotIron, 'C', blockConveyorBelt, 'R', Block.blockRedstone));
|
GameRegistry.addRecipe(new ShapedOreRecipe(blockManipulator, "SSS", "SRS", "SCS", 'S', Item.ingotIron, 'C', blockConveyorBelt, 'R', Block.blockRedstone));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockDetector, "SWS", "SRS", "SWS", 'S', Item.ingotIron, 'W', UniversalRecipe.WIRE.get()));
|
GameRegistry.addRecipe(new ShapedOreRecipe(blockDetector, "SWS", "SRS", "SWS", 'S', Item.ingotIron, 'W', UniversalRecipe.WIRE.get()));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockRejector, "S S", "SPS", "SRS", 'P', Block.pistonBase, 'S', Item.ingotIron, 'R', Item.redstone));
|
// GameRegistry.addRecipe(new ShapedOreRecipe(blockRejector, "S S", "SPS", "SRS", 'P',
|
||||||
|
// Block.pistonBase, 'S', Item.ingotIron, 'R', Item.redstone));
|
||||||
|
GameRegistry.addRecipe(new ShapedOreRecipe(blockSorter, "SSS", "SPS", "SRS", 'P', Block.pistonStickyBase, 'S', Item.ingotIron, 'R', Block.blockRedstone));
|
||||||
|
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWindTurbine, 1, 0), "CWC", "WGW", "CWC", 'G', itemGear, 'C', Block.cloth, 'W', Item.stick));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWindTurbine, 1, 0), "CWC", "WGW", "CWC", 'G', itemGear, 'C', Block.cloth, 'W', Item.stick));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWindTurbine, 1, 1), "CWC", "WGW", "CWC", 'G', new ItemStack(blockWindTurbine, 1, 0), 'C', Block.stone, 'W', Item.stick));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWindTurbine, 1, 1), "CWC", "WGW", "CWC", 'G', new ItemStack(blockWindTurbine, 1, 0), 'C', Block.stone, 'W', Item.stick));
|
||||||
|
|
|
@ -3,11 +3,13 @@ package resonantinduction.mechanical.logistic.belt;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.network.packet.Packet;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||||
import net.minecraftforge.client.model.IModelCustom;
|
import net.minecraftforge.client.model.IModelCustom;
|
||||||
|
@ -17,11 +19,14 @@ import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import resonantinduction.api.IFilterable;
|
import resonantinduction.api.IFilterable;
|
||||||
import resonantinduction.core.Reference;
|
import resonantinduction.core.Reference;
|
||||||
|
import resonantinduction.core.ResonantInduction;
|
||||||
import resonantinduction.core.prefab.imprint.ItemImprint;
|
import resonantinduction.core.prefab.imprint.ItemImprint;
|
||||||
import universalelectricity.api.UniversalElectricity;
|
import universalelectricity.api.UniversalElectricity;
|
||||||
import universalelectricity.api.vector.Vector3;
|
import universalelectricity.api.vector.Vector3;
|
||||||
import calclavia.lib.content.module.TileRender;
|
import calclavia.lib.content.module.TileRender;
|
||||||
import calclavia.lib.content.module.prefab.TileInventory;
|
import calclavia.lib.content.module.prefab.TileInventory;
|
||||||
|
import calclavia.lib.network.Synced.SyncedInput;
|
||||||
|
import calclavia.lib.network.Synced.SyncedOutput;
|
||||||
import calclavia.lib.prefab.vector.Cuboid;
|
import calclavia.lib.prefab.vector.Cuboid;
|
||||||
import calclavia.lib.render.RenderUtility;
|
import calclavia.lib.render.RenderUtility;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
@ -53,7 +58,7 @@ public class TileSorter extends TileInventory
|
||||||
|
|
||||||
if (world().isRemote)
|
if (world().isRemote)
|
||||||
{
|
{
|
||||||
player.addChatMessage("Sorter filter inversion: " + isInverted);
|
player.addChatMessage("Sorter filter inversion: " + !isInverted);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -68,33 +73,42 @@ public class TileSorter extends TileInventory
|
||||||
@Override
|
@Override
|
||||||
public void collide(Entity entity)
|
public void collide(Entity entity)
|
||||||
{
|
{
|
||||||
if (entity instanceof EntityItem)
|
if (!world().isRemote)
|
||||||
{
|
{
|
||||||
EntityItem entityItem = (EntityItem) entity;
|
if (entity instanceof EntityItem)
|
||||||
List<ForgeDirection> possibleDirections = new ArrayList<ForgeDirection>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Move item to position where a filter allows it.
|
|
||||||
*/
|
|
||||||
for (int i = 0; i < getSizeInventory(); i++)
|
|
||||||
{
|
{
|
||||||
ItemStack stack = getStackInSlot(i);
|
EntityItem entityItem = (EntityItem) entity;
|
||||||
|
List<ForgeDirection> possibleDirections = new ArrayList<ForgeDirection>();
|
||||||
|
|
||||||
if (isInverted == ItemImprint.isFiltering(stack, entityItem.getEntityItem()))
|
/**
|
||||||
|
* Move item to position where a filter allows it.
|
||||||
|
*/
|
||||||
|
for (int i = 0; i < getSizeInventory(); i++)
|
||||||
{
|
{
|
||||||
possibleDirections.add(ForgeDirection.getOrientation(i));
|
ItemStack stack = getStackInSlot(i);
|
||||||
|
|
||||||
|
if (isInverted == ItemImprint.isFiltering(stack, entityItem.getEntityItem()))
|
||||||
|
{
|
||||||
|
ForgeDirection dir = ForgeDirection.getOrientation(i);
|
||||||
|
|
||||||
|
int blockID = position().translate(dir).getBlockID(world());
|
||||||
|
Block block = Block.blocksList[blockID];
|
||||||
|
|
||||||
|
if (block == null || block.isNormalCube(blockID))
|
||||||
|
{
|
||||||
|
possibleDirections.add(dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int size = possibleDirections.size();
|
int size = possibleDirections.size();
|
||||||
|
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
ForgeDirection dir = possibleDirections.get(size > 1 ? world().rand.nextInt(size - 1) : 0);
|
ForgeDirection dir = possibleDirections.get(size > 1 ? world().rand.nextInt(size - 1) : 0);
|
||||||
Vector3 set = center().translate(dir, 0.9);
|
Vector3 set = center().translate(dir, 1);
|
||||||
entityItem.posX = set.x;
|
entityItem.setPosition(set.x, set.y, set.z);
|
||||||
entityItem.posY = set.y;
|
}
|
||||||
entityItem.posZ = set.z;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,6 +119,7 @@ public class TileSorter extends TileInventory
|
||||||
return Cuboid.full();
|
return Cuboid.full();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SyncedInput
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbt)
|
public void readFromNBT(NBTTagCompound nbt)
|
||||||
{
|
{
|
||||||
|
@ -112,6 +127,7 @@ public class TileSorter extends TileInventory
|
||||||
nbt.getBoolean("isInverted");
|
nbt.getBoolean("isInverted");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SyncedOutput
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbt)
|
public void writeToNBT(NBTTagCompound nbt)
|
||||||
{
|
{
|
||||||
|
@ -134,6 +150,26 @@ public class TileSorter extends TileInventory
|
||||||
RenderUtility.enableBlending();
|
RenderUtility.enableBlending();
|
||||||
GL11.glTranslated(position.x + 0.5, position.y + 0.5, position.z + 0.5);
|
GL11.glTranslated(position.x + 0.5, position.y + 0.5, position.z + 0.5);
|
||||||
RenderUtility.bind(TEXTURE);
|
RenderUtility.bind(TEXTURE);
|
||||||
|
|
||||||
|
for (int i = 0; i < TileSorter.this.getSizeInventory(); i++)
|
||||||
|
{
|
||||||
|
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() == 1)
|
||||||
|
GL11.glRotatef(90, 0, 0, 1);
|
||||||
|
|
||||||
|
RenderUtility.rotateBlockBasedOnDirection(dir);
|
||||||
|
MODEL.renderOnly("port");
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MODEL.renderAllExcept("port");
|
MODEL.renderAllExcept("port");
|
||||||
RenderUtility.disableBlending();
|
RenderUtility.disableBlending();
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
|
Loading…
Reference in a new issue