Flatten item conduits in prep for review and merge.
No files matched your search
@@ -15,13 +15,14 @@ import crazypants.enderio.conduit.BlockConduitBundle;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.TileConduitBundle;
|
||||
import crazypants.enderio.conduit.facade.FacadeRenderer;
|
||||
import crazypants.enderio.conduit.item.ItemConduit;
|
||||
import crazypants.enderio.conduit.liquid.LiquidConduit;
|
||||
import crazypants.enderio.conduit.liquid.LiquidConduitRenderer;
|
||||
import crazypants.enderio.conduit.power.PowerConduit;
|
||||
import crazypants.enderio.conduit.power.PowerConduitRenderer;
|
||||
import crazypants.enderio.conduit.redstone.InsulatedRedstoneConduit;
|
||||
import crazypants.enderio.conduit.redstone.RedstoneConduit;
|
||||
import crazypants.enderio.conduit.redstone.InsulatedRedstoneConduitRenderer;
|
||||
import crazypants.enderio.conduit.redstone.RedstoneConduit;
|
||||
import crazypants.enderio.conduit.redstone.RedstoneSwitch;
|
||||
import crazypants.enderio.conduit.redstone.RedstoneSwitchRenderer;
|
||||
import crazypants.enderio.conduit.render.ConduitBundleRenderer;
|
||||
@@ -67,12 +68,15 @@ public class ClientProxy extends CommonProxy {
|
||||
RedstoneSwitch.initIcons();
|
||||
PowerConduit.initIcons();
|
||||
LiquidConduit.initIcons();
|
||||
ItemConduit.initIcons();
|
||||
}
|
||||
|
||||
private List<ConduitRenderer> conduitRenderers = new ArrayList<ConduitRenderer>();
|
||||
|
||||
private DefaultConduitRenderer dcr = new DefaultConduitRenderer();
|
||||
|
||||
private ConduitBundleRenderer cbr;
|
||||
|
||||
@Override
|
||||
public World getClientWorld() {
|
||||
return FMLClientHandler.instance().getClient().theWorld;
|
||||
@@ -83,13 +87,21 @@ public class ClientProxy extends CommonProxy {
|
||||
return Minecraft.getMinecraft().thePlayer;
|
||||
}
|
||||
|
||||
public ConduitBundleRenderer getConduitBundleRenderer() {
|
||||
return cbr;
|
||||
}
|
||||
|
||||
public void setCbr(ConduitBundleRenderer cbr) {
|
||||
this.cbr = cbr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
// Renderers
|
||||
|
||||
ConduitBundleRenderer cbr = new ConduitBundleRenderer((float) Config.conduitScale);
|
||||
cbr = new ConduitBundleRenderer((float) Config.conduitScale);
|
||||
BlockConduitBundle.rendererId = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderingRegistry.registerBlockHandler(cbr);
|
||||
|
||||
@@ -114,6 +126,7 @@ public class ClientProxy extends CommonProxy {
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.itemLiquidConduit.itemID, itemConRenderer);
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.itemPowerConduit.itemID, itemConRenderer);
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.itemRedstoneConduit.itemID, itemConRenderer);
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.itemItemConduit.itemID, itemConRenderer);
|
||||
|
||||
PaintedItemRenderer pir = new PaintedItemRenderer();
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.blockCustomFence.blockID, pir);
|
||||
@@ -131,6 +144,7 @@ public class ClientProxy extends CommonProxy {
|
||||
conduitRenderers.add(new LiquidConduitRenderer());
|
||||
conduitRenderers.add(new PowerConduitRenderer());
|
||||
conduitRenderers.add(new InsulatedRedstoneConduitRenderer());
|
||||
conduitRenderers.add(new crazypants.enderio.conduit.item.ItemConduitRenderer());
|
||||
|
||||
EnderIoRenderer eior = new EnderIoRenderer();
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEnderIO.class, eior);
|
||||
|
||||
@@ -40,9 +40,13 @@ public final class Config {
|
||||
public static boolean useHardRecipes = false;
|
||||
|
||||
public static boolean detailedPowerTrackingEnabled = true;
|
||||
|
||||
|
||||
public static double maxPhotovoltaicOutput = 1.0;
|
||||
|
||||
public static boolean useSneakMouseWheelYetaWrench = true;
|
||||
|
||||
public static boolean useSneakRightClickYetaWrench = false;
|
||||
|
||||
public static void load(FMLPreInitializationEvent event) {
|
||||
configDirectory = new File(event.getModConfigurationDirectory(), "enderio");
|
||||
if(!configDirectory.exists()) {
|
||||
@@ -91,7 +95,7 @@ public final class Config {
|
||||
|
||||
maxPhotovoltaicOutput = config.get("Settings", "maxPhotovoltaicOutput", maxPhotovoltaicOutput,
|
||||
"Maximum output in MJ/t of the Photovoltaic Panels.").getDouble(maxPhotovoltaicOutput);
|
||||
|
||||
|
||||
useAlternateBinderRecipe = config.get("Settings", "useAlternateBinderRecipe", false, "Create conduit binder in crafting table instead of furnace")
|
||||
.getBoolean(useAlternateBinderRecipe);
|
||||
|
||||
@@ -115,8 +119,19 @@ public final class Config {
|
||||
detailedPowerTrackingEnabled = config.get("Settings", "detailedPowerTrackingEnabled", detailedPowerTrackingEnabled,
|
||||
"Enable per tick sampling on individual power inputs and outputs")
|
||||
.getBoolean(detailedPowerTrackingEnabled);
|
||||
|
||||
|
||||
|
||||
useSneakMouseWheelYetaWrench = config.get("Settings", "useSneakMouseWheelYetaWrench", useSneakMouseWheelYetaWrench,
|
||||
"If true, shift-mouse wheel will change the conduit display mode when the YetaWrench is eqipped.")
|
||||
.getBoolean(useSneakMouseWheelYetaWrench);
|
||||
|
||||
useSneakRightClickYetaWrench = config.get("Settings", "useSneakRightClickYetaWrench", useSneakRightClickYetaWrench,
|
||||
"If true, shift-clicking the YetaWrench on a null or non wrenchable object will change the conduit display mode.")
|
||||
.getBoolean(useSneakRightClickYetaWrench);
|
||||
|
||||
if(!useSneakMouseWheelYetaWrench && !useSneakRightClickYetaWrench) {
|
||||
Log.warn("Both useSneakMouseWheelYetaWrench and useSneakRightClickYetaWrench are set to false. Enabling mouse wheel.");
|
||||
useSneakMouseWheelYetaWrench = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -19,12 +19,15 @@ import crazypants.enderio.conduit.ConduitRecipes;
|
||||
import crazypants.enderio.conduit.facade.BlockConduitFacade;
|
||||
import crazypants.enderio.conduit.facade.ItemConduitFacade;
|
||||
import crazypants.enderio.conduit.geom.ConduitGeometryUtil;
|
||||
import crazypants.enderio.conduit.item.ItemItemConduit;
|
||||
import crazypants.enderio.conduit.liquid.ItemLiquidConduit;
|
||||
import crazypants.enderio.conduit.power.ItemPowerConduit;
|
||||
import crazypants.enderio.conduit.redstone.ItemRedstoneConduit;
|
||||
import crazypants.enderio.enderface.BlockEnderIO;
|
||||
import crazypants.enderio.enderface.EnderfaceRecipes;
|
||||
import crazypants.enderio.enderface.ItemEnderface;
|
||||
import crazypants.enderio.item.ItemRecipes;
|
||||
import crazypants.enderio.item.ItemYetaWrench;
|
||||
import crazypants.enderio.machine.MachineRecipeRegistry;
|
||||
import crazypants.enderio.machine.MachineRecipes;
|
||||
import crazypants.enderio.machine.RedstoneModePacketProcessor;
|
||||
@@ -55,7 +58,6 @@ import crazypants.enderio.material.ItemFusedQuartzFrame;
|
||||
import crazypants.enderio.material.ItemMachinePart;
|
||||
import crazypants.enderio.material.ItemMaterial;
|
||||
import crazypants.enderio.material.ItemPowderIngot;
|
||||
import crazypants.enderio.material.ItemYetaWrench;
|
||||
import crazypants.enderio.material.MaterialRecipes;
|
||||
import crazypants.enderio.trigger.TriggerEnderIO;
|
||||
import crazypants.enderio.trigger.TriggerProviderEIO;
|
||||
@@ -101,6 +103,7 @@ public class EnderIO {
|
||||
public static ItemRedstoneConduit itemRedstoneConduit;
|
||||
public static ItemPowerConduit itemPowerConduit;
|
||||
public static ItemLiquidConduit itemLiquidConduit;
|
||||
public static ItemItemConduit itemItemConduit;
|
||||
|
||||
// Machines
|
||||
public static BlockStirlingGenerator blockStirlingGenerator;
|
||||
@@ -169,6 +172,7 @@ public class EnderIO {
|
||||
itemRedstoneConduit = ItemRedstoneConduit.create();
|
||||
itemPowerConduit = ItemPowerConduit.create();
|
||||
itemLiquidConduit = ItemLiquidConduit.create();
|
||||
itemItemConduit = ItemItemConduit.create();
|
||||
|
||||
blockElectricLight = BlockElectricLight.create();
|
||||
blockLightNode = BlockLightNode.create();
|
||||
@@ -193,6 +197,7 @@ public class EnderIO {
|
||||
MaterialRecipes.addRecipes();
|
||||
ConduitRecipes.addRecipes();
|
||||
MachineRecipes.addRecipes();
|
||||
ItemRecipes.addRecipes();
|
||||
|
||||
triggerNoEnergy = new TriggerEnderIO("enderIO.trigger.noEnergy", 0);
|
||||
triggerHasEnergy = new TriggerEnderIO("enderIO.trigger.hasEnergy", 1);
|
||||
|
||||
@@ -62,7 +62,9 @@ public enum ModObject {
|
||||
itemMJReader(++Config.IID, CATEGORY_ITEM, "MJ Reader"),
|
||||
itemMaterial(++Config.IID, CATEGORY_ITEM, "Materials"),
|
||||
|
||||
blockPowerMonitor(++Config.BID, CATEGORY_BLOCK, "Power Monitor");
|
||||
blockPowerMonitor(++Config.BID, CATEGORY_BLOCK, "Power Monitor"),
|
||||
|
||||
itemItemConduit(++Config.IID, CATEGORY_ITEM, "Item Conduit");
|
||||
|
||||
public final String unlocalisedName;
|
||||
public final String name;
|
||||
|
||||
@@ -55,6 +55,8 @@ public class PacketHandler implements IPacketHandler {
|
||||
public static final int ID_MJ_READER_INFO_REQUEST = 12;
|
||||
public static final int ID_POWER_MONITOR_PACKET = 13;
|
||||
|
||||
public static final int ID_YETA_WRENCH_MODE_PACKET = 14;
|
||||
|
||||
public static final String CHANNEL = "EnderIO";
|
||||
|
||||
public static PacketHandler instance;
|
||||
|
||||
@@ -58,11 +58,15 @@ public abstract class AbstractConduit implements IConduit {
|
||||
public ConnectionMode getConectionMode(ForgeDirection dir) {
|
||||
ConnectionMode res = conectionModes.get(dir);
|
||||
if(res == null) {
|
||||
return ConnectionMode.IN_OUT;
|
||||
return getDefaultConnectionMode();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
protected ConnectionMode getDefaultConnectionMode() {
|
||||
return ConnectionMode.IN_OUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConnectionMode(ForgeDirection dir, ConnectionMode mode) {
|
||||
ConnectionMode oldVal = conectionModes.get(dir);
|
||||
@@ -171,6 +175,16 @@ public abstract class AbstractConduit implements IConduit {
|
||||
return !externalConnections.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConnections() {
|
||||
return hasConduitConnections() || hasExternalConnections();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConduitConnections() {
|
||||
return !conduitConnections.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsExternalConnection(ForgeDirection dir) {
|
||||
return externalConnections.contains(dir);
|
||||
|
||||
@@ -534,31 +534,59 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
boolean result = false;
|
||||
// if its a connector pass the event on to all conduits
|
||||
for (IConduit con : bundle.getConduits()) {
|
||||
if(con.onBlockActivated(player, closest, all)) {
|
||||
if(ConduitUtil.renderConduit(player, con.getCollidableType()) && con.onBlockActivated(player, getHitForConduitType(all, con.getCollidableType()), all)) {
|
||||
bundle.getEntity().onInventoryChanged();
|
||||
result = true;
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
if(result) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(closest == null || closest.component == null || closest.component.conduitType ==
|
||||
null) {
|
||||
null && all == null) {
|
||||
// Nothing of interest hit
|
||||
return false;
|
||||
}
|
||||
|
||||
// Conduit specific actions
|
||||
if(bundle.getConduit(closest.component.conduitType) != null && bundle.getConduit(closest.component.conduitType).onBlockActivated(player,
|
||||
closest, all)) {
|
||||
bundle.getEntity().onInventoryChanged();
|
||||
return true;
|
||||
if(all != null) {
|
||||
RaytraceResult.sort(getEyePosition(world, player), all);
|
||||
for (RaytraceResult rr : all) {
|
||||
if(ConduitUtil.renderConduit(player, rr.component.conduitType) && !(rr.component.data instanceof
|
||||
ConduitConnectorType)) {
|
||||
|
||||
IConduit con = bundle.getConduit(rr.component.conduitType);
|
||||
if(con != null && con.onBlockActivated(player,
|
||||
rr, all)) {
|
||||
bundle.getEntity().onInventoryChanged();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IConduit closestConduit = bundle.getConduit(closest.component.conduitType);
|
||||
if(closestConduit != null && ConduitUtil.renderConduit(player, closestConduit) && closestConduit.onBlockActivated(player,
|
||||
closest, all)) {
|
||||
bundle.getEntity().onInventoryChanged();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private RaytraceResult getHitForConduitType(List<RaytraceResult> all, Class<? extends IConduit> collidableType) {
|
||||
for (RaytraceResult rr : all) {
|
||||
if(rr.component != null && rr.component.conduitType == collidableType) {
|
||||
return rr;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int
|
||||
blockId) {
|
||||
@@ -656,13 +684,18 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
if(allHits == null) {
|
||||
return null;
|
||||
}
|
||||
Vec3 origin = getEyePosition(world, entityPlayer);
|
||||
return RaytraceResult.getClosestHit(origin, allHits);
|
||||
}
|
||||
|
||||
private Vec3 getEyePosition(World world, EntityPlayer entityPlayer) {
|
||||
double posY = entityPlayer.posY + 1.62 - entityPlayer.yOffset;
|
||||
if(!world.isRemote && entityPlayer.isSneaking()) {
|
||||
posY -= 0.08;
|
||||
}
|
||||
Vec3 origin = Vec3.fakePool.getVecFromPool(entityPlayer.posX, posY,
|
||||
entityPlayer.posZ);
|
||||
return RaytraceResult.getClosestHit(origin, allHits);
|
||||
return origin;
|
||||
}
|
||||
|
||||
public List<RaytraceResult> doRayTraceAll(World world, int x, int y, int z,
|
||||
@@ -676,12 +709,7 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
|
||||
double reachDistance = EnderIO.proxy.getReachDistanceForPlayer(entityPlayer);
|
||||
|
||||
double posY = entityPlayer.posY + 1.62 - entityPlayer.yOffset;
|
||||
if(!world.isRemote && entityPlayer.isSneaking()) {
|
||||
posY -= 0.08;
|
||||
}
|
||||
Vec3 origin = Vec3.fakePool.getVecFromPool(entityPlayer.posX, posY,
|
||||
entityPlayer.posZ);
|
||||
Vec3 origin = getEyePosition(world, entityPlayer);
|
||||
Vec3 direction = origin.addVector(dirX * reachDistance, dirY *
|
||||
reachDistance, dirZ * reachDistance);
|
||||
return doRayTraceAll(world, x, y, z, origin, direction,
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package crazypants.enderio.conduit;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
public enum ConduitDisplayMode {
|
||||
ALL,
|
||||
POWER,
|
||||
REDSTONE,
|
||||
ITEM,
|
||||
FLUID;
|
||||
|
||||
public static ConduitDisplayMode next(ConduitDisplayMode mode) {
|
||||
int index = mode.ordinal() + 1;
|
||||
if(index >= values().length) {
|
||||
index = 0;
|
||||
}
|
||||
return values()[index];
|
||||
}
|
||||
|
||||
public static ConduitDisplayMode previous(ConduitDisplayMode mode) {
|
||||
int index = mode.ordinal() - 1;
|
||||
if(index < 0) {
|
||||
index = values().length - 1;
|
||||
}
|
||||
return values()[index];
|
||||
}
|
||||
|
||||
public static ConduitDisplayMode getDisplayMode(ItemStack equipped) {
|
||||
int index = equipped.getItemDamage();
|
||||
index = MathHelper.clamp_int(index, 0, ConduitDisplayMode.values().length);
|
||||
return ConduitDisplayMode.values()[index];
|
||||
}
|
||||
|
||||
public static void setDisplayMode(ItemStack equipped, ConduitDisplayMode mode) {
|
||||
if(mode == null || equipped == null) {
|
||||
return;
|
||||
}
|
||||
int index = mode.ordinal();
|
||||
index = MathHelper.clamp_int(index, 0, ConduitDisplayMode.values().length);
|
||||
equipped.setItemDamage(index);
|
||||
}
|
||||
|
||||
public ConduitDisplayMode next() {
|
||||
return next(this);
|
||||
}
|
||||
|
||||
public ConduitDisplayMode previous() {
|
||||
return previous(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,10 +2,12 @@ package crazypants.enderio.conduit;
|
||||
|
||||
import static crazypants.enderio.ModObject.blockPainter;
|
||||
import static crazypants.enderio.ModObject.itemConduitFacade;
|
||||
import static crazypants.enderio.ModObject.itemItemConduit;
|
||||
import static crazypants.enderio.ModObject.itemLiquidConduit;
|
||||
import static crazypants.enderio.ModObject.itemPowerConduit;
|
||||
import static crazypants.enderio.ModObject.itemRedstoneConduit;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import crazypants.enderio.Config;
|
||||
@@ -25,8 +27,10 @@ public class ConduitRecipes {
|
||||
ItemStack fusedQuartz = new ItemStack(ModObject.blockFusedQuartz.actualId, 1, 0);
|
||||
ItemStack conductiveIron = new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.CONDUCTIVE_IRON.ordinal());
|
||||
ItemStack energeticGold = new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.ENERGETIC_ALLOY.ordinal());
|
||||
ItemStack phasedIron = new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.PHASED_GOLD.ordinal());
|
||||
ItemStack phasedGold = new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.PHASED_GOLD.ordinal());
|
||||
ItemStack phasedIron = new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.PHASED_IRON.ordinal());
|
||||
ItemStack redstoneAlloy = new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.REDSTONE_ALLOY.ordinal());
|
||||
ItemStack electricalSteel = new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.ELECTRICAL_STEEL.ordinal());
|
||||
|
||||
//Recipes
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemConduitFacade.actualId, 1, 0), "bbb", "b b", "bbb", 'b', conduitBinder);
|
||||
@@ -34,15 +38,19 @@ public class ConduitRecipes {
|
||||
int numConduits = Config.numConduitsPerRecipe;
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemLiquidConduit.actualId, numConduits, 0), "bbb", "###", "bbb", 'b', conduitBinder, '#', fusedQuartz);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemPowerConduit.actualId, numConduits, 0), "bbb", "###", "bbb", 'b', conduitBinder, '#', conductiveIron);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemPowerConduit.actualId, numConduits, 1), "bbb", "###", "bbb", 'b', conduitBinder, 'f', fusedQuartz, '#',
|
||||
energeticGold);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemPowerConduit.actualId, numConduits, 2), "bbb", "###", "bbb", 'b', conduitBinder, '#', phasedIron);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemRedstoneConduit.actualId, numConduits, 0), " ", "###", " ", 'b', conduitBinder, 'f', fusedQuartz, '#',
|
||||
redstoneAlloy);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemPowerConduit.actualId, numConduits, 1), "bbb", "###", "bbb", 'b', conduitBinder, '#', energeticGold);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemPowerConduit.actualId, numConduits, 2), "bbb", "###", "bbb", 'b', conduitBinder, '#', phasedGold);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemRedstoneConduit.actualId, numConduits, 0), " ", "###", " ", 'b', conduitBinder, '#', redstoneAlloy);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemRedstoneConduit.actualId, 1, 1), "lbl", "bcb", "lbl", 'b', conduitBinder, 'c', redstoneConduit, 'l',
|
||||
Block.lever);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemRedstoneConduit.actualId, numConduits, 2), "bbb", "###", "bbb", 'b', conduitBinder, 'f', fusedQuartz, '#',
|
||||
redstoneAlloy);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemRedstoneConduit.actualId, numConduits, 2), "bbb", "###", "bbb", 'b', conduitBinder, '#', redstoneAlloy);
|
||||
|
||||
ItemStack itemConduit = new ItemStack(itemItemConduit.actualId, numConduits, 0);
|
||||
GameRegistry.addShapedRecipe(itemConduit, "bbb", "###", "bbb", 'b', conduitBinder, '#', phasedIron);
|
||||
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemItemConduit.actualId, 2, 1), "sis", "ehe", "sis", 's', electricalSteel, 'i', itemConduit, 'e',
|
||||
new ItemStack(Item.emerald), 'h', new ItemStack(Block.hopperBlock));
|
||||
|
||||
MachineRecipeRegistry.instance.registerRecipe(blockPainter.unlocalisedName, new FacadePainterRecipe());
|
||||
|
||||
}
|
||||
|
||||
@@ -18,11 +18,15 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.IConduitBundle.FacadeRenderState;
|
||||
import crazypants.enderio.conduit.item.IItemConduit;
|
||||
import crazypants.enderio.conduit.item.ItemConduitNetwork;
|
||||
import crazypants.enderio.conduit.liquid.ILiquidConduit;
|
||||
import crazypants.enderio.conduit.liquid.LiquidConduitNetwork;
|
||||
import crazypants.enderio.conduit.power.IPowerConduit;
|
||||
import crazypants.enderio.conduit.power.PowerConduitNetwork;
|
||||
import crazypants.enderio.conduit.redstone.IInsulatedRedstoneConduit;
|
||||
import crazypants.enderio.conduit.redstone.IRedstoneConduit;
|
||||
import crazypants.enderio.conduit.redstone.RedstoneConduitNetwork;
|
||||
|
||||
@@ -37,6 +41,8 @@ public class ConduitUtil {
|
||||
return new PowerConduitNetwork();
|
||||
} else if(ILiquidConduit.class.isAssignableFrom(type)) {
|
||||
return new LiquidConduitNetwork();
|
||||
} else if(IItemConduit.class.isAssignableFrom(type)) {
|
||||
return new ItemConduitNetwork();
|
||||
}
|
||||
FMLCommonHandler.instance().raiseException(new Exception("Could not determine network type for class " + type), "ConduitUtil.createNetworkForType", false);
|
||||
return null;
|
||||
@@ -96,6 +102,54 @@ public class ConduitUtil {
|
||||
return bundle.getFacadeId() > 0 && (isToolEquipped(player) || isConduitEquipped(player));
|
||||
}
|
||||
|
||||
public static ConduitDisplayMode getDisplayMode(EntityPlayer player) {
|
||||
player = player == null ? EnderIO.proxy.getClientPlayer() : player;
|
||||
if(player == null) {
|
||||
return ConduitDisplayMode.ALL;
|
||||
}
|
||||
ItemStack equipped = player.getCurrentEquippedItem();
|
||||
if(equipped == null) {
|
||||
return ConduitDisplayMode.ALL;
|
||||
}
|
||||
if(equipped.itemID != ModObject.itemYetaWrench.actualId) {
|
||||
return ConduitDisplayMode.ALL;
|
||||
}
|
||||
ConduitDisplayMode result = ConduitDisplayMode.getDisplayMode(equipped);
|
||||
if(result == null) {
|
||||
return ConduitDisplayMode.ALL;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static boolean renderConduit(EntityPlayer player, IConduit con) {
|
||||
if(player == null || con == null) {
|
||||
return true;
|
||||
}
|
||||
return renderConduit(player, con.getBaseConduitType());
|
||||
}
|
||||
|
||||
public static boolean renderConduit(EntityPlayer player, Class<? extends IConduit> conduitType) {
|
||||
if(player == null || conduitType == null) {
|
||||
return true;
|
||||
}
|
||||
ConduitDisplayMode mode = getDisplayMode(player);
|
||||
switch (mode) {
|
||||
case ALL:
|
||||
return true;
|
||||
case FLUID:
|
||||
return conduitType == ILiquidConduit.class;
|
||||
case ITEM:
|
||||
return conduitType == IItemConduit.class;
|
||||
case POWER:
|
||||
return conduitType == IPowerConduit.class;
|
||||
case REDSTONE:
|
||||
return conduitType == IRedstoneConduit.class || conduitType == IInsulatedRedstoneConduit.class;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isConduitEquipped(EntityPlayer player) {
|
||||
player = player == null ? EnderIO.proxy.getClientPlayer() : player;
|
||||
if(player == null) {
|
||||
|
||||
@@ -43,6 +43,13 @@ public interface IConduit {
|
||||
|
||||
BlockCoord getLocation();
|
||||
|
||||
// Conections
|
||||
boolean hasConnections();
|
||||
|
||||
boolean hasExternalConnections();
|
||||
|
||||
boolean hasConduitConnections();
|
||||
|
||||
// Conduit Connections
|
||||
|
||||
boolean canConnectToConduit(ForgeDirection direction, IConduit conduit);
|
||||
@@ -67,8 +74,6 @@ public interface IConduit {
|
||||
|
||||
boolean containsExternalConnection(ForgeDirection dir);
|
||||
|
||||
boolean hasExternalConnections();
|
||||
|
||||
void externalConnectionAdded(ForgeDirection fromDirection);
|
||||
|
||||
void externalConnectionRemoved(ForgeDirection fromDirection);
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package crazypants.enderio.conduit;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
@@ -25,6 +28,18 @@ public class RaytraceResult {
|
||||
return closest;
|
||||
}
|
||||
|
||||
public static void sort(final Vec3 origin, List<RaytraceResult> toSort) {
|
||||
if(origin == null || toSort == null) {
|
||||
Collections.sort(toSort, new Comparator<RaytraceResult>() {
|
||||
|
||||
@Override
|
||||
public int compare(RaytraceResult o1, RaytraceResult o2) {
|
||||
return Double.compare(o1.getDistanceTo(origin), o1.getDistanceTo(origin));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public final CollidableComponent component;
|
||||
public final MovingObjectPosition movingObjectPosition;
|
||||
|
||||
@@ -33,4 +48,11 @@ public class RaytraceResult {
|
||||
this.movingObjectPosition = movingObjectPosition;
|
||||
}
|
||||
|
||||
public double getDistanceTo(Vec3 origin) {
|
||||
if(movingObjectPosition == null || origin == null) {
|
||||
return Double.MAX_VALUE;
|
||||
}
|
||||
return movingObjectPosition.hitVec.squareDistanceTo(origin);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,11 +24,13 @@ import crazypants.enderio.PacketHandler;
|
||||
import crazypants.enderio.conduit.geom.CollidableCache;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.conduit.geom.ConduitConnectorType;
|
||||
import crazypants.enderio.conduit.geom.ConduitGeometryUtil;
|
||||
import crazypants.enderio.conduit.geom.Offset;
|
||||
import crazypants.enderio.conduit.geom.Offsets;
|
||||
import crazypants.enderio.conduit.geom.Offsets.Axis;
|
||||
import crazypants.enderio.conduit.liquid.ILiquidConduit;
|
||||
import crazypants.enderio.conduit.power.IPowerConduit;
|
||||
import crazypants.enderio.conduit.redstone.InsulatedRedstoneConduit;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
@@ -42,8 +44,11 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
|
||||
private final List<CollidableComponent> cachedCollidables = new ArrayList<CollidableComponent>();
|
||||
|
||||
private final List<CollidableComponent> cachedConnectors = new ArrayList<CollidableComponent>();
|
||||
|
||||
private boolean conduitsDirty = true;
|
||||
private boolean collidablesDirty = true;
|
||||
private boolean connectorsDirty = true;
|
||||
|
||||
private int lightOpacity = 0;
|
||||
|
||||
@@ -308,26 +313,10 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
|
||||
@Override
|
||||
public Offset getOffset(Class<? extends IConduit> type, ForgeDirection dir) {
|
||||
|
||||
if(getConnectionCount(dir) < 2) {
|
||||
return Offset.NONE;
|
||||
}
|
||||
|
||||
if(dir == ForgeDirection.UNKNOWN) {
|
||||
if(containsOnlySingleVerticalConnections()) {
|
||||
return Offsets.get(type, true, false);
|
||||
}
|
||||
if(containsOnlySingleHorizontalConnections()) {
|
||||
return Offsets.get(type, false, true);
|
||||
}
|
||||
return Offsets.get(type, true, true);
|
||||
}
|
||||
|
||||
boolean isVertical = dir == ForgeDirection.UP || dir == ForgeDirection.DOWN;
|
||||
if(isVertical) {
|
||||
return Offsets.get(type, false, true);
|
||||
}
|
||||
return Offsets.get(type, true, false);
|
||||
return Offsets.get(type, dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -336,6 +325,9 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
for (IConduit con : conduits) {
|
||||
collidablesDirty = collidablesDirty || con.haveCollidablesChangedSinceLastCall();
|
||||
}
|
||||
if(collidablesDirty) {
|
||||
connectorsDirty = true;
|
||||
}
|
||||
if(!collidablesDirty && !cachedCollidables.isEmpty()) {
|
||||
return cachedCollidables;
|
||||
}
|
||||
@@ -359,47 +351,105 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
}
|
||||
|
||||
private void addConnectors(List<CollidableComponent> result) {
|
||||
|
||||
if(conduits.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
CollidableCache cc = CollidableCache.instance;
|
||||
if(conduits.size() == 1) {
|
||||
|
||||
IConduit con = conduits.get(0);
|
||||
result.addAll(cc.getCollidables(cc.createKey(con.getCollidableType(), Offset.NONE, ForgeDirection.UNKNOWN, false), con));
|
||||
|
||||
} else if(containsOnlySingleVerticalConnections()) {
|
||||
|
||||
if(allDirectionsHaveSameConnectionCount()) {
|
||||
for (IConduit con : conduits) {
|
||||
Class<? extends IConduit> type = con.getCollidableType();
|
||||
result.addAll(cc.getCollidables(cc.createKey(type, getOffset(con.getBaseConduitType(), ForgeDirection.UNKNOWN), ForgeDirection.UNKNOWN, false), con));
|
||||
}
|
||||
} else {
|
||||
// vertical box
|
||||
result.add(new CollidableComponent(null, ConduitGeometryUtil.instance.getBoundingBox(ConduitConnectorType.VERTICAL), ForgeDirection.UNKNOWN,
|
||||
ConduitConnectorType.VERTICAL));
|
||||
}
|
||||
|
||||
} else if(containsOnlySingleHorizontalConnections()) {
|
||||
|
||||
if(allDirectionsHaveSameConnectionCount()) {
|
||||
for (IConduit con : conduits) {
|
||||
Class<? extends IConduit> type = con.getCollidableType();
|
||||
result.addAll(cc.getCollidables(cc.createKey(type, getOffset(con.getBaseConduitType(), ForgeDirection.UNKNOWN), ForgeDirection.UNKNOWN, false), con));
|
||||
}
|
||||
|
||||
} else {
|
||||
// vertical box
|
||||
result
|
||||
.add(new CollidableComponent(null, ConduitGeometryUtil.instance.getBoundingBox(ConduitConnectorType.HORIZONTAL), ForgeDirection.UNKNOWN,
|
||||
ConduitConnectorType.HORIZONTAL));
|
||||
}
|
||||
} else {
|
||||
result.add(new CollidableComponent(null, ConduitGeometryUtil.instance.getBoundingBox(ConduitConnectorType.BOTH), ForgeDirection.UNKNOWN,
|
||||
ConduitConnectorType.BOTH));
|
||||
for (IConduit con : conduits) {
|
||||
boolean b = con.haveCollidablesChangedSinceLastCall();
|
||||
collidablesDirty = collidablesDirty || b;
|
||||
connectorsDirty = connectorsDirty || b;
|
||||
}
|
||||
|
||||
if(!connectorsDirty && !cachedConnectors.isEmpty()) {
|
||||
result.addAll(cachedConnectors);
|
||||
return;
|
||||
}
|
||||
|
||||
cachedConnectors.clear();
|
||||
|
||||
List<CollidableComponent> coreBounds = new ArrayList<CollidableComponent>();
|
||||
for (IConduit con : conduits) {
|
||||
addConduitCores(coreBounds, con);
|
||||
}
|
||||
cachedConnectors.addAll(coreBounds);
|
||||
result.addAll(coreBounds);
|
||||
|
||||
List<CollidableComponent> conduitsBounds = new ArrayList<CollidableComponent>();
|
||||
for (IConduit con : conduits) {
|
||||
conduitsBounds.addAll(con.getCollidableComponents());
|
||||
addConduitCores(conduitsBounds, con);
|
||||
}
|
||||
|
||||
Set<Class<IConduit>> collidingTypes = new HashSet<Class<IConduit>>();
|
||||
for (CollidableComponent conCC : conduitsBounds) {
|
||||
for (CollidableComponent innerCC : conduitsBounds) {
|
||||
if(!InsulatedRedstoneConduit.COLOR_CONTROLLER_ID.equals(innerCC.data) && !InsulatedRedstoneConduit.COLOR_CONTROLLER_ID.equals(conCC.data)
|
||||
&& conCC != innerCC && conCC.bound.intersects(innerCC.bound)) {
|
||||
collidingTypes.add((Class<IConduit>) conCC.conduitType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Remove the core geometries covered up by this as no point in rendering these
|
||||
if(!collidingTypes.isEmpty()) {
|
||||
List<CollidableComponent> colCores = new ArrayList<CollidableComponent>();
|
||||
for (Class<IConduit> c : collidingTypes) {
|
||||
IConduit con = getConduit(c);
|
||||
if(con != null) {
|
||||
addConduitCores(colCores, con);
|
||||
}
|
||||
}
|
||||
|
||||
BoundingBox bb = null;
|
||||
for (CollidableComponent cBB : colCores) {
|
||||
if(bb == null) {
|
||||
bb = cBB.bound;
|
||||
} else {
|
||||
bb = bb.expandBy(cBB.bound);
|
||||
}
|
||||
}
|
||||
if(bb != null) {
|
||||
bb = bb.scale(1.05, 1.05, 1.05);
|
||||
CollidableComponent cc = new CollidableComponent(null, bb, ForgeDirection.UNKNOWN,
|
||||
ConduitConnectorType.BOTH);
|
||||
result.add(cc);
|
||||
cachedConnectors.add(cc);
|
||||
}
|
||||
}
|
||||
|
||||
connectorsDirty = false;
|
||||
|
||||
}
|
||||
|
||||
private boolean axisOfConnectionsEqual(Set<ForgeDirection> cons) {
|
||||
Axis axis = null;
|
||||
for (ForgeDirection dir : cons) {
|
||||
if(axis == null) {
|
||||
axis = Offsets.getAxisForDir(dir);
|
||||
} else {
|
||||
if(axis != Offsets.getAxisForDir(dir)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void addConduitCores(List<CollidableComponent> result, IConduit con) {
|
||||
CollidableCache cc = CollidableCache.instance;
|
||||
Class<? extends IConduit> type = con.getCollidableType();
|
||||
if(con.hasConnections()) {
|
||||
for (ForgeDirection dir : con.getExternalConnections()) {
|
||||
result.addAll(cc.getCollidables(cc.createKey(type, getOffset(con.getBaseConduitType(), dir), ForgeDirection.UNKNOWN, false), con));
|
||||
}
|
||||
for (ForgeDirection dir : con.getConduitConnections()) {
|
||||
result.addAll(cc.getCollidables(cc.createKey(type, getOffset(con.getBaseConduitType(), dir), ForgeDirection.UNKNOWN, false), con));
|
||||
}
|
||||
} else {
|
||||
result.addAll(cc.getCollidables(cc.createKey(type, getOffset(con.getBaseConduitType(), ForgeDirection.UNKNOWN), ForgeDirection.UNKNOWN, false), con));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean containsOnlySingleVerticalConnections() {
|
||||
|
||||
@@ -56,24 +56,32 @@ public class CollidableCache {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(this == obj)
|
||||
if(this == obj) {
|
||||
return true;
|
||||
if(obj == null)
|
||||
}
|
||||
if(obj == null) {
|
||||
return false;
|
||||
if(getClass() != obj.getClass())
|
||||
}
|
||||
if(getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
CacheKey other = (CacheKey) obj;
|
||||
if(className == null) {
|
||||
if(other.className != null)
|
||||
if(other.className != null) {
|
||||
return false;
|
||||
} else if(!className.equals(other.className))
|
||||
}
|
||||
} else if(!className.equals(other.className)) {
|
||||
return false;
|
||||
if(dir != other.dir)
|
||||
}
|
||||
if(dir != other.dir) {
|
||||
return false;
|
||||
if(isStub != other.isStub)
|
||||
}
|
||||
if(isStub != other.isStub) {
|
||||
return false;
|
||||
if(offset != other.offset)
|
||||
}
|
||||
if(offset != other.offset) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public class ConduitGeometryUtil {
|
||||
}
|
||||
|
||||
public Vector3d getTranslation(ForgeDirection dir, Offset offset) {
|
||||
Vector3d result = new Vector3d(offset.xOffset, offset.yOffset, 0);
|
||||
Vector3d result = new Vector3d(offset.xOffset, offset.yOffset, offset.zOffset);
|
||||
result.scale(WIDTH);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
package crazypants.enderio.conduit.geom;
|
||||
|
||||
import static crazypants.util.ForgeDirectionOffsets.offsetScaled;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.conduit.render.ConduitBundleRenderer;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.VertexRotation;
|
||||
import crazypants.render.VertexTransform;
|
||||
import crazypants.render.VertexTransformComposite;
|
||||
import crazypants.render.VertexTranslation;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
import crazypants.vecmath.Vertex;
|
||||
|
||||
public class ConnectionModeGeometry {
|
||||
|
||||
private static final EnumMap<ForgeDirection, List<Vertex>> VERTS = new EnumMap<ForgeDirection, List<Vertex>>(ForgeDirection.class);
|
||||
|
||||
static {
|
||||
|
||||
float scale = 0.8f;
|
||||
BoundingBox refBB = ConduitGeometryUtil.CORE_BOUNDS;
|
||||
refBB = refBB.scale(scale, scale, scale);
|
||||
refBB = refBB.scale(scale, 1, 1);
|
||||
|
||||
double offset = (ConduitGeometryUtil.HWIDTH * scale * scale) + ConduitBundleRenderer.CONNECTOR_DEPTH;
|
||||
|
||||
ForgeDirection dir;
|
||||
Vector3d trans;
|
||||
|
||||
VertexRotation vrot = new VertexRotation(Math.PI / 2, new Vector3d(0, 1, 0), new Vector3d(0.5, 0.5, 0.5));
|
||||
VertexTranslation vtrans = new VertexTranslation(0, 0, 0);
|
||||
VertexTransformComposite xform = new VertexTransformComposite(vrot, vtrans);
|
||||
|
||||
dir = ForgeDirection.SOUTH;
|
||||
trans = offsetScaled(dir, 0.5);
|
||||
trans.sub(offsetScaled(dir, offset));
|
||||
vtrans.set(trans);
|
||||
VERTS.put(dir, createVerticesForDir(refBB, xform));
|
||||
|
||||
dir = ForgeDirection.NORTH;
|
||||
vrot.setAngle(Math.PI + Math.PI / 2);
|
||||
trans = offsetScaled(dir, 0.5);
|
||||
trans.sub(offsetScaled(dir, offset));
|
||||
vtrans.set(trans);
|
||||
VERTS.put(dir, createVerticesForDir(refBB, xform));
|
||||
|
||||
dir = ForgeDirection.EAST;
|
||||
vrot.setAngle(Math.PI);
|
||||
trans = offsetScaled(dir, 0.5);
|
||||
trans.sub(offsetScaled(dir, offset));
|
||||
vtrans.set(trans);
|
||||
VERTS.put(dir, createVerticesForDir(refBB, xform));
|
||||
|
||||
dir = ForgeDirection.WEST;
|
||||
vrot.setAngle(0);
|
||||
trans = offsetScaled(dir, 0.5);
|
||||
trans.sub(offsetScaled(dir, offset));
|
||||
vtrans.set(trans);
|
||||
VERTS.put(dir, createVerticesForDir(refBB, xform));
|
||||
|
||||
vrot.setAxis(new Vector3d(0, 0, 1));
|
||||
|
||||
dir = ForgeDirection.UP;
|
||||
vrot.setAngle(-Math.PI / 2);
|
||||
trans = offsetScaled(dir, 0.5);
|
||||
trans.sub(offsetScaled(dir, offset));
|
||||
vtrans.set(trans);
|
||||
VERTS.put(dir, createVerticesForDir(refBB, xform));
|
||||
|
||||
dir = ForgeDirection.DOWN;
|
||||
vrot.setAngle(Math.PI / 2);
|
||||
trans = offsetScaled(dir, 0.5);
|
||||
trans.sub(offsetScaled(dir, offset));
|
||||
vtrans.set(trans);
|
||||
VERTS.put(dir, createVerticesForDir(refBB, xform));
|
||||
|
||||
}
|
||||
|
||||
private static List<Vertex> createVerticesForDir(BoundingBox refBB, VertexTransform xform) {
|
||||
List<Vertex> result = new ArrayList<Vertex>(24);
|
||||
for (ForgeDirection face : ForgeDirection.VALID_DIRECTIONS) {
|
||||
result.addAll(refBB.getCornersWithUvForFace(face));
|
||||
}
|
||||
for (Vertex v : result) {
|
||||
xform.apply(v.xyz);
|
||||
//v.xyz.set(v.x(), v.y() + 1, v.z());
|
||||
xform.applyToNormal(v.normal);
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void renderModeConnector(ForgeDirection dir, Offset offset, Icon tex) {
|
||||
List<Vertex> verts = VERTS.get(dir);
|
||||
if(verts == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3d trans = ConduitGeometryUtil.instance.getTranslation(dir, offset);
|
||||
|
||||
float uWidth = tex.getMaxU() - tex.getMinU();
|
||||
float uScale = uWidth * 0.64f;
|
||||
float minU = tex.getMinU() + (uWidth - uScale);
|
||||
float vScale = tex.getMaxV() - tex.getMinV();
|
||||
|
||||
Tessellator tes = Tessellator.instance;
|
||||
for (Vertex v : verts) {
|
||||
tes.setNormal(v.nx(), v.ny(), v.nz());
|
||||
tes.addVertexWithUV(v.x() + trans.x, v.y() + trans.y, v.z() + trans.z, minU + (v.u() * uScale), tex.getMinV() + (v.v() * vScale));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package crazypants.enderio.conduit.geom;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Offset vectors are based on Y up.
|
||||
*
|
||||
@@ -7,22 +9,42 @@ package crazypants.enderio.conduit.geom;
|
||||
*/
|
||||
public enum Offset {
|
||||
|
||||
NONE(0, 0),
|
||||
TOP(0, 1),
|
||||
BOTTOM(0, -1),
|
||||
LEFT(-1, 0),
|
||||
RIGHT(1, 0),
|
||||
TL(-1, 1),
|
||||
TR(1, 1),
|
||||
BL(-1, -1),
|
||||
BR(1, -1);
|
||||
NONE(0, 0, 0),
|
||||
UP(ForgeDirection.UP),
|
||||
DOWN(ForgeDirection.DOWN),
|
||||
EAST(ForgeDirection.EAST),
|
||||
WEST(ForgeDirection.WEST),
|
||||
SOUTH(ForgeDirection.SOUTH),
|
||||
NORTH(ForgeDirection.NORTH),
|
||||
EAST_UP(ForgeDirection.EAST, ForgeDirection.UP),
|
||||
WEST_UP(ForgeDirection.WEST, ForgeDirection.UP),
|
||||
SOUTH_UP(ForgeDirection.SOUTH, ForgeDirection.UP),
|
||||
NORTH_UP(ForgeDirection.NORTH, ForgeDirection.UP),
|
||||
EAST_DOWN(ForgeDirection.EAST, ForgeDirection.DOWN),
|
||||
WEST_DOWN(ForgeDirection.WEST, ForgeDirection.DOWN),
|
||||
SOUTH_DOWN(ForgeDirection.SOUTH, ForgeDirection.DOWN),
|
||||
NORTH_DOWN(ForgeDirection.NORTH, ForgeDirection.DOWN);
|
||||
|
||||
public final int xOffset;
|
||||
public final int yOffset;
|
||||
public final int zOffset;
|
||||
|
||||
private Offset(int xOffset, int yOffset) {
|
||||
private Offset(ForgeDirection dir) {
|
||||
xOffset = dir.offsetX;
|
||||
yOffset = dir.offsetY;
|
||||
zOffset = dir.offsetZ;
|
||||
}
|
||||
|
||||
private Offset(ForgeDirection dir, ForgeDirection yDir) {
|
||||
xOffset = dir.offsetX;
|
||||
yOffset = yDir.offsetY;
|
||||
zOffset = dir.offsetZ;
|
||||
}
|
||||
|
||||
private Offset(int xOffset, int yOffset, int zOffset) {
|
||||
this.xOffset = xOffset;
|
||||
this.yOffset = yOffset;
|
||||
this.zOffset = zOffset;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,9 @@ package crazypants.enderio.conduit.geom;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.item.IItemConduit;
|
||||
import crazypants.enderio.conduit.liquid.ILiquidConduit;
|
||||
import crazypants.enderio.conduit.power.IPowerConduit;
|
||||
import crazypants.enderio.conduit.redstone.IRedstoneConduit;
|
||||
@@ -13,70 +15,111 @@ public class Offsets {
|
||||
private static Map<OffsetKey, Offset> OFFSETS = new HashMap<OffsetKey, Offset>();
|
||||
|
||||
static {
|
||||
OFFSETS.put(key(IRedstoneConduit.class, true, false), Offset.BOTTOM);
|
||||
OFFSETS.put(key(IPowerConduit.class, true, false), Offset.TOP);
|
||||
OFFSETS.put(key(ILiquidConduit.class, true, false), Offset.NONE);
|
||||
OFFSETS.put(key(IRedstoneConduit.class, Axis.NONE), Offset.UP);
|
||||
OFFSETS.put(key(IRedstoneConduit.class, Axis.X), Offset.UP);
|
||||
OFFSETS.put(key(IRedstoneConduit.class, Axis.Y), Offset.NORTH);
|
||||
OFFSETS.put(key(IRedstoneConduit.class, Axis.Z), Offset.UP);
|
||||
|
||||
OFFSETS.put(key(IRedstoneConduit.class, false, true), Offset.LEFT);
|
||||
OFFSETS.put(key(IPowerConduit.class, false, true), Offset.RIGHT);
|
||||
OFFSETS.put(key(ILiquidConduit.class, false, true), Offset.NONE);
|
||||
OFFSETS.put(key(IPowerConduit.class, Axis.NONE), Offset.DOWN);
|
||||
OFFSETS.put(key(IPowerConduit.class, Axis.X), Offset.DOWN);
|
||||
OFFSETS.put(key(IPowerConduit.class, Axis.Y), Offset.SOUTH);
|
||||
OFFSETS.put(key(IPowerConduit.class, Axis.Z), Offset.DOWN);
|
||||
|
||||
OFFSETS.put(key(IRedstoneConduit.class, true, true), Offset.BL);
|
||||
OFFSETS.put(key(IPowerConduit.class, true, true), Offset.TR);
|
||||
OFFSETS.put(key(ILiquidConduit.class, true, true), Offset.NONE);
|
||||
OFFSETS.put(key(ILiquidConduit.class, Axis.NONE), Offset.WEST);
|
||||
OFFSETS.put(key(ILiquidConduit.class, Axis.X), Offset.NORTH);
|
||||
OFFSETS.put(key(ILiquidConduit.class, Axis.Y), Offset.WEST);
|
||||
OFFSETS.put(key(ILiquidConduit.class, Axis.Z), Offset.WEST);
|
||||
|
||||
OFFSETS.put(key(IItemConduit.class, Axis.NONE), Offset.EAST);
|
||||
OFFSETS.put(key(IItemConduit.class, Axis.X), Offset.SOUTH);
|
||||
OFFSETS.put(key(IItemConduit.class, Axis.Y), Offset.EAST);
|
||||
OFFSETS.put(key(IItemConduit.class, Axis.Z), Offset.EAST);
|
||||
}
|
||||
|
||||
public static Offset get(Class<? extends IConduit> type, boolean horizontal, boolean vertical) {
|
||||
return OFFSETS.get(key(type, horizontal, vertical));
|
||||
public static Offset get(Class<? extends IConduit> type, ForgeDirection dir) {
|
||||
Offset res = OFFSETS.get(key(type, getAxisForDir(dir)));
|
||||
if(res == null) {
|
||||
res = Offset.NONE;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static OffsetKey key(Class<? extends IConduit> type, boolean horizontal, boolean vertical) {
|
||||
return new OffsetKey(type, horizontal, vertical);
|
||||
public static OffsetKey key(Class<? extends IConduit> type, Axis axis) {
|
||||
return new OffsetKey(type, axis);
|
||||
}
|
||||
|
||||
public static Axis getAxisForDir(ForgeDirection dir) {
|
||||
if(dir == ForgeDirection.UNKNOWN) {
|
||||
return Axis.NONE;
|
||||
}
|
||||
if(dir == ForgeDirection.EAST || dir == ForgeDirection.WEST) {
|
||||
return Axis.X;
|
||||
}
|
||||
if(dir == ForgeDirection.UP || dir == ForgeDirection.DOWN) {
|
||||
return Axis.Y;
|
||||
}
|
||||
if(dir == ForgeDirection.NORTH || dir == ForgeDirection.SOUTH) {
|
||||
return Axis.Z;
|
||||
}
|
||||
return Axis.NONE;
|
||||
}
|
||||
|
||||
public static enum Axis {
|
||||
NONE,
|
||||
X,
|
||||
Y,
|
||||
Z
|
||||
}
|
||||
|
||||
public static class OffsetKey {
|
||||
|
||||
String typeName;
|
||||
boolean horizontal;
|
||||
boolean vertical;
|
||||
Axis axis;
|
||||
|
||||
private OffsetKey(Class<? extends IConduit> type, boolean horizontal, boolean vertical) {
|
||||
private OffsetKey(Class<? extends IConduit> type, Axis axis) {
|
||||
this.typeName = type.getCanonicalName();
|
||||
this.horizontal = horizontal;
|
||||
this.vertical = vertical;
|
||||
this.axis = axis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (horizontal ? 1231 : 1237);
|
||||
result = prime * result + ((axis == null) ? 0 : axis.hashCode());
|
||||
result = prime * result + ((typeName == null) ? 0 : typeName.hashCode());
|
||||
result = prime * result + (vertical ? 1231 : 1237);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(this == obj)
|
||||
if(this == obj) {
|
||||
return true;
|
||||
if(obj == null)
|
||||
}
|
||||
if(obj == null) {
|
||||
return false;
|
||||
if(getClass() != obj.getClass())
|
||||
}
|
||||
if(getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
OffsetKey other = (OffsetKey) obj;
|
||||
if(horizontal != other.horizontal)
|
||||
if(axis != other.axis) {
|
||||
return false;
|
||||
}
|
||||
if(typeName == null) {
|
||||
if(other.typeName != null)
|
||||
if(other.typeName != null) {
|
||||
return false;
|
||||
} else if(!typeName.equals(other.typeName))
|
||||
return false;
|
||||
if(vertical != other.vertical)
|
||||
}
|
||||
} else if(!typeName.equals(other.typeName)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OffsetKey [typeName=" + typeName + ", axis=" + axis + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package crazypants.enderio.conduit.item;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
|
||||
public interface IItemConduit extends IConduit {
|
||||
|
||||
Icon getTextureForInputMode();
|
||||
|
||||
Icon getTextureForOutputMode();
|
||||
|
||||
Icon getTextureForInOutMode();
|
||||
|
||||
Icon getEnderIcon();
|
||||
|
||||
IInventory getExternalInventory(ForgeDirection direction);
|
||||
|
||||
int getMaximumExtracted(int slot);
|
||||
|
||||
void itemsExtracted(int numInserted, int slot);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,342 @@
|
||||
package crazypants.enderio.conduit.item;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.ClientProxy;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.AbstractConduit;
|
||||
import crazypants.enderio.conduit.AbstractConduitNetwork;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.conduit.ConnectionMode;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
import crazypants.enderio.conduit.RaytraceResult;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.IconUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.ForgeDirectionOffsets;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
import crazypants.vecmath.Vector3f;
|
||||
|
||||
public class ItemConduit extends AbstractConduit implements IItemConduit {
|
||||
|
||||
public static final String EXTERNAL_INTERFACE_GEOM = "ExternalInterface";
|
||||
|
||||
public static final String ICON_KEY = "enderio:itemConduit";
|
||||
//public static final String ICON_KEY = "enderio:tesseractPortal";
|
||||
|
||||
public static final String ICON_CORE_KEY = "enderio:itemConduitCore";
|
||||
|
||||
public static final String ICON_CORE_ADVANCED_KEY = "enderio:itemConduitCoreAdvanced";
|
||||
|
||||
public static final String ICON_KEY_INPUT = "enderio:itemConduitInput";
|
||||
|
||||
public static final String ICON_KEY_OUTPUT = "enderio:itemConduitOutput";
|
||||
|
||||
public static final String ICON_KEY_IN_OUT = "enderio:itemConduitInOut";
|
||||
|
||||
public static final String ICON_KEY_ENDER = "enderio:ender_still";
|
||||
|
||||
static final Map<String, Icon> ICONS = new HashMap<String, Icon>();
|
||||
|
||||
public static void initIcons() {
|
||||
IconUtil.addIconProvider(new IconUtil.IIconProvider() {
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister register) {
|
||||
ICONS.put(ICON_KEY, register.registerIcon(ICON_KEY));
|
||||
ICONS.put(ICON_CORE_KEY, register.registerIcon(ICON_CORE_KEY));
|
||||
ICONS.put(ICON_CORE_ADVANCED_KEY, register.registerIcon(ICON_CORE_ADVANCED_KEY));
|
||||
ICONS.put(ICON_KEY_INPUT, register.registerIcon(ICON_KEY_INPUT));
|
||||
ICONS.put(ICON_KEY_OUTPUT, register.registerIcon(ICON_KEY_OUTPUT));
|
||||
ICONS.put(ICON_KEY_IN_OUT, register.registerIcon(ICON_KEY_IN_OUT));
|
||||
ICONS.put(ICON_KEY_ENDER, register.registerIcon(ICON_KEY_ENDER));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTextureType() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
ItemConduitNetwork network;
|
||||
|
||||
int maxExtractedOnTick = 2;
|
||||
float extractRatePerTick = maxExtractedOnTick / 20f;
|
||||
long extractedAtLastTick = -1;
|
||||
|
||||
boolean isAdvanced = false;
|
||||
|
||||
public ItemConduit() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
public ItemConduit(boolean isAdvanced) {
|
||||
setAdvanced(isAdvanced);
|
||||
}
|
||||
|
||||
public void setAdvanced(boolean advanced) {
|
||||
this.isAdvanced = advanced;
|
||||
if(isAdvanced) {
|
||||
maxExtractedOnTick = 2;
|
||||
extractRatePerTick = maxExtractedOnTick / 20f;
|
||||
} else {
|
||||
maxExtractedOnTick = 64;
|
||||
extractRatePerTick = maxExtractedOnTick / 20f;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List<RaytraceResult> all) {
|
||||
if(ConduitUtil.isToolEquipped(player)) {
|
||||
if(!getBundle().getEntity().worldObj.isRemote) {
|
||||
if(res != null && res.component != null) {
|
||||
ForgeDirection connDir = res.component.dir;
|
||||
ForgeDirection faceHit = ForgeDirection.getOrientation(res.movingObjectPosition.sideHit);
|
||||
|
||||
if(connDir == ForgeDirection.UNKNOWN || connDir == faceHit) {
|
||||
// Attempt to join networks
|
||||
BlockCoord loc = getLocation().getLocation(faceHit);
|
||||
IItemConduit neighbour = ConduitUtil.getConduit(getBundle().getEntity().worldObj, loc.x, loc.y, loc.z, IItemConduit.class);
|
||||
if(neighbour != null) {
|
||||
if(network != null) {
|
||||
network.destroyNetwork();
|
||||
}
|
||||
onAddedToBundle();
|
||||
return true;
|
||||
}
|
||||
} else if(externalConnections.contains(connDir)) {
|
||||
setConnectionMode(connDir, getNextConnectionMode(connDir));
|
||||
return true;
|
||||
} else if(containsConduitConnection(connDir)) {
|
||||
conduitConnectionRemoved(connDir);
|
||||
BlockCoord loc = getLocation().getLocation(connDir);
|
||||
IItemConduit neighbour = ConduitUtil.getConduit(getBundle().getEntity().worldObj, loc.x, loc.y, loc.z, IItemConduit.class);
|
||||
if(neighbour != null) {
|
||||
neighbour.conduitConnectionRemoved(connDir.getOpposite());
|
||||
}
|
||||
if(network != null) {
|
||||
network.destroyNetwork();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumExtracted(int slot) {
|
||||
World world = getBundle().getEntity().worldObj;
|
||||
if(world == null) {
|
||||
return 0;
|
||||
}
|
||||
long curTick = world.getTotalWorldTime();
|
||||
int numTicksSinceExtract = (int) (curTick - extractedAtLastTick);
|
||||
int result = (int) (numTicksSinceExtract * extractRatePerTick);
|
||||
result = Math.min(result, maxExtractedOnTick);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void itemsExtracted(int numInserted, int slot) {
|
||||
World world = getBundle().getEntity().worldObj;
|
||||
if(world != null) {
|
||||
extractedAtLastTick = world.getTotalWorldTime();
|
||||
} else {
|
||||
extractedAtLastTick = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void externalConnectionAdded(ForgeDirection direction) {
|
||||
super.externalConnectionAdded(direction);
|
||||
if(network != null) {
|
||||
TileEntity te = bundle.getEntity();
|
||||
network.inventoryAdded(this, direction, te.xCoord + direction.offsetX, te.yCoord + direction.offsetY, te.zCoord + direction.offsetZ,
|
||||
getExternalInventory(direction));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getExternalInventory(ForgeDirection direction) {
|
||||
World world = getBundle().getWorld();
|
||||
if(world == null) {
|
||||
return null;
|
||||
}
|
||||
BlockCoord loc = getLocation().getLocation(direction);
|
||||
TileEntity te = world.getBlockTileEntity(loc.x, loc.y, loc.z);
|
||||
if(te instanceof IInventory && !(te instanceof IConduitBundle)) {
|
||||
return (IInventory) te;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void externalConnectionRemoved(ForgeDirection direction) {
|
||||
super.externalConnectionRemoved(direction);
|
||||
if(network != null) {
|
||||
TileEntity te = bundle.getEntity();
|
||||
network.inventoryRemoved(this, te.xCoord + direction.offsetX, te.yCoord + direction.offsetY, te.zCoord + direction.offsetZ);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConnectionMode(ForgeDirection dir, ConnectionMode mode) {
|
||||
ConnectionMode oldVal = conectionModes.get(dir);
|
||||
if(oldVal == mode) {
|
||||
return;
|
||||
}
|
||||
super.setConnectionMode(dir, mode);
|
||||
if(network != null) {
|
||||
network.connectionModeChanged(this, mode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectToExternal(ForgeDirection direction) {
|
||||
return getExternalInventory(direction) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConnectionMode getDefaultConnectionMode() {
|
||||
return ConnectionMode.INPUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IConduit> getBaseConduitType() {
|
||||
return IItemConduit.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack createItem() {
|
||||
ItemStack result = new ItemStack(ModObject.itemItemConduit.actualId, 1, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractConduitNetwork<?> getNetwork() {
|
||||
return network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setNetwork(AbstractConduitNetwork<?> network) {
|
||||
this.network = (ItemConduitNetwork) network;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getTextureForInputMode() {
|
||||
return ICONS.get(ICON_KEY_INPUT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getTextureForOutputMode() {
|
||||
return ICONS.get(ICON_KEY_OUTPUT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getTextureForInOutMode() {
|
||||
return ICONS.get(ICON_KEY_IN_OUT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getEnderIcon() {
|
||||
return ICONS.get(ICON_KEY_ENDER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getTextureForState(CollidableComponent component) {
|
||||
if(component.dir == ForgeDirection.UNKNOWN) {
|
||||
return isAdvanced ? ICONS.get(ICON_CORE_ADVANCED_KEY) : ICONS.get(ICON_CORE_KEY);
|
||||
}
|
||||
|
||||
if(EXTERNAL_INTERFACE_GEOM.equals(component.data)) {
|
||||
return ICONS.get(ICON_CORE_ADVANCED_KEY);
|
||||
}
|
||||
|
||||
if(getExternalConnections().contains(component.dir)) {
|
||||
if(getConectionMode(component.dir) == ConnectionMode.OUTPUT) {
|
||||
return ICONS.get(ICON_KEY_INPUT);
|
||||
}
|
||||
if(getConectionMode(component.dir) == ConnectionMode.INPUT) {
|
||||
return ICONS.get(ICON_KEY_OUTPUT);
|
||||
}
|
||||
if(getConectionMode(component.dir) == ConnectionMode.IN_OUT) {
|
||||
return ICONS.get(ICON_KEY_IN_OUT);
|
||||
}
|
||||
}
|
||||
return ICONS.get(ICON_KEY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getTransmitionTextureForState(CollidableComponent component) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CollidableComponent> getCollidableComponents() {
|
||||
if(!isAdvanced) {
|
||||
return super.getCollidableComponents();
|
||||
}
|
||||
|
||||
if(collidables != null && !collidablesDirty) {
|
||||
return collidables;
|
||||
}
|
||||
List<CollidableComponent> result = super.getCollidableComponents();
|
||||
|
||||
for (ForgeDirection dir : getExternalConnections()) {
|
||||
if(getConectionMode(dir) != ConnectionMode.DISABLED && getConectionMode(dir) != ConnectionMode.NOT_SET) { //
|
||||
float scale = 0.1f;
|
||||
BoundingBox bb = BoundingBox.UNIT_CUBE.scale(scale, scale, scale);
|
||||
|
||||
Vector3d offset = ForgeDirectionOffsets.forDirCopy(dir);
|
||||
offset.scale(0.5);
|
||||
offset.scale(scale);
|
||||
|
||||
BoundingBox conectorBounds = ((ClientProxy) EnderIO.proxy).getConduitBundleRenderer().getExternalConnectorBoundsForDirection(dir);
|
||||
List<Vector3f> corners = conectorBounds.getCornersForFace(dir);
|
||||
|
||||
for (Vector3f vec : corners) {
|
||||
vec.sub(new Vector3f(0.5f, 0.5f, 0.5f));
|
||||
vec.sub(new Vector3f(offset));
|
||||
|
||||
BoundingBox bbb = bb.translate(vec);
|
||||
result.add(new CollidableComponent(IItemConduit.class, bbb, dir, EXTERNAL_INTERFACE_GEOM));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtRoot) {
|
||||
super.writeToNBT(nbtRoot);
|
||||
nbtRoot.setBoolean("isAdvanced", isAdvanced);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtRoot) {
|
||||
super.readFromNBT(nbtRoot);
|
||||
isAdvanced = nbtRoot.getBoolean("isAdvanced");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,346 @@
|
||||
package crazypants.enderio.conduit.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.conduit.AbstractConduitNetwork;
|
||||
import crazypants.enderio.conduit.ConnectionMode;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public class ItemConduitNetwork extends AbstractConduitNetwork<IItemConduit> {
|
||||
|
||||
private long timeAtLastApply;
|
||||
|
||||
private final List<NetworkedInventory> inventories = new ArrayList<ItemConduitNetwork.NetworkedInventory>();
|
||||
private final Map<BlockCoord, NetworkedInventory> invMap = new HashMap<BlockCoord, ItemConduitNetwork.NetworkedInventory>();
|
||||
|
||||
private boolean requiresSort = true;
|
||||
|
||||
@Override
|
||||
public Class<? extends IItemConduit> getBaseConduitType() {
|
||||
return IItemConduit.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addConduit(IItemConduit con) {
|
||||
super.addConduit(con);
|
||||
|
||||
TileEntity te = con.getBundle().getEntity();
|
||||
if(te != null) {
|
||||
for (ForgeDirection direction : con.getExternalConnections()) {
|
||||
IInventory extCon = con.getExternalInventory(direction);
|
||||
if(extCon != null) {
|
||||
inventoryAdded(con, direction, te.xCoord + direction.offsetX, te.yCoord + direction.offsetY, te.zCoord + direction.offsetZ, extCon);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void inventoryAdded(IItemConduit itemConduit, ForgeDirection direction, int x, int y, int z, IInventory externalInventory) {
|
||||
BlockCoord bc = new BlockCoord(x, y, z);
|
||||
NetworkedInventory inv = new NetworkedInventory(externalInventory, itemConduit, direction, bc);
|
||||
inventories.add(inv);
|
||||
invMap.put(bc, inv);
|
||||
requiresSort = true;
|
||||
}
|
||||
|
||||
public void inventoryRemoved(ItemConduit itemConduit, int x, int y, int z) {
|
||||
BlockCoord bc = new BlockCoord(x, y, z);
|
||||
NetworkedInventory inv = invMap.remove(bc);
|
||||
if(inv != null) {
|
||||
inventories.remove(inv);
|
||||
}
|
||||
requiresSort = true;
|
||||
}
|
||||
|
||||
public void connectionModeChanged(ItemConduit itemConduit, ConnectionMode mode) {
|
||||
requiresSort = true;
|
||||
}
|
||||
|
||||
private boolean isRemote(ItemConduit itemConduit) {
|
||||
World world = itemConduit.getBundle().getEntity().worldObj;
|
||||
if(world != null && world.isRemote) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateEntity(IConduit conduit) {
|
||||
World world = conduit.getBundle().getEntity().worldObj;
|
||||
if(world == null) {
|
||||
return;
|
||||
}
|
||||
if(world.isRemote) {
|
||||
return;
|
||||
}
|
||||
long curTime = world.getTotalWorldTime();
|
||||
if(curTime != timeAtLastApply) {
|
||||
timeAtLastApply = curTime;
|
||||
doTick();
|
||||
}
|
||||
}
|
||||
|
||||
private void doTick() {
|
||||
for (NetworkedInventory ni : inventories) {
|
||||
if(requiresSort) {
|
||||
ni.updateInsertOrder();
|
||||
}
|
||||
ni.onTick();
|
||||
}
|
||||
requiresSort = false;
|
||||
}
|
||||
|
||||
static int compare(int x, int y) {
|
||||
return (x < y) ? -1 : ((x == y) ? 0 : 1);
|
||||
}
|
||||
|
||||
class NetworkedInventory {
|
||||
|
||||
IInventory inv;
|
||||
ISidedInventory sidedInv;
|
||||
IItemConduit con;
|
||||
ForgeDirection conDir;
|
||||
BlockCoord location;
|
||||
int inventorySide;
|
||||
|
||||
List<Target> sendPriority = new ArrayList<Target>();
|
||||
|
||||
NetworkedInventory(IInventory inv, IItemConduit con, ForgeDirection conDir, BlockCoord location) {
|
||||
this.inv = inv;
|
||||
if(inv instanceof ISidedInventory) {
|
||||
sidedInv = (ISidedInventory) inv;
|
||||
}
|
||||
this.con = con;
|
||||
this.conDir = conDir;
|
||||
this.location = location;
|
||||
inventorySide = conDir.getOpposite().ordinal();
|
||||
}
|
||||
|
||||
boolean canExtract() {
|
||||
ConnectionMode mode = con.getConectionMode(conDir);
|
||||
return mode == ConnectionMode.INPUT || mode == ConnectionMode.IN_OUT;
|
||||
}
|
||||
|
||||
boolean canInsert() {
|
||||
ConnectionMode mode = con.getConectionMode(conDir);
|
||||
return mode == ConnectionMode.OUTPUT || mode == ConnectionMode.IN_OUT;
|
||||
}
|
||||
|
||||
void onTick() {
|
||||
if(!canExtract()) {
|
||||
return;
|
||||
}
|
||||
if(sidedInv != null) {
|
||||
trasnferItemsSided();
|
||||
} else {
|
||||
tranfserItems();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void tranfserItems() {
|
||||
int size = inv.getSizeInventory();
|
||||
int numSlots = inv.getSizeInventory();
|
||||
ItemStack extractItem = null;
|
||||
|
||||
int slot = -1;
|
||||
for (int i = 0; i < numSlots && extractItem == null; i++) {
|
||||
ItemStack item = inv.getStackInSlot(i);
|
||||
if(item != null) {
|
||||
extractItem = item.copy();
|
||||
slot = i;
|
||||
}
|
||||
}
|
||||
|
||||
int maxExtracted = con.getMaximumExtracted(slot);
|
||||
if(maxExtracted > 0) {
|
||||
doTranfser(extractItem, slot, maxExtracted);
|
||||
}
|
||||
}
|
||||
|
||||
private void trasnferItemsSided() {
|
||||
|
||||
int size = sidedInv.getSizeInventory();
|
||||
int[] slotIndices = sidedInv.getAccessibleSlotsFromSide(inventorySide);
|
||||
ItemStack extractItem = null;
|
||||
|
||||
int slot = -1;
|
||||
for (int i = 0; i < slotIndices.length && extractItem == null; i++) {
|
||||
ItemStack item = sidedInv.getStackInSlot(i);
|
||||
if(item != null) {
|
||||
extractItem = item.copy();
|
||||
slot = i;
|
||||
if(!sidedInv.canExtractItem(i, extractItem, inventorySide)) {
|
||||
extractItem = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int maxExtracted = con.getMaximumExtracted(slot);
|
||||
if(maxExtracted > 0) {
|
||||
doTranfser(extractItem, slot, maxExtracted);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void doTranfser(ItemStack extractedItem, int slot, int maxExtract) {
|
||||
if(extractedItem != null) {
|
||||
ItemStack toExtract = extractedItem.copy();
|
||||
toExtract.stackSize = Math.min(maxExtract, toExtract.stackSize);
|
||||
int numInserted = insertIntoTargets(toExtract, slot);
|
||||
|
||||
toExtract.stackSize = extractedItem.stackSize - numInserted;
|
||||
if(toExtract.stackSize > 0) {
|
||||
inv.setInventorySlotContents(slot, toExtract);
|
||||
} else {
|
||||
inv.setInventorySlotContents(slot, null);
|
||||
}
|
||||
con.itemsExtracted(numInserted, slot);
|
||||
}
|
||||
}
|
||||
|
||||
private int insertIntoTargets(ItemStack toExtract, int slot) {
|
||||
if(toExtract == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int totalToInsert = toExtract.stackSize;
|
||||
int leftToInsert = totalToInsert;
|
||||
for (Target target : sendPriority) {
|
||||
int inserted = target.inv.insertItem(toExtract);
|
||||
if(inserted > 0) {
|
||||
toExtract.stackSize -= inserted;
|
||||
if(toExtract.stackSize > 0) {
|
||||
inv.setInventorySlotContents(slot, toExtract);
|
||||
} else {
|
||||
inv.setInventorySlotContents(slot, null);
|
||||
}
|
||||
leftToInsert -= inserted;
|
||||
}
|
||||
if(leftToInsert <= 0) {
|
||||
return totalToInsert;
|
||||
}
|
||||
}
|
||||
return totalToInsert - leftToInsert;
|
||||
}
|
||||
|
||||
private int insertItem(ItemStack item) {
|
||||
if(sidedInv != null) {
|
||||
return doInsertItemSided(item);
|
||||
}
|
||||
return doInsertItem(item);
|
||||
}
|
||||
|
||||
private int doInsertItem(ItemStack item) {
|
||||
if(!canInsert() || item == null) {
|
||||
return 0;
|
||||
|
||||
}
|
||||
int numInserted = 0;
|
||||
int numToInsert = item.stackSize;
|
||||
for (int slot = 0; slot < inv.getSizeInventory() && numToInsert > 0; slot++) {
|
||||
ItemStack contents = inv.getStackInSlot(slot);
|
||||
ItemStack toInsert = item.copy();
|
||||
toInsert.stackSize = Math.min(toInsert.stackSize, inv.getInventoryStackLimit());
|
||||
toInsert.stackSize = Math.min(toInsert.stackSize, numToInsert);
|
||||
int inserted = 0;
|
||||
if(contents == null) {
|
||||
inserted = toInsert.stackSize;
|
||||
} else {
|
||||
if(contents.isItemEqual(item)) {
|
||||
int space = inv.getInventoryStackLimit() - contents.stackSize;
|
||||
space = Math.min(space, contents.getMaxStackSize() - contents.stackSize);
|
||||
inserted += Math.min(space, toInsert.stackSize);
|
||||
toInsert.stackSize = contents.stackSize + inserted;
|
||||
} else {
|
||||
toInsert.stackSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(inserted > 0) {
|
||||
numInserted += inserted;
|
||||
numToInsert -= inserted;
|
||||
inv.setInventorySlotContents(slot, toInsert);
|
||||
}
|
||||
}
|
||||
return numInserted;
|
||||
|
||||
}
|
||||
|
||||
private int doInsertItemSided(ItemStack item) {
|
||||
|
||||
int numInserted = 0;
|
||||
int numToInsert = item.stackSize;
|
||||
for (int slot = 0; slot < inv.getSizeInventory() && numToInsert > 0; slot++) {
|
||||
if(sidedInv.canInsertItem(slot, item, inventorySide)) {
|
||||
ItemStack contents = inv.getStackInSlot(slot);
|
||||
ItemStack toInsert = item.copy();
|
||||
toInsert.stackSize = Math.min(toInsert.stackSize, inv.getInventoryStackLimit());
|
||||
toInsert.stackSize = Math.min(toInsert.stackSize, numToInsert);
|
||||
int inserted = 0;
|
||||
if(contents == null) {
|
||||
inserted = toInsert.stackSize;
|
||||
} else {
|
||||
if(contents.isItemEqual(item)) {
|
||||
int space = inv.getInventoryStackLimit() - contents.stackSize;
|
||||
space = Math.min(space, contents.getMaxStackSize() - contents.stackSize);
|
||||
inserted += Math.min(space, toInsert.stackSize);
|
||||
toInsert.stackSize = contents.stackSize + inserted;
|
||||
} else {
|
||||
toInsert.stackSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(inserted > 0) {
|
||||
numInserted += inserted;
|
||||
numToInsert -= inserted;
|
||||
inv.setInventorySlotContents(slot, toInsert);
|
||||
}
|
||||
}
|
||||
}
|
||||
return numInserted;
|
||||
}
|
||||
|
||||
void updateInsertOrder() {
|
||||
sendPriority.clear();
|
||||
if(!canExtract()) {
|
||||
return;
|
||||
}
|
||||
for (NetworkedInventory other : inventories) {
|
||||
if(other != this && other.canInsert()) {
|
||||
sendPriority.add(new Target(other, location.distanceSquared(other.location)));
|
||||
}
|
||||
}
|
||||
Collections.sort(sendPriority);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Target implements Comparable<Target> {
|
||||
NetworkedInventory inv;
|
||||
int distance;
|
||||
|
||||
Target(NetworkedInventory inv, int distance) {
|
||||
this.inv = inv;
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Target o) {
|
||||
return compare(distance, o.distance);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package crazypants.enderio.conduit.item;
|
||||
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.conduit.render.DefaultConduitRenderer;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.CubeRenderer;
|
||||
|
||||
public class ItemConduitRenderer extends DefaultConduitRenderer {
|
||||
|
||||
@Override
|
||||
public boolean isRendererForConduit(IConduit conduit) {
|
||||
if(conduit instanceof IItemConduit) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void renderEntity(ConduitBundleRenderer conduitBundleRenderer, IConduitBundle te, IConduit conduit, double x, double y, double z, float partialTick,
|
||||
// float worldLight) {
|
||||
// super.renderEntity(conduitBundleRenderer, te, conduit, x, y, z, partialTick, worldLight);
|
||||
//
|
||||
// // IItemConduit pc = (IItemConduit) conduit;
|
||||
// // for (ForgeDirection dir : conduit.getExternalConnections()) {
|
||||
// // Icon tex = null;
|
||||
// // if(conduit.getConectionMode(dir) == ConnectionMode.INPUT) {
|
||||
// // tex = pc.getTextureForInputMode();
|
||||
// // } else if(conduit.getConectionMode(dir) == ConnectionMode.OUTPUT) {
|
||||
// // tex = pc.getTextureForOutputMode();
|
||||
// // } else if(conduit.getConectionMode(dir) == ConnectionMode.IN_OUT) {
|
||||
// // tex = pc.getTextureForInOutMode();
|
||||
// // }
|
||||
// // if(tex != null) {
|
||||
// // Offset offset = te.getOffset(IItemConduit.class, dir);
|
||||
// // ConnectionModeGeometry.renderModeConnector(dir, offset, tex);
|
||||
// // }
|
||||
// // }
|
||||
//
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected void renderConduit(Icon tex, IConduit conduit, CollidableComponent component, float brightness) {
|
||||
if(ItemConduit.EXTERNAL_INTERFACE_GEOM.equals(component.data)) {
|
||||
CubeRenderer.render(component.bound, tex);
|
||||
} else if(isNSEWUP(component.dir)) {
|
||||
IItemConduit lc = (IItemConduit) conduit;
|
||||
|
||||
float scaleFactor = 0.6f;
|
||||
float xLen = Math.abs(component.dir.offsetX) == 1 ? 1 : scaleFactor;
|
||||
float yLen = Math.abs(component.dir.offsetY) == 1 ? 1 : scaleFactor;
|
||||
float zLen = Math.abs(component.dir.offsetZ) == 1 ? 1 : scaleFactor;
|
||||
|
||||
scaleFactor -= 0.1f;
|
||||
float xLen2 = Math.abs(component.dir.offsetX) == 1 ? 1 : scaleFactor;
|
||||
float yLen2 = Math.abs(component.dir.offsetY) == 1 ? 1 : scaleFactor;
|
||||
float zLen2 = Math.abs(component.dir.offsetZ) == 1 ? 1 : scaleFactor;
|
||||
|
||||
BoundingBox[] cubes = toCubes(component.bound);
|
||||
for (BoundingBox cube : cubes) {
|
||||
|
||||
BoundingBox bb = cube.scale(xLen, yLen, zLen);
|
||||
drawSection(bb, tex.getMinU(), tex.getMaxU(), tex.getMinV(), tex.getMaxV(), component.dir, false);
|
||||
bb = cube.scale(xLen2, yLen2, zLen2);
|
||||
CubeRenderer.render(bb, ((IItemConduit) conduit).getEnderIcon());
|
||||
}
|
||||
|
||||
} else {
|
||||
drawSection(component.bound, tex.getMinU(), tex.getMaxU(), tex.getMinV(), tex.getMaxV(), component.dir, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void renderFluidCenter(CollidableComponent component, IItemConduit conduit) {
|
||||
|
||||
if(component == null || component.dir == ForgeDirection.UNKNOWN) {
|
||||
return;
|
||||
}
|
||||
|
||||
BoundingBox bb = component.bound;
|
||||
float scaleFactor = 0.6f;
|
||||
float xLen = Math.abs(component.dir.offsetX) == 1 ? 1 : scaleFactor;
|
||||
float yLen = Math.abs(component.dir.offsetY) == 1 ? 1 : scaleFactor;
|
||||
float zLen = Math.abs(component.dir.offsetZ) == 1 ? 1 : scaleFactor;
|
||||
bb = bb.scale(xLen, yLen, zLen);
|
||||
CubeRenderer.render(bb, conduit.getEnderIcon());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package crazypants.enderio.conduit.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.AbstractItemConduit;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.ItemConduitSubtype;
|
||||
|
||||
public class ItemItemConduit extends AbstractItemConduit {
|
||||
|
||||
private static ItemConduitSubtype[] subtypes = new ItemConduitSubtype[] {
|
||||
new ItemConduitSubtype(ModObject.itemItemConduit.unlocalisedName, ModObject.itemItemConduit.name, "enderio:itemItemConduit"),
|
||||
new ItemConduitSubtype(ModObject.itemItemConduit.unlocalisedName + "Advanced", "Advanced Item Conduit", "enderio:itemItemConduitAdvanced"),
|
||||
};
|
||||
|
||||
public static ItemItemConduit create() {
|
||||
ItemItemConduit result = new ItemItemConduit();
|
||||
result.init(subtypes);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected ItemItemConduit() {
|
||||
super(ModObject.itemItemConduit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IConduit> getBaseConduitType() {
|
||||
return IItemConduit.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConduit createConduit(ItemStack item) {
|
||||
if(item.getItemDamage() == 1) {
|
||||
return new ItemConduit(true);
|
||||
}
|
||||
return new ItemConduit();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class LiquidConduit extends AbstractConduit implements ILiquidConduit {
|
||||
|
||||
if(!getBundle().getEntity().worldObj.isRemote) {
|
||||
|
||||
if(res.component != null) {
|
||||
if(res != null && res.component != null) {
|
||||
ForgeDirection connDir = res.component.dir;
|
||||
ForgeDirection faceHit = ForgeDirection.getOrientation(res.movingObjectPosition.sideHit);
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ public class LiquidConduitRenderer extends DefaultConduitRenderer {
|
||||
Tessellator tes = Tessellator.instance;
|
||||
tes.setNormal(face.offsetX, face.offsetY, face.offsetZ);
|
||||
|
||||
float scaleFactor = 14f / 16f;
|
||||
float scaleFactor = 13f / 16f;
|
||||
Vector2d uv = new Vector2d();
|
||||
List<ForgeDirection> edges = RenderUtil.getEdgesForFace(face);
|
||||
for (ForgeDirection edge : edges) {
|
||||
|
||||
@@ -101,7 +101,7 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
public boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List<RaytraceResult> all) {
|
||||
if(ConduitUtil.isToolEquipped(player)) {
|
||||
if(!getBundle().getEntity().worldObj.isRemote) {
|
||||
if(res.component != null) {
|
||||
if(res != null && res.component != null) {
|
||||
ForgeDirection connDir = res.component.dir;
|
||||
ForgeDirection faceHit = ForgeDirection.getOrientation(res.movingObjectPosition.sideHit);
|
||||
|
||||
|
||||
@@ -1,113 +1,22 @@
|
||||
package crazypants.enderio.conduit.power;
|
||||
|
||||
import static crazypants.util.ForgeDirectionOffsets.offsetScaled;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.conduit.ConnectionMode;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
import crazypants.enderio.conduit.geom.ConduitGeometryUtil;
|
||||
import crazypants.enderio.conduit.geom.ConnectionModeGeometry;
|
||||
import crazypants.enderio.conduit.geom.Offset;
|
||||
import crazypants.enderio.conduit.render.ConduitBundleRenderer;
|
||||
import crazypants.enderio.conduit.render.DefaultConduitRenderer;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.VertexRotation;
|
||||
import crazypants.render.VertexTransform;
|
||||
import crazypants.render.VertexTransformComposite;
|
||||
import crazypants.render.VertexTranslation;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
import crazypants.vecmath.Vertex;
|
||||
|
||||
public class PowerConduitRenderer extends DefaultConduitRenderer {
|
||||
|
||||
private static final EnumMap<ForgeDirection, List<Vertex>> VERTS = new EnumMap<ForgeDirection, List<Vertex>>(ForgeDirection.class);
|
||||
|
||||
static {
|
||||
|
||||
float scale = 0.8f;
|
||||
BoundingBox refBB = ConduitGeometryUtil.CORE_BOUNDS;
|
||||
refBB = refBB.scale(scale, scale, scale);
|
||||
refBB = refBB.scale(scale, 1, 1);
|
||||
|
||||
double offset = (ConduitGeometryUtil.HWIDTH * scale * scale) + ConduitBundleRenderer.CONNECTOR_DEPTH;
|
||||
|
||||
ForgeDirection dir;
|
||||
Vector3d trans;
|
||||
|
||||
VertexRotation vrot = new VertexRotation(Math.PI / 2, new Vector3d(0, 1, 0), new Vector3d(0.5, 0.5, 0.5));
|
||||
VertexTranslation vtrans = new VertexTranslation(0, 0, 0);
|
||||
VertexTransformComposite xform = new VertexTransformComposite(vrot, vtrans);
|
||||
|
||||
dir = ForgeDirection.SOUTH;
|
||||
trans = offsetScaled(dir, 0.5);
|
||||
trans.sub(offsetScaled(dir, offset));
|
||||
vtrans.set(trans);
|
||||
VERTS.put(dir, createVerticesForDir(refBB, xform));
|
||||
|
||||
dir = ForgeDirection.NORTH;
|
||||
vrot.setAngle(Math.PI + Math.PI / 2);
|
||||
trans = offsetScaled(dir, 0.5);
|
||||
trans.sub(offsetScaled(dir, offset));
|
||||
vtrans.set(trans);
|
||||
VERTS.put(dir, createVerticesForDir(refBB, xform));
|
||||
|
||||
dir = ForgeDirection.EAST;
|
||||
vrot.setAngle(Math.PI);
|
||||
trans = offsetScaled(dir, 0.5);
|
||||
trans.sub(offsetScaled(dir, offset));
|
||||
vtrans.set(trans);
|
||||
VERTS.put(dir, createVerticesForDir(refBB, xform));
|
||||
|
||||
dir = ForgeDirection.WEST;
|
||||
vrot.setAngle(0);
|
||||
trans = offsetScaled(dir, 0.5);
|
||||
trans.sub(offsetScaled(dir, offset));
|
||||
vtrans.set(trans);
|
||||
VERTS.put(dir, createVerticesForDir(refBB, xform));
|
||||
|
||||
vrot.setAxis(new Vector3d(0, 0, 1));
|
||||
|
||||
dir = ForgeDirection.UP;
|
||||
vrot.setAngle(-Math.PI / 2);
|
||||
trans = offsetScaled(dir, 0.5);
|
||||
trans.sub(offsetScaled(dir, offset));
|
||||
vtrans.set(trans);
|
||||
VERTS.put(dir, createVerticesForDir(refBB, xform));
|
||||
|
||||
dir = ForgeDirection.DOWN;
|
||||
vrot.setAngle(Math.PI / 2);
|
||||
trans = offsetScaled(dir, 0.5);
|
||||
trans.sub(offsetScaled(dir, offset));
|
||||
vtrans.set(trans);
|
||||
VERTS.put(dir, createVerticesForDir(refBB, xform));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRendererForConduit(IConduit conduit) {
|
||||
return conduit instanceof IPowerConduit;
|
||||
}
|
||||
|
||||
private static List<Vertex> createVerticesForDir(BoundingBox refBB, VertexTransform xform) {
|
||||
List<Vertex> result = new ArrayList<Vertex>(24);
|
||||
for (ForgeDirection face : ForgeDirection.VALID_DIRECTIONS) {
|
||||
result.addAll(refBB.getCornersWithUvForFace(face));
|
||||
}
|
||||
for (Vertex v : result) {
|
||||
xform.apply(v.xyz);
|
||||
//v.xyz.set(v.x(), v.y() + 1, v.z());
|
||||
xform.applyToNormal(v.normal);
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderEntity(ConduitBundleRenderer conduitBundleRenderer, IConduitBundle te, IConduit conduit, double x, double y, double z, float partialTick,
|
||||
float worldLight) {
|
||||
@@ -126,34 +35,10 @@ public class PowerConduitRenderer extends DefaultConduitRenderer {
|
||||
}
|
||||
if(tex != null) {
|
||||
Offset offset = te.getOffset(IPowerConduit.class, dir);
|
||||
renderModeConnector(pc, dir, offset, tex);
|
||||
ConnectionModeGeometry.renderModeConnector(dir, offset, tex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void renderModeConnector(IPowerConduit pc, ForgeDirection dir, Offset offset, Icon tex) {
|
||||
List<Vertex> verts = VERTS.get(dir);
|
||||
if(verts == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3d trans = ConduitGeometryUtil.instance.getTranslation(dir, offset);
|
||||
|
||||
// double xOffset = offset.xOffset * ConduitGeometryUtil.WIDTH;
|
||||
// double yOffset = offset.yOffset * ConduitGeometryUtil.HEIGHT;
|
||||
|
||||
float uWidth = tex.getMaxU() - tex.getMinU();
|
||||
float uScale = uWidth * 0.64f;
|
||||
float minU = tex.getMinU() + (uWidth - uScale);
|
||||
float vScale = tex.getMaxV() - tex.getMinV();
|
||||
|
||||
Tessellator tes = Tessellator.instance;
|
||||
for (Vertex v : verts) {
|
||||
tes.setNormal(v.nx(), v.ny(), v.nz());
|
||||
tes.addVertexWithUV(v.x() + trans.x, v.y() + trans.y, v.z() + trans.z, minU + (v.u() * uScale), tex.getMinV() + (v.v() * vScale));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ public interface IInsulatedRedstoneConduit extends IRedstoneConduit {
|
||||
static final String KEY_INS_CORE_ON_ICON = "enderio:redstoneInsulatedConduitCoreOn";
|
||||
static final String KEY_COLOR_CONTROLLER = "enderio:white";
|
||||
|
||||
static final String COLOR_CONTROLLER_ID = "ColorController";
|
||||
public static final String COLOR_CONTROLLER_ID = "ColorController";
|
||||
|
||||
public void onInputsChanged(ForgeDirection side, int[] inputValues);
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
|
||||
return true;
|
||||
} else if(ConduitUtil.isToolEquipped(player)) {
|
||||
|
||||
if(res.component != null) {
|
||||
if(res != null && res.component != null) {
|
||||
ForgeDirection connDir = res.component.dir;
|
||||
ForgeDirection faceHit = ForgeDirection.getOrientation(res.movingObjectPosition.sideHit);
|
||||
|
||||
@@ -167,7 +167,7 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
|
||||
|
||||
@Override
|
||||
public Class<? extends IConduit> getCollidableType() {
|
||||
return InsulatedRedstoneConduit.class;
|
||||
return IInsulatedRedstoneConduit.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package crazypants.enderio.conduit.render;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -24,6 +26,7 @@ import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.BlockConduitBundle;
|
||||
import crazypants.enderio.conduit.ConduitDisplayMode;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.conduit.ConnectionMode;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
@@ -48,6 +51,12 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements
|
||||
}
|
||||
}
|
||||
|
||||
public BoundingBox getExternalConnectorBoundsForDirection(ForgeDirection dir) {
|
||||
BoundingBox[] bbs = connectorBounds.get(dir);
|
||||
BoundingBox result = bbs[0];
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTick) {
|
||||
IConduitBundle bundle = (IConduitBundle) te;
|
||||
@@ -95,13 +104,25 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements
|
||||
|
||||
// Conduits
|
||||
Set<ForgeDirection> externals = new HashSet<ForgeDirection>();
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
List<BoundingBox> wireBounds = new ArrayList<BoundingBox>();
|
||||
|
||||
for (IConduit con : bundle.getConduits()) {
|
||||
ConduitRenderer renderer = EnderIO.proxy.getRendererForConduit(con);
|
||||
renderer.renderEntity(this, bundle, con, x, y, z, partialTick, brightness);
|
||||
Set<ForgeDirection> extCons = con.getExternalConnections();
|
||||
for (ForgeDirection dir : extCons) {
|
||||
if(con.getConectionMode(dir) != ConnectionMode.DISABLED && con.getConectionMode(dir) != ConnectionMode.NOT_SET) {
|
||||
externals.add(dir);
|
||||
|
||||
if(ConduitUtil.renderConduit(player, con)) {
|
||||
ConduitRenderer renderer = EnderIO.proxy.getRendererForConduit(con);
|
||||
renderer.renderEntity(this, bundle, con, x, y, z, partialTick, brightness);
|
||||
Set<ForgeDirection> extCons = con.getExternalConnections();
|
||||
for (ForgeDirection dir : extCons) {
|
||||
if(con.getConectionMode(dir) != ConnectionMode.DISABLED && con.getConectionMode(dir) != ConnectionMode.NOT_SET) {
|
||||
externals.add(dir);
|
||||
}
|
||||
}
|
||||
} else if(con != null) {
|
||||
Collection<CollidableComponent> components = con.getCollidableComponents();
|
||||
for (CollidableComponent component : components) {
|
||||
wireBounds.add(component.bound);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,16 +132,30 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements
|
||||
List<CollidableComponent> connectors = bundle.getConnectors();
|
||||
for (CollidableComponent component : connectors) {
|
||||
if(component.conduitType != null) {
|
||||
IConduit con = bundle.getConduit(component.conduitType);
|
||||
float selfIllum = Math.max(brightness, con.getSelfIlluminationForState(component));
|
||||
tessellator.setColorRGBA_F(selfIllum, selfIllum, selfIllum, 1);
|
||||
CubeRenderer.render(component.bound, con.getTextureForState(component));
|
||||
} else {
|
||||
IConduit conduit = bundle.getConduit(component.conduitType);
|
||||
if(conduit != null) {
|
||||
if(ConduitUtil.renderConduit(player, component.conduitType)) {
|
||||
float selfIllum = Math.max(brightness, conduit.getSelfIlluminationForState(component));
|
||||
tessellator.setColorRGBA_F(selfIllum, selfIllum, selfIllum, 1);
|
||||
CubeRenderer.render(component.bound, conduit.getTextureForState(component));
|
||||
} else {
|
||||
wireBounds.add(component.bound);
|
||||
}
|
||||
}
|
||||
|
||||
} else if(ConduitUtil.getDisplayMode(player) == ConduitDisplayMode.ALL) {
|
||||
Icon tex = EnderIO.blockConduitBundle.getConnectorIcon();
|
||||
CubeRenderer.render(component.bound, tex);
|
||||
}
|
||||
}
|
||||
|
||||
//render these after the 'normal' conduits so help with proper blending
|
||||
for (BoundingBox wireBound : wireBounds) {
|
||||
Tessellator.instance.setColorRGBA_F(1, 1, 1, 0.25f);
|
||||
CubeRenderer.render(wireBound, EnderIO.blockConduitFacade.getIcon(0, 0));
|
||||
Tessellator.instance.setColorRGBA_F(1, 1, 1, 1f);
|
||||
}
|
||||
|
||||
// External connection terminations
|
||||
for (ForgeDirection dir : externals) {
|
||||
renderExternalConnection(dir);
|
||||
|
||||
@@ -8,6 +8,8 @@ import java.util.List;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.conduit.geom.ConduitGeometryUtil;
|
||||
import crazypants.enderio.conduit.geom.Offsets;
|
||||
import crazypants.enderio.conduit.geom.Offsets.Axis;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.vecmath.Matrix4d;
|
||||
import crazypants.vecmath.Vector2f;
|
||||
@@ -173,10 +175,13 @@ public class RoundedSegmentRenderer {
|
||||
private static Vector3d calcOffset(ForgeDirection dir, BoundingBox bounds) {
|
||||
Vector3d res = new Vector3d();
|
||||
Vector3d center = bounds.getCenter();
|
||||
if(dir != ForgeDirection.UP && dir != ForgeDirection.DOWN) {
|
||||
res.set(0, center.y - REF_TRANS.y, 0);
|
||||
} else {
|
||||
res.set(center.x - REF_TRANS.x, 0, 0);
|
||||
Axis axis = Offsets.getAxisForDir(dir);
|
||||
if(axis == Axis.X) {
|
||||
res.set(0, center.y - REF_TRANS.y, center.z - REF_TRANS.z);
|
||||
} else if(axis == Axis.Y) {
|
||||
res.set(center.x - REF_TRANS.x, 0, center.z - REF_TRANS.z);
|
||||
} else if(axis == Axis.Z) {
|
||||
res.set(center.x - REF_TRANS.x, center.y - REF_TRANS.y, 0);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,6 @@ package crazypants.enderio.gui;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import crazypants.render.RenderUtil;
|
||||
|
||||
public final class IconEIO {
|
||||
@@ -23,6 +20,13 @@ public final class IconEIO {
|
||||
public static final IconEIO BUTTON_DOWN = new IconEIO(48, 116);
|
||||
public static final IconEIO BUTTON_DOWN_HIGHLIGHT = new IconEIO(64, 116);
|
||||
|
||||
public static final IconEIO WRENCH_OVERLAY_ALL_ON = new IconEIO(0, 148, 32, 32);
|
||||
public static final IconEIO WRENCH_OVERLAY_ALL_OFF = new IconEIO(32, 148, 32, 32);
|
||||
public static final IconEIO WRENCH_OVERLAY_POWER = new IconEIO(0, 148);
|
||||
public static final IconEIO WRENCH_OVERLAY_REDSTONE = new IconEIO(16, 148);
|
||||
public static final IconEIO WRENCH_OVERLAY_ITEM = new IconEIO(0, 164);
|
||||
public static final IconEIO WRENCH_OVERLAY_FLUID = new IconEIO(16, 164);
|
||||
|
||||
private static final int TEX_SIZE = 256;
|
||||
private static final double PIX_SIZE = 1d / TEX_SIZE;
|
||||
|
||||
@@ -30,6 +34,8 @@ public final class IconEIO {
|
||||
public final double maxU;
|
||||
public final double minV;
|
||||
public final double maxV;
|
||||
public final double width;
|
||||
public final double height;
|
||||
|
||||
public static final ResourceLocation TEXTURE = new ResourceLocation("enderio:textures/gui/widgets.png");
|
||||
|
||||
@@ -38,22 +44,20 @@ public final class IconEIO {
|
||||
}
|
||||
|
||||
public IconEIO(int x, int y, int width, int height) {
|
||||
this((float) (PIX_SIZE * x), (float) (PIX_SIZE * (x + width)), (float) (PIX_SIZE * y), (float) (PIX_SIZE * (y + height)));
|
||||
this(width, height, (float) (PIX_SIZE * x), (float) (PIX_SIZE * (x + width)), (float) (PIX_SIZE * y), (float) (PIX_SIZE * (y + height)));
|
||||
}
|
||||
|
||||
public IconEIO(double minU, double maxU, double minV, double maxV) {
|
||||
public IconEIO(double width, double height, double minU, double maxU, double minV, double maxV) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.minU = minU;
|
||||
this.maxU = maxU;
|
||||
this.minV = minV;
|
||||
this.maxV = maxV;
|
||||
// this.minU = maxU;
|
||||
// this.maxU = minU;
|
||||
// this.minV = maxV;
|
||||
// this.maxV = minV;
|
||||
}
|
||||
|
||||
public void renderIcon(double x, double y) {
|
||||
renderIcon(x, y, 16, 16, 0, false);
|
||||
renderIcon(x, y, width, height, 0, false);
|
||||
}
|
||||
|
||||
public void renderIcon(double x, double y, double width, double height, double zLevel, boolean doDraw) {
|
||||
@@ -61,7 +65,6 @@ public final class IconEIO {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
if(doDraw) {
|
||||
RenderUtil.bindTexture(TEXTURE);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
tessellator.startDrawingQuads();
|
||||
}
|
||||
tessellator.addVertexWithUV(x, y + height, zLevel, minU, maxV);
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package crazypants.enderio.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.material.Alloy;
|
||||
import crazypants.enderio.material.MachinePart;
|
||||
|
||||
public class ItemRecipes {
|
||||
|
||||
public static void addRecipes() {
|
||||
ItemStack basicGear = new ItemStack(ModObject.itemMachinePart.actualId, 1, MachinePart.BASIC_GEAR.ordinal());
|
||||
ItemStack electricalSteel = new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.ELECTRICAL_STEEL.ordinal());
|
||||
ItemStack wrench = new ItemStack(ModObject.itemYetaWrench.actualId, 1, 0);
|
||||
|
||||
// Wrench
|
||||
GameRegistry.addShapedRecipe(wrench, "s s", " b ", " s ", 's', electricalSteel, 'b', basicGear);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package crazypants.enderio.material;
|
||||
package crazypants.enderio.item;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
@@ -10,14 +10,22 @@ import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.common.registry.TickRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.Config;
|
||||
import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.PacketHandler;
|
||||
import crazypants.enderio.conduit.ConduitDisplayMode;
|
||||
|
||||
public class ItemYetaWrench extends Item implements IToolWrench {
|
||||
|
||||
public static ItemYetaWrench create() {
|
||||
if(Config.useSneakMouseWheelYetaWrench) {
|
||||
PacketHandler.instance.addPacketProcessor(new YetaWrenchPacketProcessor());
|
||||
TickRegistry.registerTickHandler(new YetaWrenchTickHandler(), Side.CLIENT);
|
||||
}
|
||||
ItemYetaWrench result = new ItemYetaWrench();
|
||||
result.init();
|
||||
return result;
|
||||
@@ -33,6 +41,7 @@ public class ItemYetaWrench extends Item implements IToolWrench {
|
||||
protected void init() {
|
||||
LanguageRegistry.addName(this, ModObject.itemYetaWrench.name);
|
||||
GameRegistry.registerItem(this, ModObject.itemYetaWrench.unlocalisedName);
|
||||
new YetaWrenchOverlayRenderer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,6 +61,23 @@ public class ItemYetaWrench extends Item implements IToolWrench {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack equipped, World world, EntityPlayer player) {
|
||||
if(!Config.useSneakRightClickYetaWrench) {
|
||||
return equipped;
|
||||
}
|
||||
if(!player.isSneaking()) {
|
||||
return equipped;
|
||||
}
|
||||
ConduitDisplayMode curMode = ConduitDisplayMode.getDisplayMode(equipped);
|
||||
if(curMode == null) {
|
||||
curMode = ConduitDisplayMode.ALL;
|
||||
}
|
||||
ConduitDisplayMode newMode = curMode.next();
|
||||
ConduitDisplayMode.setDisplayMode(equipped, newMode);
|
||||
return equipped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrench(EntityPlayer player, int x, int y, int z) {
|
||||
return true;
|
||||
@@ -0,0 +1,71 @@
|
||||
package crazypants.enderio.item;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.EventPriority;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import crazypants.enderio.conduit.ConduitDisplayMode;
|
||||
import crazypants.enderio.gui.IconEIO;
|
||||
|
||||
public class YetaWrenchOverlayRenderer {
|
||||
|
||||
private ItemYetaWrench wrench;
|
||||
|
||||
public YetaWrenchOverlayRenderer(ItemYetaWrench wrench) {
|
||||
this.wrench = wrench;
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@ForgeSubscribe(priority = EventPriority.NORMAL)
|
||||
public void renderOverlay(RenderGameOverlayEvent event) {
|
||||
ItemStack equippedWrench = getEquippedWrench();
|
||||
if(equippedWrench != null && event.type == ElementType.ALL) {
|
||||
doRenderOverlay(event, equippedWrench);
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack getEquippedWrench() {
|
||||
ItemStack equipped = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem();
|
||||
if(equipped != null && equipped.itemID == wrench.itemID) {
|
||||
return equipped;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void doRenderOverlay(RenderGameOverlayEvent event, ItemStack equippedWrench) {
|
||||
ConduitDisplayMode mode = ConduitDisplayMode.getDisplayMode(equippedWrench);
|
||||
ScaledResolution res = event.resolution;
|
||||
|
||||
double offsetX = 16;
|
||||
double offsetY = res.getScaledHeight() - 16;
|
||||
|
||||
if(mode == ConduitDisplayMode.ALL) {
|
||||
GL11.glColor4f(1, 1, 1, 0.75f);
|
||||
IconEIO.WRENCH_OVERLAY_ALL_ON.renderIcon(offsetX, offsetY - 32, 32, 32, 0, true);
|
||||
return;
|
||||
}
|
||||
|
||||
float c = 0.6f;
|
||||
GL11.glColor4f(c, c, c, 0.33f);
|
||||
IconEIO.WRENCH_OVERLAY_ALL_OFF.renderIcon(offsetX, offsetY - 32, 32, 32, 0, true);
|
||||
GL11.glColor4f(1, 1, 1, 0.75f);
|
||||
if(mode == ConduitDisplayMode.POWER) {
|
||||
IconEIO.WRENCH_OVERLAY_POWER.renderIcon(offsetX, offsetY - 32, 16, 16, 0, true);
|
||||
} else if(mode == ConduitDisplayMode.FLUID) {
|
||||
IconEIO.WRENCH_OVERLAY_FLUID.renderIcon(offsetX + 16, offsetY - 16, 16, 16, 0, true);
|
||||
} else if(mode == ConduitDisplayMode.ITEM) {
|
||||
IconEIO.WRENCH_OVERLAY_ITEM.renderIcon(offsetX, offsetY - 16, 16, 16, 0, true);
|
||||
} else if(mode == ConduitDisplayMode.REDSTONE) {
|
||||
IconEIO.WRENCH_OVERLAY_REDSTONE.renderIcon(offsetX + 16, offsetY - 32, 16, 16, 0, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package crazypants.enderio.item;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import crazypants.enderio.IPacketProcessor;
|
||||
import crazypants.enderio.PacketHandler;
|
||||
import crazypants.enderio.conduit.ConduitDisplayMode;
|
||||
|
||||
public class YetaWrenchPacketProcessor implements IPacketProcessor {
|
||||
|
||||
public static Packet getSmeltingModePacket(int slot, ConduitDisplayMode mode) {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(140);
|
||||
DataOutputStream dos = new DataOutputStream(bos);
|
||||
try {
|
||||
dos.writeInt(PacketHandler.ID_YETA_WRENCH_MODE_PACKET);
|
||||
dos.writeInt(slot);
|
||||
dos.writeShort(mode.ordinal());
|
||||
} catch (IOException e) {
|
||||
// never thrown
|
||||
}
|
||||
|
||||
Packet250CustomPayload pkt = new Packet250CustomPayload();
|
||||
pkt.channel = PacketHandler.CHANNEL;
|
||||
pkt.data = bos.toByteArray();
|
||||
pkt.length = bos.size();
|
||||
pkt.isChunkDataPacket = true;
|
||||
return pkt;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProcessPacket(int packetID) {
|
||||
return packetID == PacketHandler.ID_YETA_WRENCH_MODE_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPacket(int packetID, INetworkManager manager, DataInputStream data, Player playerIn) throws IOException {
|
||||
|
||||
int slot = -1;
|
||||
if(!(playerIn instanceof EntityPlayerMP)) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayerMP player = (EntityPlayerMP) playerIn;
|
||||
slot = data.readInt();
|
||||
short ordinal = data.readShort();
|
||||
|
||||
ItemStack stack = null;
|
||||
if(slot > -1 && slot < 9) {
|
||||
stack = player.inventory.getStackInSlot(slot);
|
||||
}
|
||||
if(stack == null) {
|
||||
return;
|
||||
}
|
||||
ConduitDisplayMode.setDisplayMode(stack, ConduitDisplayMode.values()[ordinal]);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package crazypants.enderio.item;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import crazypants.enderio.conduit.ConduitDisplayMode;
|
||||
|
||||
public class YetaWrenchTickHandler implements ITickHandler {
|
||||
protected int slotSelected = -1;
|
||||
public static int dWheel;
|
||||
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData) {
|
||||
|
||||
dWheel = Mouse.getDWheel() / 120;
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
if(player != null && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemYetaWrench
|
||||
&& player.isSneaking()) {
|
||||
slotSelected = player.inventory.currentItem;
|
||||
} else {
|
||||
slotSelected = -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
if(player != null) {
|
||||
if(slotSelected > -1 && dWheel != Mouse.getDWheel()) {
|
||||
player.inventory.currentItem = slotSelected;
|
||||
Minecraft.getMinecraft().playerController.updateController();
|
||||
|
||||
ItemStack stack = player.inventory.getStackInSlot(slotSelected);
|
||||
ConduitDisplayMode curMode = ConduitDisplayMode.getDisplayMode(stack);
|
||||
if(curMode == null) {
|
||||
curMode = ConduitDisplayMode.ALL;
|
||||
}
|
||||
|
||||
int dif = dWheel - Mouse.getDWheel();
|
||||
ConduitDisplayMode newMode = null;
|
||||
if(dif > 0) {
|
||||
newMode = curMode.next();
|
||||
ConduitDisplayMode.setDisplayMode(stack, newMode);
|
||||
} else if(dif < 0) {
|
||||
newMode = curMode.previous();
|
||||
ConduitDisplayMode.setDisplayMode(stack, newMode);
|
||||
}
|
||||
if(newMode != null) {
|
||||
player.sendQueue.addToSendQueue(YetaWrenchPacketProcessor.getSmeltingModePacket(slotSelected, newMode));
|
||||
}
|
||||
}
|
||||
slotSelected = -1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks() {
|
||||
return EnumSet.of(TickType.CLIENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "YetaWrenchTickHandler: Client Tick";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -538,7 +538,7 @@ public class TileHyperCube extends TileEntity implements IInternalPowerReceptor,
|
||||
nbtRoot.setString("channelUser", channel.user);
|
||||
}
|
||||
}
|
||||
if (owner != null && !(owner.isEmpty())) {
|
||||
if(owner != null && !(owner.isEmpty())) {
|
||||
nbtRoot.setString("owner", owner);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,11 @@ public enum Alloy {
|
||||
|
||||
CONDUCTIVE_IRON("Conductive Iron", "conductiveIron",
|
||||
new ItemStack(Item.redstone, 2),
|
||||
new ItemStack(Item.ingotIron));
|
||||
new ItemStack(Item.ingotIron)),
|
||||
|
||||
PHASED_IRON("Phased Iron", "phasedIron",
|
||||
new ItemStack(Item.ingotIron),
|
||||
new ItemStack(ModObject.itemPowderIngot.actualId, 1, PowderIngot.POWDER_ENDER.ordinal()));
|
||||
|
||||
public final String unlocalisedName;
|
||||
public final String uiName;
|
||||
|
||||
@@ -27,6 +27,7 @@ public class MaterialRecipes {
|
||||
OreDictionary.registerOre("dustGold", new ItemStack(ModObject.itemPowderIngot.actualId, 1, PowderIngot.POWDER_GOLD.ordinal()));
|
||||
OreDictionary.registerOre("dustCopper", new ItemStack(ModObject.itemPowderIngot.actualId, 1, PowderIngot.POWDER_COPPER.ordinal()));
|
||||
OreDictionary.registerOre("dustTin", new ItemStack(ModObject.itemPowderIngot.actualId, 1, PowderIngot.POWDER_TIN.ordinal()));
|
||||
OreDictionary.registerOre("dustEnderPearl", new ItemStack(ModObject.itemPowderIngot.actualId, 1, PowderIngot.POWDER_ENDER.ordinal()));
|
||||
}
|
||||
|
||||
public static void addRecipes() {
|
||||
@@ -36,7 +37,6 @@ public class MaterialRecipes {
|
||||
ItemStack basicGear = new ItemStack(ModObject.itemMachinePart.actualId, 1, MachinePart.BASIC_GEAR.ordinal());
|
||||
ItemStack binderComposite = new ItemStack(ModObject.itemMaterial.actualId, 1, Material.BINDER_COMPOSITE.ordinal());
|
||||
ItemStack industrialBinder = new ItemStack(ModObject.itemMaterial.actualId, 1, Material.CONDUIT_BINDER.ordinal());
|
||||
ItemStack wrench = new ItemStack(ModObject.itemYetaWrench.actualId, 1, 0);
|
||||
ItemStack enderCapacitor = new ItemStack(itemBasicCapacitor.actualId, 1, 2);
|
||||
ItemStack fusedQuartzFrame = new ItemStack(ModObject.itemFusedQuartzFrame.actualId, 1, 0);
|
||||
ItemStack machineChassi = new ItemStack(ModObject.itemMachinePart.actualId, 1, MachinePart.MACHINE_CHASSI.ordinal());
|
||||
@@ -73,16 +73,18 @@ public class MaterialRecipes {
|
||||
MachineRecipeRegistry.instance.registerRecipe(ModObject.blockAlloySmelter.unlocalisedName, new FusedQuartzRecipe());
|
||||
MachineRecipeRegistry.instance.registerRecipe(ModObject.blockAlloySmelter.unlocalisedName, new VanillaSmeltingRecipe());
|
||||
|
||||
//Smelting
|
||||
FurnaceRecipes.smelting().addSmelting(ModObject.itemPowderIngot.actualId, PowderIngot.POWDER_IRON.ordinal(), new ItemStack(Item.ingotIron), 0);
|
||||
FurnaceRecipes.smelting().addSmelting(ModObject.itemPowderIngot.actualId, PowderIngot.POWDER_GOLD.ordinal(), new ItemStack(Item.ingotGold), 0);
|
||||
|
||||
//Ender Dusts
|
||||
ItemStack enderDust = new ItemStack(ModObject.itemPowderIngot.actualId, 1, PowderIngot.POWDER_ENDER.ordinal());
|
||||
GameRegistry.addShapedRecipe(new ItemStack(Item.enderPearl), "eee", "eee", "eee", 'e', enderDust);
|
||||
|
||||
// Fused Quartz Frame
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(fusedQuartzFrame, "bsb", "s s", "bsb", 'b', conduitBinder, 's', "stickWood"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(fusedQuartzFrame, "bsb", "s s", "bsb", 'b', conduitBinder, 's', "woodStick"));
|
||||
|
||||
// Wrench
|
||||
GameRegistry.addShapedRecipe(wrench, "s s", " b ", " s ", 's', electricalSteel, 'b', basicGear);
|
||||
|
||||
// Machine Chassi
|
||||
GameRegistry.addShapedRecipe(machineChassi, "fif", "i i", "fif", 'f', Block.fenceIron, 'i', Item.ingotIron);
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@ public enum PowderIngot {
|
||||
POWDER_IRON("powderIron", "Iron Powder", "powderIron"),
|
||||
POWDER_GOLD("powderGold", "Gold Powder", "powderGold"),
|
||||
POWDER_COPPER("powderCopper", "Copper Powder", "powderCopper"),
|
||||
POWDER_TIN("powderTin", "Tin Powder", "powderTin");
|
||||
POWDER_TIN("powderTin", "Tin Powder", "powderTin"),
|
||||
POWDER_ENDER("powderEnder", "Ender Pearl Powder", "powderEnder");
|
||||
// POWDER_LEAD("powderLead", "Lead Powder", "powderLead"),
|
||||
// POWDER_SILVER("powderSilver", "Silver Powder", "powderSilver"),
|
||||
// POWDER_BRONZE("powderBronze", "Bronze Powder", "powderBronze"),
|
||||
|
||||
@@ -57,6 +57,15 @@ public final class BoundingBox {
|
||||
Math.max(maxX, other.maxX), Math.max(maxY, other.maxY), Math.max(maxZ, other.maxZ));
|
||||
}
|
||||
|
||||
public boolean contains(BoundingBox other) {
|
||||
return minX >= other.minX && minY <= other.minY && minZ <= other.minZ && maxX >= other.maxX && maxY <= other.maxY && maxZ <= other.maxZ;
|
||||
}
|
||||
|
||||
public boolean intersects(BoundingBox other) {
|
||||
return other.maxX > this.minX && other.minX < this.maxX ? (other.maxY > this.minY && other.minY < this.maxY ? other.maxZ > this.minZ
|
||||
&& other.minZ < this.maxZ : false) : false;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return minX < maxX && minY < maxY && minZ < maxZ;
|
||||
}
|
||||
@@ -83,6 +92,10 @@ public final class BoundingBox {
|
||||
return translate((float) translation.x, (float) translation.y, (float) translation.z);
|
||||
}
|
||||
|
||||
public BoundingBox translate(Vector3f vec) {
|
||||
return translate(vec.x, vec.y, vec.z);
|
||||
}
|
||||
|
||||
public BoundingBox transform(VertexTransform iTransformation) {
|
||||
Vector3d min = new Vector3d(minX, minY, minZ);
|
||||
Vector3d max = new Vector3d(maxX, maxY, maxZ);
|
||||
|
||||
@@ -104,4 +104,10 @@ public class Vector3d {
|
||||
return "Vector3d(" + x + ", " + y + ", " + z + ")";
|
||||
}
|
||||
|
||||
public void abs() {
|
||||
x = Math.abs(x);
|
||||
y = Math.abs(y);
|
||||
z = Math.abs(z);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -176,6 +176,15 @@
|
||||
<itemStack modID="EnderIO" itemName="enderIO:itemPowderIngot" itemMeta="2" />
|
||||
</output>
|
||||
</recipe>
|
||||
|
||||
<recipe name="EnderPearl" energyCost="160">
|
||||
<input>
|
||||
<itemStack itemID="368" />
|
||||
</input>
|
||||
<output>
|
||||
<itemStack modID="EnderIO" itemName="enderIO:itemPowderIngot" itemMeta="5" number="9" />
|
||||
</output>
|
||||
</recipe>
|
||||
|
||||
</recipeGroup>
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 3.8 KiB |
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"animation": {
|
||||
"frametime": 2,
|
||||
"frames": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19,
|
||||
18,
|
||||
17,
|
||||
16,
|
||||
15,
|
||||
14,
|
||||
13,
|
||||
12,
|
||||
11,
|
||||
10,
|
||||
9,
|
||||
8,
|
||||
7,
|
||||
6,
|
||||
5,
|
||||
4,
|
||||
3,
|
||||
2,
|
||||
1
|
||||
]
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 202 B |
|
After Width: | Height: | Size: 507 B |
|
After Width: | Height: | Size: 442 B |
|
After Width: | Height: | Size: 245 B |
|
After Width: | Height: | Size: 242 B |
|
After Width: | Height: | Size: 245 B |
|
Before Width: | Height: | Size: 401 B After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 950 B After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 622 B After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 169 B After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 396 B After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 435 B After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 443 B After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 180 B After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 171 B After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 218 B After Width: | Height: | Size: 833 B |
|
Before Width: | Height: | Size: 220 B After Width: | Height: | Size: 833 B |
|
Before Width: | Height: | Size: 221 B After Width: | Height: | Size: 833 B |
|
Before Width: | Height: | Size: 229 B After Width: | Height: | Size: 864 B |
|
Before Width: | Height: | Size: 233 B After Width: | Height: | Size: 864 B |
|
Before Width: | Height: | Size: 238 B After Width: | Height: | Size: 864 B |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 507 B |
|
After Width: | Height: | Size: 442 B |
|
Before Width: | Height: | Size: 950 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 396 B After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 435 B After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 443 B After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 410 B |