mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-10-26 14:24:40 +00:00
Ran formatter, organise imports and cleanup on code to get it all ion sync.
This commit is contained in:
1 parent
485ef1733b
commit
c37faa8549
147 files changed
+2343
-2513
No files matched your search
@@ -39,21 +39,19 @@ import crazypants.enderio.material.BlockFusedQuartz;
|
||||
import crazypants.enderio.material.FusedQuartzFrameRenderer;
|
||||
import crazypants.enderio.material.FusedQuartzRenderer;
|
||||
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
|
||||
//@formatter:off
|
||||
|
||||
// @formatter:off
|
||||
public static int[][] sideAndFacingToSpriteOffset = new int[][] {
|
||||
|
||||
{ 3, 2, 0, 0, 0, 0 },
|
||||
{ 2, 3, 1, 1, 1, 1 },
|
||||
{ 1, 1, 3, 2, 5, 4 },
|
||||
{ 0, 0, 2, 3, 4, 5 },
|
||||
{ 4, 5, 4, 5, 3, 2 },
|
||||
{ 5, 4, 5, 4, 2, 3 } };
|
||||
//@formatter:on
|
||||
|
||||
|
||||
{ 3, 2, 0, 0, 0, 0 },
|
||||
{ 2, 3, 1, 1, 1, 1 },
|
||||
{ 1, 1, 3, 2, 5, 4 },
|
||||
{ 0, 0, 2, 3, 4, 5 },
|
||||
{ 4, 5, 4, 5, 3, 2 },
|
||||
{ 5, 4, 5, 4, 2, 3 } };
|
||||
// @formatter:on
|
||||
|
||||
static {
|
||||
AbstractMachineBlock.initIcon();
|
||||
RedstoneConduit.initIcons();
|
||||
@@ -61,75 +59,75 @@ public class ClientProxy extends CommonProxy {
|
||||
PowerConduit.initIcons();
|
||||
LiquidConduit.initIcons();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private List<ConduitRenderer> conduitRenderers = new ArrayList<ConduitRenderer>();
|
||||
|
||||
|
||||
private DefaultConduitRenderer dcr = new DefaultConduitRenderer();
|
||||
|
||||
|
||||
@Override
|
||||
public World getClientWorld() {
|
||||
return FMLClientHandler.instance().getClient().theWorld;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EntityPlayer getClientPlayer() {
|
||||
return Minecraft.getMinecraft().thePlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
//Renderers
|
||||
|
||||
|
||||
// Renderers
|
||||
|
||||
ConduitBundleRenderer cbr = new ConduitBundleRenderer();
|
||||
BlockConduitBundle.rendererId = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderingRegistry.registerBlockHandler(cbr);
|
||||
|
||||
|
||||
BlockCustomFenceGateRenderer bcfgr = new BlockCustomFenceGateRenderer();
|
||||
BlockCustomFenceGate.renderId = RenderingRegistry.getNextAvailableRenderId();;
|
||||
BlockCustomFenceGate.renderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
;
|
||||
RenderingRegistry.registerBlockHandler(bcfgr);
|
||||
|
||||
BlockFusedQuartz.renderId = RenderingRegistry.getNextAvailableRenderId();;
|
||||
|
||||
BlockFusedQuartz.renderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
;
|
||||
RenderingRegistry.registerBlockHandler(new FusedQuartzRenderer());
|
||||
|
||||
|
||||
BlockElectricLight.renderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderingRegistry.registerBlockHandler(new ElectricLightRenderer());
|
||||
|
||||
|
||||
FusedQuartzFrameRenderer fqfr = new FusedQuartzFrameRenderer();
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.itemFusedQuartzFrame.itemID, fqfr);
|
||||
|
||||
|
||||
ItemConduitRenderer itemConRenderer = new ItemConduitRenderer();
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.itemLiquidConduit.itemID, itemConRenderer);
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.itemPowerConduit.itemID, itemConRenderer);
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.itemRedstoneConduit.itemID, itemConRenderer);
|
||||
|
||||
|
||||
PaintedItemRenderer pir = new PaintedItemRenderer();
|
||||
|
||||
PaintedItemRenderer pir = new PaintedItemRenderer();
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.blockCustomFence.blockID, pir);
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.blockCustomFenceGate.blockID, pir);
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.blockCustomWall.blockID, pir);
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.blockCustomStair.blockID, pir);
|
||||
|
||||
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.itemConduitFacade.itemID, new FacadeRenderer());
|
||||
|
||||
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileConduitBundle.class, cbr);
|
||||
conduitRenderers.add(RedstoneSwitchRenderer.instance);
|
||||
conduitRenderers.add(RedstoneSwitchRenderer.instance);
|
||||
conduitRenderers.add(new LiquidConduitRenderer());
|
||||
|
||||
|
||||
EnderIoRenderer eior = new EnderIoRenderer();
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEnderIO.class, eior);
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.blockEnderIo.blockID, eior);
|
||||
|
||||
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileReservoir.class, new ReservoirRenderer(EnderIO.blockReservoir));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ConduitRenderer getRendererForConduit(IConduit conduit) {
|
||||
for(ConduitRenderer renderer : conduitRenderers) {
|
||||
if(renderer.isRendererForConduit(conduit)) {
|
||||
for (ConduitRenderer renderer : conduitRenderers) {
|
||||
if (renderer.isRendererForConduit(conduit)) {
|
||||
return renderer;
|
||||
}
|
||||
}
|
||||
@@ -143,7 +141,5 @@ public class ClientProxy extends CommonProxy {
|
||||
}
|
||||
return super.getReachDistanceForPlayer(entityPlayer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -15,31 +15,30 @@ public class ClientTickHandler implements ITickHandler {
|
||||
|
||||
private boolean hidingConduits = false;
|
||||
private boolean first = true;
|
||||
|
||||
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData) {
|
||||
EntityPlayer player = (EntityPlayer) tickData[0];
|
||||
EntityPlayer player = (EntityPlayer) tickData[0];
|
||||
boolean curVal = ConduitUtil.isToolEquipped(player) || ConduitUtil.isConduitEquipped(player);
|
||||
if(first) {
|
||||
if (first) {
|
||||
hidingConduits = curVal;
|
||||
first = false;
|
||||
}
|
||||
if(curVal != hidingConduits) {
|
||||
hidingConduits = curVal;
|
||||
if (curVal != hidingConduits) {
|
||||
hidingConduits = curVal;
|
||||
WorldClient world = FMLClientHandler.instance().getClient().theWorld;
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<TileEntity> checkList = world.loadedTileEntityList;
|
||||
for(TileEntity o : checkList) {
|
||||
if(o.blockType != null && o.blockType.blockID == EnderIO.blockConduitBundle.blockID) {
|
||||
if(o.getDistanceFrom(player.posX, player.posY, player.posZ) < o.getMaxRenderDistanceSquared()) {
|
||||
for (TileEntity o : checkList) {
|
||||
if (o.blockType != null && o.blockType.blockID == EnderIO.blockConduitBundle.blockID) {
|
||||
if (o.getDistanceFrom(player.posX, player.posY, player.posZ) < o.getMaxRenderDistanceSquared()) {
|
||||
world.markBlockForRenderUpdate(o.xCoord, o.yCoord, o.zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,5 +55,4 @@ public class ClientTickHandler implements ITickHandler {
|
||||
return "EnderIO Client Tick Handler";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -7,22 +7,22 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.render.ConduitRenderer;
|
||||
|
||||
public class CommonProxy {
|
||||
public class CommonProxy {
|
||||
|
||||
private final ServerTickHandler serverTickHandler = new ServerTickHandler();
|
||||
|
||||
|
||||
public World getClientWorld() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public EntityPlayer getClientPlayer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
|
||||
public void load() {
|
||||
TickRegistry.registerTickHandler(serverTickHandler, Side.SERVER);
|
||||
}
|
||||
|
||||
|
||||
public ConduitRenderer getRendererForConduit(IConduit conduit) {
|
||||
return null;
|
||||
}
|
||||
@@ -32,12 +32,12 @@ public class CommonProxy {
|
||||
}
|
||||
|
||||
public void serverStopped() {
|
||||
serverTickHandler.serverStopped();
|
||||
serverTickHandler.serverStopped();
|
||||
}
|
||||
|
||||
public double getReachDistanceForPlayer(EntityPlayer entityPlayer) {
|
||||
return 5;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@ public final class Config {
|
||||
|
||||
static int BID = 700;
|
||||
static int IID = 8524;
|
||||
|
||||
|
||||
public static void load(Configuration config) {
|
||||
for (ModObject e : ModObject.values()) {
|
||||
e.load(config);
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
package crazypants.enderio;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.ForgeChunkManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
@@ -93,14 +87,14 @@ public class EnderIO {
|
||||
|
||||
// Machines
|
||||
public static BlockStirlingGenerator blockStirlingGenerator;
|
||||
public static BlockSolarPanel blockSolarPanel;
|
||||
public static BlockSolarPanel blockSolarPanel;
|
||||
public static BlockReservoir blockReservoir;
|
||||
public static BlockAlloySmelter blockAlloySmelter;
|
||||
|
||||
|
||||
public static BlockElectricLight blockElectricLight;
|
||||
public static BlockLightNode blockLightNode;
|
||||
|
||||
public static ItemYetaWrench itemYetaWench;
|
||||
public static ItemYetaWrench itemYetaWench;
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
|
||||
@@ -6,9 +6,8 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class EnderIOTab extends CreativeTabs {
|
||||
|
||||
|
||||
public static final CreativeTabs tabEnderIO = new EnderIOTab();
|
||||
|
||||
|
||||
public EnderIOTab() {
|
||||
super("EnderIO");
|
||||
}
|
||||
|
||||
@@ -13,26 +13,26 @@ public class GuiHandler implements IGuiHandler {
|
||||
public static final int GUI_ID_PAINTER = 2;
|
||||
public static final int GUI_ID_STIRLING_GEN = 3;
|
||||
public static final int GUI_ID_ALLOY_SMELTER = 4;
|
||||
|
||||
|
||||
protected final Map<Integer, IGuiHandler> guiHandlers = new HashMap<Integer, IGuiHandler>();
|
||||
|
||||
|
||||
public void registerGuiHandler(int id, IGuiHandler handler) {
|
||||
guiHandlers.put(id, handler);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
IGuiHandler handler = guiHandlers.get(id);
|
||||
if(handler != null) {
|
||||
if (handler != null) {
|
||||
return handler.getServerGuiElement(id, player, world, x, y, z);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
IGuiHandler handler = guiHandlers.get(id);
|
||||
if(handler != null) {
|
||||
if (handler != null) {
|
||||
return handler.getClientGuiElement(id, player, world, x, y, z);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -13,7 +13,7 @@ public enum ModObject {
|
||||
blockConduitBundle(++Config.BID, CATEGORY_BLOCK, "Conduit Bundle"),
|
||||
blockConduitFacade(++Config.BID, CATEGORY_BLOCK, "Conduit Facade"),
|
||||
itemConduitFacade(++Config.IID, CATEGORY_ITEM, "Conduit Facade"),
|
||||
itemRedstoneConduit(++Config.IID, CATEGORY_ITEM, "Redstone Conduit"),
|
||||
itemRedstoneConduit(++Config.IID, CATEGORY_ITEM, "Redstone Conduit"),
|
||||
|
||||
// Power
|
||||
itemPowerConduit(++Config.IID, CATEGORY_ITEM, "Power Conduit"),
|
||||
@@ -31,21 +31,21 @@ public enum ModObject {
|
||||
blockStirlingGenerator(++Config.BID, CATEGORY_BLOCK, "Stirling Generator"),
|
||||
blockReservoir(++Config.BID, CATEGORY_BLOCK, "Reservoir"),
|
||||
blockAlloySmelter(++Config.BID, CATEGORY_BLOCK, "Alloy Smelter"),
|
||||
|
||||
|
||||
// Painter
|
||||
blockPainter(++Config.BID, CATEGORY_BLOCK, "Painter"),
|
||||
blockCustomFence(++Config.BID, CATEGORY_BLOCK, "Fence"),
|
||||
blockCustomFenceGate(++Config.BID, CATEGORY_BLOCK, "Gate"),
|
||||
blockCustomWall(++Config.BID, CATEGORY_BLOCK, "Wall"),
|
||||
blockCustomStair(++Config.BID, CATEGORY_BLOCK, "Stair"),
|
||||
blockCustomStair(++Config.BID, CATEGORY_BLOCK, "Stair"),
|
||||
itemFusedQuartzFrame(++Config.IID, CATEGORY_ITEM, "Fused Quartz Frame"),
|
||||
|
||||
|
||||
// Solar Panel
|
||||
blockSolarPanel(++Config.BID, CATEGORY_BLOCK, "Photovoltaic Panel"),
|
||||
|
||||
|
||||
blockElectricLight(++Config.BID, CATEGORY_BLOCK, "Electric Light"),
|
||||
blockLightNode(++Config.BID, CATEGORY_BLOCK, "Light Node (Internal Only)"),
|
||||
|
||||
|
||||
itemYetaWrench(++Config.IID, CATEGORY_ITEM, "Yeta Wrench");
|
||||
|
||||
public final String unlocalisedName;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package crazypants.enderio;
|
||||
|
||||
import java.awt.Container;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
@@ -16,7 +15,6 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ContainerBeacon;
|
||||
import net.minecraft.inventory.ContainerRepair;
|
||||
import net.minecraft.item.ItemInWorldManager;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet100OpenWindow;
|
||||
@@ -25,7 +23,6 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityBeacon;
|
||||
import net.minecraft.world.World;
|
||||
import net.sf.cglib.proxy.Callback;
|
||||
import net.sf.cglib.proxy.Enhancer;
|
||||
import net.sf.cglib.proxy.MethodInterceptor;
|
||||
import net.sf.cglib.proxy.MethodProxy;
|
||||
@@ -44,7 +41,6 @@ public class PacketHandler implements IPacketHandler {
|
||||
private static final int ID_MACHINE_REDSTONE_PACKET = 2;
|
||||
|
||||
private static final String CHANNEL = "EnderIO";
|
||||
|
||||
|
||||
@Override
|
||||
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
|
||||
@@ -56,12 +52,12 @@ public class PacketHandler implements IPacketHandler {
|
||||
try {
|
||||
int id = data.readInt();
|
||||
if (id == ID_ENDERFACE) {
|
||||
handleEnderfacePacket(data, manager, player);
|
||||
} else if(id == ID_TILE_ENTITY) {
|
||||
handleEnderfacePacket(data, manager, player);
|
||||
} else if (id == ID_TILE_ENTITY) {
|
||||
PacketUtil.handleTileEntityPacket(false, data);
|
||||
} else if(id == ID_MACHINE_REDSTONE_PACKET) {
|
||||
} else if (id == ID_MACHINE_REDSTONE_PACKET) {
|
||||
handleRedstoneControlPacket(data, manager, player);
|
||||
} else {
|
||||
} else {
|
||||
System.out.println("PacketHandler.onPacketData: Recieved packet of unknown type: " + id);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
@@ -69,13 +65,12 @@ public class PacketHandler implements IPacketHandler {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Packet getPacket(TileEntity te) {
|
||||
return PacketUtil.createTileEntityPacket(CHANNEL, ID_TILE_ENTITY, te);
|
||||
}
|
||||
|
||||
// ---------------- Redstone Control --------------------------------------------------------
|
||||
// ---------------- Redstone Control
|
||||
// --------------------------------------------------------
|
||||
|
||||
private void handleRedstoneControlPacket(DataInputStream data, INetworkManager manager, Player player) throws IOException {
|
||||
int x = data.readInt();
|
||||
@@ -84,14 +79,14 @@ public class PacketHandler implements IPacketHandler {
|
||||
short ordinal = data.readShort();
|
||||
EntityPlayerMP p = (EntityPlayerMP) player;
|
||||
TileEntity te = p.worldObj.getBlockTileEntity(x, y, z);
|
||||
if(te instanceof AbstractMachineEntity) {
|
||||
AbstractMachineEntity me = (AbstractMachineEntity)te;
|
||||
if (te instanceof AbstractMachineEntity) {
|
||||
AbstractMachineEntity me = (AbstractMachineEntity) te;
|
||||
me.setRedstoneControlMode(RedstoneControlMode.values()[ordinal]);
|
||||
p.worldObj.markBlockForUpdate(x, y, z);
|
||||
p.worldObj.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static Packet getRedstoneControlPacket(AbstractMachineEntity te) {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(140);
|
||||
DataOutputStream dos = new DataOutputStream(bos);
|
||||
@@ -100,7 +95,7 @@ public class PacketHandler implements IPacketHandler {
|
||||
dos.writeInt(te.xCoord);
|
||||
dos.writeInt(te.yCoord);
|
||||
dos.writeInt(te.zCoord);
|
||||
dos.writeShort((short)te.getRedstoneControlMode().ordinal());
|
||||
dos.writeShort((short) te.getRedstoneControlMode().ordinal());
|
||||
} catch (IOException e) {
|
||||
// never thrown
|
||||
}
|
||||
@@ -111,9 +106,8 @@ public class PacketHandler implements IPacketHandler {
|
||||
pkt.length = bos.size();
|
||||
pkt.isChunkDataPacket = true;
|
||||
return pkt;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ---------------- Enderface
|
||||
// ------------------------------------------------------------
|
||||
@@ -151,18 +145,17 @@ public class PacketHandler implements IPacketHandler {
|
||||
PlayerProxy pp = new PlayerProxy(player);
|
||||
EntityPlayerMP proxy = createPlayerProxy(player, pp);
|
||||
proxy.playerNetServerHandler = player.playerNetServerHandler;
|
||||
proxy.inventory = player.inventory;
|
||||
proxy.inventory = player.inventory;
|
||||
proxy.currentWindowId = player.currentWindowId;
|
||||
proxy.inventoryContainer = player.inventoryContainer;
|
||||
proxy.mcServer = player.mcServer;
|
||||
proxy.openContainer = player.openContainer;
|
||||
proxy.theItemInWorldManager = player.theItemInWorldManager;
|
||||
proxy.worldObj = player.worldObj;
|
||||
|
||||
|
||||
proxy.worldObj = player.worldObj;
|
||||
|
||||
player.theItemInWorldManager.activateBlockOrUseItem(proxy, player.worldObj, null, x, y, z, 0, 0, 0, 0);
|
||||
player.theItemInWorldManager.thisPlayerMP = player;
|
||||
if(c != proxy.openContainer) {
|
||||
player.theItemInWorldManager.thisPlayerMP = player;
|
||||
if (c != proxy.openContainer) {
|
||||
player.openContainer = proxy.openContainer;
|
||||
}
|
||||
|
||||
@@ -190,8 +183,8 @@ public class PacketHandler implements IPacketHandler {
|
||||
private Set<String> interceptNames = new HashSet<String>();
|
||||
|
||||
private Set<String> beaconNames = new HashSet<String>();
|
||||
private Set<String> anvilNames = new HashSet<String>();
|
||||
|
||||
private Set<String> anvilNames = new HashSet<String>();
|
||||
|
||||
private Set<String> distanceNames = new HashSet<String>();
|
||||
|
||||
public PlayerProxy(EntityPlayerMP obj) {
|
||||
@@ -200,7 +193,7 @@ public class PacketHandler implements IPacketHandler {
|
||||
interceptNames.add("openGui");
|
||||
|
||||
interceptNames.add("displayGUIBrewingStand");
|
||||
interceptNames.add("func_71017_a");
|
||||
interceptNames.add("func_71017_a");
|
||||
|
||||
interceptNames.add("displayGUIChest");
|
||||
interceptNames.add("func_71007_a");
|
||||
@@ -219,52 +212,55 @@ public class PacketHandler implements IPacketHandler {
|
||||
|
||||
interceptNames.add("displayGuiHopper"); // for when its added
|
||||
interceptNames.add("func_94064_a"); // displayGuiHopper
|
||||
|
||||
|
||||
interceptNames.add("displayGUIHopper");
|
||||
|
||||
beaconNames.add("displayGUIBeacon");
|
||||
beaconNames.add("func_82240_a");
|
||||
|
||||
|
||||
anvilNames.add("displayGUIAnvil");
|
||||
anvilNames.add("func_82244_d");
|
||||
|
||||
|
||||
distanceNames.add("getDistanceSq");
|
||||
distanceNames.add("getDistance");
|
||||
distanceNames.add("func_70092_e");
|
||||
distanceNames.add("func_70011_f");
|
||||
distanceNames.add("func_71569_e");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
|
||||
|
||||
|
||||
if (interceptNames.contains(method.getName())) {
|
||||
|
||||
|
||||
Object res = method.invoke(realObj, objects);
|
||||
if (realObj.openContainer != null) {
|
||||
|
||||
// if("appeng.me.container.ContainerTerminal".equals(realObj.openContainer.getClass().getName())) {
|
||||
// try {
|
||||
// realObj.currentWindowId = realObj.openContainer.windowId;
|
||||
// realObj.openContainer = createMeTerminalProxy(realObj, ((Integer)objects[3]).intValue(),((Integer)objects[4]).intValue(),((Integer)objects[5]).intValue());
|
||||
// Method m = realObj.openContainer.getClass().getMethod("setPlayerIsPresent", EntityPlayer.class, boolean.class);
|
||||
// m.invoke(realObj.openContainer, realObj,true);
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// System.out.println("PacketHandler.PlayerProxy.intercept: " + e);
|
||||
// }
|
||||
|
||||
// } else {
|
||||
realObj.openContainer = new ContainerWrapper(realObj.openContainer);
|
||||
// }
|
||||
|
||||
|
||||
// if("appeng.me.container.ContainerTerminal".equals(realObj.openContainer.getClass().getName()))
|
||||
// {
|
||||
// try {
|
||||
// realObj.currentWindowId = realObj.openContainer.windowId;
|
||||
// realObj.openContainer = createMeTerminalProxy(realObj,
|
||||
// ((Integer)objects[3]).intValue(),((Integer)objects[4]).intValue(),((Integer)objects[5]).intValue());
|
||||
// Method m =
|
||||
// realObj.openContainer.getClass().getMethod("setPlayerIsPresent",
|
||||
// EntityPlayer.class, boolean.class);
|
||||
// m.invoke(realObj.openContainer, realObj,true);
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// System.out.println("PacketHandler.PlayerProxy.intercept: " + e);
|
||||
// }
|
||||
|
||||
// } else {
|
||||
realObj.openContainer = new ContainerWrapper(realObj.openContainer);
|
||||
// }
|
||||
|
||||
}
|
||||
return res;
|
||||
|
||||
|
||||
} else if (beaconNames.contains(method.getName())) {
|
||||
|
||||
|
||||
// Beacon needs to be done manually for some reason to work properly
|
||||
TileEntityBeacon par1TileEntityBeacon = (TileEntityBeacon) objects[0];
|
||||
realObj.incrementWindowID();
|
||||
@@ -279,12 +275,13 @@ public class PacketHandler implements IPacketHandler {
|
||||
realObj.openContainer.windowId = realObj.currentWindowId;
|
||||
realObj.openContainer.addCraftingToCrafters(realObj);
|
||||
return null;
|
||||
|
||||
|
||||
} else if (anvilNames.contains(method.getName())) {
|
||||
|
||||
|
||||
realObj.incrementWindowID();
|
||||
realObj.playerNetServerHandler.sendPacketToPlayer(new Packet100OpenWindow(realObj.currentWindowId, 8, "Repairing", 9, true));
|
||||
realObj.openContainer = new ContainerRepair(realObj.inventory, realObj.worldObj, ((Integer)objects[0]).intValue(), ((Integer)objects[1]).intValue(), ((Integer)objects[2]).intValue(), realObj) {
|
||||
realObj.openContainer = new ContainerRepair(realObj.inventory, realObj.worldObj, ((Integer) objects[0]).intValue(), ((Integer) objects[1]).intValue(),
|
||||
((Integer) objects[2]).intValue(), realObj) {
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer par1EntityPlayer) {
|
||||
return true;
|
||||
@@ -293,46 +290,42 @@ public class PacketHandler implements IPacketHandler {
|
||||
realObj.openContainer.windowId = realObj.currentWindowId;
|
||||
realObj.openContainer.addCraftingToCrafters(realObj);
|
||||
return null;
|
||||
} else if(distanceNames.contains(method.getName())) {
|
||||
} else if (distanceNames.contains(method.getName())) {
|
||||
return 6;
|
||||
}
|
||||
}
|
||||
method.setAccessible(true);
|
||||
return method.invoke(realObj, objects);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static class ContainerTerminalProxy implements MethodInterceptor {
|
||||
|
||||
Object realObj;
|
||||
|
||||
|
||||
|
||||
private ContainerTerminalProxy(Object realObj) {
|
||||
|
||||
private ContainerTerminalProxy(Object realObj) {
|
||||
this.realObj = realObj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
|
||||
if("canInteractWith".equals(method.getName())) {
|
||||
if ("canInteractWith".equals(method.getName())) {
|
||||
return true;
|
||||
}
|
||||
method.setAccessible(true);
|
||||
return method.invoke(realObj, objects);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static <T> T createMeTerminalProxy(EntityPlayerMP player, int x, int y, int z) throws Exception {
|
||||
Enhancer e = new Enhancer();
|
||||
e.setCallback(new ContainerTerminalProxy(player.openContainer));
|
||||
|
||||
e.setSuperclass(Class.forName("appeng.me.container.ContainerTerminal"));
|
||||
//InventoryPlayer ip, IGridTileEntity te, boolean isWireless
|
||||
// InventoryPlayer ip, IGridTileEntity te, boolean isWireless
|
||||
Class<?> gteClass = Class.forName("appeng.api.me.tiles.IGridTileEntity");
|
||||
Class<?>[] argTypes = new Class[] { InventoryPlayer.class, gteClass, boolean.class};
|
||||
Class<?>[] argTypes = new Class[] { InventoryPlayer.class, gteClass, boolean.class };
|
||||
Object[] args = new Object[] { player.inventory, player.worldObj.getBlockTileEntity(x, y, z), false };
|
||||
|
||||
e.setInterceptDuringConstruction(false);
|
||||
@@ -341,7 +334,5 @@ public class PacketHandler implements IPacketHandler {
|
||||
|
||||
return proxifiedObj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -10,33 +10,32 @@ import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
|
||||
public class ServerTickHandler implements ITickHandler {
|
||||
|
||||
private static final EnumSet<TickType> TICKS = EnumSet.of(TickType.SERVER);
|
||||
|
||||
private static final EnumSet<TickType> TICKS = EnumSet.of(TickType.SERVER);
|
||||
|
||||
private final List<WeakReference<TickListener>> listeners = new CopyOnWriteArrayList<WeakReference<TickListener>>();
|
||||
|
||||
|
||||
public void addListener(TickListener listener) {
|
||||
listeners.add(new WeakReference<TickListener>(listener));
|
||||
listeners.add(new WeakReference<TickListener>(listener));
|
||||
}
|
||||
|
||||
|
||||
public void removeListener(TickListener listener) {
|
||||
WeakReference<TickListener> toRemove = null;
|
||||
for(WeakReference<TickListener> ref : listeners) {
|
||||
if(ref.get() == listener) {
|
||||
WeakReference<TickListener> toRemove = null;
|
||||
for (WeakReference<TickListener> ref : listeners) {
|
||||
if (ref.get() == listener) {
|
||||
toRemove = ref;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(toRemove != null) {
|
||||
if (toRemove != null) {
|
||||
listeners.remove(toRemove);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData) {
|
||||
List<TickListener> lists = processListeners();
|
||||
for(TickListener listener : lists) {
|
||||
for (TickListener listener : lists) {
|
||||
listener.tickStart(type, tickData);
|
||||
}
|
||||
}
|
||||
@@ -44,31 +43,31 @@ public class ServerTickHandler implements ITickHandler {
|
||||
@Override
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
|
||||
List<TickListener> lists = processListeners();
|
||||
for(TickListener listener : lists) {
|
||||
for (TickListener listener : lists) {
|
||||
listener.tickEnd(type, tickData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<TickListener> processListeners() {
|
||||
List<TickListener> result = new ArrayList<TickListener>(listeners.size());
|
||||
List<WeakReference<TickListener>> toRemove = new ArrayList<WeakReference<TickListener>>();
|
||||
for(WeakReference<TickListener> ref : listeners) {
|
||||
for (WeakReference<TickListener> ref : listeners) {
|
||||
TickListener l = ref.get();
|
||||
if(l == null) {
|
||||
if (l == null) {
|
||||
toRemove.add(ref);
|
||||
} else {
|
||||
result.add(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public void serverStopped() {
|
||||
listeners.clear();
|
||||
listeners.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks() {
|
||||
public EnumSet<TickType> ticks() {
|
||||
return TICKS;
|
||||
}
|
||||
|
||||
@@ -77,5 +76,4 @@ public class ServerTickHandler implements ITickHandler {
|
||||
return "EnderIO Server Tick Handler";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -9,5 +9,5 @@ public interface TickListener {
|
||||
void tickStart(EnumSet<TickType> type, Object... tickData);
|
||||
|
||||
void tickEnd(EnumSet<TickType> type, Object... tickData);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,22 +1,11 @@
|
||||
package crazypants.enderio;
|
||||
|
||||
import crazypants.vecmath.Matrix4d;
|
||||
import crazypants.vecmath.VecmathUtil;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
|
||||
|
||||
public class Tst {
|
||||
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,19 +1,26 @@
|
||||
package crazypants.enderio.conduit;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.conduit.geom.*;
|
||||
import crazypants.enderio.conduit.geom.CollidableCache.CacheKey;
|
||||
import crazypants.util.BlockCoord;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.conduit.geom.CollidableCache;
|
||||
import crazypants.enderio.conduit.geom.CollidableCache.CacheKey;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.conduit.geom.ConduitGeometryUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public abstract class AbstractConduit implements IConduit {
|
||||
public abstract class AbstractConduit implements IConduit {
|
||||
|
||||
protected final Set<ForgeDirection> conduitConnections = new HashSet<ForgeDirection>();
|
||||
|
||||
@@ -22,7 +29,7 @@ public abstract class AbstractConduit implements IConduit {
|
||||
public static final float STUB_WIDTH = 0.2f;
|
||||
|
||||
public static final float STUB_HEIGHT = 0.2f;
|
||||
|
||||
|
||||
public static final float TRANSMISSION_SCALE = 0.3f;
|
||||
|
||||
// NB: This is a transient field controlled by the owning bundle. It is not
|
||||
@@ -34,19 +41,19 @@ public abstract class AbstractConduit implements IConduit {
|
||||
protected List<CollidableComponent> collidables;
|
||||
|
||||
protected boolean collidablesDirty = true;
|
||||
|
||||
|
||||
private boolean clientStateDirty = true;
|
||||
|
||||
|
||||
private boolean dodgyChangeSinceLastCallFlagForBundle = true;
|
||||
|
||||
protected AbstractConduit() {
|
||||
protected AbstractConduit() {
|
||||
}
|
||||
|
||||
|
||||
private int lastNumConections = -1;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean haveCollidablesChangedSinceLastCall() {
|
||||
if(dodgyChangeSinceLastCallFlagForBundle) {
|
||||
if (dodgyChangeSinceLastCallFlagForBundle) {
|
||||
dodgyChangeSinceLastCallFlagForBundle = false;
|
||||
return true;
|
||||
}
|
||||
@@ -142,7 +149,7 @@ public abstract class AbstractConduit implements IConduit {
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active) {
|
||||
if(active != this.active) {
|
||||
if (active != this.active) {
|
||||
clientStateDirty = true;
|
||||
}
|
||||
this.active = active;
|
||||
@@ -180,7 +187,7 @@ public abstract class AbstractConduit implements IConduit {
|
||||
externalConnections.add(ForgeDirection.values()[dirs[i]]);
|
||||
}
|
||||
active = nbtRoot.getBoolean("signalActive");
|
||||
//collidablesDirty = true;
|
||||
// collidablesDirty = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -197,7 +204,7 @@ public abstract class AbstractConduit implements IConduit {
|
||||
public float getSelfIlluminationForState(CollidableComponent component) {
|
||||
return isActive() ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float getTransmitionGeometryScale() {
|
||||
return TRANSMISSION_SCALE;
|
||||
@@ -218,20 +225,19 @@ public abstract class AbstractConduit implements IConduit {
|
||||
return;
|
||||
}
|
||||
updateNetwork(world);
|
||||
|
||||
if(clientStateDirty) {
|
||||
|
||||
if (clientStateDirty) {
|
||||
getBundle().dirty();
|
||||
clientStateDirty = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void connectionsChanged() {
|
||||
protected void connectionsChanged() {
|
||||
collidablesDirty = true;
|
||||
clientStateDirty = true;
|
||||
dodgyChangeSinceLastCallFlagForBundle = true;
|
||||
}
|
||||
|
||||
|
||||
protected void updateNetwork(World world) {
|
||||
if (getNetwork() == null) {
|
||||
ConduitUtil.ensureValidNetwork(this);
|
||||
@@ -243,7 +249,7 @@ public abstract class AbstractConduit implements IConduit {
|
||||
public void onAddedToBundle() {
|
||||
|
||||
TileEntity te = bundle.getEntity();
|
||||
World world = te.worldObj;
|
||||
World world = te.worldObj;
|
||||
|
||||
conduitConnections.clear();
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
@@ -290,13 +296,14 @@ public abstract class AbstractConduit implements IConduit {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNeighborBlockChange(int blockId) {
|
||||
public boolean onNeighborBlockChange(int blockId) {
|
||||
// Check for changes to external connections, connections to conduits are
|
||||
// handled by the bundle
|
||||
|
||||
//NB: No need to check externals if the neighbour that changed was a conduit bundle as this
|
||||
//can't effect external connections.
|
||||
if(blockId == EnderIO.blockConduitBundle.blockID) {
|
||||
|
||||
// NB: No need to check externals if the neighbour that changed was a
|
||||
// conduit bundle as this
|
||||
// can't effect external connections.
|
||||
if (blockId == EnderIO.blockConduitBundle.blockID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -324,45 +331,44 @@ public abstract class AbstractConduit implements IConduit {
|
||||
}
|
||||
return externalConnectionsChanged;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<CollidableComponent> createCollidables(CacheKey key) {
|
||||
return Collections.singletonList(new CollidableComponent(getBaseConduitType(),ConduitGeometryUtil.instance.getBoundingBox(getBaseConduitType(), key.dir, key.isStub, key.offset),key.dir,null));
|
||||
return Collections.singletonList(new CollidableComponent(getBaseConduitType(), ConduitGeometryUtil.instance.getBoundingBox(getBaseConduitType(), key.dir,
|
||||
key.isStub, key.offset), key.dir, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CollidableComponent> getCollidableComponents() {
|
||||
|
||||
|
||||
if (collidables != null && !collidablesDirty) {
|
||||
return collidables;
|
||||
}
|
||||
|
||||
List<CollidableComponent> result = new ArrayList<CollidableComponent>();
|
||||
|
||||
List<CollidableComponent> result = new ArrayList<CollidableComponent>();
|
||||
CollidableCache cc = CollidableCache.instance;
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
Collection<CollidableComponent> col = getCollidables(dir);
|
||||
if(col != null) {
|
||||
if (col != null) {
|
||||
result.addAll(col);
|
||||
}
|
||||
}
|
||||
collidables = result;
|
||||
|
||||
collidablesDirty = false;
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private Collection<CollidableComponent> getCollidables(ForgeDirection dir) {
|
||||
CollidableCache cc = CollidableCache.instance;
|
||||
Class<? extends IConduit> type = getBaseConduitType();
|
||||
|
||||
|
||||
if (isConnectedTo(dir)) {
|
||||
return cc.getCollidables(cc.createKey(type, getBundle().getOffset(type, dir), dir, false), this);
|
||||
}
|
||||
return cc.getCollidables(cc.createKey(type, getBundle().getOffset(type, dir), dir, false), this);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package crazypants.enderio.conduit;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -5,23 +5,25 @@ import java.util.List;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import cpw.mods.fml.common.registry.*;
|
||||
import crazypants.enderio.*;
|
||||
import crazypants.enderio.material.Alloy;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.ModObject;
|
||||
|
||||
public abstract class AbstractItemConduit extends Item implements IConduitItem {
|
||||
|
||||
protected ModObject modObj;
|
||||
|
||||
|
||||
protected ItemConduitSubtype[] subtypes;
|
||||
|
||||
|
||||
protected Icon[] icons;
|
||||
|
||||
|
||||
protected AbstractItemConduit(ModObject modObj) {
|
||||
super(modObj.id);
|
||||
this.modObj = modObj;
|
||||
@@ -34,19 +36,19 @@ public abstract class AbstractItemConduit extends Item implements IConduitItem {
|
||||
protected void init(ItemConduitSubtype[] subtypes) {
|
||||
this.subtypes = subtypes;
|
||||
icons = new Icon[subtypes.length];
|
||||
|
||||
|
||||
LanguageRegistry.addName(this, modObj.name);
|
||||
GameRegistry.registerItem(this, modObj.unlocalisedName);
|
||||
for(ItemConduitSubtype subtype : subtypes) {
|
||||
for (ItemConduitSubtype subtype : subtypes) {
|
||||
LanguageRegistry.instance().addStringLocalization(getUnlocalizedName() + "." + subtype.unlocalisedName + ".name", subtype.uiName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister iconRegister) {
|
||||
int index = 0;
|
||||
for(ItemConduitSubtype subtype : subtypes) {
|
||||
for (ItemConduitSubtype subtype : subtypes) {
|
||||
icons[index] = iconRegister.registerIcon(subtype.iconKey);
|
||||
index++;
|
||||
}
|
||||
@@ -61,60 +63,58 @@ public abstract class AbstractItemConduit extends Item implements IConduitItem {
|
||||
int placeZ = z + dir.offsetZ;
|
||||
|
||||
if (world.isAirBlock(placeX, placeY, placeZ)) {
|
||||
if(!world.isRemote) {
|
||||
if(world.setBlock(placeX, placeY, placeZ, ModObject.blockConduitBundle.actualId,0,1)) {
|
||||
if (!world.isRemote) {
|
||||
if (world.setBlock(placeX, placeY, placeZ, ModObject.blockConduitBundle.actualId, 0, 1)) {
|
||||
IConduitBundle bundle = (IConduitBundle) world.getBlockTileEntity(placeX, placeY, placeZ);
|
||||
bundle.addConduit(createConduit(stack));
|
||||
}
|
||||
}
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
stack.stackSize--;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if(world.getBlockId(placeX, placeY, placeZ) == ModObject.blockConduitBundle.actualId) {
|
||||
|
||||
IConduitBundle bundle = (TileConduitBundle)world.getBlockTileEntity(placeX, placeY, placeZ);
|
||||
if(bundle == null) {
|
||||
} else if (world.getBlockId(placeX, placeY, placeZ) == ModObject.blockConduitBundle.actualId) {
|
||||
|
||||
IConduitBundle bundle = (TileConduitBundle) world.getBlockTileEntity(placeX, placeY, placeZ);
|
||||
if (bundle == null) {
|
||||
System.out.println("AbstractItemConduit.onItemUse: Bunle null");
|
||||
return false;
|
||||
}
|
||||
IConduit con = createConduit(stack);
|
||||
if(con == null) {
|
||||
if (con == null) {
|
||||
System.out.println("AbstractItemConduit.onItemUse: Conduit null.");
|
||||
return false;
|
||||
}
|
||||
if(bundle.getConduit(con.getBaseConduitType()) == null) {
|
||||
if(!world.isRemote) {
|
||||
if (bundle.getConduit(con.getBaseConduitType()) == null) {
|
||||
if (!world.isRemote) {
|
||||
bundle.addConduit(con);
|
||||
}
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Icon getIconFromDamage(int damage) {
|
||||
damage = MathHelper.clamp_int(damage, 0, subtypes.length);
|
||||
return icons[damage];
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack par1ItemStack) {
|
||||
int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, subtypes.length);
|
||||
int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, subtypes.length);
|
||||
return super.getUnlocalizedName() + "." + subtypes[i].unlocalisedName;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
for (int j = 0; j < subtypes.length; ++j) {
|
||||
par3List.add(new ItemStack(par1, 1, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,8 +1,14 @@
|
||||
package crazypants.enderio.conduit;
|
||||
|
||||
import static crazypants.enderio.ModObject.*;
|
||||
import static crazypants.enderio.ModObject.blockPainter;
|
||||
import static crazypants.enderio.ModObject.itemConduitFacade;
|
||||
import static crazypants.enderio.ModObject.itemIndustrialBinder;
|
||||
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.*;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.facade.ItemConduitFacade.FacadePainterRecipe;
|
||||
@@ -13,29 +19,28 @@ public class ConduitRecipes {
|
||||
|
||||
public static void addRecipes() {
|
||||
ItemStack industialBinder = new ItemStack(itemIndustrialBinder.actualId, 1, 0);
|
||||
//ItemStack glassPane = new ItemStack(Block.thinGlass, 1, 0);
|
||||
// ItemStack glassPane = new ItemStack(Block.thinGlass, 1, 0);
|
||||
ItemStack fusedQuartz = new ItemStack(ModObject.blockFusedQuartz.actualId, 1, 0);
|
||||
|
||||
//Facade
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemConduitFacade.actualId,1,0), "bbb", "b b", "bbb", 'b', industialBinder);
|
||||
|
||||
// Facade
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemConduitFacade.actualId, 1, 0), "bbb", "b b", "bbb", 'b', industialBinder);
|
||||
MachineRecipeRegistry.instance.registerRecipe(blockPainter.unlocalisedName, new FacadePainterRecipe());
|
||||
|
||||
//Liquids
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemLiquidConduit.actualId,4,0), "bgb", "g g", "bgb", 'b', industialBinder, 'g', fusedQuartz);
|
||||
|
||||
//Power
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemPowerConduit.actualId,4,0), " b ", "bib", " b ", 'b', industialBinder, 'i', new ItemStack(Item.ingotIron));
|
||||
ItemStack activatedIron = new ItemStack(ModObject.itemAlloy.actualId,1,Alloy.ACTIVATED_IRON.ordinal());
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemPowerConduit.actualId,4,1), " b ", "bib", " b ", 'b', industialBinder, 'i', activatedIron);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemPowerConduit.actualId,4,2), " b ", "bib", " b ", 'b', industialBinder, 'i', new ItemStack(ModObject.itemAlloy.actualId,1,Alloy.ENDER_IRON.ordinal()));
|
||||
|
||||
|
||||
//Redstone
|
||||
ItemStack redstoneConduit = new ItemStack(itemRedstoneConduit.actualId,1,0);
|
||||
GameRegistry.addShapedRecipe(redstoneConduit , " b ", "brb", " b ", 'b', industialBinder, 'r', new ItemStack(Item.redstone));
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemRedstoneConduit.actualId,1,1), " l ", "lcl", " l ", 'c', redstoneConduit, 'l', Block.lever);
|
||||
|
||||
|
||||
|
||||
// Liquids
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemLiquidConduit.actualId, 4, 0), "bgb", "g g", "bgb", 'b', industialBinder, 'g', fusedQuartz);
|
||||
|
||||
// Power
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemPowerConduit.actualId, 4, 0), " b ", "bib", " b ", 'b', industialBinder, 'i', new ItemStack(Item.ingotIron));
|
||||
ItemStack activatedIron = new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.ACTIVATED_IRON.ordinal());
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemPowerConduit.actualId, 4, 1), " b ", "bib", " b ", 'b', industialBinder, 'i', activatedIron);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemPowerConduit.actualId, 4, 2), " b ", "bib", " b ", 'b', industialBinder, 'i', new ItemStack(
|
||||
ModObject.itemAlloy.actualId, 1, Alloy.ENDER_IRON.ordinal()));
|
||||
|
||||
// Redstone
|
||||
ItemStack redstoneConduit = new ItemStack(itemRedstoneConduit.actualId, 1, 0);
|
||||
GameRegistry.addShapedRecipe(redstoneConduit, " b ", "brb", " b ", 'b', industialBinder, 'r', new ItemStack(Item.redstone));
|
||||
GameRegistry.addShapedRecipe(new ItemStack(itemRedstoneConduit.actualId, 1, 1), " l ", "lcl", " l ", 'c', redstoneConduit, 'l', Block.lever);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
package crazypants.enderio.conduit;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -8,37 +12,39 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.*;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.conduit.liquid.*;
|
||||
import crazypants.enderio.conduit.power.*;
|
||||
import crazypants.enderio.conduit.redstone.*;
|
||||
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.IRedstoneConduit;
|
||||
import crazypants.enderio.conduit.redstone.RedstoneConduitNetwork;
|
||||
|
||||
public class ConduitUtil {
|
||||
|
||||
|
||||
|
||||
public static final Random RANDOM = new Random();
|
||||
|
||||
|
||||
|
||||
public static AbstractConduitNetwork<?> createNetworkForType(Class<? extends IConduit> type) {
|
||||
if(IRedstoneConduit.class.isAssignableFrom(type)) {
|
||||
if (IRedstoneConduit.class.isAssignableFrom(type)) {
|
||||
return new RedstoneConduitNetwork();
|
||||
} else if(IPowerConduit.class.isAssignableFrom(type)) {
|
||||
} else if (IPowerConduit.class.isAssignableFrom(type)) {
|
||||
return new PowerConduitNetwork();
|
||||
} else if(ILiquidConduit.class.isAssignableFrom(type)) {
|
||||
} else if (ILiquidConduit.class.isAssignableFrom(type)) {
|
||||
return new LiquidConduitNetwork();
|
||||
}
|
||||
FMLCommonHandler.instance().raiseException(new Exception("Could not determine network type for class " + type), "ConduitUtil.createNetworkForType", false);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static void ensureValidNetwork(IConduit conduit) {
|
||||
TileEntity te = conduit.getBundle().getEntity();
|
||||
World world = te.worldObj;
|
||||
World world = te.worldObj;
|
||||
Collection<? extends IConduit> connections = ConduitUtil.getConnectedConduits(world, te.xCoord, te.yCoord, te.zCoord, conduit.getBaseConduitType());
|
||||
|
||||
if (reuseNetwork(conduit, connections, world)) {
|
||||
@@ -49,7 +55,7 @@ public class ConduitUtil {
|
||||
res.init(conduit.getBundle(), connections, world);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private static boolean reuseNetwork(IConduit con, Collection<? extends IConduit> connections, World world) {
|
||||
AbstractConduitNetwork network = null;
|
||||
@@ -62,17 +68,17 @@ public class ConduitUtil {
|
||||
}
|
||||
if (network == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
con.setNetwork(network);
|
||||
network.addConduit(con);
|
||||
network.addConduit(con);
|
||||
network.notifyNetworkOfUpdate();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static void dropConduit(World world, IConduit conduit, int x, int y, int z) {
|
||||
dropItems(world, conduit.createItem(), x, y, z);
|
||||
}
|
||||
|
||||
|
||||
public static void dropItems(World world, ItemStack stack, int x, int y, int z) {
|
||||
if (stack.stackSize <= 0) {
|
||||
return;
|
||||
@@ -86,58 +92,58 @@ public class ConduitUtil {
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
|
||||
public static void dropItems(World world, IInventory inventory, int x, int y, int z) {
|
||||
for (int l = 0; l < inventory.getSizeInventory(); ++l) {
|
||||
ItemStack items = inventory.getStackInSlot(l);
|
||||
|
||||
if (items != null && items.stackSize > 0) {
|
||||
dropItems(world, inventory.getStackInSlot(l).copy(), x, y, z);
|
||||
dropItems(world, inventory.getStackInSlot(l).copy(), x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean renderFacade(IConduitBundle bundle, EntityPlayer player) {
|
||||
return bundle.getFacadeId() > 0 && !isFacadeHidden(bundle, player);
|
||||
}
|
||||
|
||||
|
||||
public static boolean isFacadeHidden(IConduitBundle bundle, EntityPlayer player) {
|
||||
return bundle.getFacadeId() > 0 && (isToolEquipped(player) || isConduitEquipped(player));
|
||||
}
|
||||
|
||||
|
||||
public static boolean isConduitEquipped(EntityPlayer player) {
|
||||
player = player == null ? EnderIO.proxy.getClientPlayer() : player;
|
||||
if(player == null) {
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
ItemStack equipped = player.getCurrentEquippedItem();
|
||||
if (equipped == null) {
|
||||
return false;
|
||||
}
|
||||
return equipped.getItem() instanceof IConduitItem ;
|
||||
}
|
||||
return equipped.getItem() instanceof IConduitItem;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isToolEquipped(EntityPlayer player) {
|
||||
player = player == null ? EnderIO.proxy.getClientPlayer() : player;
|
||||
if(player == null) {
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
ItemStack equipped = player.getCurrentEquippedItem();
|
||||
if (equipped == null) {
|
||||
return false;
|
||||
}
|
||||
return /*equipped.itemID == Block.stone.blockID ||*/ equipped.getItem() instanceof IToolWrench;
|
||||
return /* equipped.itemID == Block.stone.blockID || */equipped.getItem() instanceof IToolWrench;
|
||||
}
|
||||
|
||||
|
||||
public static <T extends IConduit> T getConduit(IBlockAccess world, int x, int y, int z, Class<T> type) {
|
||||
if(world == null) {
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
if (te instanceof IConduitBundle) {
|
||||
IConduitBundle con = (IConduitBundle) te;
|
||||
return con.getConduit(type);
|
||||
IConduitBundle con = (IConduitBundle) te;
|
||||
return con.getConduit(type);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -175,22 +181,20 @@ public class ConduitUtil {
|
||||
}
|
||||
|
||||
public static IConduit readConduitFromNBT(NBTTagCompound conduitRoot) {
|
||||
String typeName = conduitRoot.getString("conduitType");
|
||||
String typeName = conduitRoot.getString("conduitType");
|
||||
NBTTagCompound conduitBody = conduitRoot.getCompoundTag("conduit");
|
||||
if(typeName == null || conduitBody == null) {
|
||||
if (typeName == null || conduitBody == null) {
|
||||
return null;
|
||||
}
|
||||
IConduit result;
|
||||
try {
|
||||
result = (IConduit) Class.forName(typeName).newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Could not create an instance of the conduit with name: " + typeName, e);
|
||||
throw new RuntimeException("Could not create an instance of the conduit with name: " + typeName, e);
|
||||
}
|
||||
result.readFromNBT(conduitBody);
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
package crazypants.enderio.conduit;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import crazypants.enderio.conduit.geom.*;
|
||||
import crazypants.enderio.conduit.geom.CollidableCache.CacheKey;
|
||||
import crazypants.util.BlockCoord;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -12,6 +9,9 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.conduit.geom.CollidableCache.CacheKey;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public interface IConduit {
|
||||
|
||||
@@ -33,7 +33,7 @@ public interface IConduit {
|
||||
// Container
|
||||
|
||||
void setBundle(IConduitBundle tileConduitBundle);
|
||||
|
||||
|
||||
IConduitBundle getBundle();
|
||||
|
||||
void onAddedToBundle();
|
||||
@@ -69,15 +69,15 @@ public interface IConduit {
|
||||
void externalConnectionAdded(ForgeDirection fromDirection);
|
||||
|
||||
void externalConnectionRemoved(ForgeDirection fromDirection);
|
||||
|
||||
|
||||
boolean isConnectedTo(ForgeDirection dir);
|
||||
|
||||
// rendering, only needed us default rendering is used
|
||||
|
||||
Icon getTextureForState(CollidableComponent component);
|
||||
|
||||
|
||||
Icon getTransmitionTextureForState(CollidableComponent component);
|
||||
|
||||
|
||||
float getTransmitionGeometryScale();
|
||||
|
||||
float getSelfIlluminationForState(CollidableComponent component);
|
||||
@@ -85,10 +85,10 @@ public interface IConduit {
|
||||
// geometry
|
||||
|
||||
boolean haveCollidablesChangedSinceLastCall();
|
||||
|
||||
|
||||
Collection<CollidableComponent> getCollidableComponents();
|
||||
|
||||
Collection<CollidableComponent> createCollidables(CacheKey key);
|
||||
|
||||
Collection<CollidableComponent> createCollidables(CacheKey key);
|
||||
|
||||
// Actions
|
||||
|
||||
|
||||
@@ -4,32 +4,30 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.conduit.geom.Offset;
|
||||
import crazypants.enderio.power.IInternalPowerReceptor;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.conduit.geom.Offset;
|
||||
import crazypants.enderio.power.IInternalPowerReceptor;
|
||||
|
||||
public interface IConduitBundle extends IInternalPowerReceptor, IFluidHandler {
|
||||
|
||||
TileEntity getEntity();
|
||||
|
||||
//conduits
|
||||
|
||||
// conduits
|
||||
|
||||
boolean hasType(Class<? extends IConduit> type);
|
||||
|
||||
|
||||
<T extends IConduit> T getConduit(Class<T> type);
|
||||
|
||||
|
||||
void addConduit(IConduit conduit);
|
||||
|
||||
|
||||
void removeConduit(IConduit conduit);
|
||||
|
||||
|
||||
Collection<IConduit> getConduits();
|
||||
|
||||
Offset getOffset(Class<? extends IConduit> type, ForgeDirection dir);
|
||||
|
||||
Offset getOffset(Class<? extends IConduit> type, ForgeDirection dir);
|
||||
|
||||
// connections
|
||||
|
||||
@@ -42,27 +40,27 @@ public interface IConduitBundle extends IInternalPowerReceptor, IFluidHandler {
|
||||
boolean containsConnection(ForgeDirection dir);
|
||||
|
||||
// events
|
||||
|
||||
|
||||
void onNeighborBlockChange(int blockId);
|
||||
|
||||
void onBlockRemoved();
|
||||
|
||||
// Facade
|
||||
|
||||
|
||||
boolean hasFacade();
|
||||
|
||||
|
||||
void setFacadeId(int blockID);
|
||||
|
||||
|
||||
int getFacadeId();
|
||||
|
||||
|
||||
void setFacadeMetadata(int meta);
|
||||
|
||||
|
||||
int getFacadeMetadata();
|
||||
|
||||
List<CollidableComponent> getCollidableComponents();
|
||||
|
||||
List<CollidableComponent> getConnectors();
|
||||
|
||||
void dirty();
|
||||
void dirty();
|
||||
|
||||
}
|
||||
@@ -3,9 +3,9 @@ package crazypants.enderio.conduit;
|
||||
public class ItemConduitSubtype {
|
||||
|
||||
public final String unlocalisedName;
|
||||
|
||||
|
||||
public final String uiName;
|
||||
|
||||
|
||||
public final String iconKey;
|
||||
|
||||
public ItemConduitSubtype(String unlocalisedName, String uiName, String iconKey) {
|
||||
@@ -14,5 +14,5 @@ public class ItemConduitSubtype {
|
||||
this.uiName = uiName;
|
||||
this.iconKey = iconKey;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -2,11 +2,9 @@ package crazypants.enderio.conduit;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
|
||||
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
|
||||
public class RaytraceResult {
|
||||
|
||||
|
||||
@@ -6,18 +6,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import crazypants.enderio.EnderIO;
|
||||
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.liquid.ILiquidConduit;
|
||||
import crazypants.enderio.conduit.power.IPowerConduit;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
@@ -29,26 +17,36 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import crazypants.enderio.EnderIO;
|
||||
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.liquid.ILiquidConduit;
|
||||
import crazypants.enderio.conduit.power.IPowerConduit;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
|
||||
|
||||
private final List<IConduit> conduits = new ArrayList<IConduit>();
|
||||
|
||||
private int facadeId = -1;
|
||||
private int facadeMeta = 0;
|
||||
|
||||
private boolean facadeChanged;
|
||||
|
||||
private final List<CollidableComponent> cachedCollidables = new ArrayList<CollidableComponent>();
|
||||
|
||||
|
||||
private final List<CollidableComponent> cachedCollidables = new ArrayList<CollidableComponent>();
|
||||
|
||||
private boolean conduitsDirty = true;
|
||||
private boolean collidablesDirty = true;
|
||||
|
||||
public TileConduitBundle() {
|
||||
blockType = EnderIO.blockConduitBundle;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void dirty() {
|
||||
conduitsDirty = true;
|
||||
@@ -132,13 +130,13 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
for (IConduit conduit : conduits) {
|
||||
conduit.updateEntity(worldObj);
|
||||
}
|
||||
|
||||
if(worldObj != null && !worldObj.isRemote && conduitsDirty) {
|
||||
|
||||
if (worldObj != null && !worldObj.isRemote && conduitsDirty) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
conduitsDirty = false;
|
||||
}
|
||||
|
||||
if(worldObj != null && facadeChanged) {
|
||||
|
||||
if (worldObj != null && facadeChanged) {
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
facadeChanged = false;
|
||||
}
|
||||
@@ -196,7 +194,7 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
|
||||
@Override
|
||||
public void removeConduit(IConduit conduit) {
|
||||
if(conduit != null) {
|
||||
if (conduit != null) {
|
||||
removeConduit(conduit, true);
|
||||
}
|
||||
}
|
||||
@@ -271,12 +269,12 @@ 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 (dir == ForgeDirection.UNKNOWN) {
|
||||
if (containsOnlySingleVerticalConnections()) {
|
||||
return Offsets.get(type, true, false);
|
||||
}
|
||||
@@ -285,32 +283,32 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
}
|
||||
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, false, true);
|
||||
}
|
||||
return Offsets.get(type, true, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<CollidableComponent> getCollidableComponents() {
|
||||
|
||||
for(IConduit con : conduits) {
|
||||
|
||||
for (IConduit con : conduits) {
|
||||
collidablesDirty = collidablesDirty || con.haveCollidablesChangedSinceLastCall();
|
||||
}
|
||||
if(!collidablesDirty && !cachedCollidables.isEmpty()) {
|
||||
if (!collidablesDirty && !cachedCollidables.isEmpty()) {
|
||||
return cachedCollidables;
|
||||
}
|
||||
cachedCollidables.clear();
|
||||
cachedCollidables.clear();
|
||||
for (IConduit conduit : conduits) {
|
||||
cachedCollidables.addAll(conduit.getCollidableComponents());
|
||||
}
|
||||
|
||||
addConnectors(cachedCollidables);
|
||||
|
||||
|
||||
collidablesDirty = false;
|
||||
|
||||
|
||||
return cachedCollidables;
|
||||
}
|
||||
|
||||
@@ -337,27 +335,30 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
for (IConduit con : conduits) {
|
||||
Class<? extends IConduit> type = con.getBaseConduitType();
|
||||
result.addAll(cc.getCollidables(cc.createKey(type, getOffset(type, ForgeDirection.UNKNOWN), ForgeDirection.UNKNOWN, false), con));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// vertical box
|
||||
result.add(new CollidableComponent(null, ConduitGeometryUtil.instance.getBoundingBox(ConduitConnectorType.VERTICAL), ForgeDirection.UNKNOWN, ConduitConnectorType.VERTICAL));
|
||||
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.getBaseConduitType();
|
||||
result.addAll(cc.getCollidables(cc.createKey(type, getOffset(type, ForgeDirection.UNKNOWN), ForgeDirection.UNKNOWN, false), con));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
} else {
|
||||
// vertical box
|
||||
result
|
||||
.add(new CollidableComponent(null, ConduitGeometryUtil.instance.getBoundingBox(ConduitConnectorType.HORIZONTAL), ForgeDirection.UNKNOWN, ConduitConnectorType.HORIZONTAL));
|
||||
.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));
|
||||
result.add(new CollidableComponent(null, ConduitGeometryUtil.instance.getBoundingBox(ConduitConnectorType.BOTH), ForgeDirection.UNKNOWN,
|
||||
ConduitConnectorType.BOTH));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -400,25 +401,25 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
}
|
||||
|
||||
private int getConnectionCount(ForgeDirection dir) {
|
||||
if(dir == ForgeDirection.UNKNOWN) {
|
||||
if (dir == ForgeDirection.UNKNOWN) {
|
||||
return conduits.size();
|
||||
}
|
||||
int result = 0;
|
||||
for (IConduit con : conduits) {
|
||||
if (con.containsConduitConnection(dir) || con.containsExternalConnection(dir)) {
|
||||
result++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// ------------ Power -----------------------------
|
||||
|
||||
|
||||
@Override
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
IPowerConduit pc = getConduit(IPowerConduit.class);
|
||||
if (pc != null) {
|
||||
pc.doWork(workProvider);
|
||||
pc.doWork(workProvider);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,11 +427,11 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side) {
|
||||
IPowerConduit pc = getConduit(IPowerConduit.class);
|
||||
if (pc != null) {
|
||||
return pc.getPowerReceiver(side);
|
||||
return pc.getPowerReceiver(side);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PowerHandler getPowerHandler() {
|
||||
IPowerConduit pc = getConduit(IPowerConduit.class);
|
||||
@@ -453,11 +454,8 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
public World getWorld() {
|
||||
return worldObj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------- Liquids -----------------------------
|
||||
|
||||
// ------- Liquids -----------------------------
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
@@ -512,6 +510,5 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -52,15 +52,14 @@ public class BlockConduitFacade extends Block {
|
||||
int meta = cb.getFacadeMetadata();
|
||||
if (id <= 0 || id == blockID) {
|
||||
return blockIcon;
|
||||
}
|
||||
}
|
||||
Block block = Block.blocksList[id];
|
||||
if(block != null) {
|
||||
if (block != null) {
|
||||
return block.getIcon(side, meta);
|
||||
}
|
||||
return blockIcon;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getDamageValue(World par1World, int x, int y, int z) {
|
||||
Mimic m = getMimic(par1World, x, y, z);
|
||||
@@ -68,7 +67,7 @@ public class BlockConduitFacade extends Block {
|
||||
return m.meta;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private Mimic getMimic(IBlockAccess ba, int x, int y, int z) {
|
||||
TileEntity te = ba.getBlockTileEntity(x, y, z);
|
||||
@@ -80,10 +79,10 @@ public class BlockConduitFacade extends Block {
|
||||
int id = cb.getFacadeId();
|
||||
int meta = cb.getFacadeMetadata();
|
||||
|
||||
if(id <= 0) {
|
||||
if (id <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return new Mimic(id, meta);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.machine.painter.PainterUtil;
|
||||
import crazypants.render.RenderUtil;
|
||||
|
||||
|
||||
public class FacadeRenderer implements IItemRenderer {
|
||||
|
||||
@Override
|
||||
@@ -29,15 +28,15 @@ public class FacadeRenderer implements IItemRenderer {
|
||||
if (type == ItemRenderType.INVENTORY) {
|
||||
RenderBlocks renderBlocks = (RenderBlocks) data[0];
|
||||
renderToInventory(item, renderBlocks);
|
||||
} else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||
renderEquipped(item, (RenderBlocks) data[0]);
|
||||
} else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||
renderEquipped(item, (RenderBlocks) data[0]);
|
||||
} else if (type == ItemRenderType.ENTITY) {
|
||||
renderEntity(item, (RenderBlocks) data[0]);
|
||||
} else {
|
||||
System.out.println("FacadeRenderer.renderItem: Unsupported render type");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void renderEntity(ItemStack item, RenderBlocks renderBlocks) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(0.5f, 0.5f, 0.5f);
|
||||
@@ -46,48 +45,47 @@ public class FacadeRenderer implements IItemRenderer {
|
||||
}
|
||||
|
||||
private void renderEquipped(ItemStack item, RenderBlocks renderBlocks) {
|
||||
renderToInventory(item, renderBlocks);
|
||||
renderToInventory(item, renderBlocks);
|
||||
}
|
||||
|
||||
private void renderToInventory(ItemStack item, RenderBlocks renderBlocks) {
|
||||
|
||||
Block block = PainterUtil.getSourceBlock(item);
|
||||
if (block != null ) {
|
||||
//Render the facade block
|
||||
|
||||
if (block != null) {
|
||||
// Render the facade block
|
||||
|
||||
RenderUtil.bindBlockTexture();
|
||||
renderBlocks.renderBlockAsItem(block, PainterUtil.getSourceBlockMetadata(item), 1.0F);
|
||||
|
||||
//then the 'overlay' that marks it as a facade
|
||||
//GL11.glDepthFunc(GL11.GL_ALWAYS);
|
||||
|
||||
// then the 'overlay' that marks it as a facade
|
||||
// GL11.glDepthFunc(GL11.GL_ALWAYS);
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
|
||||
GL11.glPolygonOffset(-1.0f, -1.0f);
|
||||
|
||||
|
||||
|
||||
RenderUtil.bindItemTexture();
|
||||
renderBlocks.setOverrideBlockTexture(EnderIO.itemConduitFacade.getOverlayIcon());
|
||||
renderBlocks.setOverrideBlockTexture(EnderIO.itemConduitFacade.getOverlayIcon());
|
||||
renderBlocks.renderBlockAsItem(block, item.getItemDamage(), 1.0F);
|
||||
|
||||
|
||||
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
renderBlocks.clearOverrideBlockTexture();
|
||||
|
||||
renderBlocks.clearOverrideBlockTexture();
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
|
||||
|
||||
} else {
|
||||
renderBlocks.setOverrideBlockTexture(EnderIO.itemConduitFacade.getIconFromDamage(0));
|
||||
renderBlocks.renderBlockAsItem(Block.stone, 0, 1.0F);
|
||||
renderBlocks.clearOverrideBlockTexture();
|
||||
renderBlocks.clearOverrideBlockTexture();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,15 +2,21 @@ package crazypants.enderio.conduit.facade;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import cpw.mods.fml.common.registry.*;
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
import crazypants.enderio.*;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
import crazypants.enderio.machine.painter.*;
|
||||
import crazypants.enderio.machine.painter.BasicPainterTemplate;
|
||||
import crazypants.enderio.machine.painter.PainterUtil;
|
||||
|
||||
public class ItemConduitFacade extends Item {
|
||||
|
||||
@@ -31,7 +37,7 @@ public class ItemConduitFacade extends Item {
|
||||
|
||||
protected void init() {
|
||||
LanguageRegistry.addName(this, ModObject.itemConduitFacade.name);
|
||||
GameRegistry.registerItem(this, ModObject.itemConduitFacade.unlocalisedName);
|
||||
GameRegistry.registerItem(this, ModObject.itemConduitFacade.unlocalisedName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,7 +72,7 @@ public class ItemConduitFacade extends Item {
|
||||
bundle.setFacadeMetadata(PainterUtil.getSourceBlockMetadata(itemStack));
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
itemStack.stackSize--;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -82,7 +88,7 @@ public class ItemConduitFacade extends Item {
|
||||
@Override
|
||||
public void onCreated(ItemStack itemStack, World world, EntityPlayer player) {
|
||||
if (PainterUtil.getSourceBlock(itemStack) == null) {
|
||||
PainterUtil.setSourceBlock(itemStack, ModObject.blockConduitFacade.id, 0);
|
||||
PainterUtil.setSourceBlock(itemStack, ModObject.blockConduitFacade.id, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,8 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
|
||||
public class CollidableCache {
|
||||
|
||||
@@ -17,21 +16,21 @@ public class CollidableCache {
|
||||
public CacheKey createKey(Class<? extends IConduit> baseType, Offset offset, ForgeDirection dir, boolean isStub) {
|
||||
return new CacheKey(baseType, offset, dir, isStub);
|
||||
}
|
||||
|
||||
|
||||
public Collection<CollidableComponent> getCollidables(CacheKey key, IConduit conduit) {
|
||||
Collection<CollidableComponent> result = cache.get(key);
|
||||
if(result == null) {
|
||||
if (result == null) {
|
||||
result = conduit.createCollidables(key);
|
||||
cache.put(key, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static class CacheKey {
|
||||
|
||||
public final Class<? extends IConduit> baseType;
|
||||
public final String className; //used to generate reliable equals / hashcode
|
||||
public final String className; // used to generate reliable equals /
|
||||
// hashcode
|
||||
public final Offset offset;
|
||||
public final ForgeDirection dir;
|
||||
public final boolean isStub;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package crazypants.enderio.conduit.geom;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.render.BoundingBox;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class CollidableComponent {
|
||||
|
||||
@@ -10,8 +10,8 @@ public class CollidableComponent {
|
||||
public final BoundingBox bound;
|
||||
public final ForgeDirection dir;
|
||||
public final Object data;
|
||||
|
||||
public CollidableComponent(Class<? extends IConduit> conduitType, BoundingBox bound, ForgeDirection id,Object data) {
|
||||
|
||||
public CollidableComponent(Class<? extends IConduit> conduitType, BoundingBox bound, ForgeDirection id, Object data) {
|
||||
this.conduitType = conduitType;
|
||||
this.bound = bound;
|
||||
this.dir = id;
|
||||
@@ -21,8 +21,6 @@ public class CollidableComponent {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CollidableComponent [conduitType=" + conduitType + ", bound=" + bound + ", id=" + dir + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,5 +5,5 @@ public enum ConduitConnectorType {
|
||||
VERTICAL,
|
||||
HORIZONTAL,
|
||||
BOTH
|
||||
|
||||
|
||||
}
|
||||
@@ -4,13 +4,12 @@ import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.vecmath.VecmathUtil;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class ConduitGeometryUtil {
|
||||
|
||||
public static final ConduitGeometryUtil instance = new ConduitGeometryUtil();
|
||||
@@ -72,8 +71,8 @@ public class ConduitGeometryUtil {
|
||||
return result;
|
||||
}
|
||||
|
||||
public Vector3d getTranslation(ForgeDirection dir, Offset offset) {
|
||||
Vector3d result = new Vector3d(offset.xOffset, offset.yOffset,0);
|
||||
public Vector3d getTranslation(ForgeDirection dir, Offset offset) {
|
||||
Vector3d result = new Vector3d(offset.xOffset, offset.yOffset, 0);
|
||||
result.scale(WIDTH);
|
||||
return result;
|
||||
}
|
||||
@@ -84,9 +83,9 @@ public class ConduitGeometryUtil {
|
||||
|
||||
private BoundingBox createConduitBounds(Class<? extends IConduit> type, ForgeDirection dir, boolean isStub, Offset offset) {
|
||||
BoundingBox bb = CORE_BOUNDS;
|
||||
// if(type == IRedstoneConduit.class) {
|
||||
// bb = bb.scale(0.5f, 0.5f, 0.5f);
|
||||
// }
|
||||
// if(type == IRedstoneConduit.class) {
|
||||
// bb = bb.scale(0.5f, 0.5f, 0.5f);
|
||||
// }
|
||||
Vector3d min = bb.getMin();
|
||||
Vector3d max = bb.getMax();
|
||||
|
||||
@@ -122,10 +121,8 @@ public class ConduitGeometryUtil {
|
||||
Vector3d trans = getTranslation(dir, offset);
|
||||
min.add(trans);
|
||||
max.add(trans);
|
||||
bb = new BoundingBox(VecmathUtil.clamp(min,0,1), VecmathUtil.clamp(max,0,1));
|
||||
bb = new BoundingBox(VecmathUtil.clamp(min, 0, 1), VecmathUtil.clamp(max, 0, 1));
|
||||
return bb;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package crazypants.enderio.conduit.geom;
|
||||
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
|
||||
public final class GeometryKey {
|
||||
|
||||
@@ -9,8 +9,8 @@ public final class GeometryKey {
|
||||
public final boolean isStub;
|
||||
public final Offset offset;
|
||||
public final String className;
|
||||
|
||||
public GeometryKey(ForgeDirection dir, boolean isStub, Offset offset,Class<? extends IConduit> type) {
|
||||
|
||||
public GeometryKey(ForgeDirection dir, boolean isStub, Offset offset, Class<? extends IConduit> type) {
|
||||
this.dir = dir;
|
||||
this.isStub = isStub;
|
||||
this.offset = offset;
|
||||
@@ -50,11 +50,5 @@ public final class GeometryKey {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,31 +1,28 @@
|
||||
package crazypants.enderio.conduit.geom;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Offset vectors are based on Y up.
|
||||
*
|
||||
* @author brad
|
||||
*/
|
||||
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);
|
||||
|
||||
public final int xOffset;
|
||||
public final int yOffset;
|
||||
|
||||
private Offset(int xOffset, int yOffset) {
|
||||
this.xOffset = xOffset;
|
||||
this.yOffset = yOffset;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
public final int xOffset;
|
||||
public final int yOffset;
|
||||
|
||||
private Offset(int xOffset, int yOffset) {
|
||||
this.xOffset = xOffset;
|
||||
this.yOffset = yOffset;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
package crazypants.enderio.conduit.geom;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.liquid.ILiquidConduit;
|
||||
import crazypants.enderio.conduit.power.IPowerConduit;
|
||||
import crazypants.enderio.conduit.redstone.IRedstoneConduit;
|
||||
|
||||
|
||||
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, 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(IRedstoneConduit.class, true, true), Offset.BL);
|
||||
OFFSETS.put(key(IPowerConduit.class, true, true), Offset.TR);
|
||||
OFFSETS.put(key(ILiquidConduit.class, true, true), Offset.NONE);
|
||||
}
|
||||
|
||||
|
||||
public static Offset get(Class<? extends IConduit> type, boolean horizontal, boolean vertical) {
|
||||
return OFFSETS.get(key(type,horizontal,vertical));
|
||||
return OFFSETS.get(key(type, horizontal, vertical));
|
||||
}
|
||||
|
||||
|
||||
public static OffsetKey key(Class<? extends IConduit> type, boolean horizontal, boolean vertical) {
|
||||
return new OffsetKey(type, horizontal, vertical);
|
||||
}
|
||||
|
||||
|
||||
public static class OffsetKey {
|
||||
|
||||
String typeName;
|
||||
@@ -79,6 +79,4 @@ public class Offsets {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -15,16 +15,17 @@ public class ConduitTank implements IFluidTank {
|
||||
ConduitTank(int capacity) {
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getFluidAmount() {
|
||||
return fluid == null ? 0 : fluid.amount;
|
||||
}
|
||||
|
||||
public float getFilledRatio() {
|
||||
if(getFluidAmount() <= 0) {
|
||||
if (getFluidAmount() <= 0) {
|
||||
return 0;
|
||||
}
|
||||
if(getCapacity() <= 0) {
|
||||
if (getCapacity() <= 0) {
|
||||
return -1;
|
||||
}
|
||||
return (float) getFluidAmount() / getCapacity();
|
||||
@@ -35,9 +36,9 @@ public class ConduitTank implements IFluidTank {
|
||||
}
|
||||
|
||||
public void setAmount(int amount) {
|
||||
if(fluid != null) {
|
||||
if (fluid != null) {
|
||||
fluid.amount = amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getAvailableSpace() {
|
||||
@@ -47,12 +48,11 @@ public class ConduitTank implements IFluidTank {
|
||||
public void addAmount(int amount) {
|
||||
setAmount(getFluidAmount() + amount);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FluidTankInfo getInfo() {
|
||||
return new FluidTankInfo(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FluidStack getFluid() {
|
||||
@@ -79,7 +79,7 @@ public class ConduitTank implements IFluidTank {
|
||||
public int fill(FluidStack resource, boolean doFill) {
|
||||
if (resource == null || resource.fluidID <= 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (fluid == null || fluid.fluidID <= 0) {
|
||||
if (resource.amount <= capacity) {
|
||||
@@ -90,7 +90,7 @@ public class ConduitTank implements IFluidTank {
|
||||
} else {
|
||||
if (doFill) {
|
||||
fluid = resource.copy();
|
||||
fluid.amount = capacity;
|
||||
fluid.amount = capacity;
|
||||
}
|
||||
return capacity;
|
||||
}
|
||||
@@ -134,7 +134,7 @@ public class ConduitTank implements IFluidTank {
|
||||
}
|
||||
|
||||
FluidStack drained = new FluidStack(fluid.fluidID, used);
|
||||
|
||||
|
||||
if (fluid.amount < 0) {
|
||||
fluid.amount = 0;
|
||||
}
|
||||
@@ -173,11 +173,11 @@ public class ConduitTank implements IFluidTank {
|
||||
}
|
||||
|
||||
public void remove(int amount) {
|
||||
if(fluid == null) {
|
||||
if (fluid == null) {
|
||||
return;
|
||||
}
|
||||
fluid.amount -= amount;
|
||||
fluid.amount = Math.max(0, fluid.amount);
|
||||
fluid.amount = Math.max(0, fluid.amount);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,33 +1,33 @@
|
||||
package crazypants.enderio.conduit.liquid;
|
||||
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
|
||||
public interface ILiquidConduit extends IConduit, IFluidHandler {
|
||||
|
||||
static final int VOLUME_PER_CONNECTION = FluidContainerRegistry.BUCKET_VOLUME/4;
|
||||
|
||||
public static final String ICON_KEY ="enderio:liquidConduit";
|
||||
public static final String ICON_CORE_KEY ="enderio:liquidConduitCore";
|
||||
public static final String ICON_EXTRACT_KEY ="enderio:liquidConduitExtract";
|
||||
|
||||
static final int VOLUME_PER_CONNECTION = FluidContainerRegistry.BUCKET_VOLUME / 4;
|
||||
|
||||
public static final String ICON_KEY = "enderio:liquidConduit";
|
||||
public static final String ICON_CORE_KEY = "enderio:liquidConduitCore";
|
||||
public static final String ICON_EXTRACT_KEY = "enderio:liquidConduitExtract";
|
||||
|
||||
void setFluidType(FluidStack fluidType);
|
||||
|
||||
|
||||
FluidStack getFluidType();
|
||||
|
||||
ConduitTank getTank();
|
||||
|
||||
|
||||
IFluidHandler getExternalHandler(ForgeDirection direction);
|
||||
|
||||
boolean canOutputToDir(ForgeDirection dir);
|
||||
|
||||
|
||||
boolean isExtractingFromDir(ForgeDirection dir);
|
||||
|
||||
|
||||
void setExtractingFromDir(ForgeDirection dir, boolean extracting);
|
||||
|
||||
|
||||
int fill(ForgeDirection from, FluidStack resource, boolean doFill, boolean doPush);
|
||||
|
||||
}
|
||||
@@ -1,18 +1,17 @@
|
||||
package crazypants.enderio.conduit.liquid;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.AbstractItemConduit;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.ItemConduitSubtype;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemLiquidConduit extends AbstractItemConduit {
|
||||
|
||||
private static ItemConduitSubtype[] subtypes = new ItemConduitSubtype[] {
|
||||
new ItemConduitSubtype(ModObject.itemLiquidConduit.unlocalisedName, ModObject.itemLiquidConduit.name, "enderio:itemLiquidConduit"),
|
||||
new ItemConduitSubtype(ModObject.itemLiquidConduit.unlocalisedName, ModObject.itemLiquidConduit.name, "enderio:itemLiquidConduit"),
|
||||
};
|
||||
|
||||
|
||||
public static ItemLiquidConduit create() {
|
||||
ItemLiquidConduit result = new ItemLiquidConduit();
|
||||
result.init(subtypes);
|
||||
@@ -20,7 +19,7 @@ public class ItemLiquidConduit extends AbstractItemConduit {
|
||||
}
|
||||
|
||||
protected ItemLiquidConduit() {
|
||||
super(ModObject.itemLiquidConduit);
|
||||
super(ModObject.itemLiquidConduit);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,21 +8,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.AbstractConduit;
|
||||
import crazypants.enderio.conduit.AbstractConduitNetwork;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
import crazypants.enderio.conduit.RaytraceResult;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.machine.reservoir.TileReservoir;
|
||||
import crazypants.render.IconUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -39,6 +24,19 @@ import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.AbstractConduit;
|
||||
import crazypants.enderio.conduit.AbstractConduitNetwork;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
import crazypants.enderio.conduit.RaytraceResult;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.machine.reservoir.TileReservoir;
|
||||
import crazypants.render.IconUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public class LiquidConduit extends AbstractConduit implements ILiquidConduit {
|
||||
|
||||
@@ -92,7 +90,7 @@ public class LiquidConduit extends AbstractConduit implements ILiquidConduit {
|
||||
if (!getBundle().getEntity().worldObj.isRemote) {
|
||||
ForgeDirection faceHit = ForgeDirection.getOrientation(res.movingObjectPosition.sideHit);
|
||||
if (res.component != null) {
|
||||
ForgeDirection connDir = (ForgeDirection) res.component.dir;
|
||||
ForgeDirection connDir = res.component.dir;
|
||||
|
||||
if (connDir == ForgeDirection.UNKNOWN || connDir == faceHit) {
|
||||
// Attempt to join networls
|
||||
@@ -265,7 +263,7 @@ public class LiquidConduit extends AbstractConduit implements ILiquidConduit {
|
||||
}
|
||||
tank.setLiquid(liquidType);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
return fill(from, resource, doFill, true);
|
||||
@@ -287,11 +285,11 @@ public class LiquidConduit extends AbstractConduit implements ILiquidConduit {
|
||||
}
|
||||
|
||||
int pushedVolume = 0;
|
||||
if(doPush) {
|
||||
if (doPush) {
|
||||
int maxPush = Math.max(0, recieveAmount + tank.getFluidAmount() - tank.getCapacity());
|
||||
pushedVolume = pushLiquid(from, maxPush, doFill);
|
||||
pushedVolume = pushLiquid(from, maxPush, doFill);
|
||||
}
|
||||
|
||||
|
||||
if (doFill) {
|
||||
tank.drain(pushedVolume, doFill);
|
||||
return tank.fill(resource, doFill);
|
||||
@@ -521,7 +519,7 @@ public class LiquidConduit extends AbstractConduit implements ILiquidConduit {
|
||||
if (component.dir == ForgeDirection.UNKNOWN) {
|
||||
return ICONS.get(ICON_CORE_KEY);
|
||||
}
|
||||
if (isExtractingFromDir((ForgeDirection) component.dir)) {
|
||||
if (isExtractingFromDir(component.dir)) {
|
||||
return ICONS.get(ICON_EXTRACT_KEY);
|
||||
}
|
||||
return ICONS.get(ICON_KEY);
|
||||
|
||||
@@ -4,15 +4,14 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import crazypants.enderio.conduit.AbstractConduitNetwork;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import crazypants.enderio.conduit.AbstractConduitNetwork;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public class LiquidConduitNetwork extends AbstractConduitNetwork<ILiquidConduit> {
|
||||
|
||||
@@ -82,7 +81,7 @@ public class LiquidConduitNetwork extends AbstractConduitNetwork<ILiquidConduit>
|
||||
if (world.isRemote || liquidType == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
long curTime = world.getTotalWorldTime();
|
||||
if (curTime != timeAtLastApply) {
|
||||
timeAtLastApply = curTime;
|
||||
@@ -149,7 +148,7 @@ public class LiquidConduitNetwork extends AbstractConduitNetwork<ILiquidConduit>
|
||||
BlockCoord loc = con.getLocation().getLocation(ForgeDirection.DOWN);
|
||||
ILiquidConduit downCon = ConduitUtil.getConduit(con.getBundle().getEntity().worldObj, loc.x, loc.y, loc.z, ILiquidConduit.class);
|
||||
int filled = downCon.fill(ForgeDirection.UP, tank.getFluid().copy(), false, false);
|
||||
tank.addAmount(-filled);
|
||||
tank.addAmount(-filled);
|
||||
downCon.getTank().addAmount(filled);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package crazypants.enderio.conduit.liquid;
|
||||
|
||||
import static crazypants.render.CubeRenderer.setupVertices;
|
||||
import crazypants.enderio.conduit.*;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.conduit.render.*;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.conduit.render.ConduitBundleRenderer;
|
||||
import crazypants.enderio.conduit.render.DefaultConduitRenderer;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
|
||||
public class LiquidConduitRenderer extends DefaultConduitRenderer {
|
||||
|
||||
@@ -33,6 +34,7 @@ public class LiquidConduitRenderer extends DefaultConduitRenderer {
|
||||
super.renderEntity(conduitBundleRenderer, te, conduit, x, y, z, partialTick, worldLight);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderConduit(Icon tex, CollidableComponent component) {
|
||||
if (isNSEWUP(component.dir)) {
|
||||
BoundingBox[] cubes = toCubes(component.bound);
|
||||
@@ -44,6 +46,7 @@ public class LiquidConduitRenderer extends DefaultConduitRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderTransmission(Icon tex, CollidableComponent component) {
|
||||
BoundingBox[] cubes = toCubes(component.bound);
|
||||
for (BoundingBox cube : cubes) {
|
||||
@@ -56,9 +59,9 @@ public class LiquidConduitRenderer extends DefaultConduitRenderer {
|
||||
|
||||
float yScale = getRatioForConnection(id);
|
||||
|
||||
float xs = ((ForgeDirection) id).offsetX == 0 ? 0.9f : 1;
|
||||
float ys = ((ForgeDirection) id).offsetY == 0 ? Math.min(yScale, 0.9f) : yScale;
|
||||
float zs = ((ForgeDirection) id).offsetZ == 0 ? 0.9f : 1;
|
||||
float xs = id.offsetX == 0 ? 0.9f : 1;
|
||||
float ys = id.offsetY == 0 ? Math.min(yScale, 0.9f) : yScale;
|
||||
float zs = id.offsetZ == 0 ? 0.9f : 1;
|
||||
|
||||
float sizeY = bound.sizeY();
|
||||
bound = bound.scale(xs, ys, zs);
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
package crazypants.enderio.conduit.power;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.power.ICapacitor;
|
||||
import crazypants.enderio.power.IInternalPowerReceptor;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
|
||||
public interface IPowerConduit extends IConduit, IInternalPowerReceptor {
|
||||
|
||||
public static final String ICON_KEY ="enderio:powerConduit";
|
||||
public static final String ICON_CORE_KEY ="enderio:powerConduitCore";
|
||||
public static final String ICON_KEY = "enderio:powerConduit";
|
||||
public static final String ICON_CORE_KEY = "enderio:powerConduitCore";
|
||||
public static final String ICON_TRANSMISSION_KEY = "enderio:powerConduitTransmission";
|
||||
|
||||
|
||||
IPowerReceptor getExternalPowerReceptor(ForgeDirection direction);
|
||||
|
||||
|
||||
ICapacitor getCapacitor();
|
||||
|
||||
|
||||
float getEnergyStored();
|
||||
|
||||
|
||||
void setEnergyStored(float energyStored);
|
||||
|
||||
|
||||
}
|
||||
@@ -15,11 +15,12 @@ import crazypants.enderio.power.ICapacitor;
|
||||
public class ItemPowerConduit extends AbstractItemConduit {
|
||||
|
||||
static ItemConduitSubtype[] subtypes = new ItemConduitSubtype[] {
|
||||
new ItemConduitSubtype(ModObject.itemPowerConduit.unlocalisedName, ModObject.itemPowerConduit.name, "enderio:itemPowerConduit"),
|
||||
new ItemConduitSubtype(ModObject.itemPowerConduit.unlocalisedName + "Enhanced", "Enhanced " + ModObject.itemPowerConduit.name, "enderio:itemPowerConduitEnhanced"),
|
||||
new ItemConduitSubtype(ModObject.itemPowerConduit.unlocalisedName + "Ender", "Ender " + ModObject.itemPowerConduit.name, "enderio:itemPowerConduitEnder")
|
||||
new ItemConduitSubtype(ModObject.itemPowerConduit.unlocalisedName, ModObject.itemPowerConduit.name, "enderio:itemPowerConduit"),
|
||||
new ItemConduitSubtype(ModObject.itemPowerConduit.unlocalisedName + "Enhanced", "Enhanced " + ModObject.itemPowerConduit.name,
|
||||
"enderio:itemPowerConduitEnhanced"),
|
||||
new ItemConduitSubtype(ModObject.itemPowerConduit.unlocalisedName + "Ender", "Ender " + ModObject.itemPowerConduit.name, "enderio:itemPowerConduitEnder")
|
||||
};
|
||||
|
||||
|
||||
public static ItemPowerConduit create() {
|
||||
ItemPowerConduit result = new ItemPowerConduit();
|
||||
result.init(subtypes);
|
||||
@@ -27,7 +28,7 @@ public class ItemPowerConduit extends AbstractItemConduit {
|
||||
}
|
||||
|
||||
protected ItemPowerConduit() {
|
||||
super(ModObject.itemPowerConduit);
|
||||
super(ModObject.itemPowerConduit);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,8 +47,7 @@ public class ItemPowerConduit extends AbstractItemConduit {
|
||||
super.addInformation(itemStack, par2EntityPlayer, list, par4);
|
||||
ICapacitor cap = PowerConduit.CAPACITORS[itemStack.getItemDamage()];
|
||||
list.add(String.format("I/O %d MJ/t", cap.getMaxEnergyExtracted()));
|
||||
list.add(String.format("Storage %d MJ", cap.getMaxEnergyStored()));
|
||||
list.add(String.format("Storage %d MJ", cap.getMaxEnergyStored()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -6,23 +6,20 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import crazypants.enderio.conduit.power.PowerConduitNetwork.ReceptorEntry;
|
||||
import crazypants.enderio.power.IInternalPowerReceptor;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
|
||||
public class NetworkPowerManager {
|
||||
|
||||
private PowerConduitNetwork network;
|
||||
|
||||
|
||||
private int maxEnergyStored;
|
||||
private float energyStored;
|
||||
private float reserved;
|
||||
@@ -35,34 +32,33 @@ public class NetworkPowerManager {
|
||||
|
||||
private boolean lastActiveValue = false;
|
||||
private int ticksWithNoPower = 0;
|
||||
|
||||
|
||||
private final Map<BlockCoord, StarveBuffer> starveBuffers = new HashMap<BlockCoord, NetworkPowerManager.StarveBuffer>();
|
||||
|
||||
|
||||
public NetworkPowerManager(PowerConduitNetwork netowrk, World world) {
|
||||
this.network = netowrk;
|
||||
maxEnergyStored = 64;
|
||||
}
|
||||
|
||||
|
||||
public float addEnergy(float quantity) {
|
||||
float used = quantity;
|
||||
energyStored += quantity;
|
||||
energyStored += quantity;
|
||||
if (energyStored > maxEnergyStored) {
|
||||
used -= energyStored - maxEnergyStored;
|
||||
energyStored = maxEnergyStored;
|
||||
} else if (energyStored < 0) {
|
||||
used -= energyStored;
|
||||
energyStored = 0;
|
||||
}
|
||||
}
|
||||
updateConduitStorage();
|
||||
return used;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void applyRecievedPower() {
|
||||
|
||||
|
||||
updateStorage();
|
||||
|
||||
float extracted = extractRecievedEnergy();
|
||||
|
||||
float extracted = extractRecievedEnergy();
|
||||
addEnergy(extracted);
|
||||
checkReserves();
|
||||
float quantity = energyStored;
|
||||
@@ -81,14 +77,13 @@ public class NetworkPowerManager {
|
||||
lastActiveValue = active;
|
||||
for (IPowerConduit con : network.getConduits()) {
|
||||
con.setActive(active);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (quantity <= 0 || receptors.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int appliedCount = 0;
|
||||
int numReceptors = receptors.size();
|
||||
int numEngines = 0;
|
||||
@@ -97,151 +92,148 @@ public class NetworkPowerManager {
|
||||
if (!receptors.isEmpty() && !receptorIterator.hasNext()) {
|
||||
receptorIterator = receptors.listIterator();
|
||||
}
|
||||
|
||||
|
||||
ReceptorEntry r = receptorIterator.next();
|
||||
float reservedForEntry = removeReservedEnergy(r);
|
||||
|
||||
for (ForgeDirection dir : r.directions) {
|
||||
|
||||
for (ForgeDirection dir : r.directions) {
|
||||
|
||||
PowerReceiver pp = r.powerReceptor.getPowerReceiver(dir);
|
||||
if(pp != null) {
|
||||
if(pp.getType() != Type.ENGINE) {
|
||||
|
||||
if (pp != null) {
|
||||
if (pp.getType() != Type.ENGINE) {
|
||||
|
||||
float used = 0;
|
||||
float nonReservedPower = quantity - reserved;
|
||||
float available = nonReservedPower + reservedForEntry;
|
||||
float canOffer = Math.min(r.emmiter.getCapacitor().getMaxEnergyExtracted(),available);
|
||||
float available = nonReservedPower + reservedForEntry;
|
||||
float canOffer = Math.min(r.emmiter.getCapacitor().getMaxEnergyExtracted(), available);
|
||||
float requested = pp.powerRequest();
|
||||
|
||||
//If it is possible to supply the minimum amount of energy
|
||||
if(pp.getMinEnergyReceived() <= r.emmiter.getCapacitor().getMaxEnergyExtracted()) {
|
||||
//Buffer energy if we can't meet it now
|
||||
if(pp.getMinEnergyReceived() > canOffer && requested > 0) {
|
||||
|
||||
// If it is possible to supply the minimum amount of energy
|
||||
if (pp.getMinEnergyReceived() <= r.emmiter.getCapacitor().getMaxEnergyExtracted()) {
|
||||
// Buffer energy if we can't meet it now
|
||||
if (pp.getMinEnergyReceived() > canOffer && requested > 0) {
|
||||
reserveEnergy(r, canOffer);
|
||||
used += canOffer;
|
||||
} else if (r.powerReceptor instanceof IInternalPowerReceptor) {
|
||||
used = PowerHandlerUtil.transmitInternal((IInternalPowerReceptor) r.powerReceptor, pp, canOffer, Type.PIPE, dir);
|
||||
} else {
|
||||
used = pp.receiveEnergy(Type.PIPE, Math.min(requested, canOffer), dir);
|
||||
used += canOffer;
|
||||
} else if (r.powerReceptor instanceof IInternalPowerReceptor) {
|
||||
used = PowerHandlerUtil.transmitInternal((IInternalPowerReceptor) r.powerReceptor, pp, canOffer, Type.PIPE, dir);
|
||||
} else {
|
||||
used = pp.receiveEnergy(Type.PIPE, Math.min(requested, canOffer), dir);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
quantity -= used;
|
||||
|
||||
} else if(pp.getType() == Type.ENGINE && !(r.powerReceptor instanceof IInternalPowerReceptor)) {
|
||||
|
||||
} else if (pp.getType() == Type.ENGINE && !(r.powerReceptor instanceof IInternalPowerReceptor)) {
|
||||
numEngines++;
|
||||
}
|
||||
|
||||
if(quantity <= 0) {
|
||||
|
||||
if (quantity <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
appliedCount++;
|
||||
}
|
||||
appliedCount++;
|
||||
}
|
||||
float leaveForBlowingUpEngines = numEngines * 8;
|
||||
if(leaveForBlowingUpEngines > maxEnergyStored) {
|
||||
if (leaveForBlowingUpEngines > maxEnergyStored) {
|
||||
leaveForBlowingUpEngines = maxEnergyStored;
|
||||
}
|
||||
energyStored = Math.min(quantity, maxEnergyStored - leaveForBlowingUpEngines);
|
||||
energyStored = Math.min(quantity, maxEnergyStored - leaveForBlowingUpEngines);
|
||||
updateConduitStorage();
|
||||
}
|
||||
|
||||
|
||||
private float removeReservedEnergy(ReceptorEntry r) {
|
||||
StarveBuffer starveBuf = starveBuffers.remove(r.coord);
|
||||
if(starveBuf == null) {
|
||||
if (starveBuf == null) {
|
||||
return 0;
|
||||
}
|
||||
float result = starveBuf.stored;
|
||||
reserved -= result;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private void reserveEnergy(ReceptorEntry r, float amount) {
|
||||
starveBuffers.put(r.coord, new StarveBuffer(amount));
|
||||
reserved += amount;
|
||||
}
|
||||
|
||||
|
||||
private void checkReserves() {
|
||||
if(reserved > maxEnergyStored * 0.9) {
|
||||
if (reserved > maxEnergyStored * 0.9) {
|
||||
starveBuffers.clear();
|
||||
reserved = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void updateConduitStorage() {
|
||||
float energyLeft = energyStored;
|
||||
for(IPowerConduit con : network.getConduits()) {
|
||||
for (IPowerConduit con : network.getConduits()) {
|
||||
float give = con.getCapacitor().getMaxEnergyStored();
|
||||
if(give > energyLeft) {
|
||||
give = energyLeft;
|
||||
if (give > energyLeft) {
|
||||
give = energyLeft;
|
||||
}
|
||||
con.setEnergyStored(give);
|
||||
energyLeft -= give;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boolean isActive() {
|
||||
boolean isActive() {
|
||||
return energyStored > 0;
|
||||
}
|
||||
|
||||
private void updateStorage() {
|
||||
maxEnergyStored = 0;
|
||||
energyStored = 0;
|
||||
for(IPowerConduit con : network.getConduits()) {
|
||||
for (IPowerConduit con : network.getConduits()) {
|
||||
maxEnergyStored += con.getCapacitor().getMaxEnergyStored();
|
||||
energyStored += con.getEnergyStored();
|
||||
}
|
||||
if(energyStored > maxEnergyStored) {
|
||||
}
|
||||
if (energyStored > maxEnergyStored) {
|
||||
energyStored = maxEnergyStored;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private float extractRecievedEnergy() {
|
||||
float extracted = 0;
|
||||
for(IPowerConduit conduit : network.getConduits()) {
|
||||
for (IPowerConduit conduit : network.getConduits()) {
|
||||
PowerHandler ph = conduit.getPowerHandler();
|
||||
extracted += ph.getEnergyStored();
|
||||
ph.update();
|
||||
ph.setEnergy(0);
|
||||
}
|
||||
return extracted;
|
||||
}
|
||||
}
|
||||
|
||||
public void receptorsChanged() {
|
||||
receptors.clear();
|
||||
receptors.addAll(network.getPowerReceptors());
|
||||
receptorIterator = receptors.listIterator();
|
||||
receptorIterator = receptors.listIterator();
|
||||
}
|
||||
|
||||
|
||||
void onNetworkDestroyed() {
|
||||
//Pass out all the stored energy to the conduits
|
||||
for(IPowerConduit con : network.getConduits()) {
|
||||
// Pass out all the stored energy to the conduits
|
||||
for (IPowerConduit con : network.getConduits()) {
|
||||
PowerHandler ph = con.getPowerHandler();
|
||||
float give = ph.getMaxEnergyStored() - ph.getEnergyStored();
|
||||
give = Math.min(give, energyStored);
|
||||
ph.setEnergy(ph.getEnergyStored() + give);
|
||||
energyStored -= give;
|
||||
if(energyStored <= 0) {
|
||||
if (energyStored <= 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static class StarveBuffer {
|
||||
|
||||
float stored;
|
||||
|
||||
|
||||
float stored;
|
||||
|
||||
public StarveBuffer(float stored) {
|
||||
this.stored = stored;
|
||||
this.stored = stored;
|
||||
}
|
||||
|
||||
|
||||
void addToStore(float val) {
|
||||
stored += val;
|
||||
}
|
||||
|
||||
@@ -3,19 +3,6 @@ package crazypants.enderio.conduit.power;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.AbstractConduit;
|
||||
import crazypants.enderio.conduit.AbstractConduitNetwork;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.power.BasicCapacitor;
|
||||
import crazypants.enderio.power.ICapacitor;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.IconUtil;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -28,23 +15,35 @@ import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.AbstractConduit;
|
||||
import crazypants.enderio.conduit.AbstractConduitNetwork;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.power.BasicCapacitor;
|
||||
import crazypants.enderio.power.ICapacitor;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.IconUtil;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
|
||||
public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
|
||||
static final Map<String, Icon> ICONS = new HashMap<String, Icon>();
|
||||
|
||||
static final ICapacitor[] CAPACITORS = new BasicCapacitor[] {
|
||||
new BasicCapacitor(0, 64, 128, 0, 0, 0, 256),
|
||||
new BasicCapacitor(0, 128, 256, 0, 0, 0, 1024),
|
||||
new BasicCapacitor(0, 1024, 1024, 0, 0, 0, 2048)
|
||||
};
|
||||
|
||||
new BasicCapacitor(0, 64, 128, 0, 0, 0, 256),
|
||||
new BasicCapacitor(0, 128, 256, 0, 0, 0, 1024),
|
||||
new BasicCapacitor(0, 1024, 1024, 0, 0, 0, 2048)
|
||||
};
|
||||
|
||||
static final String[] POSTFIX = new String[] { "", "Enhanced", "Ender" };
|
||||
|
||||
|
||||
static ItemStack createItemStackForSubtype(int subtype) {
|
||||
ItemStack result = new ItemStack(ModObject.itemPowerConduit.actualId, 1, subtype);
|
||||
ItemStack result = new ItemStack(ModObject.itemPowerConduit.actualId, 1, subtype);
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void initIcons() {
|
||||
@@ -60,7 +59,7 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTextureType() {
|
||||
public int getTextureType() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -79,7 +78,7 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
private PowerHandler powerHandler;
|
||||
|
||||
private int subtype;
|
||||
|
||||
|
||||
private float energyStored;
|
||||
|
||||
public PowerConduit() {
|
||||
@@ -89,7 +88,7 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
this.subtype = meta;
|
||||
powerHandler = createPowerHandlerForType();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICapacitor getCapacitor() {
|
||||
return CAPACITORS[subtype];
|
||||
@@ -99,10 +98,12 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
return PowerHandlerUtil.createHandler(CAPACITORS[subtype], this, Type.PIPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEnergyStored() {
|
||||
return energyStored;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergyStored(float energyStored) {
|
||||
this.energyStored = energyStored;
|
||||
}
|
||||
@@ -122,9 +123,9 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
powerHandler = createPowerHandlerForType();
|
||||
}
|
||||
energyStored = nbtRoot.getFloat("energyStored");
|
||||
if(energyStored < 0) {
|
||||
if (energyStored < 0) {
|
||||
energyStored = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -162,10 +163,10 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectToExternal(ForgeDirection direction) {
|
||||
public boolean canConnectToExternal(ForgeDirection direction) {
|
||||
IPowerReceptor rec = getExternalPowerReceptor(direction);
|
||||
if(rec instanceof IPowerEmitter) {
|
||||
return ((IPowerEmitter)rec).canEmitPowerFrom(direction.getOpposite());
|
||||
if (rec instanceof IPowerEmitter) {
|
||||
return ((IPowerEmitter) rec).canEmitPowerFrom(direction.getOpposite());
|
||||
}
|
||||
return rec != null;
|
||||
}
|
||||
@@ -199,7 +200,7 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
TileEntity test = world.getBlockTileEntity(te.xCoord + direction.offsetX, te.yCoord + direction.offsetY, te.zCoord + direction.offsetZ);
|
||||
if (test instanceof IConduitBundle) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (test instanceof IPowerReceptor) {
|
||||
return (IPowerReceptor) test;
|
||||
}
|
||||
@@ -208,7 +209,7 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
|
||||
@Override
|
||||
public ItemStack createItem() {
|
||||
return createItemStackForSubtype(subtype);
|
||||
return createItemStackForSubtype(subtype);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -227,7 +228,7 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
|
||||
@Override
|
||||
public Icon getTransmitionTextureForState(CollidableComponent component) {
|
||||
//return ICONS.get(ICON_TRANSMISSION_KEY);
|
||||
// return ICONS.get(ICON_TRANSMISSION_KEY);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,28 +6,23 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import crazypants.enderio.conduit.AbstractConduitNetwork;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import crazypants.enderio.conduit.AbstractConduitNetwork;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public class PowerConduitNetwork extends AbstractConduitNetwork<IPowerConduit> {
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
NetworkPowerManager powerManager;
|
||||
|
||||
|
||||
private Map<BlockCoord, ReceptorEntry> powerReceptors = new HashMap<BlockCoord, ReceptorEntry>();
|
||||
|
||||
|
||||
private long timeAtLastApply = -1;
|
||||
|
||||
public PowerConduitNetwork() {
|
||||
@@ -35,7 +30,7 @@ public class PowerConduitNetwork extends AbstractConduitNetwork<IPowerConduit> {
|
||||
|
||||
@Override
|
||||
public void init(IConduitBundle tile, Collection<IPowerConduit> connections, World world) {
|
||||
super.init(tile, connections, world);
|
||||
super.init(tile, connections, world);
|
||||
powerManager = new NetworkPowerManager(this, world);
|
||||
powerManager.receptorsChanged();
|
||||
}
|
||||
@@ -45,7 +40,7 @@ public class PowerConduitNetwork extends AbstractConduitNetwork<IPowerConduit> {
|
||||
for (IPowerConduit con : conduits) {
|
||||
con.setActive(false);
|
||||
}
|
||||
powerManager.onNetworkDestroyed();
|
||||
powerManager.onNetworkDestroyed();
|
||||
super.destroyNetwork();
|
||||
}
|
||||
|
||||
@@ -63,8 +58,8 @@ public class PowerConduitNetwork extends AbstractConduitNetwork<IPowerConduit> {
|
||||
TileEntity te = con.getBundle().getEntity();
|
||||
powerReceptorAdded(con, dir, te.xCoord + dir.offsetX, te.yCoord + dir.offsetY, te.zCoord + dir.offsetZ, pr);
|
||||
}
|
||||
}
|
||||
if(powerManager != null) {
|
||||
}
|
||||
if (powerManager != null) {
|
||||
con.setActive(powerManager.isActive());
|
||||
}
|
||||
}
|
||||
@@ -75,17 +70,17 @@ public class PowerConduitNetwork extends AbstractConduitNetwork<IPowerConduit> {
|
||||
}
|
||||
|
||||
public void powerReceptorAdded(IPowerConduit powerConduit, ForgeDirection direction, int x, int y, int z, IPowerReceptor powerReceptor) {
|
||||
if(powerReceptor == null) {
|
||||
if (powerReceptor == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
BlockCoord key = new BlockCoord(x, y, z);
|
||||
ReceptorEntry re = powerReceptors.get(key);
|
||||
if(re == null) {
|
||||
if (re == null) {
|
||||
re = new ReceptorEntry(powerReceptor, key, powerConduit);
|
||||
powerReceptors.put(key, re);
|
||||
}
|
||||
re.directions.add(direction);
|
||||
if(powerManager != null) {
|
||||
re.directions.add(direction);
|
||||
if (powerManager != null) {
|
||||
powerManager.receptorsChanged();
|
||||
}
|
||||
}
|
||||
@@ -98,39 +93,37 @@ public class PowerConduitNetwork extends AbstractConduitNetwork<IPowerConduit> {
|
||||
public Collection<ReceptorEntry> getPowerReceptors() {
|
||||
return powerReceptors.values();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onUpdateEntity(IConduit conduit) {
|
||||
World world = conduit.getBundle().getEntity().worldObj;
|
||||
if(world == null) {
|
||||
if (world == null) {
|
||||
return;
|
||||
}
|
||||
if(world.isRemote) {
|
||||
if (world.isRemote) {
|
||||
return;
|
||||
}
|
||||
long curTime = world.getTotalWorldTime();
|
||||
if(curTime != timeAtLastApply) {
|
||||
long curTime = world.getTotalWorldTime();
|
||||
if (curTime != timeAtLastApply) {
|
||||
timeAtLastApply = curTime;
|
||||
powerManager.applyRecievedPower();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class ReceptorEntry {
|
||||
|
||||
|
||||
IPowerConduit emmiter;
|
||||
IPowerReceptor powerReceptor;
|
||||
BlockCoord coord;
|
||||
//The different directions that we connect to the sucker
|
||||
// The different directions that we connect to the sucker
|
||||
Set<ForgeDirection> directions = new HashSet<ForgeDirection>();
|
||||
|
||||
public ReceptorEntry(IPowerReceptor powerReceptor, BlockCoord coord,IPowerConduit emmiter) {
|
||||
|
||||
public ReceptorEntry(IPowerReceptor powerReceptor, BlockCoord coord, IPowerConduit emmiter) {
|
||||
this.powerReceptor = powerReceptor;
|
||||
this.coord = coord;
|
||||
this.coord = coord;
|
||||
this.emmiter = emmiter;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -2,38 +2,35 @@ package crazypants.enderio.conduit.redstone;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
|
||||
public interface IRedstoneConduit extends IConduit {
|
||||
|
||||
public static final String KEY_CONDUIT_ICON ="enderio:redstoneConduit";
|
||||
public static final String KEY_TRANSMISSION_ICON ="enderio:redstoneConduitTransmission";
|
||||
public static final String KEY_CORE_OFF_ICON ="enderio:redstoneConduitCoreOff";
|
||||
public static final String KEY_CORE_ON_ICON ="enderio:redstoneConduitCoreOn";
|
||||
|
||||
public static final String KEY_CONDUIT_ICON = "enderio:redstoneConduit";
|
||||
public static final String KEY_TRANSMISSION_ICON = "enderio:redstoneConduitTransmission";
|
||||
public static final String KEY_CORE_OFF_ICON = "enderio:redstoneConduitCoreOff";
|
||||
public static final String KEY_CORE_ON_ICON = "enderio:redstoneConduitCoreOn";
|
||||
|
||||
enum SignalColor {
|
||||
RED
|
||||
}
|
||||
|
||||
//External redstone interface
|
||||
|
||||
int isProvidingStrongPower(ForgeDirection toDirection);
|
||||
|
||||
// External redstone interface
|
||||
|
||||
int isProvidingStrongPower(ForgeDirection toDirection);
|
||||
|
||||
int isProvidingWeakPower(ForgeDirection toDirection);
|
||||
|
||||
//signals
|
||||
|
||||
//--- Server Side Only
|
||||
// signals
|
||||
|
||||
// --- Server Side Only
|
||||
Set<Signal> getNetworkInputs();
|
||||
|
||||
|
||||
Set<Signal> getNetworkOutputs(ForgeDirection side);
|
||||
|
||||
//--- Set on server side, used on client side for rendering
|
||||
|
||||
|
||||
// --- Set on server side, used on client side for rendering
|
||||
|
||||
boolean isReplaceableByControl(Class<? extends IRedstoneConduit> replacenebtType);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
package crazypants.enderio.conduit.redstone;
|
||||
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.*;
|
||||
import crazypants.enderio.conduit.facade.ItemConduitFacade;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
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 ItemRedstoneConduit extends AbstractItemConduit {
|
||||
|
||||
private static ItemConduitSubtype[] subtypes = new ItemConduitSubtype[] {
|
||||
new ItemConduitSubtype(ModObject.itemRedstoneConduit.unlocalisedName, ModObject.itemRedstoneConduit.name, "enderio:itemRedstoneConduit"),
|
||||
new ItemConduitSubtype(ModObject.itemRedstoneConduit.unlocalisedName + "switch", "Conduit Switch", "enderio:itemRedstoneSwitch")
|
||||
|
||||
new ItemConduitSubtype(ModObject.itemRedstoneConduit.unlocalisedName, ModObject.itemRedstoneConduit.name, "enderio:itemRedstoneConduit"),
|
||||
new ItemConduitSubtype(ModObject.itemRedstoneConduit.unlocalisedName + "switch", "Conduit Switch", "enderio:itemRedstoneSwitch")
|
||||
|
||||
};
|
||||
|
||||
|
||||
public static ItemRedstoneConduit create() {
|
||||
ItemRedstoneConduit result = new ItemRedstoneConduit();
|
||||
result.init(subtypes);
|
||||
@@ -21,9 +21,9 @@ public class ItemRedstoneConduit extends AbstractItemConduit {
|
||||
}
|
||||
|
||||
protected ItemRedstoneConduit() {
|
||||
super(ModObject.itemRedstoneConduit);
|
||||
super(ModObject.itemRedstoneConduit);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<? extends IConduit> getBaseConduitType() {
|
||||
return IRedstoneConduit.class;
|
||||
@@ -31,7 +31,7 @@ public class ItemRedstoneConduit extends AbstractItemConduit {
|
||||
|
||||
@Override
|
||||
public IConduit createConduit(ItemStack stack) {
|
||||
if(stack.getItemDamage() == 1) {
|
||||
if (stack.getItemDamage() == 1) {
|
||||
return new RedstoneSwitch();
|
||||
} else {
|
||||
return new RedstoneConduit();
|
||||
|
||||
@@ -6,9 +6,15 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.AbstractConduit;
|
||||
@@ -18,28 +24,20 @@ import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.render.IconUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class RedstoneConduit extends AbstractConduit implements IRedstoneConduit {
|
||||
|
||||
static final Map<String, Icon> ICONS = new HashMap<String, Icon>();
|
||||
|
||||
static final Map<String, Icon> ICONS = new HashMap<String, Icon>();
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void initIcons() {
|
||||
IconUtil.addIconProvider(new IconUtil.IIconProvider() {
|
||||
IconUtil.addIconProvider(new IconUtil.IIconProvider() {
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister register) {
|
||||
ICONS.put(KEY_CORE_OFF_ICON, register.registerIcon(KEY_CORE_OFF_ICON));
|
||||
ICONS.put(KEY_CORE_ON_ICON, register.registerIcon(KEY_CORE_ON_ICON));
|
||||
ICONS.put(KEY_CONDUIT_ICON, register.registerIcon(KEY_CONDUIT_ICON));
|
||||
ICONS.put(KEY_TRANSMISSION_ICON, register.registerIcon(KEY_TRANSMISSION_ICON));
|
||||
ICONS.put(KEY_TRANSMISSION_ICON, register.registerIcon(KEY_TRANSMISSION_ICON));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,22 +47,22 @@ public class RedstoneConduit extends AbstractConduit implements IRedstoneConduit
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
protected RedstoneConduitNetwork network;
|
||||
|
||||
protected final Set<Signal> externalSignals = new HashSet<Signal>();
|
||||
|
||||
public RedstoneConduit() {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceableByControl(Class<? extends IRedstoneConduit> replacenebtType) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack createItem() {
|
||||
return new ItemStack(ModObject.itemRedstoneConduit.actualId,1,0);
|
||||
return new ItemStack(ModObject.itemRedstoneConduit.actualId, 1, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,7 +79,7 @@ public class RedstoneConduit extends AbstractConduit implements IRedstoneConduit
|
||||
public boolean setNetwork(AbstractConduitNetwork<?> network) {
|
||||
this.network = (RedstoneConduitNetwork) network;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectToExternal(ForgeDirection direction) {
|
||||
@@ -92,45 +90,47 @@ public class RedstoneConduit extends AbstractConduit implements IRedstoneConduit
|
||||
}
|
||||
int id = world.getBlockId(te.xCoord + direction.offsetX, te.yCoord + direction.offsetY, te.zCoord + direction.offsetZ);
|
||||
if (id > 0 && id != EnderIO.blockConduitBundle.blockID) {
|
||||
|
||||
//We can connect to a block if it can provide power or it is receiving a string signal (not emitted by us)
|
||||
|
||||
|
||||
// We can connect to a block if it can provide power or it is receiving a
|
||||
// string signal (not emitted by us)
|
||||
|
||||
BlockCoord loc = getLocation().getLocation(direction);
|
||||
|
||||
|
||||
boolean toggleNetwork = network != null && network.isNetworkEnabled();
|
||||
if(toggleNetwork ) {
|
||||
if (toggleNetwork) {
|
||||
network.setNetworkEnabled(false);
|
||||
}
|
||||
boolean gettingStrongPower = world.getBlockPowerInput(loc.x, loc.y, loc.z) == 15;
|
||||
if(toggleNetwork) {
|
||||
if (toggleNetwork) {
|
||||
network.setNetworkEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
//We can get an input from the block when:
|
||||
return
|
||||
Block.blocksList[id].canProvidePower() || //The block can provide power
|
||||
//Or its getting a strong signal that we are not providing
|
||||
|
||||
// We can get an input from the block when:
|
||||
return Block.blocksList[id].canProvidePower() || // The block can provide
|
||||
// power
|
||||
// Or its getting a strong signal that we are not providing
|
||||
gettingStrongPower;
|
||||
//( world.getBlockPowerInput(loc.x, loc.y, loc.z) == 15 && isProvidingStrongPower(direction) != 15 );
|
||||
// ( world.getBlockPowerInput(loc.x, loc.y, loc.z) == 15 &&
|
||||
// isProvidingStrongPower(direction) != 15 );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Signal> getNetworkInputs() {
|
||||
public Set<Signal> getNetworkInputs() {
|
||||
Set<Signal> res = new HashSet<Signal>();
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (canConnectToExternal(dir)) {
|
||||
int input = getExternalPowerLevel(dir);
|
||||
if (input > 1) { //need to degrade external signals by one as they enter
|
||||
if (input > 1) { // need to degrade external signals by one as they
|
||||
// enter
|
||||
BlockCoord loc = getLocation().getLocation(dir);
|
||||
Signal signal = new Signal(loc.x, loc.y, loc.z, input - 1, SignalColor.RED);
|
||||
res.add(signal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,7 +140,7 @@ public class RedstoneConduit extends AbstractConduit implements IRedstoneConduit
|
||||
}
|
||||
return network.getSignals();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onNeighborBlockChange(int blockId) {
|
||||
World world = getBundle().getEntity().worldObj;
|
||||
@@ -151,14 +151,14 @@ public class RedstoneConduit extends AbstractConduit implements IRedstoneConduit
|
||||
return false;
|
||||
}
|
||||
boolean res = super.onNeighborBlockChange(blockId);
|
||||
|
||||
if (network == null || network.updatingNetwork) {
|
||||
|
||||
if (network == null || network.updatingNetwork) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(blockId > 0 && Block.blocksList[blockId].canProvidePower() && network != null) {
|
||||
//TODO: Just recalculate the signals, no need for a full rebuild
|
||||
network.destroyNetwork();
|
||||
}
|
||||
|
||||
if (blockId > 0 && Block.blocksList[blockId].canProvidePower() && network != null) {
|
||||
// TODO: Just recalculate the signals, no need for a full rebuild
|
||||
network.destroyNetwork();
|
||||
return false;
|
||||
}
|
||||
return res;
|
||||
@@ -167,11 +167,11 @@ public class RedstoneConduit extends AbstractConduit implements IRedstoneConduit
|
||||
private int getExternalPowerLevel(ForgeDirection dir) {
|
||||
if (network != null) {
|
||||
network.setNetworkEnabled(false);
|
||||
}
|
||||
}
|
||||
World world = getBundle().getEntity().worldObj;
|
||||
BlockCoord loc = getLocation();
|
||||
int result = world.getStrongestIndirectPower(loc.x, loc.y, loc.z);
|
||||
|
||||
BlockCoord loc = getLocation();
|
||||
int result = world.getStrongestIndirectPower(loc.x, loc.y, loc.z);
|
||||
|
||||
if (network != null) {
|
||||
network.setNetworkEnabled(true);
|
||||
}
|
||||
@@ -201,18 +201,18 @@ public class RedstoneConduit extends AbstractConduit implements IRedstoneConduit
|
||||
if (component.dir == ForgeDirection.UNKNOWN) {
|
||||
return isActive() ? ICONS.get(KEY_CORE_ON_ICON) : ICONS.get(KEY_CORE_OFF_ICON);
|
||||
}
|
||||
//return ICONS.get(KEY_CONDUIT_ICON);
|
||||
// return ICONS.get(KEY_CONDUIT_ICON);
|
||||
return isActive() ? ICONS.get(KEY_TRANSMISSION_ICON) : ICONS.get(KEY_CONDUIT_ICON);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getTransmitionTextureForState(CollidableComponent component) {
|
||||
// if (component.id == ForgeDirection.UNKNOWN) {
|
||||
// return null;
|
||||
// }
|
||||
// return isActive() ? ICONS.get(KEY_TRANSMISSION_ICON) : null;
|
||||
// if (component.id == ForgeDirection.UNKNOWN) {
|
||||
// return null;
|
||||
// }
|
||||
// return isActive() ? ICONS.get(KEY_TRANSMISSION_ICON) : null;
|
||||
return null;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,20 +7,19 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import crazypants.enderio.conduit.AbstractConduitNetwork;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import crazypants.enderio.conduit.AbstractConduitNetwork;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
|
||||
public class RedstoneConduitNetwork extends AbstractConduitNetwork<IRedstoneConduit> {
|
||||
|
||||
private final Set<Signal> signals = new HashSet<Signal>();
|
||||
|
||||
boolean updatingNetwork = false;
|
||||
|
||||
|
||||
private boolean networkEnabled = true;
|
||||
|
||||
|
||||
public RedstoneConduitNetwork() {
|
||||
}
|
||||
|
||||
@@ -43,58 +42,59 @@ public class RedstoneConduitNetwork extends AbstractConduitNetwork<IRedstoneCond
|
||||
for (IRedstoneConduit con : conduits) {
|
||||
con.setActive(false);
|
||||
}
|
||||
//Notify neighbours that all signals have been lost
|
||||
List<Signal> copy = new ArrayList<Signal>(signals);
|
||||
// Notify neighbours that all signals have been lost
|
||||
List<Signal> copy = new ArrayList<Signal>(signals);
|
||||
signals.clear();
|
||||
for(Signal s : copy) {
|
||||
for (Signal s : copy) {
|
||||
notifyNeigborsOfSignalUpdate(s);
|
||||
}
|
||||
}
|
||||
updatingNetwork = false;
|
||||
super.destroyNetwork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addConduit(IRedstoneConduit con) {
|
||||
public void addConduit(IRedstoneConduit con) {
|
||||
updatingNetwork = true;
|
||||
super.addConduit(con);
|
||||
Set<Signal> newInputs = con.getNetworkInputs();
|
||||
signals.addAll(newInputs);
|
||||
//Notify existing nodes of new signals
|
||||
for (Signal signal : newInputs) {
|
||||
// Notify existing nodes of new signals
|
||||
for (Signal signal : newInputs) {
|
||||
notifyNeigborsOfSignalUpdate(signal);
|
||||
}
|
||||
//and new nodes neighbours of all signals
|
||||
for (Signal signal : signals) {
|
||||
// and new nodes neighbours of all signals
|
||||
for (Signal signal : signals) {
|
||||
notifyConduitNeighbours(con, signal);
|
||||
}
|
||||
}
|
||||
updatingNetwork = false;
|
||||
}
|
||||
|
||||
public Set<Signal> getSignals() {
|
||||
if(networkEnabled) {
|
||||
if (networkEnabled) {
|
||||
return signals;
|
||||
} else {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
}
|
||||
|
||||
//Need to disable the network when determining the strength of external signals
|
||||
//to avoid feed back looops
|
||||
|
||||
// Need to disable the network when determining the strength of external
|
||||
// signals
|
||||
// to avoid feed back looops
|
||||
void setNetworkEnabled(boolean enabled) {
|
||||
networkEnabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isNetworkEnabled() {
|
||||
return networkEnabled;
|
||||
}
|
||||
|
||||
public void addSignal(Signal signal) {
|
||||
public void addSignal(Signal signal) {
|
||||
updatingNetwork = true;
|
||||
signals.add(signal);
|
||||
notifyNetworkOfUpdate();
|
||||
notifyNeigborsOfSignalUpdate(signal);
|
||||
updatingNetwork = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void removeSignal(Signal signal) {
|
||||
@@ -104,7 +104,7 @@ public class RedstoneConduitNetwork extends AbstractConduitNetwork<IRedstoneCond
|
||||
notifyNeigborsOfSignalUpdate(signal);
|
||||
updatingNetwork = false;
|
||||
}
|
||||
|
||||
|
||||
public void replaceSignal(Signal oldSig, Signal newSig) {
|
||||
updatingNetwork = true;
|
||||
signals.remove(oldSig);
|
||||
@@ -148,9 +148,9 @@ public class RedstoneConduitNetwork extends AbstractConduitNetwork<IRedstoneCond
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
private void notifyNeigborsOfSignals() {
|
||||
for(Signal signal : signals) {
|
||||
for (Signal signal : signals) {
|
||||
notifyNeigborsOfSignalUpdate(signal);
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ public class RedstoneConduitNetwork extends AbstractConduitNetwork<IRedstoneCond
|
||||
notifyConduitNeighbours(con, signal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void notifyConduitNeighbours(IRedstoneConduit con, Signal signal) {
|
||||
if (con.getBundle() == null) {
|
||||
System.out.println("RedstoneConduitNetwork.notifyNeigborsOfSignalUpdate: NULL BUNDLE!!!!");
|
||||
|
||||
@@ -3,6 +3,13 @@ package crazypants.enderio.conduit.redstone;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.RaytraceResult;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
@@ -13,14 +20,6 @@ import crazypants.render.IconUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class RedstoneSwitch extends RedstoneConduit {
|
||||
|
||||
static final String SWITCH_TAG = "switch";
|
||||
@@ -53,7 +52,7 @@ public class RedstoneSwitch extends RedstoneConduit {
|
||||
|
||||
@Override
|
||||
public ItemStack createItem() {
|
||||
return new ItemStack(ModObject.itemRedstoneConduit.actualId,1,1);
|
||||
return new ItemStack(ModObject.itemRedstoneConduit.actualId, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,16 +87,15 @@ public class RedstoneSwitch extends RedstoneConduit {
|
||||
return super.getTextureForState(component);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<CollidableComponent> getCollidableComponents() {
|
||||
if (collidables != null && !collidablesDirty) {
|
||||
return collidables;
|
||||
}
|
||||
|
||||
|
||||
Offset o = getBundle().getOffset(getBaseConduitType(), ForgeDirection.UNKNOWN);
|
||||
Vector3d trans = ConduitGeometryUtil.instance.getTranslation(ForgeDirection.UNKNOWN, o);
|
||||
|
||||
|
||||
List<CollidableComponent> result = super.getCollidableComponents();
|
||||
BoundingBox[] aabb = RedstoneSwitchRenderer.instance.getAABB();
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package crazypants.enderio.conduit.redstone;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
@@ -12,101 +15,96 @@ import crazypants.render.CubeRenderer;
|
||||
import crazypants.render.VertexRotation;
|
||||
import crazypants.render.VertexTransform;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class RedstoneSwitchRenderer extends DefaultConduitRenderer {
|
||||
|
||||
public static RedstoneSwitchRenderer instance = new RedstoneSwitchRenderer();
|
||||
|
||||
|
||||
private static final float SIZE = 0.2f;
|
||||
private static final float HW = SIZE/3;
|
||||
private static final float HH = SIZE/2;
|
||||
private static final float HW = SIZE / 3;
|
||||
private static final float HH = SIZE / 2;
|
||||
private static final float DEPTH = 0.05f;
|
||||
private static final float HD = DEPTH/2;
|
||||
|
||||
private static final float HD = DEPTH / 2;
|
||||
|
||||
private static final float DIST = 0.25f;
|
||||
|
||||
|
||||
private static final float CON_HW = 0.015f;
|
||||
|
||||
|
||||
|
||||
private final VertexTransform[] xForms;
|
||||
private final BoundingBox switchBounds;
|
||||
private final BoundingBox switchBounds;
|
||||
private final BoundingBox connectorBounds;
|
||||
|
||||
|
||||
private final BoundingBox[] aabb;
|
||||
|
||||
|
||||
private RedstoneSwitchRenderer() {
|
||||
BoundingBox bb = new BoundingBox(0.5- HW, 0.5- HH, 0.5- HD, 0.5+ HW, 0.5+ HH, 0.5 + HD);
|
||||
switchBounds = bb.translate(0, 0, DIST);
|
||||
|
||||
connectorBounds = new BoundingBox(0.5- CON_HW, 0.5- CON_HW, 0.5- CON_HW, 0.5+ CON_HW, 0.5+ CON_HW, 0.5 + DIST);
|
||||
|
||||
Vector3d axis = new Vector3d(0,1,0);
|
||||
Vector3d p = new Vector3d(0.5,0.5,0.5);
|
||||
BoundingBox bb = new BoundingBox(0.5 - HW, 0.5 - HH, 0.5 - HD, 0.5 + HW, 0.5 + HH, 0.5 + HD);
|
||||
switchBounds = bb.translate(0, 0, DIST);
|
||||
|
||||
connectorBounds = new BoundingBox(0.5 - CON_HW, 0.5 - CON_HW, 0.5 - CON_HW, 0.5 + CON_HW, 0.5 + CON_HW, 0.5 + DIST);
|
||||
|
||||
Vector3d axis = new Vector3d(0, 1, 0);
|
||||
Vector3d p = new Vector3d(0.5, 0.5, 0.5);
|
||||
xForms = new VertexTransform[4];
|
||||
double angle = Math.toRadians(45);
|
||||
for(int i=0; i < xForms.length; i++) {
|
||||
//TODO
|
||||
//xForms[i] = new Rotation(angle, axis, p);
|
||||
for (int i = 0; i < xForms.length; i++) {
|
||||
// TODO
|
||||
// xForms[i] = new Rotation(angle, axis, p);
|
||||
xForms[i] = new VertexRotation(angle, axis, p);
|
||||
angle += Math.toRadians(90);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
aabb = new BoundingBox[xForms.length];
|
||||
for(int i=0; i < xForms.length; i++) {
|
||||
for (int i = 0; i < xForms.length; i++) {
|
||||
aabb[i] = switchBounds.transform(xForms[i]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public BoundingBox[] getAABB() {
|
||||
return aabb;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isRendererForConduit(IConduit conduit) {
|
||||
return conduit.getClass() == RedstoneSwitch.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderEntity(ConduitBundleRenderer conduitBundleRenderer, IConduitBundle bundle, IConduit conduit, double x, double y, double z, float partialTick,
|
||||
public void renderEntity(ConduitBundleRenderer conduitBundleRenderer, IConduitBundle bundle, IConduit conduit, double x, double y, double z,
|
||||
float partialTick,
|
||||
float worldLight) {
|
||||
|
||||
|
||||
super.renderEntity(conduitBundleRenderer, bundle, conduit, x, y, z, partialTick, worldLight);
|
||||
|
||||
RedstoneSwitch sw = (RedstoneSwitch)conduit;
|
||||
|
||||
|
||||
RedstoneSwitch sw = (RedstoneSwitch) conduit;
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
float selfIllum = Math.max(worldLight, conduit.getSelfIlluminationForState(null));
|
||||
tessellator.setColorOpaque_F(selfIllum, selfIllum, selfIllum);
|
||||
|
||||
|
||||
Icon[] icons = new Icon[6];
|
||||
for(int i=0;i<icons.length;i++) {
|
||||
for (int i = 0; i < icons.length; i++) {
|
||||
icons[i] = EnderIO.blockConduitBundle.getConnectorIcon();
|
||||
}
|
||||
icons[1] = sw.getSwitchIcon();;
|
||||
|
||||
|
||||
icons[1] = sw.getSwitchIcon();
|
||||
;
|
||||
|
||||
Vector3d trans = ConduitGeometryUtil.instance.getTranslation(ForgeDirection.UNKNOWN, bundle.getOffset(IRedstoneConduit.class, ForgeDirection.UNKNOWN));
|
||||
BoundingBox bb = switchBounds.translate(trans);
|
||||
|
||||
for(VertexTransform tf : xForms) {
|
||||
|
||||
for (VertexTransform tf : xForms) {
|
||||
CubeRenderer.render(bb, icons, tf);
|
||||
}
|
||||
}
|
||||
bb = connectorBounds.translate(trans);
|
||||
for(VertexTransform tf : xForms) {
|
||||
for (VertexTransform tf : xForms) {
|
||||
CubeRenderer.render(bb, icons[0], tf);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean renderComponent(CollidableComponent component) {
|
||||
return !RedstoneSwitch.SWITCH_TAG.equals(component.data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -3,10 +3,8 @@ package crazypants.enderio.conduit.redstone;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import crazypants.enderio.conduit.redstone.IRedstoneConduit.SignalColor;
|
||||
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.conduit.redstone.IRedstoneConduit.SignalColor;
|
||||
|
||||
public class SignalSource {
|
||||
|
||||
@@ -72,12 +70,12 @@ public class SignalSource {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static Set<SignalSource> fromIntArray(int[] enc) {
|
||||
Set<SignalSource> result = new HashSet<SignalSource>();
|
||||
for(int i=0; i < enc.length; i+=5) {
|
||||
Signal sig = new Signal(enc[i], enc[i+1], enc[i+2], enc[i+3], SignalColor.values()[enc[i+4]]);
|
||||
result.add(new SignalSource(sig, ForgeDirection.values()[enc[i+4]]));
|
||||
Set<SignalSource> result = new HashSet<SignalSource>();
|
||||
for (int i = 0; i < enc.length; i += 5) {
|
||||
Signal sig = new Signal(enc[i], enc[i + 1], enc[i + 2], enc[i + 3], SignalColor.values()[enc[i + 4]]);
|
||||
result.add(new SignalSource(sig, ForgeDirection.values()[enc[i + 4]]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -58,21 +58,20 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements
|
||||
float val = RenderUtil.claculateTotalBrightnessForLocation(te.worldObj, te.xCoord, te.yCoord, te.zCoord);
|
||||
renderTileEntityAt(bundle, x, y, z, partialTick, val);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void renderTileEntityAt(IConduitBundle bundle, double x, double y, double z, float partialTick, float brightness) {
|
||||
|
||||
|
||||
RenderUtil.bindBlockTexture();
|
||||
Minecraft.getMinecraft().entityRenderer.disableLightmap(0);
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
|
||||
//GL11.glPushAttrib(GL11.GL_POLYGON_BIT);
|
||||
// GL11.glPushAttrib(GL11.GL_POLYGON_BIT);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
//GL11.glDisable (GL11.GL_CULL_FACE);
|
||||
// GL11.glDisable (GL11.GL_CULL_FACE);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x, y, z);
|
||||
@@ -111,7 +110,7 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopAttrib();
|
||||
//GL11.glPopAttrib();
|
||||
// GL11.glPopAttrib();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ public interface ConduitRenderer {
|
||||
|
||||
boolean isRendererForConduit(IConduit conduit);
|
||||
|
||||
void renderEntity(ConduitBundleRenderer conduitBundleRenderer, IConduitBundle te, IConduit con, double x, double y, double z, float partialTick, float worldLight);
|
||||
void renderEntity(ConduitBundleRenderer conduitBundleRenderer, IConduitBundle te, IConduit con, double x, double y, double z, float partialTick,
|
||||
float worldLight);
|
||||
|
||||
}
|
||||
@@ -1,17 +1,24 @@
|
||||
package crazypants.enderio.conduit.render;
|
||||
|
||||
import static crazypants.render.CubeRenderer.*;
|
||||
import static net.minecraftforge.common.ForgeDirection.*;
|
||||
import static crazypants.render.CubeRenderer.addVecWithUV;
|
||||
import static crazypants.render.CubeRenderer.setupVertices;
|
||||
import static crazypants.render.CubeRenderer.verts;
|
||||
import static net.minecraftforge.common.ForgeDirection.DOWN;
|
||||
import static net.minecraftforge.common.ForgeDirection.EAST;
|
||||
import static net.minecraftforge.common.ForgeDirection.NORTH;
|
||||
import static net.minecraftforge.common.ForgeDirection.SOUTH;
|
||||
import static net.minecraftforge.common.ForgeDirection.UP;
|
||||
import static net.minecraftforge.common.ForgeDirection.WEST;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import crazypants.enderio.conduit.*;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.render.BoundingBox;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.render.BoundingBox;
|
||||
|
||||
public class DefaultConduitRenderer implements ConduitRenderer {
|
||||
|
||||
@@ -115,9 +122,10 @@ public class DefaultConduitRenderer implements ConduitRenderer {
|
||||
setVerticesForTransmission(bound, dir);
|
||||
}
|
||||
|
||||
if (dir == NORTH || dir == UP || dir == EAST) { // maintain consistent texture
|
||||
// dir relative to the cneter
|
||||
// of the conduit
|
||||
if (dir == NORTH || dir == UP || dir == EAST) { // maintain consistent
|
||||
// texture
|
||||
// dir relative to the cneter
|
||||
// of the conduit
|
||||
float tmp = minU;
|
||||
minU = maxU;
|
||||
maxU = tmp;
|
||||
|
||||
@@ -10,17 +10,14 @@ import org.lwjgl.opengl.GL11;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.CubeRenderer;
|
||||
|
||||
|
||||
public class ItemConduitRenderer implements IItemRenderer {
|
||||
|
||||
private final BoundingBox bb;
|
||||
|
||||
public ItemConduitRenderer() {
|
||||
private final BoundingBox bb;
|
||||
|
||||
public ItemConduitRenderer() {
|
||||
float scale = 0.8f;
|
||||
bb = BoundingBox.UNIT_CUBE.scale(scale,scale,scale);
|
||||
bb = BoundingBox.UNIT_CUBE.scale(scale, scale, scale);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
@@ -35,9 +32,9 @@ public class ItemConduitRenderer implements IItemRenderer {
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
RenderBlocks renderBlocks = (RenderBlocks) data[0];
|
||||
if (type == ItemRenderType.INVENTORY) {
|
||||
if (type == ItemRenderType.INVENTORY) {
|
||||
renderToInventory(item, renderBlocks);
|
||||
} else if (type == ItemRenderType.EQUIPPED) {
|
||||
} else if (type == ItemRenderType.EQUIPPED) {
|
||||
renderEquipped(item, renderBlocks);
|
||||
} else if (type == ItemRenderType.ENTITY) {
|
||||
renderEntity(item, renderBlocks);
|
||||
@@ -47,7 +44,7 @@ public class ItemConduitRenderer implements IItemRenderer {
|
||||
System.out.println("FacadeRenderer.renderItem: Unsupported render type");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void renderEntity(ItemStack item, RenderBlocks renderBlocks) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(0.5f, 0.5f, 0.5f);
|
||||
@@ -56,13 +53,13 @@ public class ItemConduitRenderer implements IItemRenderer {
|
||||
}
|
||||
|
||||
private void renderEquipped(ItemStack item, RenderBlocks renderBlocks) {
|
||||
renderToInventory(item, renderBlocks);
|
||||
renderToInventory(item, renderBlocks);
|
||||
}
|
||||
|
||||
private void renderToInventory(ItemStack item, RenderBlocks renderBlocks) {
|
||||
Tessellator.instance.startDrawingQuads();
|
||||
CubeRenderer.render(bb, item.getItem().getIconFromDamage(item.getItemDamage()));
|
||||
Tessellator.instance.draw();
|
||||
Tessellator.instance.draw();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,30 +3,26 @@ package crazypants.enderio.conduit.render;
|
||||
import static crazypants.util.ForgeDirectionOffsets.offsetScaled;
|
||||
import static net.minecraftforge.common.ForgeDirection.SOUTH;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.conduit.geom.ConduitGeometryUtil;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.util.ForgeDirectionOffsets;
|
||||
import crazypants.vecmath.Matrix4d;
|
||||
import crazypants.vecmath.Vector2d;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
import crazypants.vecmath.Vector3f;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class RoundedSegmentRenderer {
|
||||
|
||||
private static Coord[][] DIR_COORDS = new Coord[ForgeDirection.VALID_DIRECTIONS.length][];
|
||||
|
||||
private static final Vector3d REF_TRANS = new Vector3d(0.5, 0.5, 0.5);
|
||||
|
||||
private static final Vector3d REF_TRANS = new Vector3d(0.5, 0.5, 0.5);
|
||||
|
||||
static {
|
||||
double circ = ConduitGeometryUtil.WIDTH * 0.7;
|
||||
|
||||
|
||||
Coord[] refCoords = createUnitSectionQuads(16, -0.25, 0.25);
|
||||
|
||||
for (Coord coord : refCoords) {
|
||||
@@ -34,34 +30,33 @@ public class RoundedSegmentRenderer {
|
||||
coord.xyz.y = coord.xyz.y * circ;
|
||||
}
|
||||
Matrix4d rotMat = new Matrix4d();
|
||||
rotMat.setIdentity();
|
||||
rotMat.setIdentity();
|
||||
rotMat.setTranslation(REF_TRANS);
|
||||
|
||||
DIR_COORDS[SOUTH.ordinal()] = xformCoords(refCoords, rotMat, offsetScaled(ForgeDirection.SOUTH, 0.25));
|
||||
|
||||
rotMat.makeRotationY(Math.PI);
|
||||
rotMat.makeRotationY(Math.PI);
|
||||
rotMat.setTranslation(REF_TRANS);
|
||||
DIR_COORDS[ForgeDirection.NORTH.ordinal()] = xformCoords(refCoords, rotMat, offsetScaled(ForgeDirection.NORTH, 0.25));
|
||||
|
||||
rotMat.makeRotationY(Math.PI / 2);
|
||||
rotMat.setTranslation(REF_TRANS);
|
||||
DIR_COORDS[ForgeDirection.EAST.ordinal()] = xformCoords(refCoords, rotMat, offsetScaled(ForgeDirection.EAST, 0.25));
|
||||
|
||||
|
||||
rotMat.makeRotationY(-Math.PI / 2);
|
||||
rotMat.setTranslation(REF_TRANS);
|
||||
DIR_COORDS[ForgeDirection.WEST.ordinal()] = xformCoords(refCoords, rotMat, offsetScaled(ForgeDirection.WEST, 0.25));
|
||||
|
||||
|
||||
rotMat.makeRotationX(-Math.PI / 2);
|
||||
rotMat.setTranslation(REF_TRANS);
|
||||
DIR_COORDS[ForgeDirection.UP.ordinal()] = xformCoords(refCoords, rotMat, offsetScaled(ForgeDirection.UP, 0.25));
|
||||
|
||||
|
||||
rotMat.makeRotationX(Math.PI / 2);
|
||||
rotMat.setTranslation(REF_TRANS);
|
||||
DIR_COORDS[ForgeDirection.DOWN.ordinal()] = xformCoords(refCoords, rotMat, offsetScaled(ForgeDirection.DOWN, 0.25));
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static Coord[] xformCoords(Coord[] refCoords, Matrix4d rotMat, Vector3d trans) {
|
||||
Coord[] res = new Coord[refCoords.length];
|
||||
for (int i = 0; i < res.length; i++) {
|
||||
@@ -72,7 +67,7 @@ public class RoundedSegmentRenderer {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private static Coord[] xformCoords(List<Coord> refCoords, Matrix4d rotMat, Vector3d trans) {
|
||||
Coord[] res = new Coord[refCoords.size()];
|
||||
for (int i = 0; i < res.length; i++) {
|
||||
@@ -106,9 +101,9 @@ public class RoundedSegmentRenderer {
|
||||
public static void renderSegment(ForgeDirection dir, BoundingBox bounds, float minU, float maxU, float minV, float maxV) {
|
||||
float uScale = maxU - minU;
|
||||
float vScale = maxV - minV;
|
||||
|
||||
|
||||
Vector3d offset = calcOffset(dir, bounds);
|
||||
|
||||
|
||||
Tessellator tes = Tessellator.instance;
|
||||
Coord[] coords = DIR_COORDS[dir.ordinal()];
|
||||
for (Coord coord : coords) {
|
||||
@@ -119,14 +114,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);
|
||||
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);
|
||||
res.set(center.x - REF_TRANS.x, 0, 0);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -170,9 +164,9 @@ public class RoundedSegmentRenderer {
|
||||
void setUV(double u, double v) {
|
||||
uv.set(u, v);
|
||||
}
|
||||
|
||||
|
||||
void setNormal(double x, double y, double z) {
|
||||
normal.set((float)x,(float)y,(float)z);
|
||||
normal.set((float) x, (float) y, (float) z);
|
||||
normal.normalize();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -40,7 +39,7 @@ public class BlockEnderIO extends Block implements ITileEntityProvider {
|
||||
private void init() {
|
||||
LanguageRegistry.addName(this, ModObject.blockEnderIo.name);
|
||||
GameRegistry.registerBlock(this, ModObject.blockEnderIo.unlocalisedName);
|
||||
GameRegistry.registerTileEntity(TileEnderIO.class, ModObject.blockEnderIo.unlocalisedName + "TileEntity");
|
||||
GameRegistry.registerTileEntity(TileEnderIO.class, ModObject.blockEnderIo.unlocalisedName + "TileEntity");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,7 +63,7 @@ public class BlockEnderIO extends Block implements ITileEntityProvider {
|
||||
entityPlayer.setCurrentItemOrArmor(0, enderFaceStack);
|
||||
|
||||
if (world.isRemote) {
|
||||
ChatMessageComponent c = ChatMessageComponent.func_111066_d("EnderIO Interface Selected");
|
||||
ChatMessageComponent c = ChatMessageComponent.func_111066_d("EnderIO Interface Selected");
|
||||
entityPlayer.sendChatToPlayer(c);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package crazypants.enderio.enderface;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerWrapper extends net.minecraft.inventory.Container {
|
||||
|
||||
@@ -14,7 +12,7 @@ public class ContainerWrapper extends net.minecraft.inventory.Container {
|
||||
this.inventorySlots = wrapped.inventorySlots;
|
||||
this.windowId = wrapped.windowId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canDragIntoSlot(Slot par1Slot) {
|
||||
return wrapped.canDragIntoSlot(par1Slot);
|
||||
|
||||
@@ -20,7 +20,6 @@ import crazypants.vecmath.Matrix4d;
|
||||
import crazypants.vecmath.VecmathUtil;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
|
||||
|
||||
public class EnderIoRenderer extends TileEntitySpecialRenderer implements IItemRenderer {
|
||||
|
||||
@Override
|
||||
@@ -38,7 +37,6 @@ public class EnderIoRenderer extends TileEntitySpecialRenderer implements IItemR
|
||||
}
|
||||
|
||||
public void render(double x, double y, double z, Matrix4d lookMat, int brightness) {
|
||||
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
||||
@@ -63,23 +61,23 @@ public class EnderIoRenderer extends TileEntitySpecialRenderer implements IItemR
|
||||
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
|
||||
float blendFactor = 1F;
|
||||
GL11.glColor4f(0.5F * blendFactor, 0.25F * blendFactor, 0.8F * blendFactor, 1.0F);
|
||||
|
||||
|
||||
GL11.glMatrixMode(GL11.GL_TEXTURE);
|
||||
GL11.glPushMatrix();
|
||||
float scale = 0.125F;
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
float tans = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F;
|
||||
GL11.glTranslatef(tans, 0.0F, 0.0F);
|
||||
GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
|
||||
renderBillboard(lookMat, 0, maxUV, 0, maxUV, 0.8, brightness);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
tans = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F;
|
||||
tans = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F;
|
||||
GL11.glTranslatef(-tans, 0.0F, 0.0F);
|
||||
GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
|
||||
renderBillboard(lookMat, 0, maxUV, 0, maxUV, 0.8,brightness);
|
||||
renderBillboard(lookMat, 0, maxUV, 0, maxUV, 0.8, brightness);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
@@ -87,19 +85,16 @@ public class EnderIoRenderer extends TileEntitySpecialRenderer implements IItemR
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
|
||||
|
||||
|
||||
GL11.glColor4f(1, 1, 1, 1.0F);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x, y, z);
|
||||
|
||||
|
||||
RenderUtil.bindBlockTexture();
|
||||
Tessellator.instance.startDrawingQuads();
|
||||
Tessellator.instance.setBrightness(brightness);
|
||||
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
CubeRenderer.render(BoundingBox.UNIT_CUBE, EnderIO.blockEnderIo.frameIcon);
|
||||
@@ -115,7 +110,7 @@ public class EnderIoRenderer extends TileEntitySpecialRenderer implements IItemR
|
||||
Tessellator tes = Tessellator.instance;
|
||||
tes.startDrawingQuads();
|
||||
tes.setBrightness(brightness);
|
||||
|
||||
|
||||
double s = size / 2;
|
||||
Vector3d v = new Vector3d();
|
||||
v.set(-s, s, 0);
|
||||
|
||||
@@ -7,10 +7,11 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import crazypants.enderio.EnderIO;
|
||||
|
||||
public class EnderfaceRecipes {
|
||||
|
||||
|
||||
public static void addRecipes() {
|
||||
GameRegistry.addRecipe(new ItemStack(EnderIO.itemEnderface), " x ", "xyx", " x ", 'x', new ItemStack(Item.diamond), 'y', new ItemStack(Item.eyeOfEnder));
|
||||
GameRegistry.addRecipe(new ItemStack(EnderIO.blockEnderIo), "zxz", "xyx", "zxz", 'x', new ItemStack(Item.eyeOfEnder), 'y', new ItemStack(Block.enderChest), 'z',
|
||||
GameRegistry.addRecipe(new ItemStack(EnderIO.blockEnderIo), "zxz", "xyx", "zxz", 'x', new ItemStack(Item.eyeOfEnder), 'y', new ItemStack(Block.enderChest),
|
||||
'z',
|
||||
new ItemStack(Item.diamond));
|
||||
}
|
||||
|
||||
|
||||
@@ -157,8 +157,8 @@ public class GuiEnderface extends GuiScreen {
|
||||
|
||||
long elapsed = world.getTotalWorldTime() - initTime;
|
||||
|
||||
if (Mouse.getEventButton() == 1 && !Mouse.getEventButtonState() && camera.isValid() && elapsed > 10) {
|
||||
|
||||
if (Mouse.getEventButton() == 1 && !Mouse.getEventButtonState() && camera.isValid() && elapsed > 10) {
|
||||
|
||||
int x = Mouse.getEventX();
|
||||
int y = Mouse.getEventY();
|
||||
Vector3d start = new Vector3d();
|
||||
@@ -237,7 +237,7 @@ public class GuiEnderface extends GuiScreen {
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
mc.entityRenderer.enableLightmap(0);
|
||||
RenderUtil.bindBlockTexture();
|
||||
RenderUtil.bindBlockTexture();
|
||||
|
||||
Vector3d trans = new Vector3d((-origin.x) + eye.x, (-origin.y) + eye.y, (-origin.z) + eye.z);
|
||||
Tessellator.instance.startDrawingQuads();
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ItemEnderface extends Item implements IGuiHandler {
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
LanguageRegistry.addName(this, ModObject.itemEnderface.name);
|
||||
LanguageRegistry.addName(this, ModObject.itemEnderface.name);
|
||||
GameRegistry.registerItem(this, ModObject.itemEnderface.unlocalisedName);
|
||||
EnderIO.guiHandler.registerGuiHandler(GuiHandler.GUI_ID_ENDERFACE, this);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class ItemEnderface extends Item implements IGuiHandler {
|
||||
public boolean hasEffect(ItemStack par1ItemStack, int pass) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreated(ItemStack itemStack, World world, EntityPlayer entityPlayer) {
|
||||
super.onCreated(itemStack, world, entityPlayer);
|
||||
@@ -61,7 +61,7 @@ public class ItemEnderface extends Item implements IGuiHandler {
|
||||
nbttagcompound.setInteger(KEY_IO_X, -1);
|
||||
nbttagcompound.setInteger(KEY_IO_Y, -1);
|
||||
nbttagcompound.setInteger(KEY_IO_Z, -1);
|
||||
nbttagcompound.setInteger(KEY_DIMENSION, -1);
|
||||
nbttagcompound.setInteger(KEY_DIMENSION, -1);
|
||||
itemStack.setTagCompound(nbttagcompound);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class ItemEnderface extends Item implements IGuiHandler {
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStack, World world, final EntityPlayer entityPlayer) {
|
||||
|
||||
|
||||
if (!world.isRemote) {
|
||||
return itemStack;
|
||||
}
|
||||
@@ -91,15 +91,15 @@ public class ItemEnderface extends Item implements IGuiHandler {
|
||||
int y = tag.getInteger(KEY_IO_Y);
|
||||
int z = tag.getInteger(KEY_IO_Z);
|
||||
int dimension = tag.getInteger(KEY_DIMENSION);
|
||||
|
||||
if(world.provider.dimensionId != dimension) {
|
||||
|
||||
if (world.provider.dimensionId != dimension) {
|
||||
ChatMessageComponent c = ChatMessageComponent.func_111066_d("EnderIO block is in a different dimension.");
|
||||
entityPlayer.sendChatToPlayer(c);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
|
||||
Chunk c = world.getChunkFromBlockCoords(x, z);
|
||||
if(c == null || !c.isChunkLoaded) {
|
||||
if (c == null || !c.isChunkLoaded) {
|
||||
ChatMessageComponent cm = ChatMessageComponent.func_111066_d("EnderIO block's chunk is not loaded.");
|
||||
entityPlayer.sendChatToPlayer(cm);
|
||||
return itemStack;
|
||||
|
||||
@@ -14,7 +14,7 @@ public abstract class AbstractMachineContainer extends Container {
|
||||
this.tileEntity = te;
|
||||
|
||||
addMachineSlots(playerInv);
|
||||
|
||||
|
||||
addSlotToContainer(new Slot(te, te.inventory.length - 1, 12, 60) {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack) {
|
||||
@@ -43,7 +43,8 @@ public abstract class AbstractMachineContainer extends Container {
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) {
|
||||
boolean hasOutput = tileEntity.getSizeInventory() > 2; //Assume one input and capacitor
|
||||
boolean hasOutput = tileEntity.getSizeInventory() > 2; // Assume one input
|
||||
// and capacitor
|
||||
int outputSlot = tileEntity.getSizeInventory() - 2;
|
||||
int capacitorSlot = outputSlot + 1;
|
||||
int startPlayerSlot = capacitorSlot + 1;
|
||||
@@ -58,18 +59,18 @@ public abstract class AbstractMachineContainer extends Container {
|
||||
ItemStack origStack = slot.getStack();
|
||||
copystack = origStack.copy();
|
||||
|
||||
if ( (hasOutput ? (slotIndex < outputSlot) : (slotIndex <= outputSlot)) || slotIndex == capacitorSlot) {
|
||||
//merge from machine input slots to inventory
|
||||
if ((hasOutput ? (slotIndex < outputSlot) : (slotIndex <= outputSlot)) || slotIndex == capacitorSlot) {
|
||||
// merge from machine input slots to inventory
|
||||
if (!mergeItemStack(origStack, startPlayerSlot, endHotBarSlot, false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
} else if (hasOutput && slotIndex == outputSlot) { // merge result
|
||||
|
||||
if (!mergeItemStack(origStack, startPlayerSlot, endHotBarSlot, true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
} else /* if (slotIndex > capacitorSlot) */{ // from inventory into inputs
|
||||
|
||||
boolean merged = false;
|
||||
@@ -78,9 +79,9 @@ public abstract class AbstractMachineContainer extends Container {
|
||||
merged = mergeItemStack(origStack, i, i + 1, false);
|
||||
}
|
||||
}
|
||||
|
||||
//check for capacitor mergers
|
||||
if(!merged) {
|
||||
|
||||
// check for capacitor mergers
|
||||
if (!merged) {
|
||||
merged = mergeItemStack(origStack, capacitorSlot, capacitorSlot + 1, false);
|
||||
}
|
||||
|
||||
@@ -90,17 +91,17 @@ public abstract class AbstractMachineContainer extends Container {
|
||||
|
||||
if ((hasOutput ? (slotIndex < outputSlot) : (slotIndex <= outputSlot)) && slotIndex < startHotBarSlot) {
|
||||
// merge into hotbar
|
||||
if (!mergeItemStack(origStack, startHotBarSlot, endHotBarSlot, false)) {
|
||||
if (!mergeItemStack(origStack, startHotBarSlot, endHotBarSlot, false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//merge from hotbar
|
||||
}
|
||||
|
||||
// merge from hotbar
|
||||
} else if (!mergeItemStack(origStack, startPlayerSlot, endPlayerSlot, false)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (origStack.stackSize == 0) {
|
||||
slot.putStack((ItemStack) null);
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
package crazypants.enderio.machine;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.PacketHandler;
|
||||
import crazypants.enderio.power.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.api.power.*;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.PacketHandler;
|
||||
import crazypants.enderio.power.Capacitors;
|
||||
import crazypants.enderio.power.ICapacitor;
|
||||
import crazypants.enderio.power.IInternalPowerReceptor;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
|
||||
public abstract class AbstractMachineEntity extends TileEntity implements IInventory, IInternalPowerReceptor, IMachine {
|
||||
|
||||
@@ -28,7 +29,7 @@ public abstract class AbstractMachineEntity extends TileEntity implements IInven
|
||||
protected boolean lastActive;
|
||||
protected float lastSyncPowerStored = -1;
|
||||
|
||||
// Power
|
||||
// Power
|
||||
protected Capacitors capacitorType;
|
||||
|
||||
// Used on the client as the power provided isn't sinked
|
||||
@@ -44,23 +45,24 @@ public abstract class AbstractMachineEntity extends TileEntity implements IInven
|
||||
protected boolean redstoneCheckPassed;
|
||||
|
||||
public AbstractMachineEntity(int inventorySize, Type powerType) {
|
||||
this.inventorySize = inventorySize + 1; //plus one for capacitor
|
||||
this.inventorySize = inventorySize + 1; // plus one for capacitor
|
||||
facing = 3;
|
||||
capacitorType = Capacitors.BASIC_CAPACITOR;
|
||||
powerHandler = PowerHandlerUtil.createHandler(capacitorType.capacitor, this, powerType);
|
||||
|
||||
inventory = new ItemStack[this.inventorySize];
|
||||
inventory = new ItemStack[this.inventorySize];
|
||||
|
||||
redstoneControlMode = RedstoneControlMode.IGNORE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||
if(i == inventorySize - 1) {
|
||||
if (i == inventorySize - 1) {
|
||||
return itemstack.itemID == ModObject.itemBasicCapacitor.actualId && itemstack.getItemDamage() > 0;
|
||||
}
|
||||
return isMachineItemValidForSlot(i, itemstack);
|
||||
}
|
||||
|
||||
|
||||
protected abstract boolean isMachineItemValidForSlot(int i, ItemStack itemstack);
|
||||
|
||||
public AbstractMachineEntity(int inventorySize) {
|
||||
@@ -224,8 +226,8 @@ public abstract class AbstractMachineEntity extends TileEntity implements IInven
|
||||
super.readFromNBT(nbtRoot);
|
||||
|
||||
facing = nbtRoot.getShort("facing");
|
||||
|
||||
setCapacitor(Capacitors.values()[nbtRoot.getShort("capacitorType")]);
|
||||
|
||||
setCapacitor(Capacitors.values()[nbtRoot.getShort("capacitorType")]);
|
||||
|
||||
float storedEnergy = nbtRoot.getFloat("storedEnergy");
|
||||
powerHandler.setEnergy(storedEnergy);
|
||||
@@ -257,7 +259,7 @@ public abstract class AbstractMachineEntity extends TileEntity implements IInven
|
||||
super.writeToNBT(nbtRoot);
|
||||
nbtRoot.setShort("facing", facing);
|
||||
nbtRoot.setFloat("storedEnergy", powerHandler.getEnergyStored());
|
||||
nbtRoot.setShort("capacitorType", (short)capacitorType.ordinal());
|
||||
nbtRoot.setShort("capacitorType", (short) capacitorType.ordinal());
|
||||
|
||||
// write inventory list
|
||||
NBTTagList itemList = new NBTTagList();
|
||||
@@ -338,19 +340,19 @@ public abstract class AbstractMachineEntity extends TileEntity implements IInven
|
||||
if (contents != null && contents.stackSize > getInventoryStackLimit()) {
|
||||
contents.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
|
||||
if(slot == inventory.length - 1) {
|
||||
updateCapacitorFromSlot();
|
||||
|
||||
if (slot == inventory.length - 1) {
|
||||
updateCapacitorFromSlot();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCapacitorFromSlot() {
|
||||
ItemStack contents = inventory[inventory.length - 1];
|
||||
if(contents == null) {
|
||||
ItemStack contents = inventory[inventory.length - 1];
|
||||
if (contents == null) {
|
||||
setCapacitor(Capacitors.BASIC_CAPACITOR);
|
||||
} else {
|
||||
setCapacitor(Capacitors.values()[contents.getItemDamage()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,15 +7,15 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity implements ISidedInventory {
|
||||
|
||||
protected PoweredTask currentTask = null;
|
||||
|
||||
|
||||
public AbstractPoweredTaskEntity(int inventorySize) {
|
||||
super(inventorySize);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int var1) {
|
||||
int[] res = new int[inventory.length];
|
||||
for(int i=0;i<res.length;i++) {
|
||||
for (int i = 0; i < res.length; i++) {
|
||||
res[i] = i;
|
||||
}
|
||||
return res;
|
||||
@@ -38,7 +38,7 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
|
||||
}
|
||||
return inventory[i].isItemEqual(itemstack);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
|
||||
int outputIndex = inventory.length - 2;
|
||||
@@ -50,7 +50,7 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
|
||||
}
|
||||
return itemstack.itemID == inventory[outputIndex].itemID;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return currentTask == null ? false : currentTask.getProgress() > 0 && hasPower() && redstoneCheckPassed;
|
||||
@@ -60,23 +60,23 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
|
||||
public float getProgress() {
|
||||
return currentTask == null ? 0 : currentTask.getProgress();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean processTasks(boolean redstoneChecksPassed) {
|
||||
|
||||
if(!redstoneChecksPassed) {
|
||||
|
||||
if (!redstoneChecksPassed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
boolean requiresClientSync = false;
|
||||
// Process any current items
|
||||
requiresClientSync |= checkProgress();
|
||||
|
||||
|
||||
// Then see if we need to start a new one
|
||||
IMachineRecipe nextRecipe = canStartNextTask();
|
||||
if (nextRecipe != null) {
|
||||
requiresClientSync |= startNextTask(nextRecipe);
|
||||
}
|
||||
requiresClientSync |= startNextTask(nextRecipe);
|
||||
}
|
||||
return requiresClientSync;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected void taskComplete() {
|
||||
int outputIndex = inventory.length - 2;
|
||||
if (currentTask != null) {
|
||||
@@ -110,10 +110,10 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
|
||||
}
|
||||
currentTask = null;
|
||||
}
|
||||
|
||||
|
||||
protected RecipeInput[] getInputs() {
|
||||
RecipeInput[] res = new RecipeInput[inventorySize - 2];
|
||||
for(int i=0;i < res.length;i++) {
|
||||
for (int i = 0; i < res.length; i++) {
|
||||
res[i] = new RecipeInput(i, inventory[i]);
|
||||
}
|
||||
return res;
|
||||
@@ -142,13 +142,13 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
|
||||
return null; // no room for output
|
||||
}
|
||||
|
||||
if(!canMergeWithCurrentOuput(nextResult)) {
|
||||
if (!canMergeWithCurrentOuput(nextResult)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return nextRecipe;
|
||||
}
|
||||
|
||||
|
||||
protected boolean canMergeWithCurrentOuput(ItemStack nextResult) {
|
||||
if (!nextResult.isItemEqual(inventory[inventory.length - 2])) {
|
||||
// next result is a different item type
|
||||
@@ -157,22 +157,21 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean startNextTask(IMachineRecipe nextRecipe) {
|
||||
protected boolean startNextTask(IMachineRecipe nextRecipe) {
|
||||
if (hasPower() && nextRecipe.isRecipe(getInputs())) {
|
||||
// then get our recipe and take away the source items
|
||||
currentTask = new PoweredTask(nextRecipe, getInputs());
|
||||
|
||||
|
||||
RecipeInput[] consumed = nextRecipe.getQuantitiesConsumed(getInputs());
|
||||
for(RecipeInput item : consumed) {
|
||||
if(item != null && item.item != null && item.item.stackSize > 0) {
|
||||
for (RecipeInput item : consumed) {
|
||||
if (item != null && item.item != null && item.item.stackSize > 0) {
|
||||
decrStackSize(item.slotNumber, item.item.stackSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtRoot) {
|
||||
@@ -189,7 +188,5 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
|
||||
nbtRoot.setCompoundTag("currentTask", currentTaskNBT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,61 +1,53 @@
|
||||
package crazypants.enderio.machine;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import crazypants.enderio.PacketHandler;
|
||||
import crazypants.enderio.machine.painter.PainterContainer;
|
||||
import crazypants.render.GuiContainerBase;
|
||||
import crazypants.render.GuiToolTip;
|
||||
import crazypants.render.IconButton;
|
||||
import crazypants.render.ItemButton;
|
||||
import crazypants.render.RenderUtil;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
|
||||
public abstract class GuiMachineBase extends GuiContainerBase {
|
||||
|
||||
|
||||
protected static final int POWER_Y = 14;
|
||||
protected final int POWER_X = 15;
|
||||
protected static final int POWER_WIDTH = 10;
|
||||
protected static final int POWER_HEIGHT = 42;
|
||||
protected static final int BOTTOM_POWER_Y = POWER_Y + POWER_HEIGHT;
|
||||
|
||||
|
||||
protected static final int BUTTON_SIZE = 16;
|
||||
protected static final int REDSTONE_BUTTON_ID = 99;
|
||||
|
||||
|
||||
|
||||
private AbstractMachineEntity tileEntity;
|
||||
|
||||
private IconButton redstoneButton;
|
||||
|
||||
|
||||
public GuiMachineBase(AbstractMachineEntity machine, Container container) {
|
||||
super(container);
|
||||
tileEntity = machine;
|
||||
addToolTip(new GuiToolTip(new Rectangle(POWER_X, POWER_Y, POWER_WIDTH, POWER_HEIGHT),"") {
|
||||
addToolTip(new GuiToolTip(new Rectangle(POWER_X, POWER_Y, POWER_WIDTH, POWER_HEIGHT), "") {
|
||||
|
||||
@Override
|
||||
protected void updateText() {
|
||||
protected void updateText() {
|
||||
text.clear();
|
||||
text.add(Math.round(tileEntity.getEnergyStored()) + "/" + tileEntity.getCapacitor().getMaxEnergyStored() + " MJ");
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
addToolTip(new GuiToolTip(new Rectangle(0, 0, 0, 0),"") {
|
||||
addToolTip(new GuiToolTip(new Rectangle(0, 0, 0, 0), "") {
|
||||
|
||||
@Override
|
||||
protected void updateText() {
|
||||
protected void updateText() {
|
||||
text.clear();
|
||||
switch(tileEntity.getRedstoneControlMode()) {
|
||||
switch (tileEntity.getRedstoneControlMode()) {
|
||||
case ON:
|
||||
text.add("Active when");
|
||||
text.add("recieving a");
|
||||
@@ -68,9 +60,9 @@ public abstract class GuiMachineBase extends GuiContainerBase {
|
||||
break;
|
||||
case IGNORE:
|
||||
default:
|
||||
text.add("Allways active.");
|
||||
text.add("Allways active.");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,53 +70,53 @@ public abstract class GuiMachineBase extends GuiContainerBase {
|
||||
bounds.setBounds(xSize - 5 - BUTTON_SIZE, 5, BUTTON_SIZE, BUTTON_SIZE);
|
||||
super.onTick(mouseX, mouseY);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
if(par1GuiButton.id == REDSTONE_BUTTON_ID) {
|
||||
if (par1GuiButton.id == REDSTONE_BUTTON_ID) {
|
||||
int ordinal = tileEntity.getRedstoneControlMode().ordinal();
|
||||
ordinal++;
|
||||
if(ordinal >= RedstoneControlMode.values().length) {
|
||||
if (ordinal >= RedstoneControlMode.values().length) {
|
||||
ordinal = 0;
|
||||
}
|
||||
tileEntity.setRedstoneControlMode(RedstoneControlMode.values()[ordinal]);
|
||||
redstoneButton.setIcon(AbstractMachineBlock.getRedstoneControlIcon(tileEntity.getRedstoneControlMode()));
|
||||
redstoneButton.setIcon(AbstractMachineBlock.getRedstoneControlIcon(tileEntity.getRedstoneControlMode()));
|
||||
Packet pkt = PacketHandler.getRedstoneControlPacket(tileEntity);
|
||||
PacketDispatcher.sendPacketToServer(pkt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
int x = guiLeft + xSize - 5 - BUTTON_SIZE;
|
||||
int y = guiTop + 5;
|
||||
|
||||
redstoneButton = new IconButton(fontRenderer, REDSTONE_BUTTON_ID, x, y, AbstractMachineBlock.getRedstoneControlIcon(tileEntity.getRedstoneControlMode()), RenderUtil.BLOCK_TEX);
|
||||
int x = guiLeft + xSize - 5 - BUTTON_SIZE;
|
||||
int y = guiTop + 5;
|
||||
|
||||
redstoneButton = new IconButton(fontRenderer, REDSTONE_BUTTON_ID, x, y, AbstractMachineBlock.getRedstoneControlIcon(tileEntity.getRedstoneControlMode()),
|
||||
RenderUtil.BLOCK_TEX);
|
||||
redstoneButton.setSize(BUTTON_SIZE, BUTTON_SIZE);
|
||||
|
||||
|
||||
buttonList.add(redstoneButton);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int k = (width - xSize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
int i1 = tileEntity.getEnergyStoredScaled(POWER_HEIGHT);
|
||||
//x, y, u, v, width, height
|
||||
// x, y, u, v, width, height
|
||||
drawTexturedModalRect(k + POWER_X, l + BOTTOM_POWER_Y - i1, 176, 31, POWER_WIDTH, i1);
|
||||
|
||||
|
||||
for (int i = 0; i < buttonList.size(); ++i) {
|
||||
GuiButton guibutton = (GuiButton)this.buttonList.get(i);
|
||||
guibutton.drawButton(this.mc, 0, 0);
|
||||
GuiButton guibutton = (GuiButton) this.buttonList.get(i);
|
||||
guibutton.drawButton(this.mc, 0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package crazypants.enderio.machine;
|
||||
|
||||
public interface IMachine {
|
||||
|
||||
|
||||
String getMachineName();
|
||||
|
||||
|
||||
}
|
||||
@@ -5,17 +5,17 @@ import net.minecraft.item.ItemStack;
|
||||
public interface IMachineRecipe {
|
||||
|
||||
String getUid();
|
||||
|
||||
|
||||
float getEnergyRequired(RecipeInput... inputs);
|
||||
|
||||
|
||||
public boolean isRecipe(RecipeInput... inputs);
|
||||
|
||||
ItemStack[] getCompletedResult(RecipeInput... inputs);
|
||||
|
||||
|
||||
ItemStack[] getCompletedResult(RecipeInput... inputs);
|
||||
|
||||
boolean isValidInput(int slotNumber, ItemStack item);
|
||||
|
||||
|
||||
String getMachineName();
|
||||
|
||||
RecipeInput[] getQuantitiesConsumed(RecipeInput[] inputs);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,30 +1,34 @@
|
||||
package crazypants.enderio.machine;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MachineRecipeRegistry {
|
||||
|
||||
public static final MachineRecipeRegistry instance = new MachineRecipeRegistry();
|
||||
|
||||
private final Map<String, Map<String,IMachineRecipe>> machineRecipes = new HashMap<String, Map<String,IMachineRecipe>>();
|
||||
|
||||
|
||||
private final Map<String, Map<String, IMachineRecipe>> machineRecipes = new HashMap<String, Map<String, IMachineRecipe>>();
|
||||
|
||||
public void registerRecipe(String machine, IMachineRecipe recipe) {
|
||||
getRecipesForMachine(machine).put(recipe.getUid(), recipe);
|
||||
}
|
||||
|
||||
public Map<String,IMachineRecipe> getRecipesForMachine(String machineName) {
|
||||
|
||||
public Map<String, IMachineRecipe> getRecipesForMachine(String machineName) {
|
||||
Map<String, IMachineRecipe> res = machineRecipes.get(machineName);
|
||||
if(res == null) {
|
||||
if (res == null) {
|
||||
res = new HashMap<String, IMachineRecipe>();
|
||||
machineRecipes.put(machineName, res);
|
||||
machineRecipes.put(machineName, res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public IMachineRecipe getRecipeForUid(String uid) {
|
||||
for(Map<String, IMachineRecipe> recipes : machineRecipes.values()) {
|
||||
for(IMachineRecipe recipe : recipes.values()) {
|
||||
if(uid.equals(recipe.getUid())) {
|
||||
|
||||
public IMachineRecipe getRecipeForUid(String uid) {
|
||||
for (Map<String, IMachineRecipe> recipes : machineRecipes.values()) {
|
||||
for (IMachineRecipe recipe : recipes.values()) {
|
||||
if (uid.equals(recipe.getUid())) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
@@ -34,29 +38,29 @@ public class MachineRecipeRegistry {
|
||||
|
||||
public IMachineRecipe getRecipeForInputs(String machineName, RecipeInput... inputs) {
|
||||
Map<String, IMachineRecipe> recipes = getRecipesForMachine(machineName);
|
||||
if(recipes == null) {
|
||||
if (recipes == null) {
|
||||
return null;
|
||||
}
|
||||
for(IMachineRecipe recipe : recipes.values()) {
|
||||
if(recipe.isRecipe(inputs)) {
|
||||
for (IMachineRecipe recipe : recipes.values()) {
|
||||
if (recipe.isRecipe(inputs)) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public List<IMachineRecipe> getRecipesForInput(String machineName, RecipeInput input) {
|
||||
if(input == null) {
|
||||
if (input == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<IMachineRecipe> result = new ArrayList<IMachineRecipe>();
|
||||
Map<String, IMachineRecipe> recipes = getRecipesForMachine(machineName);
|
||||
for(IMachineRecipe recipe : recipes.values()) {
|
||||
if(recipe.isValidInput(input.slotNumber, input.item)) {
|
||||
for (IMachineRecipe recipe : recipes.values()) {
|
||||
if (recipe.isValidInput(input.slotNumber, input.item)) {
|
||||
result.add(recipe);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,10 +1,17 @@
|
||||
package crazypants.enderio.machine;
|
||||
|
||||
import static crazypants.enderio.ModObject.*;
|
||||
import static crazypants.enderio.ModObject.blockAlloySmelter;
|
||||
import static crazypants.enderio.ModObject.blockElectricLight;
|
||||
import static crazypants.enderio.ModObject.blockPainter;
|
||||
import static crazypants.enderio.ModObject.blockReservoir;
|
||||
import static crazypants.enderio.ModObject.blockSolarPanel;
|
||||
import static crazypants.enderio.ModObject.blockStirlingGenerator;
|
||||
import static crazypants.enderio.ModObject.itemBasicCapacitor;
|
||||
import static crazypants.enderio.ModObject.itemIndustrialBinder;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.material.Alloy;
|
||||
|
||||
@@ -30,20 +37,19 @@ public class MachineRecipes {
|
||||
|
||||
ItemStack alloySmelter = new ItemStack(blockAlloySmelter.actualId, 1, 0);
|
||||
GameRegistry.addShapedRecipe(alloySmelter, "bbb", "CfC", "bcb", 'b', industialBinder, 'f', Block.furnaceIdle, 'c', capacitor, 'C', Item.cauldron);
|
||||
|
||||
ItemStack solarPanel = new ItemStack(blockSolarPanel.actualId,1,0);
|
||||
ItemStack activatedIron = new ItemStack(ModObject.itemAlloy.actualId,1,Alloy.ACTIVATED_IRON.ordinal());
|
||||
ItemStack activatedGold = new ItemStack(ModObject.itemAlloy.actualId,1,Alloy.ACTIVATED_GOLD.ordinal());
|
||||
|
||||
ItemStack solarPanel = new ItemStack(blockSolarPanel.actualId, 1, 0);
|
||||
ItemStack activatedIron = new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.ACTIVATED_IRON.ordinal());
|
||||
ItemStack activatedGold = new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.ACTIVATED_GOLD.ordinal());
|
||||
ItemStack fusedQuartz = new ItemStack(ModObject.blockFusedQuartz.actualId, 1, 0);
|
||||
|
||||
GameRegistry.addShapedRecipe(solarPanel, "qqq", "gig", "bcb", 'q', fusedQuartz, 'g', activatedGold, 'i', activatedIron, 'b', industialBinder,'c', capacitor);
|
||||
|
||||
|
||||
ItemStack electricLight = new ItemStack(blockElectricLight.actualId,1,0);
|
||||
|
||||
GameRegistry.addShapedRecipe(solarPanel, "qqq", "gig", "bcb", 'q', fusedQuartz, 'g', activatedGold, 'i', activatedIron, 'b', industialBinder, 'c',
|
||||
capacitor);
|
||||
|
||||
ItemStack electricLight = new ItemStack(blockElectricLight.actualId, 1, 0);
|
||||
ItemStack glowstone = new ItemStack(Item.glowstone);
|
||||
GameRegistry.addShapedRecipe(electricLight, "bqb", "bgb", "bcb", 'q', fusedQuartz, 'g', glowstone, 'b', industialBinder,'c', capacitor);
|
||||
|
||||
|
||||
GameRegistry.addShapedRecipe(electricLight, "bqb", "bgb", "bcb", 'q', fusedQuartz, 'g', glowstone, 'b', industialBinder, 'c', capacitor);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package crazypants.enderio.machine;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
public class PoweredTask {
|
||||
@@ -31,7 +33,7 @@ public class PoweredTask {
|
||||
numInputs++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inputs = new RecipeInput[numInputs];
|
||||
int index = 0;
|
||||
for (int i = 0; i < inputsIn.length; i++) {
|
||||
@@ -40,7 +42,7 @@ public class PoweredTask {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.recipe = recipe;
|
||||
this.usedEnergy = usedEnergy;
|
||||
requiredEnergy = recipe.getEnergyRequired(inputsIn);
|
||||
|
||||
@@ -5,26 +5,25 @@ import net.minecraft.item.ItemStack;
|
||||
public class RecipeInput {
|
||||
|
||||
public static ItemStack getInputForSlot(int slot, RecipeInput... inputs) {
|
||||
for(RecipeInput ri: inputs) {
|
||||
if(ri.slotNumber == slot) {
|
||||
for (RecipeInput ri : inputs) {
|
||||
if (ri.slotNumber == slot) {
|
||||
return ri.item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static RecipeInput create(int slotNumber, ItemStack item) {
|
||||
return new RecipeInput(slotNumber, item);
|
||||
}
|
||||
|
||||
|
||||
public final int slotNumber;
|
||||
public final ItemStack item;
|
||||
|
||||
|
||||
public RecipeInput(int slotNumber, ItemStack item) {
|
||||
super();
|
||||
this.slotNumber = slotNumber;
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package crazypants.enderio.machine;
|
||||
|
||||
public enum RedstoneControlMode {
|
||||
|
||||
|
||||
IGNORE,
|
||||
ON,
|
||||
OFF
|
||||
|
||||
@@ -11,28 +11,28 @@ import crazypants.enderio.machine.RecipeInput;
|
||||
public class BasicAlloyRecipe implements IMachineRecipe {
|
||||
|
||||
public static final int DEFAULT_ENERGY_USE = 1600;
|
||||
|
||||
|
||||
private final String uid;
|
||||
|
||||
|
||||
private float energyRequired = DEFAULT_ENERGY_USE;
|
||||
|
||||
|
||||
private ItemStack[] inputs;
|
||||
|
||||
|
||||
private ItemStack output;
|
||||
|
||||
|
||||
public BasicAlloyRecipe(ItemStack output, String uid, ItemStack... recipeInputs) {
|
||||
this.output = output.copy();
|
||||
this.uid = uid;
|
||||
inputs = new ItemStack[recipeInputs.length];
|
||||
for(int i=0;i<inputs.length;i++) {
|
||||
if(recipeInputs[i] != null) {
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
if (recipeInputs[i] != null) {
|
||||
inputs[i] = recipeInputs[i].copy();
|
||||
} else {
|
||||
inputs[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
return uid;
|
||||
@@ -46,12 +46,12 @@ public class BasicAlloyRecipe implements IMachineRecipe {
|
||||
@Override
|
||||
public boolean isRecipe(RecipeInput... checking) {
|
||||
checking = getNonNullInputs(checking);
|
||||
if(inputs.length != checking.length) {
|
||||
if (inputs.length != checking.length) {
|
||||
return false;
|
||||
}
|
||||
for(RecipeInput input : checking) {
|
||||
for (RecipeInput input : checking) {
|
||||
ItemStack ing = getIngrediantForInput(input.item);
|
||||
if(ing == null || ing.stackSize > input.item.stackSize) {
|
||||
if (ing == null || ing.stackSize > input.item.stackSize) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -60,15 +60,15 @@ public class BasicAlloyRecipe implements IMachineRecipe {
|
||||
|
||||
private RecipeInput[] getNonNullInputs(RecipeInput[] checking) {
|
||||
int numNonNulls = 0;
|
||||
for(int i=0;i<checking.length;i++) {
|
||||
if(checking[i] != null && checking[i].item != null) {
|
||||
for (int i = 0; i < checking.length; i++) {
|
||||
if (checking[i] != null && checking[i].item != null) {
|
||||
numNonNulls++;
|
||||
}
|
||||
}
|
||||
RecipeInput[] result = new RecipeInput[numNonNulls];
|
||||
int index = 0;
|
||||
for(int i=0;i<checking.length;i++) {
|
||||
if(checking[i] != null && checking[i].item != null) {
|
||||
for (int i = 0; i < checking.length; i++) {
|
||||
if (checking[i] != null && checking[i].item != null) {
|
||||
result[index] = checking[i];
|
||||
index++;
|
||||
}
|
||||
@@ -78,12 +78,12 @@ public class BasicAlloyRecipe implements IMachineRecipe {
|
||||
|
||||
@Override
|
||||
public ItemStack[] getCompletedResult(RecipeInput... inputs) {
|
||||
return new ItemStack[] {output.copy()};
|
||||
return new ItemStack[] { output.copy() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidInput(int slotNumber, ItemStack item) {
|
||||
return getIngrediantForInput(item) != null;
|
||||
return getIngrediantForInput(item) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -95,34 +95,34 @@ public class BasicAlloyRecipe implements IMachineRecipe {
|
||||
ItemStack ing = getIngrediantForInput(input.item);
|
||||
return ing == null ? 0 : ing.stackSize;
|
||||
}
|
||||
|
||||
|
||||
private ItemStack getIngrediantForInput(ItemStack input) {
|
||||
if(input == null) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
for(ItemStack st : inputs) {
|
||||
if(st != null && st.itemID == input.itemID) {
|
||||
for (ItemStack st : inputs) {
|
||||
if (st != null && st.itemID == input.itemID) {
|
||||
return st;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeInput[] getQuantitiesConsumed(RecipeInput[] inputs) {
|
||||
List<RecipeInput> result = new ArrayList<RecipeInput>();
|
||||
for(RecipeInput input : inputs) {
|
||||
int numConsumed = getQuantityConsumed(input);
|
||||
if(numConsumed > 0) {
|
||||
ItemStack consumed = input.item.copy();
|
||||
consumed.stackSize = numConsumed;
|
||||
result.add(new RecipeInput(input.slotNumber, consumed));
|
||||
@Override
|
||||
public RecipeInput[] getQuantitiesConsumed(RecipeInput[] inputs) {
|
||||
List<RecipeInput> result = new ArrayList<RecipeInput>();
|
||||
for (RecipeInput input : inputs) {
|
||||
int numConsumed = getQuantityConsumed(input);
|
||||
if (numConsumed > 0) {
|
||||
ItemStack consumed = input.item.copy();
|
||||
consumed.stackSize = numConsumed;
|
||||
result.add(new RecipeInput(input.slotNumber, consumed));
|
||||
}
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return result.toArray(new RecipeInput[result.size()]);
|
||||
}
|
||||
if(result.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return result.toArray(new RecipeInput[result.size()]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,15 @@
|
||||
package crazypants.enderio.machine.alloy;
|
||||
|
||||
import crazypants.enderio.*;
|
||||
import crazypants.enderio.machine.*;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
import crazypants.enderio.machine.IMachineRecipe;
|
||||
import crazypants.enderio.machine.MachineRecipeRegistry;
|
||||
|
||||
public class BlockAlloySmelter extends AbstractMachineBlock<TileAlloySmelter> {
|
||||
|
||||
@@ -22,14 +26,17 @@ public class BlockAlloySmelter extends AbstractMachineBlock<TileAlloySmelter> {
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
|
||||
// GameRegistry.addRecipe(new ItemStack(this), "bbb", "iri", "bbb", 'i', new ItemStack(Item.ingotIron), 'r', new ItemStack(Item.redstone), 'b', new ItemStack(
|
||||
// ModObject.itemIndustrialBinder.id, 1, 0));
|
||||
|
||||
// GameRegistry.addRecipe(new ItemStack(this), "bbb", "iri", "bbb", 'i', new
|
||||
// ItemStack(Item.ingotIron), 'r', new ItemStack(Item.redstone), 'b', new
|
||||
// ItemStack(
|
||||
// ModObject.itemIndustrialBinder.id, 1, 0));
|
||||
IMachineRecipe recipe;
|
||||
recipe = new BasicAlloyRecipe(new ItemStack(Item.axeDiamond), "Diamond Axe", new ItemStack(Item.diamond,3,0), new ItemStack(Item.stick,2,0));
|
||||
recipe = new BasicAlloyRecipe(new ItemStack(Item.axeDiamond), "Diamond Axe", new ItemStack(Item.diamond, 3, 0), new ItemStack(Item.stick, 2, 0));
|
||||
MachineRecipeRegistry.instance.registerRecipe(ModObject.blockAlloySmelter.unlocalisedName, recipe);
|
||||
|
||||
recipe = new BasicAlloyRecipe(new ItemStack(Item.blazeRod), "Blazedy Blaze", new ItemStack(Item.ingotIron,1,0), new ItemStack(Item.ingotGold,1,0),new ItemStack(Item.diamond,1,0));
|
||||
|
||||
recipe = new BasicAlloyRecipe(new ItemStack(Item.blazeRod), "Blazedy Blaze", new ItemStack(Item.ingotIron, 1, 0), new ItemStack(Item.ingotGold, 1, 0),
|
||||
new ItemStack(Item.diamond, 1, 0));
|
||||
MachineRecipeRegistry.instance.registerRecipe(ModObject.blockAlloySmelter.unlocalisedName, recipe);
|
||||
}
|
||||
|
||||
@@ -49,7 +56,7 @@ public class BlockAlloySmelter extends AbstractMachineBlock<TileAlloySmelter> {
|
||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
return new GuiAlloySmelter(player.inventory, (TileAlloySmelter) te);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getGuiId() {
|
||||
return GuiHandler.GUI_ID_ALLOY_SMELTER;
|
||||
@@ -57,7 +64,7 @@ public class BlockAlloySmelter extends AbstractMachineBlock<TileAlloySmelter> {
|
||||
|
||||
@Override
|
||||
protected String getMachineFrontIconKey(boolean active) {
|
||||
if(active) {
|
||||
if (active) {
|
||||
return "enderio:alloySmelterFrontOn";
|
||||
}
|
||||
return "enderio:alloySmelterFront";
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package crazypants.enderio.machine.alloy;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import crazypants.enderio.machine.AbstractMachineContainer;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import net.minecraft.entity.player.*;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerAlloySmelter extends AbstractMachineContainer {
|
||||
|
||||
@@ -18,7 +18,7 @@ public class ContainerAlloySmelter extends AbstractMachineContainer {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack) {
|
||||
return tileEntity.isItemValidForSlot(0, itemStack);
|
||||
}
|
||||
}
|
||||
});
|
||||
addSlotToContainer(new Slot(tileEntity, 1, 78, 7) {
|
||||
@Override
|
||||
@@ -38,7 +38,7 @@ public class ContainerAlloySmelter extends AbstractMachineContainer {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +1,12 @@
|
||||
package crazypants.enderio.machine.alloy;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import crazypants.enderio.machine.GuiMachineBase;
|
||||
import crazypants.render.RenderUtil;
|
||||
|
||||
|
||||
public class GuiAlloySmelter extends GuiMachineBase {
|
||||
|
||||
private TileAlloySmelter tileEntity;
|
||||
@@ -19,28 +16,27 @@ public class GuiAlloySmelter extends GuiMachineBase {
|
||||
this.tileEntity = furnaceInventory;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draw the background layer for the GuiContainer (everything behind the
|
||||
* items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderUtil.bindTexture("enderio:textures/gui/alloySmelter.png");
|
||||
int sx = (width - xSize) / 2;
|
||||
int sy = (height - ySize) / 2;
|
||||
|
||||
|
||||
drawTexturedModalRect(sx, sy, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
int scaled;
|
||||
|
||||
if(tileEntity.getProgress() < 1 && tileEntity.getProgress() > 0) {
|
||||
|
||||
int scaled;
|
||||
|
||||
if (tileEntity.getProgress() < 1 && tileEntity.getProgress() > 0) {
|
||||
scaled = tileEntity.getProgressScaled(12);
|
||||
drawTexturedModalRect(sx + 55, sy + 48 - scaled, 176, 12 - scaled, 14, scaled + 2);
|
||||
drawTexturedModalRect(sx + 55, sy + 48 - scaled, 176, 12 - scaled, 14, scaled + 2);
|
||||
drawTexturedModalRect(sx + 103, sy + 48 - scaled, 176, 12 - scaled, 14, scaled + 2);
|
||||
}
|
||||
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package crazypants.enderio.machine.alloy;
|
||||
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.AbstractPoweredTaskEntity;
|
||||
import crazypants.enderio.machine.MachineRecipeRegistry;
|
||||
import crazypants.enderio.machine.RecipeInput;
|
||||
|
||||
public class TileAlloySmelter extends AbstractPoweredTaskEntity {
|
||||
|
||||
@@ -22,10 +24,10 @@ public class TileAlloySmelter extends AbstractPoweredTaskEntity {
|
||||
|
||||
@Override
|
||||
public boolean isMachineItemValidForSlot(int i, ItemStack itemstack) {
|
||||
if(i >= 3) {
|
||||
if (i >= 3) {
|
||||
return false;
|
||||
}
|
||||
return !MachineRecipeRegistry.instance.getRecipesForInput(getMachineName(), RecipeInput.create(i, itemstack)).isEmpty();
|
||||
}
|
||||
return !MachineRecipeRegistry.instance.getRecipesForInput(getMachineName(), RecipeInput.create(i, itemstack)).isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.IMachineRecipe;
|
||||
import crazypants.enderio.machine.RecipeInput;
|
||||
|
||||
@@ -1,30 +1,31 @@
|
||||
package crazypants.enderio.machine.generator;
|
||||
|
||||
import crazypants.enderio.*;
|
||||
import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
|
||||
public class BlockStirlingGenerator extends AbstractMachineBlock<TileEntityStirlingGenerator> {
|
||||
|
||||
|
||||
public static BlockStirlingGenerator create() {
|
||||
BlockStirlingGenerator gen = new BlockStirlingGenerator();
|
||||
gen.init();
|
||||
return gen;
|
||||
}
|
||||
|
||||
|
||||
protected BlockStirlingGenerator() {
|
||||
super(ModObject.blockStirlingGenerator, TileEntityStirlingGenerator.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new StirlingGeneratorContainer(player.inventory, (TileEntityStirlingGenerator) world.getBlockTileEntity(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new GuiStirlingGenerator(player.inventory, (TileEntityStirlingGenerator) world.getBlockTileEntity(x, y, z));
|
||||
return new GuiStirlingGenerator(player.inventory, (TileEntityStirlingGenerator) world.getBlockTileEntity(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,12 +35,10 @@ public class BlockStirlingGenerator extends AbstractMachineBlock<TileEntityStirl
|
||||
|
||||
@Override
|
||||
protected String getMachineFrontIconKey(boolean active) {
|
||||
if(active) {
|
||||
if (active) {
|
||||
return "enderio:stirlingGenFrontOn";
|
||||
}
|
||||
return "enderio:stirlingGenFrontOff";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
package crazypants.enderio.machine.generator;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.machine.GuiMachineBase;
|
||||
@@ -29,20 +26,19 @@ public class GuiStirlingGenerator extends GuiMachineBase {
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderUtil.bindTexture("enderio:textures/gui/stirlingGenerator.png");
|
||||
RenderUtil.bindTexture("enderio:textures/gui/stirlingGenerator.png");
|
||||
int sx = (width - xSize) / 2;
|
||||
int sy = (height - ySize) / 2;
|
||||
|
||||
|
||||
drawTexturedModalRect(sx, sy, 0, 0, this.xSize, this.ySize);
|
||||
int scaled;
|
||||
|
||||
if(entity.getProgress() < 1 && entity.getProgress() > 0) {
|
||||
|
||||
if (entity.getProgress() < 1 && entity.getProgress() > 0) {
|
||||
scaled = entity.getProgressScaled(12);
|
||||
drawTexturedModalRect(sx + 80, sy + 65 - scaled, 176, 12 - scaled, 14, scaled + 2);
|
||||
}
|
||||
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package crazypants.enderio.machine.generator;
|
||||
|
||||
import crazypants.enderio.machine.AbstractMachineContainer;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import crazypants.enderio.machine.AbstractMachineContainer;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
|
||||
public class StirlingGeneratorContainer extends AbstractMachineContainer {
|
||||
|
||||
@@ -21,7 +19,7 @@ public class StirlingGeneratorContainer extends AbstractMachineContainer {
|
||||
public boolean isItemValid(ItemStack itemStack) {
|
||||
return tileEntity.isItemValidForSlot(0, itemStack);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +1,24 @@
|
||||
package crazypants.enderio.machine.generator;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
import crazypants.enderio.conduit.power.PowerConduitNetwork.ReceptorEntry;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.power.IInternalPowerReceptor;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.*;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.api.power.IPowerEmitter;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.power.IInternalPowerReceptor;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public class TileEntityStirlingGenerator extends AbstractMachineEntity implements ISidedInventory, IPowerEmitter {
|
||||
|
||||
@@ -121,7 +119,7 @@ public class TileEntityStirlingGenerator extends AbstractMachineEntity implement
|
||||
|
||||
if (burnTime <= 0 && powerHandler.getEnergyStored() < powerHandler.getMaxEnergyStored() && redstoneCheckPassed) {
|
||||
if (inventory[0] != null && inventory[0].stackSize > 0) {
|
||||
burnTime = TileEntityFurnace.getItemBurnTime(inventory[0]);
|
||||
burnTime = TileEntityFurnace.getItemBurnTime(inventory[0]);
|
||||
if (burnTime > 0) {
|
||||
totalBurnTime = burnTime;
|
||||
decrStackSize(0, 1);
|
||||
@@ -134,7 +132,7 @@ public class TileEntityStirlingGenerator extends AbstractMachineEntity implement
|
||||
}
|
||||
|
||||
private boolean transmitEnergy() {
|
||||
|
||||
|
||||
if (powerHandler.getEnergyStored() <= 0) {
|
||||
powerHandler.update();
|
||||
return false;
|
||||
@@ -144,9 +142,8 @@ public class TileEntityStirlingGenerator extends AbstractMachineEntity implement
|
||||
|
||||
float stored = powerHandler.getEnergyStored();
|
||||
powerHandler.update();
|
||||
float storedAfter = powerHandler.getEnergyStored();
|
||||
|
||||
|
||||
float storedAfter = powerHandler.getEnergyStored();
|
||||
|
||||
checkReceptors();
|
||||
|
||||
if (!receptors.isEmpty() && !receptorIterator.hasNext()) {
|
||||
@@ -162,16 +159,19 @@ public class TileEntityStirlingGenerator extends AbstractMachineEntity implement
|
||||
if (pp != null && pp.getMinEnergyReceived() <= canTransmit && pp.getType() != Type.ENGINE) {
|
||||
float used;
|
||||
if (receptor.receptor instanceof IInternalPowerReceptor) {
|
||||
//System.out.println("TileEntityStirlingGenerator.transmitEnergy: Sending " + canTransmit + " to internal.");
|
||||
used = PowerHandlerUtil.transmitInternal((IInternalPowerReceptor) receptor.receptor, pp, canTransmit,Type.ENGINE,receptor.fromDir);
|
||||
} else {
|
||||
//System.out.println("TileEntityStirlingGenerator.transmitEnergy: Sending " + canTransmit + " to EXTERNAL. Receptor is: " + receptor.receptor);
|
||||
// System.out.println("TileEntityStirlingGenerator.transmitEnergy: Sending "
|
||||
// + canTransmit + " to internal.");
|
||||
used = PowerHandlerUtil.transmitInternal((IInternalPowerReceptor) receptor.receptor, pp, canTransmit, Type.ENGINE, receptor.fromDir);
|
||||
} else {
|
||||
// System.out.println("TileEntityStirlingGenerator.transmitEnergy: Sending "
|
||||
// + canTransmit + " to EXTERNAL. Receptor is: " + receptor.receptor);
|
||||
used = pp.receiveEnergy(Type.ENGINE, canTransmit, receptor.fromDir);
|
||||
}
|
||||
transmitted += used;
|
||||
// if (used > 0) {
|
||||
// System.out.println("TileEntityStirlingGenerator.transmitEnergy: Trasnmitted energy " + used + " to " + receptor.receptor);
|
||||
// }
|
||||
// if (used > 0) {
|
||||
// System.out.println("TileEntityStirlingGenerator.transmitEnergy: Trasnmitted energy "
|
||||
// + used + " to " + receptor.receptor);
|
||||
// }
|
||||
canTransmit -= used;
|
||||
}
|
||||
if (canTransmit <= 0) {
|
||||
@@ -183,7 +183,7 @@ public class TileEntityStirlingGenerator extends AbstractMachineEntity implement
|
||||
}
|
||||
appliedCount++;
|
||||
}
|
||||
|
||||
|
||||
powerHandler.setEnergy(powerHandler.getEnergyStored() - transmitted);
|
||||
|
||||
return transmitted > 0;
|
||||
|
||||
@@ -1,26 +1,21 @@
|
||||
package crazypants.enderio.machine.light;
|
||||
|
||||
import static net.minecraftforge.common.ForgeDirection.EAST;
|
||||
import static net.minecraftforge.common.ForgeDirection.NORTH;
|
||||
import static net.minecraftforge.common.ForgeDirection.SOUTH;
|
||||
import static net.minecraftforge.common.ForgeDirection.WEST;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.*;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import cpw.mods.fml.common.registry.*;
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.vecmath.Vector3f;
|
||||
|
||||
public class BlockElectricLight extends Block implements ITileEntityProvider {
|
||||
@@ -30,7 +25,7 @@ public class BlockElectricLight extends Block implements ITileEntityProvider {
|
||||
|
||||
private static final float BLOCK_EDGE_MAX = 0.5f + (BLOCK_WIDTH / 2);
|
||||
private static final float BLOCK_EDGE_MIN = 0.5f - (BLOCK_WIDTH / 2);
|
||||
|
||||
|
||||
public static int renderId;
|
||||
|
||||
public static BlockElectricLight create() {
|
||||
@@ -58,7 +53,7 @@ public class BlockElectricLight extends Block implements ITileEntityProvider {
|
||||
GameRegistry.registerBlock(this, ModObject.blockElectricLight.unlocalisedName);
|
||||
GameRegistry.registerTileEntity(TileElectricLight.class, ModObject.blockElectricLight.unlocalisedName + "TileEntity");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
return null;
|
||||
@@ -70,29 +65,29 @@ public class BlockElectricLight extends Block implements ITileEntityProvider {
|
||||
blockIconOff = iconRegister.registerIcon("enderio:blockElectricLightFaceOff");
|
||||
blockIconSide = iconRegister.registerIcon("enderio:conduitConnector");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getBlockTexture(IBlockAccess blockAccess, int x, int y, int z, int side) {
|
||||
|
||||
|
||||
TileEntity te = blockAccess.getBlockTileEntity(x, y, z);
|
||||
if (te instanceof TileElectricLight) {
|
||||
ForgeDirection onFace = ((TileElectricLight) te).getFace();
|
||||
if(side == (onFace.offsetX == 0 ? onFace.getOpposite().ordinal() : onFace.ordinal())) {
|
||||
if (side == (onFace.offsetX == 0 ? onFace.getOpposite().ordinal() : onFace.ordinal())) {
|
||||
boolean on = blockAccess.getBlockMetadata(x, y, z) != 0;
|
||||
return on ? blockIcon : blockIconOff;
|
||||
}
|
||||
return blockIconSide;
|
||||
}
|
||||
return getIcon(side,0);
|
||||
return getIcon(side, 0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon(int side, int par2) {
|
||||
if(side == ForgeDirection.DOWN.ordinal()) {
|
||||
if (side == ForgeDirection.DOWN.ordinal()) {
|
||||
return blockIcon;
|
||||
}
|
||||
}
|
||||
return blockIconSide;
|
||||
}
|
||||
|
||||
@@ -105,14 +100,14 @@ public class BlockElectricLight extends Block implements ITileEntityProvider {
|
||||
public int getRenderType() {
|
||||
return renderId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z) {
|
||||
Block block = blocksList[world.getBlockId(x, y, z)];
|
||||
if (block != null && block != this) {
|
||||
return block.getLightValue(world, x, y, z);
|
||||
return block.getLightValue(world, x, y, z);
|
||||
}
|
||||
return world.getBlockMetadata(x, y, z) > 0 ? 15 : 0;
|
||||
return world.getBlockMetadata(x, y, z) > 0 ? 15 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,8 +115,8 @@ public class BlockElectricLight extends Block implements ITileEntityProvider {
|
||||
ForgeDirection onFace = ForgeDirection.DOWN;
|
||||
TileEntity te = blockAccess.getBlockTileEntity(x, y, z);
|
||||
if (te instanceof TileElectricLight) {
|
||||
onFace = ((TileElectricLight) te).getFace();
|
||||
}
|
||||
onFace = ((TileElectricLight) te).getFace();
|
||||
}
|
||||
|
||||
Vector3f min = new Vector3f();
|
||||
Vector3f max = new Vector3f();
|
||||
@@ -144,7 +139,7 @@ public class BlockElectricLight extends Block implements ITileEntityProvider {
|
||||
break;
|
||||
case NORTH:
|
||||
min.set(BLOCK_EDGE_MIN, BLOCK_EDGE_MIN, 0);
|
||||
max.set(BLOCK_EDGE_MAX, BLOCK_EDGE_MAX, BLOCK_HEIGHT);
|
||||
max.set(BLOCK_EDGE_MAX, BLOCK_EDGE_MAX, BLOCK_HEIGHT);
|
||||
break;
|
||||
case SOUTH:
|
||||
min.set(BLOCK_EDGE_MIN, BLOCK_EDGE_MIN, 1 - BLOCK_HEIGHT);
|
||||
@@ -157,7 +152,7 @@ public class BlockElectricLight extends Block implements ITileEntityProvider {
|
||||
break;
|
||||
}
|
||||
|
||||
setBlockBounds(min.x, min.y,min.z, max.x,max.y,max.z);
|
||||
setBlockBounds(min.x, min.y, min.z, max.x, max.y, max.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -165,6 +160,7 @@ public class BlockElectricLight extends Block implements ITileEntityProvider {
|
||||
setBlockBounds(BLOCK_EDGE_MIN, 0.0F, BLOCK_EDGE_MIN, BLOCK_EDGE_MAX, BLOCK_HEIGHT, BLOCK_EDGE_MAX);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onBlockPlaced(World world, int x, int y, int z, int side, float par6, float par7, float par8, int meta) {
|
||||
return side;
|
||||
}
|
||||
@@ -174,9 +170,9 @@ public class BlockElectricLight extends Block implements ITileEntityProvider {
|
||||
ForgeDirection onFace = ForgeDirection.values()[meta].getOpposite();
|
||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
if (te instanceof TileElectricLight) {
|
||||
((TileElectricLight) te).setFace(onFace);
|
||||
}
|
||||
world.setBlockMetadataWithNotify(x, y, z, 0, 0);
|
||||
((TileElectricLight) te).setFace(onFace);
|
||||
}
|
||||
world.setBlockMetadataWithNotify(x, y, z, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -191,13 +187,13 @@ public class BlockElectricLight extends Block implements ITileEntityProvider {
|
||||
((TileElectricLight) te).onNeighborBlockChange(blockID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, int par5, int par6) {
|
||||
public void breakBlock(World world, int x, int y, int z, int par5, int par6) {
|
||||
TileElectricLight te = (TileElectricLight) world.getBlockTileEntity(x, y, z);
|
||||
if (te != null) {
|
||||
if (te != null) {
|
||||
te.onBlockRemoved();
|
||||
}
|
||||
}
|
||||
world.removeBlockTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,16 @@
|
||||
package crazypants.enderio.machine.light;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import crazypants.enderio.ModObject;
|
||||
|
||||
public class BlockLightNode extends Block implements ITileEntityProvider {
|
||||
|
||||
@@ -39,7 +27,7 @@ public class BlockLightNode extends Block implements ITileEntityProvider {
|
||||
setUnlocalizedName(ModObject.blockLightNode.unlocalisedName);
|
||||
setLightOpacity(0);
|
||||
setLightValue(0);
|
||||
//setBlockBounds(0.45f, 0.45F, 0.45f, 0.55f, 0.55f, 0.55f);
|
||||
// setBlockBounds(0.45f, 0.45F, 0.45f, 0.55f, 0.55f, 0.55f);
|
||||
setBlockBounds(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@@ -90,11 +78,11 @@ public class BlockLightNode extends Block implements ITileEntityProvider {
|
||||
return block.getLightValue(world, x, y, z);
|
||||
}
|
||||
int onVal = 15;
|
||||
// TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
// if(te instanceof TileLightNode && ((TileLightNode)te).isDiagnal) {
|
||||
// System.out.println("BlockLightNode.getLightValue: ");
|
||||
// onVal = 5;
|
||||
// }
|
||||
// TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
// if(te instanceof TileLightNode && ((TileLightNode)te).isDiagnal) {
|
||||
// System.out.println("BlockLightNode.getLightValue: ");
|
||||
// onVal = 5;
|
||||
// }
|
||||
return world.getBlockMetadata(x, y, z) > 0 ? onVal : 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package crazypants.enderio.machine.light;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.CubeRenderer;
|
||||
import crazypants.render.RenderUtil;
|
||||
@@ -17,23 +15,23 @@ public class ElectricLightRenderer implements ISimpleBlockRenderingHandler {
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
|
||||
|
||||
|
||||
BoundingBox bb = new BoundingBox(0, 0, 0, 1, 0.2, 1);
|
||||
boolean doDraw = false;
|
||||
if (!Tessellator.instance.isDrawing) {
|
||||
doDraw = true;
|
||||
Tessellator.instance.startDrawingQuads();
|
||||
}
|
||||
Icon[] textures = new Icon[6];
|
||||
}
|
||||
Icon[] textures = new Icon[6];
|
||||
textures[0] = block.getBlockTextureFromSide(ForgeDirection.NORTH.ordinal());
|
||||
textures[1] = block.getBlockTextureFromSide(ForgeDirection.SOUTH.ordinal());
|
||||
textures[2] = block.getBlockTextureFromSide(ForgeDirection.DOWN.ordinal());
|
||||
textures[3] = block.getBlockTextureFromSide(ForgeDirection.UP.ordinal());
|
||||
textures[4] = block.getBlockTextureFromSide(ForgeDirection.WEST.ordinal());
|
||||
textures[5] = block.getBlockTextureFromSide(ForgeDirection.EAST.ordinal());
|
||||
|
||||
textures[5] = block.getBlockTextureFromSide(ForgeDirection.EAST.ordinal());
|
||||
|
||||
CubeRenderer.render(bb, textures, null);
|
||||
|
||||
|
||||
if (doDraw) {
|
||||
Tessellator.instance.draw();
|
||||
}
|
||||
@@ -48,14 +46,14 @@ public class ElectricLightRenderer implements ISimpleBlockRenderingHandler {
|
||||
bb = bb.translate(x, y, z);
|
||||
RenderUtil.setTesselatorBrightness(world, x, y, z);
|
||||
|
||||
Icon[] textures = new Icon[6];
|
||||
Icon[] textures = new Icon[6];
|
||||
textures[0] = block.getBlockTexture(world, x, y, z, ForgeDirection.NORTH.ordinal());
|
||||
textures[1] = block.getBlockTexture(world, x, y, z, ForgeDirection.SOUTH.ordinal());
|
||||
textures[2] = block.getBlockTexture(world, x, y, z, ForgeDirection.UP.ordinal());
|
||||
textures[3] = block.getBlockTexture(world, x, y, z, ForgeDirection.DOWN.ordinal());
|
||||
textures[4] = block.getBlockTexture(world, x, y, z, ForgeDirection.WEST.ordinal());
|
||||
textures[5] = block.getBlockTexture(world, x, y, z, ForgeDirection.EAST.ordinal());
|
||||
|
||||
textures[5] = block.getBlockTexture(world, x, y, z, ForgeDirection.EAST.ordinal());
|
||||
|
||||
CubeRenderer.render(bb, textures, null);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -3,23 +3,22 @@ package crazypants.enderio.machine.light;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.PacketHandler;
|
||||
import crazypants.enderio.power.BasicCapacitor;
|
||||
import crazypants.enderio.power.Capacitors;
|
||||
import crazypants.enderio.power.IInternalPowerReceptor;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
import crazypants.util.ForgeDirectionOffsets;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.PacketHandler;
|
||||
import crazypants.enderio.power.Capacitors;
|
||||
import crazypants.enderio.power.IInternalPowerReceptor;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
import crazypants.util.ForgeDirectionOffsets;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
|
||||
public class TileElectricLight extends TileEntity implements IInternalPowerReceptor {
|
||||
|
||||
@@ -36,7 +35,7 @@ public class TileElectricLight extends TileEntity implements IInternalPowerRecep
|
||||
private int[] lightNodeCoords;
|
||||
|
||||
private boolean updatingLightNodes = false;
|
||||
|
||||
|
||||
private boolean lastActive = false;
|
||||
|
||||
public TileElectricLight() {
|
||||
@@ -75,7 +74,7 @@ public class TileElectricLight extends TileEntity implements IInternalPowerRecep
|
||||
float stored = powerHandler.getEnergyStored();
|
||||
powerHandler.update();
|
||||
powerHandler.setEnergy(stored);
|
||||
|
||||
|
||||
if (hasRedstone) {
|
||||
powerHandler.setEnergy(Math.max(0, powerHandler.getEnergyStored() - MJ_USE_PER_TICK));
|
||||
}
|
||||
@@ -86,7 +85,7 @@ public class TileElectricLight extends TileEntity implements IInternalPowerRecep
|
||||
updateLightNodes();
|
||||
}
|
||||
|
||||
if (isActivated && !lastActive || init) {
|
||||
if (isActivated && !lastActive || init) {
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, isActivated ? 1 : 0, 2);
|
||||
for (TileLightNode ln : lightNodes) {
|
||||
if (ln != null) {
|
||||
@@ -138,29 +137,29 @@ public class TileElectricLight extends TileEntity implements IInternalPowerRecep
|
||||
}
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (dir != face && dir != face.getOpposite()) { // don't project behind us
|
||||
if (dir != face && dir != face.getOpposite()) { // don't project behind
|
||||
// us
|
||||
Vector3d offset = ForgeDirectionOffsets.forDirCopy(dir);
|
||||
addNodeInDirection(new Vector3d(offset));
|
||||
addNodeInDirection(offset.add(ForgeDirectionOffsets.forDirCopy(face.getOpposite())));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addNodeInDirection(ForgeDirectionOffsets.forDirCopy(face.getOpposite()));
|
||||
|
||||
|
||||
Vector3d[] diags = new Vector3d[2];
|
||||
if(face.offsetX != 0) {
|
||||
if (face.offsetX != 0) {
|
||||
diags[0] = ForgeDirectionOffsets.forDirCopy(ForgeDirection.UP);
|
||||
diags[1] = ForgeDirectionOffsets.forDirCopy(ForgeDirection.SOUTH);
|
||||
} else if(face.offsetY != 0) {
|
||||
} else if (face.offsetY != 0) {
|
||||
diags[0] = ForgeDirectionOffsets.forDirCopy(ForgeDirection.EAST);
|
||||
diags[1] = ForgeDirectionOffsets.forDirCopy(ForgeDirection.SOUTH);
|
||||
} else {
|
||||
diags[0] = ForgeDirectionOffsets.forDirCopy(ForgeDirection.UP);
|
||||
diags[1] = ForgeDirectionOffsets.forDirCopy(ForgeDirection.EAST);
|
||||
}
|
||||
addDiaganals(diags, new Vector3d());
|
||||
addDiaganals(diags,ForgeDirectionOffsets.forDirCopy(face.getOpposite()));
|
||||
|
||||
}
|
||||
addDiaganals(diags, new Vector3d());
|
||||
addDiaganals(diags, ForgeDirectionOffsets.forDirCopy(face.getOpposite()));
|
||||
|
||||
} finally {
|
||||
updatingLightNodes = false;
|
||||
@@ -168,19 +167,19 @@ public class TileElectricLight extends TileEntity implements IInternalPowerRecep
|
||||
}
|
||||
|
||||
private void addDiaganals(Vector3d[] diags, Vector3d trans) {
|
||||
Vector3d offset = new Vector3d();
|
||||
Vector3d offset = new Vector3d();
|
||||
offset.set(diags[0]);
|
||||
offset.add(diags[1]);
|
||||
addNodeInDirection(offset.add(trans), true);
|
||||
|
||||
|
||||
offset.set(diags[0]);
|
||||
offset.sub(diags[1]);
|
||||
addNodeInDirection(offset.add(trans), true);
|
||||
|
||||
|
||||
offset.set(new Vector3d(diags[0]).negate());
|
||||
offset.add(diags[1]);
|
||||
addNodeInDirection(offset.add(trans), true);
|
||||
|
||||
|
||||
offset.set(new Vector3d(diags[0]).negate());
|
||||
offset.sub(diags[1]);
|
||||
addNodeInDirection(offset.add(trans), true);
|
||||
@@ -189,30 +188,29 @@ public class TileElectricLight extends TileEntity implements IInternalPowerRecep
|
||||
private void addNodeInDirection(Vector3d offset) {
|
||||
addNodeInDirection(offset, false);
|
||||
}
|
||||
|
||||
private void addNodeInDirection(Vector3d offset, boolean isDiag) {
|
||||
|
||||
|
||||
private void addNodeInDirection(Vector3d offset, boolean isDiag) {
|
||||
|
||||
boolean isAir = isAir(offset);
|
||||
boolean isTransp = isTranparent(offset);
|
||||
if (isAir || isTransp) {
|
||||
offset.scale(2);
|
||||
if (isAir(offset)) {
|
||||
addLightNode(offset, isDiag);
|
||||
if (isAir(offset)) {
|
||||
addLightNode(offset, isDiag);
|
||||
} else if (isAir) {
|
||||
offset.scale(0.5);
|
||||
addLightNode(offset, isDiag);
|
||||
offset.scale(0.5);
|
||||
addLightNode(offset, isDiag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isLightNode(Vector3d offset) {
|
||||
|
||||
private boolean isLightNode(Vector3d offset) {
|
||||
return worldObj.getBlockId(xCoord + (int) offset.x, yCoord + (int) offset.y, zCoord + (int) offset.z) == ModObject.blockLightNode.actualId;
|
||||
}
|
||||
|
||||
|
||||
private void clearLightNodes() {
|
||||
if (lightNodes != null) {
|
||||
for (TileLightNode ln : lightNodes) {
|
||||
for (TileLightNode ln : lightNodes) {
|
||||
worldObj.setBlockToAir(ln.xCoord, ln.yCoord, ln.zCoord);
|
||||
}
|
||||
lightNodes.clear();
|
||||
@@ -220,21 +218,21 @@ public class TileElectricLight extends TileEntity implements IInternalPowerRecep
|
||||
}
|
||||
|
||||
private void addLightNode(Vector3d offset, boolean isDiag) {
|
||||
|
||||
|
||||
int x = xCoord + (int) offset.x;
|
||||
int y = yCoord + (int) offset.y;
|
||||
int z = zCoord + (int) offset.z;
|
||||
|
||||
if(isLightNode(offset)) {
|
||||
TileLightNode te = (TileLightNode)worldObj.getBlockTileEntity(x,y,z);
|
||||
if(te.parentX != xCoord || te.parentY != yCoord || te.parentZ != zCoord) {
|
||||
//its somebody else's so leave it alone
|
||||
|
||||
if (isLightNode(offset)) {
|
||||
TileLightNode te = (TileLightNode) worldObj.getBlockTileEntity(x, y, z);
|
||||
if (te.parentX != xCoord || te.parentY != yCoord || te.parentZ != zCoord) {
|
||||
// its somebody else's so leave it alone
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
worldObj.setBlock(x,y,z, ModObject.blockLightNode.actualId);
|
||||
TileLightNode ln = (TileLightNode)worldObj.getBlockTileEntity(x,y,z);
|
||||
|
||||
worldObj.setBlock(x, y, z, ModObject.blockLightNode.actualId);
|
||||
TileLightNode ln = (TileLightNode) worldObj.getBlockTileEntity(x, y, z);
|
||||
ln.parentX = xCoord;
|
||||
ln.parentY = yCoord;
|
||||
ln.parentZ = zCoord;
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
package crazypants.enderio.machine.light;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.ModObject;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import crazypants.enderio.ModObject;
|
||||
|
||||
public class TileLightNode extends TileEntity {
|
||||
|
||||
@@ -16,48 +11,42 @@ public class TileLightNode extends TileEntity {
|
||||
int parentZ;
|
||||
|
||||
boolean isDiagnal = false;
|
||||
|
||||
|
||||
public TileElectricLight getParent() {
|
||||
TileEntity te = worldObj.getBlockTileEntity(parentX, parentY, parentZ);
|
||||
if(te instanceof TileElectricLight) {
|
||||
return (TileElectricLight)te;
|
||||
if (te instanceof TileElectricLight) {
|
||||
return (TileElectricLight) te;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if(worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
if(worldObj.getWorldTime() % 42 == 0) {
|
||||
if(worldObj.getBlockId(parentX, parentY, parentZ) != ModObject.blockElectricLight.actualId) {
|
||||
System.out.println("TileLightNode.updateEntity: ");
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
if (worldObj.getWorldTime() % 42 == 0) {
|
||||
if (worldObj.getBlockId(parentX, parentY, parentZ) != ModObject.blockElectricLight.actualId) {
|
||||
System.out.println("TileLightNode.updateEntity: ");
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onNeighbourChanged() {
|
||||
TileElectricLight p = getParent();
|
||||
if(p != null) {
|
||||
if (p != null) {
|
||||
p.nodeNeighbourChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onBlockRemoved() {
|
||||
TileElectricLight p = getParent();
|
||||
if(p != null) {
|
||||
if (p != null) {
|
||||
p.nodeRemoved(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound root) {
|
||||
super.readFromNBT(root);
|
||||
@@ -72,7 +61,7 @@ public class TileLightNode extends TileEntity {
|
||||
super.writeToNBT(root);
|
||||
root.setInteger("parentX", parentX);
|
||||
root.setInteger("parentY", parentY);
|
||||
root.setInteger("parentZ", parentZ);
|
||||
root.setInteger("parentZ", parentZ);
|
||||
root.setBoolean("isDiagnal", isDiagnal);
|
||||
}
|
||||
|
||||
@@ -81,7 +70,5 @@ public class TileLightNode extends TileEntity {
|
||||
return "TileLightNode [parentX=" + parentX + ", parentY=" + parentY + ", parentZ=" + parentZ + ", isDiagnal=" + isDiagnal + ", xCoord=" + xCoord
|
||||
+ ", yCoord=" + yCoord + ", zCoord=" + zCoord + ", tileEntityInvalid=" + tileEntityInvalid + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,30 +1,33 @@
|
||||
package crazypants.enderio.machine.painter;
|
||||
|
||||
import static crazypants.enderio.machine.RecipeInput.getInputForSlot;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.*;
|
||||
import crazypants.util.Util;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.IMachineRecipe;
|
||||
import crazypants.enderio.machine.RecipeInput;
|
||||
import crazypants.util.Util;
|
||||
|
||||
public class BasicPainterTemplate implements IMachineRecipe {
|
||||
|
||||
public static float DEFAULT_ENERGY_PER_TASK = 200; //5 seconds at the default energy use of 2 mj per tick.
|
||||
|
||||
public static float DEFAULT_ENERGY_PER_TASK = 200; // 5 seconds at the default
|
||||
// energy use of 2 mj per
|
||||
// tick.
|
||||
|
||||
public static boolean isValidSourceDefault(ItemStack paintSource) {
|
||||
if(paintSource == null) {
|
||||
if (paintSource == null) {
|
||||
return false;
|
||||
}
|
||||
Block block = Util.getBlockFromItemId(paintSource.itemID);
|
||||
if(block == null) {
|
||||
if (block == null) {
|
||||
return false;
|
||||
}
|
||||
return Block.isNormalCube(block.blockID) || block.blockID == Block.glass.blockID;
|
||||
}
|
||||
|
||||
|
||||
protected final int[] validIds;
|
||||
|
||||
protected BasicPainterTemplate(int... validTargetBlocksIds) {
|
||||
|
||||
protected BasicPainterTemplate(int... validTargetBlocksIds) {
|
||||
this.validIds = validTargetBlocksIds;
|
||||
}
|
||||
|
||||
@@ -42,28 +45,28 @@ public class BasicPainterTemplate implements IMachineRecipe {
|
||||
public ItemStack[] getCompletedResult(RecipeInput... inputs) {
|
||||
ItemStack target = getTarget(inputs);
|
||||
ItemStack paintSource = getPaintSource(inputs);
|
||||
if(target == null || paintSource == null) {
|
||||
if (target == null || paintSource == null) {
|
||||
return null;
|
||||
}
|
||||
ItemStack result = new ItemStack(getResultId(target), 1, target.getItemDamage());
|
||||
PainterUtil.setSourceBlock(result, paintSource.itemID, paintSource.getItemDamage());
|
||||
return new ItemStack[] {result};
|
||||
}
|
||||
|
||||
return new ItemStack[] { result };
|
||||
}
|
||||
|
||||
public ItemStack getTarget(RecipeInput... inputs) {
|
||||
return getInputForSlot(0, inputs);
|
||||
}
|
||||
|
||||
|
||||
public ItemStack getPaintSource(RecipeInput... inputs) {
|
||||
return getInputForSlot(1, inputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidInput(int slotNumber, ItemStack item) {
|
||||
if(slotNumber == 0) {
|
||||
if (slotNumber == 0) {
|
||||
return isValidTarget(item);
|
||||
}
|
||||
if(slotNumber == 1) {
|
||||
}
|
||||
if (slotNumber == 1) {
|
||||
return isValidPaintSource(item);
|
||||
}
|
||||
return false;
|
||||
@@ -73,35 +76,35 @@ public class BasicPainterTemplate implements IMachineRecipe {
|
||||
public String getMachineName() {
|
||||
return ModObject.blockPainter.unlocalisedName;
|
||||
}
|
||||
|
||||
public boolean isValidPaintSource(ItemStack paintSource) {
|
||||
|
||||
public boolean isValidPaintSource(ItemStack paintSource) {
|
||||
return isValidSourceDefault(paintSource);
|
||||
}
|
||||
|
||||
public boolean isValidTarget(ItemStack target) {
|
||||
//first check for exact matches, then check for item blocks
|
||||
if(target == null) {
|
||||
public boolean isValidTarget(ItemStack target) {
|
||||
// first check for exact matches, then check for item blocks
|
||||
if (target == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for(int i=0; i < validIds.length; i++) {
|
||||
if(validIds[i] == target.itemID) {
|
||||
|
||||
for (int i = 0; i < validIds.length; i++) {
|
||||
if (validIds[i] == target.itemID) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Block blk = Util.getBlockFromItemId(target.itemID);
|
||||
if(blk == null) {
|
||||
if (blk == null) {
|
||||
return false;
|
||||
}
|
||||
for(int i=0; i < validIds.length; i++) {
|
||||
if(validIds[i] == blk.blockID) {
|
||||
for (int i = 0; i < validIds.length; i++) {
|
||||
if (validIds[i] == blk.blockID) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
return getClass().getCanonicalName();
|
||||
@@ -110,27 +113,25 @@ public class BasicPainterTemplate implements IMachineRecipe {
|
||||
protected int getResultId(ItemStack target) {
|
||||
return target.itemID;
|
||||
}
|
||||
|
||||
|
||||
public int getQuantityConsumed(RecipeInput input) {
|
||||
return input.slotNumber == 0 ? 1 : 0;
|
||||
return input.slotNumber == 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeInput[] getQuantitiesConsumed(RecipeInput[] inputs) {
|
||||
RecipeInput consume = null;
|
||||
for(RecipeInput input : inputs) {
|
||||
if(input != null && input.slotNumber == 0 && input.item != null) {
|
||||
for (RecipeInput input : inputs) {
|
||||
if (input != null && input.slotNumber == 0 && input.item != null) {
|
||||
ItemStack consumed = input.item.copy();
|
||||
consumed.stackSize = 1;
|
||||
consume = new RecipeInput(input.slotNumber, consumed);
|
||||
}
|
||||
}
|
||||
if(consume != null) {
|
||||
return new RecipeInput[] {consume};
|
||||
}
|
||||
if (consume != null) {
|
||||
return new RecipeInput[] { consume };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -2,20 +2,25 @@ package crazypants.enderio.machine.painter;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFence;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.*;
|
||||
import cpw.mods.fml.common.registry.*;
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.*;
|
||||
import crazypants.enderio.machine.MachineRecipeRegistry;
|
||||
import crazypants.enderio.machine.RecipeInput;
|
||||
|
||||
public class BlockCustomFence extends BlockFence implements ITileEntityProvider {
|
||||
|
||||
@@ -37,7 +42,7 @@ public class BlockCustomFence extends BlockFence implements ITileEntityProvider
|
||||
private void init() {
|
||||
LanguageRegistry.addName(this, ModObject.blockCustomFence.name);
|
||||
GameRegistry.registerBlock(this, BlockItemCustomFence.class, ModObject.blockCustomFence.unlocalisedName);
|
||||
GameRegistry.registerTileEntity(TileEntityCustomBlock.class, ModObject.blockCustomFence.unlocalisedName + "TileEntity");
|
||||
GameRegistry.registerTileEntity(TileEntityCustomBlock.class, ModObject.blockCustomFence.unlocalisedName + "TileEntity");
|
||||
MachineRecipeRegistry.instance.registerRecipe(ModObject.blockPainter.unlocalisedName, new PainterTemplate());
|
||||
}
|
||||
|
||||
@@ -46,13 +51,13 @@ public class BlockCustomFence extends BlockFence implements ITileEntityProvider
|
||||
PainterUtil.setSourceBlock(result, id, damage);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getLightOpacity(World world, int x, int y, int z) {
|
||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
if (te instanceof TileEntityCustomBlock) {
|
||||
TileEntityCustomBlock tef = (TileEntityCustomBlock) te;
|
||||
if(tef.getSourceBlockId() > 0) {
|
||||
if (tef.getSourceBlockId() > 0) {
|
||||
return Math.min(super.getLightOpacity(world, x, y, z), Block.lightOpacity[tef.getSourceBlockId()]);
|
||||
}
|
||||
}
|
||||
@@ -68,11 +73,10 @@ public class BlockCustomFence extends BlockFence implements ITileEntityProvider
|
||||
return super.canPlaceTorchOnTop(world, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canConnectFenceTo(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {
|
||||
int l = par1IBlockAccess.getBlockId(par2, par3, par4);
|
||||
if(l == ModObject.blockCustomFenceGate.id) {
|
||||
if (l == ModObject.blockCustomFenceGate.id) {
|
||||
return true;
|
||||
}
|
||||
return super.canConnectFenceTo(par1IBlockAccess, par2, par3, par4);
|
||||
@@ -182,8 +186,8 @@ public class BlockCustomFence extends BlockFence implements ITileEntityProvider
|
||||
@Override
|
||||
public ItemStack[] getCompletedResult(RecipeInput... inputs) {
|
||||
ItemStack paintSource = RecipeInput.getInputForSlot(1, inputs);
|
||||
return new ItemStack[] {createItemStackForSourceBlock(paintSource.itemID, paintSource.getItemDamage())};
|
||||
}
|
||||
return new ItemStack[] { createItemStackForSourceBlock(paintSource.itemID, paintSource.getItemDamage()) };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,29 +2,33 @@ package crazypants.enderio.machine.painter;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFenceGate;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.*;
|
||||
import cpw.mods.fml.common.registry.*;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.*;
|
||||
import crazypants.enderio.machine.MachineRecipeRegistry;
|
||||
import crazypants.enderio.machine.RecipeInput;
|
||||
|
||||
public class BlockCustomFenceGate extends BlockFenceGate implements ITileEntityProvider{
|
||||
public class BlockCustomFenceGate extends BlockFenceGate implements ITileEntityProvider {
|
||||
|
||||
|
||||
public static int renderId;
|
||||
|
||||
|
||||
public static BlockCustomFenceGate create() {
|
||||
BlockCustomFenceGate result = new BlockCustomFenceGate();
|
||||
result.init();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public BlockCustomFenceGate() {
|
||||
super(ModObject.blockCustomFenceGate.id);
|
||||
setCreativeTab(null);
|
||||
@@ -33,14 +37,14 @@ public class BlockCustomFenceGate extends BlockFenceGate implements ITileEntityP
|
||||
setResistance(5.0F);
|
||||
setStepSound(soundWoodFootstep);
|
||||
}
|
||||
|
||||
|
||||
private void init() {
|
||||
LanguageRegistry.addName(this, ModObject.blockCustomFenceGate.name);
|
||||
GameRegistry.registerBlock(this, BlockItemCustomFenceGate.class, ModObject.blockCustomFenceGate.unlocalisedName);
|
||||
GameRegistry.registerTileEntity(TileEntityCustomBlock.class, ModObject.blockCustomFenceGate.unlocalisedName + "TileEntity");
|
||||
MachineRecipeRegistry.instance.registerRecipe(ModObject.blockPainter.unlocalisedName, new PainterTemplate());
|
||||
MachineRecipeRegistry.instance.registerRecipe(ModObject.blockPainter.unlocalisedName, new PainterTemplate());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return renderId;
|
||||
@@ -51,25 +55,24 @@ public class BlockCustomFenceGate extends BlockFenceGate implements ITileEntityP
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getLightOpacity(World world, int x, int y, int z) {
|
||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
if (te instanceof TileEntityCustomBlock) {
|
||||
TileEntityCustomBlock tef = (TileEntityCustomBlock) te;
|
||||
if(tef.getSourceBlockId() > 0) {
|
||||
if (tef.getSourceBlockId() > 0) {
|
||||
return Math.min(super.getLightOpacity(world, x, y, z), Block.lightOpacity[tef.getSourceBlockId()]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return super.getLightOpacity(world, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, int metadata) {
|
||||
return new TileEntityCustomBlock();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int blockSide) {
|
||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
@@ -83,7 +86,6 @@ public class BlockCustomFenceGate extends BlockFenceGate implements ITileEntityP
|
||||
}
|
||||
return blocksList[Block.anvil.blockID].getBlockTexture(world, x, y, z, blockSide);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
||||
@@ -99,19 +101,18 @@ public class BlockCustomFenceGate extends BlockFenceGate implements ITileEntityP
|
||||
tef.setSourceBlockId(id);
|
||||
tef.setSourceBlockMetadata(PainterUtil.getSourceBlockMetadata(stack));
|
||||
}
|
||||
//world.markBlockForUpdate(x, y, z);
|
||||
|
||||
// world.markBlockForUpdate(x, y, z);
|
||||
|
||||
int l = (MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3) % 4;
|
||||
world.setBlockMetadataWithNotify(x, y, z, l, 2);
|
||||
}
|
||||
|
||||
|
||||
public static ItemStack createItemStackForSourceBlock(int id, int damage) {
|
||||
ItemStack result = new ItemStack(ModObject.blockCustomFenceGate.actualId, 1, damage);
|
||||
PainterUtil.setSourceBlock(result, id, damage);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove the tile entity too.
|
||||
*/
|
||||
@@ -134,7 +135,7 @@ public class BlockCustomFenceGate extends BlockFenceGate implements ITileEntityP
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -146,18 +147,17 @@ public class BlockCustomFenceGate extends BlockFenceGate implements ITileEntityP
|
||||
return 0; // need to do custom dropping to maintain source metadata
|
||||
}
|
||||
|
||||
|
||||
public static final class PainterTemplate extends BasicPainterTemplate {
|
||||
|
||||
public PainterTemplate() {
|
||||
super(Block.fenceGate.blockID/*, Block.netherFence.blockID*/);
|
||||
super(Block.fenceGate.blockID/* , Block.netherFence.blockID */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getCompletedResult(RecipeInput... inputs) {
|
||||
ItemStack paintSource = RecipeInput.getInputForSlot(1, inputs);
|
||||
return new ItemStack[] {createItemStackForSourceBlock(paintSource.itemID, paintSource.getItemDamage())};
|
||||
}
|
||||
return new ItemStack[] { createItemStackForSourceBlock(paintSource.itemID, paintSource.getItemDamage()) };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,28 +9,27 @@ import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
|
||||
public class BlockCustomFenceGateRenderer implements ISimpleBlockRenderingHandler {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
|
||||
renderer.renderBlockAsItem(Block.fenceGate, metadata, 1);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
public int getRenderId() {
|
||||
return BlockCustomFenceGate.renderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess blockAccess, int par2, int par3, int par4, Block block, int modelId, RenderBlocks rb) {
|
||||
|
||||
BlockFenceGate par1BlockFenceGate = (BlockFenceGate)block;
|
||||
|
||||
|
||||
BlockFenceGate par1BlockFenceGate = (BlockFenceGate) block;
|
||||
|
||||
boolean flag = true;
|
||||
int l = rb.blockAccess.getBlockMetadata(par2, par3, par4);
|
||||
boolean flag1 = BlockFenceGate.isFenceGateOpen(l);
|
||||
@@ -41,18 +40,22 @@ public class BlockCustomFenceGateRenderer implements ISimpleBlockRenderingHandle
|
||||
float f3 = 0.9375F;
|
||||
float f4 = 0.3125F;
|
||||
float f5 = 1.0F;
|
||||
|
||||
if ((i1 == 2 || i1 == 0) && rb.blockAccess.getBlockId(par2 - 1, par3, par4) == Block.cobblestoneWall.blockID && rb.blockAccess.getBlockId(par2 + 1, par3, par4) == Block.cobblestoneWall.blockID ||
|
||||
(i1 == 3 || i1 == 1) && rb.blockAccess.getBlockId(par2, par3, par4 - 1) == Block.cobblestoneWall.blockID && rb.blockAccess.getBlockId(par2, par3, par4 + 1) == Block.cobblestoneWall.blockID ||
|
||||
(i1 == 2 || i1 == 0) && rb.blockAccess.getBlockId(par2 - 1, par3, par4) == ModObject.blockCustomWall.id && rb.blockAccess.getBlockId(par2 + 1, par3, par4) == ModObject.blockCustomWall.id ||
|
||||
(i1 == 3 || i1 == 1) && rb.blockAccess.getBlockId(par2, par3, par4 - 1) == ModObject.blockCustomWall.id && rb.blockAccess.getBlockId(par2, par3, par4 + 1) == ModObject.blockCustomWall.id)
|
||||
|
||||
if ((i1 == 2 || i1 == 0) && rb.blockAccess.getBlockId(par2 - 1, par3, par4) == Block.cobblestoneWall.blockID
|
||||
&& rb.blockAccess.getBlockId(par2 + 1, par3, par4) == Block.cobblestoneWall.blockID ||
|
||||
(i1 == 3 || i1 == 1) && rb.blockAccess.getBlockId(par2, par3, par4 - 1) == Block.cobblestoneWall.blockID
|
||||
&& rb.blockAccess.getBlockId(par2, par3, par4 + 1) == Block.cobblestoneWall.blockID ||
|
||||
(i1 == 2 || i1 == 0) && rb.blockAccess.getBlockId(par2 - 1, par3, par4) == ModObject.blockCustomWall.id
|
||||
&& rb.blockAccess.getBlockId(par2 + 1, par3, par4) == ModObject.blockCustomWall.id ||
|
||||
(i1 == 3 || i1 == 1) && rb.blockAccess.getBlockId(par2, par3, par4 - 1) == ModObject.blockCustomWall.id
|
||||
&& rb.blockAccess.getBlockId(par2, par3, par4 + 1) == ModObject.blockCustomWall.id)
|
||||
{
|
||||
f -= 0.1875F;
|
||||
f1 -= 0.1875F;
|
||||
f2 -= 0.1875F;
|
||||
f3 -= 0.1875F;
|
||||
f4 -= 0.1875F;
|
||||
f5 -= 0.1875F;
|
||||
f -= 0.1875F;
|
||||
f1 -= 0.1875F;
|
||||
f2 -= 0.1875F;
|
||||
f3 -= 0.1875F;
|
||||
f4 -= 0.1875F;
|
||||
f5 -= 0.1875F;
|
||||
}
|
||||
|
||||
rb.renderAllFaces = true;
|
||||
@@ -63,151 +66,151 @@ public class BlockCustomFenceGateRenderer implements ISimpleBlockRenderingHandle
|
||||
|
||||
if (i1 != 3 && i1 != 1)
|
||||
{
|
||||
f6 = 0.0F;
|
||||
f8 = 0.125F;
|
||||
f7 = 0.4375F;
|
||||
f9 = 0.5625F;
|
||||
rb.setRenderBounds(f6, f4, f7, f8, f5, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
f6 = 0.875F;
|
||||
f8 = 1.0F;
|
||||
rb.setRenderBounds(f6, f4, f7, f8, f5, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
f6 = 0.0F;
|
||||
f8 = 0.125F;
|
||||
f7 = 0.4375F;
|
||||
f9 = 0.5625F;
|
||||
rb.setRenderBounds(f6, f4, f7, f8, f5, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
f6 = 0.875F;
|
||||
f8 = 1.0F;
|
||||
rb.setRenderBounds(f6, f4, f7, f8, f5, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
}
|
||||
else
|
||||
{
|
||||
rb.uvRotateTop = 1;
|
||||
f6 = 0.4375F;
|
||||
f8 = 0.5625F;
|
||||
f7 = 0.0F;
|
||||
f9 = 0.125F;
|
||||
rb.setRenderBounds(f6, f4, f7, f8, f5, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
f7 = 0.875F;
|
||||
f9 = 1.0F;
|
||||
rb.setRenderBounds(f6, f4, f7, f8, f5, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.uvRotateTop = 0;
|
||||
rb.uvRotateTop = 1;
|
||||
f6 = 0.4375F;
|
||||
f8 = 0.5625F;
|
||||
f7 = 0.0F;
|
||||
f9 = 0.125F;
|
||||
rb.setRenderBounds(f6, f4, f7, f8, f5, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
f7 = 0.875F;
|
||||
f9 = 1.0F;
|
||||
rb.setRenderBounds(f6, f4, f7, f8, f5, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.uvRotateTop = 0;
|
||||
}
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
if (i1 == 2 || i1 == 0)
|
||||
{
|
||||
rb.uvRotateTop = 1;
|
||||
}
|
||||
if (i1 == 2 || i1 == 0)
|
||||
{
|
||||
rb.uvRotateTop = 1;
|
||||
}
|
||||
|
||||
if (i1 == 3)
|
||||
{
|
||||
rb.setRenderBounds(0.8125D, f, 0.0D, 0.9375D, f3, 0.125D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.8125D, f, 0.875D, 0.9375D, f3, 1.0D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.5625D, f, 0.0D, 0.8125D, f1, 0.125D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.5625D, f, 0.875D, 0.8125D, f1, 1.0D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.5625D, f2, 0.0D, 0.8125D, f3, 0.125D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.5625D, f2, 0.875D, 0.8125D, f3, 1.0D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
}
|
||||
else if (i1 == 1)
|
||||
{
|
||||
rb.setRenderBounds(0.0625D, f, 0.0D, 0.1875D, f3, 0.125D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.0625D, f, 0.875D, 0.1875D, f3, 1.0D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.1875D, f, 0.0D, 0.4375D, f1, 0.125D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.1875D, f, 0.875D, 0.4375D, f1, 1.0D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.1875D, f2, 0.0D, 0.4375D, f3, 0.125D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.1875D, f2, 0.875D, 0.4375D, f3, 1.0D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
}
|
||||
else if (i1 == 0)
|
||||
{
|
||||
rb.setRenderBounds(0.0D, f, 0.8125D, 0.125D, f3, 0.9375D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.875D, f, 0.8125D, 1.0D, f3, 0.9375D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.0D, f, 0.5625D, 0.125D, f1, 0.8125D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.875D, f, 0.5625D, 1.0D, f1, 0.8125D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.0D, f2, 0.5625D, 0.125D, f3, 0.8125D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.875D, f2, 0.5625D, 1.0D, f3, 0.8125D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
}
|
||||
else if (i1 == 2)
|
||||
{
|
||||
rb.setRenderBounds(0.0D, f, 0.0625D, 0.125D, f3, 0.1875D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.875D, f, 0.0625D, 1.0D, f3, 0.1875D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.0D, f, 0.1875D, 0.125D, f1, 0.4375D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.875D, f, 0.1875D, 1.0D, f1, 0.4375D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.0D, f2, 0.1875D, 0.125D, f3, 0.4375D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.875D, f2, 0.1875D, 1.0D, f3, 0.4375D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
}
|
||||
if (i1 == 3)
|
||||
{
|
||||
rb.setRenderBounds(0.8125D, f, 0.0D, 0.9375D, f3, 0.125D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.8125D, f, 0.875D, 0.9375D, f3, 1.0D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.5625D, f, 0.0D, 0.8125D, f1, 0.125D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.5625D, f, 0.875D, 0.8125D, f1, 1.0D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.5625D, f2, 0.0D, 0.8125D, f3, 0.125D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.5625D, f2, 0.875D, 0.8125D, f3, 1.0D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
}
|
||||
else if (i1 == 1)
|
||||
{
|
||||
rb.setRenderBounds(0.0625D, f, 0.0D, 0.1875D, f3, 0.125D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.0625D, f, 0.875D, 0.1875D, f3, 1.0D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.1875D, f, 0.0D, 0.4375D, f1, 0.125D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.1875D, f, 0.875D, 0.4375D, f1, 1.0D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.1875D, f2, 0.0D, 0.4375D, f3, 0.125D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.1875D, f2, 0.875D, 0.4375D, f3, 1.0D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
}
|
||||
else if (i1 == 0)
|
||||
{
|
||||
rb.setRenderBounds(0.0D, f, 0.8125D, 0.125D, f3, 0.9375D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.875D, f, 0.8125D, 1.0D, f3, 0.9375D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.0D, f, 0.5625D, 0.125D, f1, 0.8125D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.875D, f, 0.5625D, 1.0D, f1, 0.8125D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.0D, f2, 0.5625D, 0.125D, f3, 0.8125D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.875D, f2, 0.5625D, 1.0D, f3, 0.8125D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
}
|
||||
else if (i1 == 2)
|
||||
{
|
||||
rb.setRenderBounds(0.0D, f, 0.0625D, 0.125D, f3, 0.1875D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.875D, f, 0.0625D, 1.0D, f3, 0.1875D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.0D, f, 0.1875D, 0.125D, f1, 0.4375D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.875D, f, 0.1875D, 1.0D, f1, 0.4375D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.0D, f2, 0.1875D, 0.125D, f3, 0.4375D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(0.875D, f2, 0.1875D, 1.0D, f3, 0.4375D);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
}
|
||||
}
|
||||
else if (i1 != 3 && i1 != 1)
|
||||
{
|
||||
f6 = 0.375F;
|
||||
f8 = 0.5F;
|
||||
f7 = 0.4375F;
|
||||
f9 = 0.5625F;
|
||||
rb.setRenderBounds(f6, f, f7, f8, f3, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
f6 = 0.5F;
|
||||
f8 = 0.625F;
|
||||
rb.setRenderBounds(f6, f, f7, f8, f3, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
f6 = 0.625F;
|
||||
f8 = 0.875F;
|
||||
rb.setRenderBounds(f6, f, f7, f8, f1, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(f6, f2, f7, f8, f3, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
f6 = 0.125F;
|
||||
f8 = 0.375F;
|
||||
rb.setRenderBounds(f6, f, f7, f8, f1, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(f6, f2, f7, f8, f3, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
f6 = 0.375F;
|
||||
f8 = 0.5F;
|
||||
f7 = 0.4375F;
|
||||
f9 = 0.5625F;
|
||||
rb.setRenderBounds(f6, f, f7, f8, f3, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
f6 = 0.5F;
|
||||
f8 = 0.625F;
|
||||
rb.setRenderBounds(f6, f, f7, f8, f3, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
f6 = 0.625F;
|
||||
f8 = 0.875F;
|
||||
rb.setRenderBounds(f6, f, f7, f8, f1, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(f6, f2, f7, f8, f3, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
f6 = 0.125F;
|
||||
f8 = 0.375F;
|
||||
rb.setRenderBounds(f6, f, f7, f8, f1, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(f6, f2, f7, f8, f3, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
}
|
||||
else
|
||||
{
|
||||
rb.uvRotateTop = 1;
|
||||
f6 = 0.4375F;
|
||||
f8 = 0.5625F;
|
||||
f7 = 0.375F;
|
||||
f9 = 0.5F;
|
||||
rb.setRenderBounds(f6, f, f7, f8, f3, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
f7 = 0.5F;
|
||||
f9 = 0.625F;
|
||||
rb.setRenderBounds(f6, f, f7, f8, f3, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
f7 = 0.625F;
|
||||
f9 = 0.875F;
|
||||
rb.setRenderBounds(f6, f, f7, f8, f1, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(f6, f2, f7, f8, f3, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
f7 = 0.125F;
|
||||
f9 = 0.375F;
|
||||
rb.setRenderBounds(f6, f, f7, f8, f1, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(f6, f2, f7, f8, f3, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.uvRotateTop = 1;
|
||||
f6 = 0.4375F;
|
||||
f8 = 0.5625F;
|
||||
f7 = 0.375F;
|
||||
f9 = 0.5F;
|
||||
rb.setRenderBounds(f6, f, f7, f8, f3, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
f7 = 0.5F;
|
||||
f9 = 0.625F;
|
||||
rb.setRenderBounds(f6, f, f7, f8, f3, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
f7 = 0.625F;
|
||||
f9 = 0.875F;
|
||||
rb.setRenderBounds(f6, f, f7, f8, f1, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(f6, f2, f7, f8, f3, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
f7 = 0.125F;
|
||||
f9 = 0.375F;
|
||||
rb.setRenderBounds(f6, f, f7, f8, f1, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
rb.setRenderBounds(f6, f2, f7, f8, f3, f9);
|
||||
rb.renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
|
||||
}
|
||||
|
||||
rb.renderAllFaces = false;
|
||||
@@ -216,6 +219,4 @@ public class BlockCustomFenceGateRenderer implements ISimpleBlockRenderingHandle
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -2,18 +2,22 @@ package crazypants.enderio.machine.painter;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.*;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import cpw.mods.fml.common.registry.*;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.*;
|
||||
import crazypants.enderio.machine.MachineRecipeRegistry;
|
||||
import crazypants.enderio.machine.RecipeInput;
|
||||
import crazypants.util.Util;
|
||||
|
||||
public class BlockCustomStair extends BlockStairs implements ITileEntityProvider {
|
||||
@@ -23,7 +27,7 @@ public class BlockCustomStair extends BlockStairs implements ITileEntityProvider
|
||||
result.init();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
protected BlockCustomStair() {
|
||||
super(ModObject.blockCustomStair.actualId, Block.brick, 0);
|
||||
setCreativeTab(null);
|
||||
@@ -31,14 +35,12 @@ public class BlockCustomStair extends BlockStairs implements ITileEntityProvider
|
||||
setLightOpacity(0);
|
||||
}
|
||||
|
||||
|
||||
private void init() {
|
||||
LanguageRegistry.addName(this, ModObject.blockCustomStair.name);
|
||||
GameRegistry.registerBlock(this, BlockItemCustomStair.class, ModObject.blockCustomStair.unlocalisedName);
|
||||
GameRegistry.registerBlock(this, BlockItemCustomStair.class, ModObject.blockCustomStair.unlocalisedName);
|
||||
GameRegistry.registerTileEntity(TileEntityCustomBlock.class, ModObject.blockCustomStair.unlocalisedName + "TileEntity");
|
||||
MachineRecipeRegistry.instance.registerRecipe(ModObject.blockPainter.unlocalisedName, new PainterTemplate());
|
||||
}
|
||||
|
||||
|
||||
public static ItemStack createItemStackForSourceBlock(int id, int damage) {
|
||||
ItemStack result = new ItemStack(ModObject.blockCustomStair.id, 1, damage);
|
||||
@@ -47,7 +49,7 @@ public class BlockCustomStair extends BlockStairs implements ITileEntityProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) {
|
||||
public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
boolean flipped = ((meta & 4) != 0);
|
||||
return ((meta & 3) + side.ordinal() == 5) || (side == ForgeDirection.UP && flipped);
|
||||
@@ -61,11 +63,10 @@ public class BlockCustomStair extends BlockStairs implements ITileEntityProvider
|
||||
if (tef.getSourceBlockId() > 0 && tef.getSourceBlockId() < Block.blocksList.length) {
|
||||
return blocksList[tef.getSourceBlockId()].getIcon(blockSide, tef.getSourceBlockMetadata());
|
||||
}
|
||||
}
|
||||
}
|
||||
return blocksList[Block.anvil.blockID].getBlockTexture(world, x, y, z, blockSide);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world) {
|
||||
return null;
|
||||
@@ -81,14 +82,13 @@ public class BlockCustomStair extends BlockStairs implements ITileEntityProvider
|
||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
if (te instanceof TileEntityCustomBlock) {
|
||||
TileEntityCustomBlock tef = (TileEntityCustomBlock) te;
|
||||
if(tef.getSourceBlockId() > 0) {
|
||||
if (tef.getSourceBlockId() > 0) {
|
||||
return Math.min(super.getLightOpacity(world, x, y, z), Block.lightOpacity[tef.getSourceBlockId()]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return super.getLightOpacity(world, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
||||
@@ -142,31 +142,30 @@ public class BlockCustomStair extends BlockStairs implements ITileEntityProvider
|
||||
@Override
|
||||
public int quantityDropped(Random par1Random) {
|
||||
return 0; // need to do custom dropping to maintain source metadata
|
||||
}
|
||||
}
|
||||
|
||||
public static final class PainterTemplate extends BasicPainterTemplate {
|
||||
|
||||
public PainterTemplate() {
|
||||
public PainterTemplate() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getCompletedResult(RecipeInput... inputs) {
|
||||
ItemStack paintSource = RecipeInput.getInputForSlot(1, inputs);
|
||||
if(paintSource == null) {
|
||||
if (paintSource == null) {
|
||||
return new ItemStack[0];
|
||||
}
|
||||
return new ItemStack[] {createItemStackForSourceBlock(paintSource.itemID, paintSource.getItemDamage())};
|
||||
}
|
||||
|
||||
return new ItemStack[] { createItemStackForSourceBlock(paintSource.itemID, paintSource.getItemDamage()) };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidTarget(ItemStack target) {
|
||||
if(target == null) {
|
||||
if (target == null) {
|
||||
return false;
|
||||
}
|
||||
Block blk = Util.getBlockFromItemId(target.itemID);
|
||||
return blk instanceof BlockStairs;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -2,54 +2,55 @@ package crazypants.enderio.machine.painter;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockWall;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.*;
|
||||
import cpw.mods.fml.common.registry.*;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.*;
|
||||
import crazypants.enderio.machine.MachineRecipeRegistry;
|
||||
import crazypants.enderio.machine.RecipeInput;
|
||||
|
||||
public class BlockCustomWall extends BlockWall implements ITileEntityProvider {
|
||||
|
||||
|
||||
public static BlockCustomWall create() {
|
||||
BlockCustomWall result = new BlockCustomWall();
|
||||
result.init();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public BlockCustomWall() {
|
||||
super(ModObject.blockCustomWall.id, Block.cobblestone);
|
||||
setCreativeTab(null);
|
||||
setUnlocalizedName(ModObject.blockCustomWall.unlocalisedName);
|
||||
}
|
||||
|
||||
|
||||
private void init() {
|
||||
LanguageRegistry.addName(this, ModObject.blockCustomWall.name);
|
||||
GameRegistry.registerBlock(this, BlockItemCustomWall.class, ModObject.blockCustomWall.unlocalisedName);
|
||||
GameRegistry.registerTileEntity(TileEntityCustomBlock.class, ModObject.blockCustomWall.unlocalisedName + "TileEntity");
|
||||
MachineRecipeRegistry.instance.registerRecipe(ModObject.blockPainter.unlocalisedName, new PainterTemplate());
|
||||
}
|
||||
|
||||
|
||||
public static ItemStack createItemStackForSourceBlock(int id, int damage) {
|
||||
ItemStack result = new ItemStack(ModObject.blockCustomWall.id, 1, damage);
|
||||
PainterUtil.setSourceBlock(result, id, damage);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getLightOpacity(World world, int x, int y, int z) {
|
||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
if (te instanceof TileEntityCustomBlock) {
|
||||
TileEntityCustomBlock tef = (TileEntityCustomBlock) te;
|
||||
if(tef.getSourceBlockId() > 0) {
|
||||
if (tef.getSourceBlockId() > 0) {
|
||||
return Math.min(super.getLightOpacity(world, x, y, z), Block.lightOpacity[tef.getSourceBlockId()]);
|
||||
}
|
||||
}
|
||||
@@ -65,11 +66,10 @@ public class BlockCustomWall extends BlockWall implements ITileEntityProvider {
|
||||
return super.canPlaceTorchOnTop(world, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canConnectWallTo(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {
|
||||
int l = par1IBlockAccess.getBlockId(par2, par3, par4);
|
||||
if(l == ModObject.blockCustomFenceGate.id) {
|
||||
if (l == ModObject.blockCustomFenceGate.id) {
|
||||
return true;
|
||||
}
|
||||
return super.canConnectWallTo(par1IBlockAccess, par2, par3, par4);
|
||||
@@ -83,11 +83,10 @@ public class BlockCustomWall extends BlockWall implements ITileEntityProvider {
|
||||
if (tef.getSourceBlockId() > 0 && tef.getSourceBlockId() < Block.blocksList.length) {
|
||||
return blocksList[tef.getSourceBlockId()].getIcon(blockSide, tef.getSourceBlockMetadata());
|
||||
}
|
||||
}
|
||||
}
|
||||
return blocksList[Block.anvil.blockID].getBlockTexture(world, x, y, z, blockSide);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world) {
|
||||
return null;
|
||||
@@ -149,7 +148,7 @@ public class BlockCustomWall extends BlockWall implements ITileEntityProvider {
|
||||
@Override
|
||||
public int quantityDropped(Random par1Random) {
|
||||
return 0; // need to do custom dropping to maintain source metadata
|
||||
}
|
||||
}
|
||||
|
||||
public static final class PainterTemplate extends BasicPainterTemplate {
|
||||
|
||||
@@ -160,9 +159,8 @@ public class BlockCustomWall extends BlockWall implements ITileEntityProvider {
|
||||
@Override
|
||||
public ItemStack[] getCompletedResult(RecipeInput... inputs) {
|
||||
ItemStack paintSource = RecipeInput.getInputForSlot(1, inputs);
|
||||
return new ItemStack[] {createItemStackForSourceBlock(paintSource.itemID, paintSource.getItemDamage())};
|
||||
}
|
||||
return new ItemStack[] { createItemStackForSourceBlock(paintSource.itemID, paintSource.getItemDamage()) };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,11 +1,6 @@
|
||||
package crazypants.enderio.machine.painter;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockItemCustomFence extends ItemBlock {
|
||||
|
||||
@@ -14,8 +9,9 @@ public class BlockItemCustomFence extends ItemBlock {
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int par1) {
|
||||
return par1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -13,5 +13,5 @@ public class BlockItemCustomFenceGate extends ItemBlock {
|
||||
public int getMetadata(int par1) {
|
||||
return par1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,14 +1,12 @@
|
||||
package crazypants.enderio.machine.painter;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.*;
|
||||
import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
|
||||
public class BlockPainter extends AbstractMachineBlock<TileEntityPainter> {
|
||||
|
||||
@@ -41,7 +39,7 @@ public class BlockPainter extends AbstractMachineBlock<TileEntityPainter> {
|
||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
return new GuiPainter(player.inventory, (AbstractMachineEntity) te);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getGuiId() {
|
||||
return GuiHandler.GUI_ID_PAINTER;
|
||||
@@ -49,7 +47,7 @@ public class BlockPainter extends AbstractMachineBlock<TileEntityPainter> {
|
||||
|
||||
@Override
|
||||
protected String getMachineFrontIconKey(boolean active) {
|
||||
if(active) {
|
||||
if (active) {
|
||||
return "enderio:painterFrontOn";
|
||||
}
|
||||
return "enderio:painterFrontOff";
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
package crazypants.enderio.machine.painter;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.machine.GuiMachineBase;
|
||||
import crazypants.render.GuiContainerBase;
|
||||
import crazypants.render.GuiToolTip;
|
||||
import crazypants.render.RenderUtil;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -23,7 +18,7 @@ public class GuiPainter extends GuiMachineBase {
|
||||
public GuiPainter(InventoryPlayer par1InventoryPlayer, AbstractMachineEntity furnaceInventory) {
|
||||
super(furnaceInventory, new PainterContainer(par1InventoryPlayer, furnaceInventory));
|
||||
tileEntity = furnaceInventory;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the background layer for the GuiContainer (everything behind the
|
||||
@@ -32,17 +27,16 @@ public class GuiPainter extends GuiMachineBase {
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderUtil.bindTexture("enderio:textures/gui/painter.png");
|
||||
RenderUtil.bindTexture("enderio:textures/gui/painter.png");
|
||||
int k = (width - xSize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
|
||||
|
||||
drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
int i1;
|
||||
|
||||
|
||||
i1 = tileEntity.getProgressScaled(24);
|
||||
drawTexturedModalRect(k + 88, l + 34, 176, 14, i1 + 1, 16);
|
||||
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ package crazypants.enderio.machine.painter;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
@@ -27,7 +25,7 @@ public class PaintedItemRenderer implements IItemRenderer {
|
||||
if (type == ItemRenderType.INVENTORY) {
|
||||
RenderBlocks renderBlocks = (RenderBlocks) data[0];
|
||||
renderToInventory(item, renderBlocks);
|
||||
} else if (type == ItemRenderType.EQUIPPED) {
|
||||
} else if (type == ItemRenderType.EQUIPPED) {
|
||||
renderEquipped(item, (RenderBlocks) data[0]);
|
||||
} else if (type == ItemRenderType.ENTITY || type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||
renderEntity(item, (RenderBlocks) data[0]);
|
||||
@@ -36,12 +34,12 @@ public class PaintedItemRenderer implements IItemRenderer {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void renderEntity(ItemStack item, RenderBlocks renderBlocks) {
|
||||
Block block = PainterUtil.getSourceBlock(item);
|
||||
if (block != null) {
|
||||
renderBlocks.setOverrideBlockTexture(renderBlocks.getBlockIconFromSideAndMetadata(block, 2, item.getItemDamage()));
|
||||
}
|
||||
}
|
||||
renderBlocks.renderBlockAsItem(Block.blocksList[item.itemID], item.getItemDamage(), 1.0f);
|
||||
renderBlocks.clearOverrideBlockTexture();
|
||||
}
|
||||
@@ -62,7 +60,7 @@ public class PaintedItemRenderer implements IItemRenderer {
|
||||
Block block = PainterUtil.getSourceBlock(item);
|
||||
if (block != null) {
|
||||
renderBlocks.setOverrideBlockTexture(renderBlocks.getBlockIconFromSideAndMetadata(block, 2, item.getItemDamage()));
|
||||
}
|
||||
}
|
||||
renderBlocks.renderBlockAsItem(Block.blocksList[item.itemID], item.getItemDamage(), 1.0f);
|
||||
renderBlocks.clearOverrideBlockTexture();
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package crazypants.enderio.machine.painter;
|
||||
|
||||
import crazypants.enderio.machine.AbstractMachineContainer;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import crazypants.enderio.machine.AbstractMachineContainer;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
|
||||
public class PainterContainer extends AbstractMachineContainer {
|
||||
|
||||
@@ -20,7 +18,7 @@ public class PainterContainer extends AbstractMachineContainer {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack) {
|
||||
return tileEntity.isItemValidForSlot(0, itemStack);
|
||||
}
|
||||
}
|
||||
});
|
||||
addSlotToContainer(new Slot(tileEntity, 1, 37, 34) {
|
||||
@Override
|
||||
@@ -33,7 +31,7 @@ public class PainterContainer extends AbstractMachineContainer {
|
||||
public boolean isItemValid(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.util.StringTranslate;
|
||||
|
||||
public final class PainterUtil {
|
||||
|
||||
|
||||
Loaded 100 of 147 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user