mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-22 13:10:13 +00:00
Power and redstone conduits working (no gui)
This commit is contained in:
1 parent
b6a2514984
commit
c3a60feafc
36 files changed
+692
-879
No files matched your search
@@ -1,5 +1,8 @@
|
||||
package crazypants.enderio;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -11,8 +14,25 @@ import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import crazypants.enderio.conduit.BlockConduitBundle;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.TileConduitBundle;
|
||||
import crazypants.enderio.conduit.facade.FacadeRenderer;
|
||||
import crazypants.enderio.conduit.power.PowerConduit;
|
||||
import crazypants.enderio.conduit.power.PowerConduitRenderer;
|
||||
import crazypants.enderio.conduit.redstone.InsulatedRedstoneConduit;
|
||||
import crazypants.enderio.conduit.redstone.InsulatedRedstoneConduitRenderer;
|
||||
import crazypants.enderio.conduit.redstone.RedstoneConduit;
|
||||
import crazypants.enderio.conduit.redstone.RedstoneSwitch;
|
||||
import crazypants.enderio.conduit.redstone.RedstoneSwitchRenderer;
|
||||
import crazypants.enderio.conduit.render.ConduitBundleRenderer;
|
||||
import crazypants.enderio.conduit.render.ConduitRenderer;
|
||||
import crazypants.enderio.conduit.render.DefaultConduitRenderer;
|
||||
import crazypants.enderio.conduit.render.ItemConduitRenderer;
|
||||
import crazypants.enderio.enderface.EnderIoRenderer;
|
||||
import crazypants.enderio.enderface.TileEnderIO;
|
||||
import crazypants.enderio.item.YetaWrenchOverlayRenderer;
|
||||
import crazypants.enderio.item.YetaWrenchTickHandler;
|
||||
import crazypants.enderio.machine.hypercube.HyperCubeRenderer;
|
||||
import crazypants.enderio.machine.hypercube.TileHyperCube;
|
||||
import crazypants.enderio.machine.light.BlockElectricLight;
|
||||
@@ -47,21 +67,21 @@ public class ClientProxy extends CommonProxy {
|
||||
// @formatter:on
|
||||
|
||||
static {
|
||||
// RedstoneConduit.initIcons();
|
||||
// InsulatedRedstoneConduit.initIcons();
|
||||
// RedstoneSwitch.initIcons();
|
||||
// PowerConduit.initIcons();
|
||||
RedstoneConduit.initIcons();
|
||||
InsulatedRedstoneConduit.initIcons();
|
||||
RedstoneSwitch.initIcons();
|
||||
PowerConduit.initIcons();
|
||||
// LiquidConduit.initIcons();
|
||||
// AdvancedLiquidConduit.initIcons();
|
||||
// ItemConduit.initIcons();
|
||||
// MeConduit.initIcons();
|
||||
}
|
||||
|
||||
// private List<ConduitRenderer> conduitRenderers = new ArrayList<ConduitRenderer>();
|
||||
//
|
||||
// private DefaultConduitRenderer dcr = new DefaultConduitRenderer();
|
||||
//
|
||||
// private ConduitBundleRenderer cbr;
|
||||
private List<ConduitRenderer> conduitRenderers = new ArrayList<ConduitRenderer>();
|
||||
|
||||
private DefaultConduitRenderer dcr = new DefaultConduitRenderer();
|
||||
|
||||
private ConduitBundleRenderer cbr;
|
||||
|
||||
@Override
|
||||
public World getClientWorld() {
|
||||
@@ -73,13 +93,13 @@ public class ClientProxy extends CommonProxy {
|
||||
return Minecraft.getMinecraft().thePlayer;
|
||||
}
|
||||
|
||||
// public ConduitBundleRenderer getConduitBundleRenderer() {
|
||||
// return cbr;
|
||||
// }
|
||||
//
|
||||
// public void setCbr(ConduitBundleRenderer cbr) {
|
||||
// this.cbr = cbr;
|
||||
// }
|
||||
public ConduitBundleRenderer getConduitBundleRenderer() {
|
||||
return cbr;
|
||||
}
|
||||
|
||||
public void setCbr(ConduitBundleRenderer cbr) {
|
||||
this.cbr = cbr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
@@ -103,10 +123,10 @@ public class ClientProxy extends CommonProxy {
|
||||
CapBankRenderer2 cbr2 = new CapBankRenderer2();
|
||||
RenderingRegistry.registerBlockHandler(cbr2);
|
||||
|
||||
// ItemConduitRenderer itemConRenderer = new ItemConduitRenderer();
|
||||
ItemConduitRenderer itemConRenderer = new ItemConduitRenderer();
|
||||
// MinecraftForgeClient.registerItemRenderer(EnderIO.itemLiquidConduit, itemConRenderer);
|
||||
// MinecraftForgeClient.registerItemRenderer(EnderIO.itemPowerConduit, itemConRenderer);
|
||||
// MinecraftForgeClient.registerItemRenderer(EnderIO.itemRedstoneConduit, itemConRenderer);
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.itemPowerConduit, itemConRenderer);
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.itemRedstoneConduit, itemConRenderer);
|
||||
// MinecraftForgeClient.registerItemRenderer(EnderIO.itemItemConduit, itemConRenderer);
|
||||
// MinecraftForgeClient.registerItemRenderer(EnderIO.itemMeConduit, itemConRenderer);
|
||||
//
|
||||
@@ -123,20 +143,20 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockPaintedSlab), pir);
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.itemMachinePart, new MachinePartRenderer());
|
||||
// MinecraftForgeClient.registerItemRenderer(EnderIO.itemConduitFacade, new FacadeRenderer());
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.itemConduitFacade, new FacadeRenderer());
|
||||
|
||||
// cbr = new ConduitBundleRenderer((float) Config.conduitScale);
|
||||
// BlockConduitBundle.rendererId = RenderingRegistry.getNextAvailableRenderId();
|
||||
// RenderingRegistry.registerBlockHandler(cbr);
|
||||
// ClientRegistry.bindTileEntitySpecialRenderer(TileConduitBundle.class, cbr);
|
||||
cbr = new ConduitBundleRenderer((float) Config.conduitScale);
|
||||
BlockConduitBundle.rendererId = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderingRegistry.registerBlockHandler(cbr);
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileConduitBundle.class, cbr);
|
||||
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileTravelAnchor.class, new TravelEntitySpecialRenderer());
|
||||
|
||||
// conduitRenderers.add(RedstoneSwitchRenderer.getInstance());
|
||||
conduitRenderers.add(RedstoneSwitchRenderer.getInstance());
|
||||
// conduitRenderers.add(new AdvancedLiquidConduitRenderer());
|
||||
// conduitRenderers.add(new LiquidConduitRenderer());
|
||||
// conduitRenderers.add(new PowerConduitRenderer());
|
||||
// conduitRenderers.add(new InsulatedRedstoneConduitRenderer());
|
||||
conduitRenderers.add(new PowerConduitRenderer());
|
||||
conduitRenderers.add(new InsulatedRedstoneConduitRenderer());
|
||||
// conduitRenderers.add(new crazypants.enderio.conduit.item.ItemConduitRenderer());
|
||||
|
||||
EnderIoRenderer eior = new EnderIoRenderer();
|
||||
@@ -149,25 +169,26 @@ public class ClientProxy extends CommonProxy {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileHyperCube.class, hcr);
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockHyperCube), hcr);
|
||||
|
||||
// new YetaWrenchOverlayRenderer(EnderIO.itemYetaWench);
|
||||
// // Tick handler
|
||||
// if(Config.useSneakMouseWheelYetaWrench) {
|
||||
// MinecraftForge.EVENT_BUS.register(new YetaWrenchTickHandler());
|
||||
// }
|
||||
new YetaWrenchOverlayRenderer(EnderIO.itemYetaWench);
|
||||
if(Config.useSneakMouseWheelYetaWrench) {
|
||||
YetaWrenchTickHandler th = new YetaWrenchTickHandler();
|
||||
MinecraftForge.EVENT_BUS.register(th);
|
||||
FMLCommonHandler.instance().bus().register(th);
|
||||
}
|
||||
MinecraftForge.EVENT_BUS.register(TravelController.instance);
|
||||
FMLCommonHandler.instance().bus().register(TravelController.instance);
|
||||
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public ConduitRenderer getRendererForConduit(IConduit conduit) {
|
||||
// for (ConduitRenderer renderer : conduitRenderers) {
|
||||
// if(renderer.isRendererForConduit(conduit)) {
|
||||
// return renderer;
|
||||
// }
|
||||
// }
|
||||
// return dcr;
|
||||
// }
|
||||
@Override
|
||||
public ConduitRenderer getRendererForConduit(IConduit conduit) {
|
||||
for (ConduitRenderer renderer : conduitRenderers) {
|
||||
if(renderer.isRendererForConduit(conduit)) {
|
||||
return renderer;
|
||||
}
|
||||
}
|
||||
return dcr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getReachDistanceForPlayer(EntityPlayer entityPlayer) {
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.text.DecimalFormat;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.render.ConduitRenderer;
|
||||
|
||||
public class CommonProxy {
|
||||
|
||||
@@ -20,10 +22,9 @@ public class CommonProxy {
|
||||
return null;
|
||||
}
|
||||
|
||||
//TODO:1.7
|
||||
// public ConduitRenderer getRendererForConduit(IConduit conduit) {
|
||||
// return null;
|
||||
// }
|
||||
public ConduitRenderer getRendererForConduit(IConduit conduit) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public double getReachDistanceForPlayer(EntityPlayer entityPlayer) {
|
||||
return 5;
|
||||
|
||||
@@ -15,8 +15,17 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStartedEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import crazypants.enderio.conduit.BlockConduitBundle;
|
||||
import crazypants.enderio.conduit.facade.BlockConduitFacade;
|
||||
import crazypants.enderio.conduit.facade.ItemConduitFacade;
|
||||
import crazypants.enderio.conduit.geom.ConduitGeometryUtil;
|
||||
import crazypants.enderio.conduit.power.ItemPowerConduit;
|
||||
import crazypants.enderio.conduit.redstone.ItemRedstoneConduit;
|
||||
import crazypants.enderio.enderface.BlockEnderIO;
|
||||
import crazypants.enderio.enderface.EnderfaceRecipes;
|
||||
import crazypants.enderio.enderface.ItemEnderface;
|
||||
import crazypants.enderio.item.ItemRecipes;
|
||||
import crazypants.enderio.item.ItemYetaWrench;
|
||||
import crazypants.enderio.machine.MachineRecipes;
|
||||
import crazypants.enderio.machine.PacketRedstoneMode;
|
||||
import crazypants.enderio.machine.alloy.AlloyRecipeManager;
|
||||
@@ -92,13 +101,13 @@ public class EnderIO {
|
||||
public static BlockPaintedStair blockPaintedStair;
|
||||
public static BlockPaintedSlab blockPaintedSlab;
|
||||
public static BlockPaintedSlab blockPaintedDoubleSlab;
|
||||
//
|
||||
|
||||
// // Conduits
|
||||
// public static BlockConduitBundle blockConduitBundle;
|
||||
// public static BlockConduitFacade blockConduitFacade;
|
||||
// public static ItemConduitFacade itemConduitFacade;
|
||||
// public static ItemRedstoneConduit itemRedstoneConduit;
|
||||
// public static ItemPowerConduit itemPowerConduit;
|
||||
public static BlockConduitBundle blockConduitBundle;
|
||||
public static BlockConduitFacade blockConduitFacade;
|
||||
public static ItemConduitFacade itemConduitFacade;
|
||||
public static ItemRedstoneConduit itemRedstoneConduit;
|
||||
public static ItemPowerConduit itemPowerConduit;
|
||||
// public static ItemLiquidConduit itemLiquidConduit;
|
||||
// public static ItemItemConduit itemItemConduit;
|
||||
// public static ItemMeConduit itemMeConduit;
|
||||
@@ -116,8 +125,7 @@ public class EnderIO {
|
||||
public static BlockElectricLight blockElectricLight;
|
||||
public static BlockLightNode blockLightNode;
|
||||
|
||||
//
|
||||
// public static ItemYetaWrench itemYetaWench;
|
||||
public static ItemYetaWrench itemYetaWench;
|
||||
public static ItemMJReader itemMJReader;
|
||||
|
||||
//
|
||||
@@ -132,7 +140,7 @@ public class EnderIO {
|
||||
|
||||
Config.load(event);
|
||||
|
||||
// ConduitGeometryUtil.setupBounds((float) Config.conduitScale);
|
||||
ConduitGeometryUtil.setupBounds((float) Config.conduitScale);
|
||||
|
||||
blockEnderIo = BlockEnderIO.create();
|
||||
|
||||
@@ -170,18 +178,18 @@ public class EnderIO {
|
||||
itemAlloy = ItemAlloy.create();
|
||||
itemPowderIngot = ItemPowderIngot.create();
|
||||
|
||||
// blockConduitBundle = BlockConduitBundle.create();
|
||||
// blockConduitFacade = BlockConduitFacade.create();
|
||||
// itemConduitFacade = ItemConduitFacade.create();
|
||||
//
|
||||
// itemRedstoneConduit = ItemRedstoneConduit.create();
|
||||
// itemPowerConduit = ItemPowerConduit.create();
|
||||
blockConduitBundle = BlockConduitBundle.create();
|
||||
blockConduitFacade = BlockConduitFacade.create();
|
||||
itemConduitFacade = ItemConduitFacade.create();
|
||||
|
||||
itemRedstoneConduit = ItemRedstoneConduit.create();
|
||||
itemPowerConduit = ItemPowerConduit.create();
|
||||
// itemLiquidConduit = ItemLiquidConduit.create();
|
||||
// itemItemConduit = ItemItemConduit.create();
|
||||
// itemMeConduit = ItemMeConduit.create();
|
||||
//
|
||||
|
||||
// itemYetaWench = ItemYetaWrench.create();
|
||||
itemYetaWench = ItemYetaWrench.create();
|
||||
itemEnderface = ItemEnderface.create();
|
||||
itemTravelStaff = ItemTravelStaff.create();
|
||||
itemMJReader = ItemMJReader.create();
|
||||
@@ -204,8 +212,8 @@ public class EnderIO {
|
||||
//Register Custom Dungeon Loot here
|
||||
ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(
|
||||
new WeightedRandomChestContent(new ItemStack(EnderIO.itemAlloy, 1, Alloy.ELECTRICAL_STEEL.ordinal()), 1, 3, 60));
|
||||
// ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST)
|
||||
// .addItem(new WeightedRandomChestContent(new ItemStack(EnderIO.itemYetaWench, 1, 0), 1, 1, 15));
|
||||
ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST)
|
||||
.addItem(new WeightedRandomChestContent(new ItemStack(EnderIO.itemYetaWench, 1, 0), 1, 1, 15));
|
||||
ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(EnderIO.itemMJReader, 1, 0), 1, 1, 1));
|
||||
|
||||
ItemStack staff = new ItemStack(EnderIO.itemTravelStaff, 1, 0);
|
||||
@@ -225,11 +233,11 @@ public class EnderIO {
|
||||
ChestGenHooks.getInfo(ChestGenHooks.VILLAGE_BLACKSMITH).addItem(new WeightedRandomChestContent(staff, 1, 1, 5));
|
||||
ChestGenHooks.getInfo(ChestGenHooks.PYRAMID_DESERT_CHEST).addItem(new WeightedRandomChestContent(staff, 1, 1, 20));
|
||||
|
||||
// EnderfaceRecipes.addRecipes();
|
||||
EnderfaceRecipes.addRecipes();
|
||||
MaterialRecipes.addRecipes();
|
||||
// ConduitRecipes.addRecipes();
|
||||
MachineRecipes.addRecipes();
|
||||
// ItemRecipes.addRecipes();
|
||||
ItemRecipes.addRecipes();
|
||||
TeleportRecipes.addRecipes();
|
||||
|
||||
// triggerNoEnergy = new TriggerEnderIO("enderIO.trigger.noEnergy", 0);
|
||||
|
||||
@@ -1,19 +1,26 @@
|
||||
package crazypants.enderio.conduit;
|
||||
|
||||
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;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
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.util.ForgeDirection;
|
||||
|
||||
import java.util.*;
|
||||
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 {
|
||||
|
||||
@@ -431,14 +438,14 @@ public abstract class AbstractConduit implements IConduit {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNeighborBlockChange(int blockId) {
|
||||
public boolean onNeighborBlockChange(Block block) {
|
||||
// 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 == Block.getIdFromBlock(EnderIO.blockConduitBundle)) {
|
||||
if(block == EnderIO.blockConduitBundle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public abstract class AbstractConduitNetwork<T extends IConduit, I extends T> {
|
||||
public void notifyNetworkOfUpdate() {
|
||||
for (I con : conduits) {
|
||||
TileEntity te = con.getBundle().getEntity();
|
||||
te.worldObj.markBlockForUpdate(te.xCoord, te.yCoord, te.zCoord);
|
||||
te.getWorldObj().markBlockForUpdate(te.xCoord, te.yCoord, te.zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.Util;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public abstract class AbstractItemConduit extends Item implements IConduitItem {
|
||||
|
||||
@@ -54,7 +53,7 @@ public abstract class AbstractItemConduit extends Item implements IConduitItem {
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
|
||||
|
||||
BlockCoord placeAt = Util.canPlaceItem(stack, ModObject.blockConduitBundle.actualId, player, world, x, y, z, side);
|
||||
BlockCoord placeAt = Util.canPlaceItem(stack, EnderIO.blockConduitBundle, player, world, x, y, z, side);
|
||||
if(placeAt != null) {
|
||||
if(!world.isRemote) {
|
||||
if(world.setBlock(placeAt.x, placeAt.y, placeAt.z, EnderIO.blockConduitBundle, 0, 1)) {
|
||||
@@ -119,12 +118,9 @@ public abstract class AbstractItemConduit extends Item implements IConduitItem {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
for (int j = 0; j < subtypes.length; ++j) {
|
||||
par3List.add(new ItemStack(this, 1, j));
|
||||
}
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
package crazypants.enderio.conduit;
|
||||
|
||||
import static net.minecraftforge.common.ForgeDirection.getOrientation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.MapColor;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.client.particle.EntityDiggingFX;
|
||||
@@ -25,38 +20,36 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import powercrystals.minefactoryreloaded.api.rednet.IConnectableRedNet;
|
||||
import powercrystals.minefactoryreloaded.api.rednet.RedNetConnectionType;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.common.registry.TickRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.PacketHandler;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.conduit.geom.ConduitConnectorType;
|
||||
import crazypants.enderio.conduit.gui.ExternalConnectionContainer;
|
||||
import crazypants.enderio.conduit.gui.GuiExternalConnection;
|
||||
import crazypants.enderio.conduit.redstone.IInsulatedRedstoneConduit;
|
||||
import crazypants.enderio.conduit.redstone.IRedstoneConduit;
|
||||
import crazypants.enderio.enderface.BlockEio;
|
||||
import crazypants.enderio.machine.painter.PainterUtil;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.util.Util;
|
||||
|
||||
public class BlockConduitBundle extends Block implements ITileEntityProvider, IConnectableRedNet, IGuiHandler {
|
||||
public class BlockConduitBundle extends BlockEio implements IGuiHandler {
|
||||
|
||||
private static final String KEY_CONNECTOR_ICON = "enderIO:conduitConnector";
|
||||
|
||||
public static BlockConduitBundle create() {
|
||||
|
||||
PacketHandler.instance.addPacketProcessor(new ConduitPacketHandler());
|
||||
TickRegistry.registerTickHandler(ConduitNetworkTickHandler.instance, Side.SERVER);
|
||||
//TODO:1.7
|
||||
// PacketHandler.instance.addPacketProcessor(new ConduitPacketHandler());
|
||||
MinecraftForge.EVENT_BUS.register(ConduitNetworkTickHandler.instance);
|
||||
FMLCommonHandler.instance().bus().register(ConduitNetworkTickHandler.instance);
|
||||
|
||||
BlockConduitBundle result = new BlockConduitBundle();
|
||||
result.init();
|
||||
@@ -72,25 +65,22 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
private Random rand = new Random();
|
||||
|
||||
protected BlockConduitBundle() {
|
||||
super(ModObject.blockConduitBundle.id, new Material(MapColor.stoneColor));
|
||||
setHardness(0.5F);
|
||||
super(ModObject.blockConduitBundle.unlocalisedName, TileConduitBundle.class);
|
||||
setBlockBounds(0.334f, 0.334f, 0.334f, 0.667f, 0.667f, 0.667f);
|
||||
setStepSound(Block.soundMetalFootstep);
|
||||
setUnlocalizedName(ModObject.blockConduitBundle.unlocalisedName);
|
||||
setCreativeTab(null);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean addBlockHitEffects(World world, MovingObjectPosition target,
|
||||
public boolean addHitEffects(World world, MovingObjectPosition target,
|
||||
EffectRenderer effectRenderer) {
|
||||
IIcon tex = null;
|
||||
|
||||
TileConduitBundle cb = (TileConduitBundle)
|
||||
world.getTileEntity(target.blockX, target.blockY, target.blockZ);
|
||||
if(ConduitUtil.isSolidFacadeRendered(cb, Minecraft.getMinecraft().thePlayer)) {
|
||||
if(cb.getFacadeId() > 0 && Block.blocksList[cb.getFacadeId()] != null) {
|
||||
tex = Block.blocksList[cb.getFacadeId()].getIcon(target.sideHit,
|
||||
if(cb.getFacadeId() != null) {
|
||||
tex = cb.getFacadeId().getIcon(target.sideHit,
|
||||
cb.getFacadeMetadata());
|
||||
}
|
||||
} else if(target.hitInfo instanceof CollidableComponent) {
|
||||
@@ -111,7 +101,7 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean addBlockDestroyEffects(World world, int x, int y, int z, int
|
||||
public boolean addDestroyEffects(World world, int x, int y, int z, int
|
||||
meta, EffectRenderer effectRenderer) {
|
||||
IIcon tex = lastRemovedComponetIcon;
|
||||
byte b0 = 4;
|
||||
@@ -164,11 +154,9 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
effectRenderer.addEffect(digFX);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
LanguageRegistry.addName(this, ModObject.blockConduitBundle.name);
|
||||
GameRegistry.registerBlock(this, ModObject.blockConduitBundle.unlocalisedName);
|
||||
GameRegistry.registerTileEntity(TileConduitBundle.class, ModObject.blockConduitBundle.unlocalisedName + "TileEntity");
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
EnderIO.guiHandler.registerGuiHandler(GuiHandler.GUI_ID_EXTERNAL_CONNECTION_BASE + dir.ordinal(), this);
|
||||
}
|
||||
@@ -185,9 +173,9 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
IConduit conduit = bundle.getConduit(cc.conduitType);
|
||||
if(conduit != null) {
|
||||
return conduit.createItem();
|
||||
} else if(cc.conduitType == null && bundle.getFacadeId() > 0) {
|
||||
} else if(cc.conduitType == null && bundle.getFacadeId() != null) {
|
||||
// use the facde
|
||||
ItemStack fac = new ItemStack(ModObject.itemConduitFacade.actualId, 1, 0);
|
||||
ItemStack fac = new ItemStack(EnderIO.itemConduitFacade, 1, 0);
|
||||
PainterUtil.setSourceBlock(fac, bundle.getFacadeId(),
|
||||
bundle.getFacadeMetadata());
|
||||
return fac;
|
||||
@@ -203,12 +191,7 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
return 0;
|
||||
}
|
||||
IConduitBundle bun = (IConduitBundle) te;
|
||||
return bun.getFacadeId() > 0 ? bun.getFacadeMetadata() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int idDropped(int par1, Random par2Random, int par3) {
|
||||
return 0;
|
||||
return bun.getFacadeId() != null ? bun.getFacadeMetadata() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -221,20 +204,20 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister IIconRegister) {
|
||||
public void registerBlockIcons(IIconRegister IIconRegister) {
|
||||
connectorIcon = IIconRegister.registerIcon(KEY_CONNECTOR_ICON);
|
||||
blockIcon = connectorIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockSolidOnSide(World world, int x, int y, int z,
|
||||
public boolean isSideSolid(IBlockAccess world, int x, int y, int z,
|
||||
ForgeDirection side) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(!(te instanceof IConduitBundle)) {
|
||||
return false;
|
||||
}
|
||||
IConduitBundle con = (IConduitBundle) te;
|
||||
if(con.getFacadeId() > 0) {
|
||||
if(con.getFacadeId() != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -256,17 +239,7 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, int metadata) {
|
||||
return new TileConduitBundle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightOpacity(World world, int x, int y, int z) {
|
||||
public int getLightOpacity(IBlockAccess world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(!(te instanceof IConduitBundle)) {
|
||||
return super.getLightOpacity(world, x, y, z);
|
||||
@@ -282,7 +255,7 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
return super.getLightValue(world, x, y, z);
|
||||
}
|
||||
IConduitBundle con = (IConduitBundle) te;
|
||||
if(con.getFacadeId() > 0) {
|
||||
if(con.getFacadeId() != null) {
|
||||
return 0;
|
||||
}
|
||||
Collection<IConduit> conduits = con.getConduits();
|
||||
@@ -305,7 +278,7 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
if(con == null) {
|
||||
return 0;
|
||||
}
|
||||
return con.isProvidingStrongPower(getOrientation(par5));
|
||||
return con.isProvidingStrongPower(ForgeDirection.getOrientation(par5));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -320,7 +293,8 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
if(con == null) {
|
||||
return 0;
|
||||
}
|
||||
return con.isProvidingWeakPower(getOrientation(par5));
|
||||
|
||||
return con.isProvidingWeakPower(ForgeDirection.getOrientation(par5));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -329,72 +303,7 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedNetConnectionType getConnectionType(World world, int x, int y, int z, ForgeDirection side) {
|
||||
return RedNetConnectionType.CableAll;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getOutputValues(World world, int x, int y, int z, ForgeDirection side) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(!(te instanceof IConduitBundle)) {
|
||||
return new int[16];
|
||||
}
|
||||
IConduitBundle bundle = (IConduitBundle) te;
|
||||
IRedstoneConduit con = bundle.getConduit(IRedstoneConduit.class);
|
||||
if(con == null) {
|
||||
return new int[16];
|
||||
}
|
||||
return con.getOutputValues(world, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOutputValue(World world, int x, int y, int z, ForgeDirection side, int subnet) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(!(te instanceof IConduitBundle)) {
|
||||
return 0;
|
||||
}
|
||||
IConduitBundle bundle = (IConduitBundle) te;
|
||||
IRedstoneConduit con = bundle.getConduit(IRedstoneConduit.class);
|
||||
if(con == null) {
|
||||
return 0;
|
||||
}
|
||||
return con.getOutputValue(world, x, y, z, side, subnet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInputsChanged(World world, int x, int y, int z, ForgeDirection side, int[] inputValues) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof IConduitBundle) {
|
||||
IConduitBundle bundle = (IConduitBundle) te;
|
||||
IRedstoneConduit con = bundle.getConduit(IRedstoneConduit.class);
|
||||
if(con != null) {
|
||||
if(con instanceof IInsulatedRedstoneConduit) {
|
||||
((IInsulatedRedstoneConduit) con).onInputsChanged(side, inputValues);
|
||||
}
|
||||
con.onNeighborBlockChange(world.getBlockId(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInputChanged(World world, int x, int y, int z, ForgeDirection side, int inputValue) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof IConduitBundle) {
|
||||
IConduitBundle bundle = (IConduitBundle) te;
|
||||
IRedstoneConduit con = bundle.getConduit(IRedstoneConduit.class);
|
||||
if(con != null) {
|
||||
if(con instanceof IInsulatedRedstoneConduit) {
|
||||
((IInsulatedRedstoneConduit) con).onInputChanged(side, inputValue);
|
||||
}
|
||||
con.onNeighborBlockChange(world.getBlockId(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeBlockByPlayer(World world, EntityPlayer player, int x,
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x,
|
||||
int y, int z) {
|
||||
IConduitBundle te = (IConduitBundle) world.getTileEntity(x, y, z);
|
||||
if(te == null) {
|
||||
@@ -405,10 +314,10 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
List<ItemStack> drop = new ArrayList<ItemStack>();
|
||||
if(ConduitUtil.isSolidFacadeRendered(te, player)) {
|
||||
breakBlock = false;
|
||||
ItemStack fac = new ItemStack(ModObject.itemConduitFacade.actualId, 1, 0);
|
||||
ItemStack fac = new ItemStack(EnderIO.itemConduitFacade, 1, 0);
|
||||
PainterUtil.setSourceBlock(fac, te.getFacadeId(), te.getFacadeMetadata());
|
||||
drop.add(fac);
|
||||
te.setFacadeId(-1);
|
||||
te.setFacadeId(null);
|
||||
te.setFacadeMetadata(0);
|
||||
}
|
||||
|
||||
@@ -481,13 +390,13 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, int par5, int
|
||||
public void breakBlock(World world, int x, int y, int z, Block par5, int
|
||||
par6) {
|
||||
IConduitBundle te = (IConduitBundle) world.getTileEntity(x, y, z);
|
||||
if(te != null) {
|
||||
te.onBlockRemoved();
|
||||
}
|
||||
world.removeBlockTileEntity(x, y, z);
|
||||
world.removeTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -500,24 +409,24 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
}
|
||||
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if(stack != null && stack.itemID == ModObject.itemConduitFacade.actualId
|
||||
if(stack != null && stack.getItem() == EnderIO.itemConduitFacade
|
||||
&& !bundle.hasFacade()) {
|
||||
// Add facade
|
||||
if(player.isSneaking()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(PainterUtil.getSourceBlockId(player.getCurrentEquippedItem()) <= 0) {
|
||||
if(PainterUtil.getSourceBlock(player.getCurrentEquippedItem()) != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bundle.setFacadeId(PainterUtil.getSourceBlockId(player.getCurrentEquippedItem()));
|
||||
bundle.setFacadeId(PainterUtil.getSourceBlock(player.getCurrentEquippedItem()));
|
||||
bundle.setFacadeMetadata(PainterUtil.getSourceBlockMetadata(player.getCurrentEquippedItem()));
|
||||
if(!player.capabilities.isCreativeMode) {
|
||||
stack.stackSize--;
|
||||
}
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
bundle.getEntity().onInventoryChanged();
|
||||
bundle.getEntity().markDirty();
|
||||
return true;
|
||||
|
||||
} else if(ConduitUtil.isConduitEquipped(player)) {
|
||||
@@ -530,7 +439,7 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
if(!bundle.hasType(equipped.getBaseConduitType())) {
|
||||
bundle.addConduit(equipped.createConduit(stack));
|
||||
if(!player.capabilities.isCreativeMode) {
|
||||
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, stepSound.getPlaceSound(),
|
||||
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, stepSound.getStepResourcePath(),
|
||||
(stepSound.getVolume() + 1.0F) / 2.0F, stepSound.getPitch() * 0.8F);
|
||||
player.getCurrentEquippedItem().stackSize--;
|
||||
}
|
||||
@@ -549,7 +458,7 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
IToolWrench wrench = (IToolWrench) player.getCurrentEquippedItem().getItem();
|
||||
if(wrench.canWrench(player, x, y, z)) {
|
||||
if(!world.isRemote) {
|
||||
removeBlockByPlayer(world, player, x, y, z);
|
||||
removedByPlayer(world, player, x, y, z);
|
||||
if(player.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
((IToolWrench) player.getCurrentEquippedItem().getItem()).wrenchUsed(player, x, y, z);
|
||||
}
|
||||
@@ -576,7 +485,7 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
for (IConduit con : bundle.getConduits()) {
|
||||
if(ConduitUtil.renderConduit(player, con.getCollidableType())
|
||||
&& con.onBlockActivated(player, getHitForConduitType(all, con.getCollidableType()), all)) {
|
||||
bundle.getEntity().onInventoryChanged();
|
||||
bundle.getEntity().markDirty();
|
||||
result = true;
|
||||
}
|
||||
|
||||
@@ -606,7 +515,7 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
IConduit con = bundle.getConduit(rr.component.conduitType);
|
||||
if(con != null && con.onBlockActivated(player,
|
||||
rr, all)) {
|
||||
bundle.getEntity().onInventoryChanged();
|
||||
bundle.getEntity().markDirty();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -615,7 +524,7 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
IConduit closestConduit = bundle.getConduit(closest.component.conduitType);
|
||||
if(closestConduit != null && ConduitUtil.renderConduit(player, closestConduit) && closestConduit.onBlockActivated(player,
|
||||
closest, all)) {
|
||||
bundle.getEntity().onInventoryChanged();
|
||||
bundle.getEntity().markDirty();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -659,7 +568,7 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block
|
||||
blockId) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if((tile instanceof IConduitBundle)) {
|
||||
@@ -677,7 +586,7 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
return;
|
||||
}
|
||||
IConduitBundle con = (IConduitBundle) te;
|
||||
if(con.getFacadeId() > 0) {
|
||||
if(con.getFacadeId() != null) {
|
||||
setBlockBounds(0, 0, 0, 1, 1, 1);
|
||||
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist,
|
||||
par7Entity);
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
package crazypants.enderio.conduit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
|
||||
public class ConduitNetworkTickHandler implements ITickHandler {
|
||||
public class ConduitNetworkTickHandler {
|
||||
|
||||
public static final ConduitNetworkTickHandler instance = new ConduitNetworkTickHandler();
|
||||
|
||||
public static interface TickListener {
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData);
|
||||
public void tickStart(TickEvent.ServerTickEvent evt);
|
||||
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData);
|
||||
public void tickEnd(TickEvent.ServerTickEvent evt);
|
||||
}
|
||||
|
||||
private final List<TickListener> listeners = new ArrayList<TickListener>();
|
||||
@@ -27,29 +27,26 @@ public class ConduitNetworkTickHandler implements ITickHandler {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData) {
|
||||
for (TickListener h : listeners) {
|
||||
h.tickStart(type, tickData);
|
||||
@SubscribeEvent
|
||||
public void onServerTick(TickEvent.ServerTickEvent event) {
|
||||
if(event.phase == Phase.START) {
|
||||
tickStart(event);
|
||||
} else {
|
||||
tickEnd(event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
|
||||
public void tickStart(TickEvent.ServerTickEvent event) {
|
||||
for (TickListener h : listeners) {
|
||||
h.tickEnd(type, tickData);
|
||||
h.tickStart(event);
|
||||
}
|
||||
}
|
||||
|
||||
public void tickEnd(TickEvent.ServerTickEvent event) {
|
||||
for (TickListener h : listeners) {
|
||||
h.tickEnd(event);
|
||||
}
|
||||
listeners.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks() {
|
||||
return EnumSet.of(TickType.WORLD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -22,7 +23,6 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.Log;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.IConduitBundle.FacadeRenderState;
|
||||
import crazypants.enderio.conduit.item.IItemConduit;
|
||||
import crazypants.enderio.conduit.item.ItemConduitNetwork;
|
||||
@@ -64,7 +64,7 @@ public class ConduitUtil {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static void ensureValidNetwork(IConduit conduit) {
|
||||
TileEntity te = conduit.getBundle().getEntity();
|
||||
World world = te.worldObj;
|
||||
World world = te.getWorldObj();
|
||||
Collection<? extends IConduit> connections = ConduitUtil.getConnectedConduits(world, te.xCoord, te.yCoord, te.zCoord, conduit.getBaseConduitType());
|
||||
|
||||
if(reuseNetwork(conduit, connections, world)) {
|
||||
@@ -100,7 +100,7 @@ public class ConduitUtil {
|
||||
public static <T extends IConduit> void disconectConduits(T con, ForgeDirection connDir) {
|
||||
con.conduitConnectionRemoved(connDir);
|
||||
BlockCoord loc = con.getLocation().getLocation(connDir);
|
||||
IConduit neighbour = ConduitUtil.getConduit(con.getBundle().getEntity().worldObj, loc.x, loc.y, loc.z, con.getBaseConduitType());
|
||||
IConduit neighbour = ConduitUtil.getConduit(con.getBundle().getEntity().getWorldObj(), loc.x, loc.y, loc.z, con.getBaseConduitType());
|
||||
if(neighbour != null) {
|
||||
neighbour.conduitConnectionRemoved(connDir.getOpposite());
|
||||
if(neighbour.getNetwork() != null) {
|
||||
@@ -114,7 +114,7 @@ public class ConduitUtil {
|
||||
|
||||
public static <T extends IConduit> boolean joinConduits(T con, ForgeDirection faceHit) {
|
||||
BlockCoord loc = con.getLocation().getLocation(faceHit);
|
||||
IConduit neighbour = ConduitUtil.getConduit(con.getBundle().getEntity().worldObj, loc.x, loc.y, loc.z, con.getBaseConduitType());
|
||||
IConduit neighbour = ConduitUtil.getConduit(con.getBundle().getEntity().getWorldObj(), loc.x, loc.y, loc.z, con.getBaseConduitType());
|
||||
if(neighbour != null && con.canConnectToConduit(faceHit, neighbour) && neighbour.canConnectToConduit(faceHit.getOpposite(), con)) {
|
||||
con.conduitConnectionAdded(faceHit);
|
||||
neighbour.conduitConnectionAdded(faceHit.getOpposite());
|
||||
@@ -138,8 +138,9 @@ public class ConduitUtil {
|
||||
//in the light reaching bellow the block from the sky. To avoid
|
||||
//modifying core classes to expose this functionality I am just placing then breaking
|
||||
//a block above this one to force the check
|
||||
worldObj.setBlock(xCoord, yCoord + i, zCoord, 1, 0, 3);
|
||||
worldObj.setBlock(xCoord, yCoord + i, zCoord, Blocks.stone, 0, 3);
|
||||
worldObj.setBlockToAir(xCoord, yCoord + i, zCoord);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -159,11 +160,11 @@ public class ConduitUtil {
|
||||
}
|
||||
|
||||
public static boolean isSolidFacadeRendered(IConduitBundle bundle, EntityPlayer player) {
|
||||
return bundle.getFacadeId() > 0 && !isFacadeHidden(bundle, player);
|
||||
return bundle.getFacadeId() != null && !isFacadeHidden(bundle, player);
|
||||
}
|
||||
|
||||
public static boolean isFacadeHidden(IConduitBundle bundle, EntityPlayer player) {
|
||||
return bundle.getFacadeId() > 0 && (isToolEquipped(player) || isConduitEquipped(player) || isProbeEquipped(player));
|
||||
return bundle.getFacadeId() != null && (isToolEquipped(player) || isConduitEquipped(player) || isProbeEquipped(player));
|
||||
}
|
||||
|
||||
public static ConduitDisplayMode getDisplayMode(EntityPlayer player) {
|
||||
@@ -175,9 +176,11 @@ public class ConduitUtil {
|
||||
if(equipped == null) {
|
||||
return ConduitDisplayMode.ALL;
|
||||
}
|
||||
if(equipped.itemID != ModObject.itemYetaWrench.actualId) {
|
||||
return ConduitDisplayMode.ALL;
|
||||
}
|
||||
|
||||
// if(equipped.getItem() != EnderIO.itemYetaWrench) {
|
||||
// return ConduitDisplayMode.ALL;
|
||||
// }
|
||||
|
||||
ConduitDisplayMode result = ConduitDisplayMode.getDisplayMode(equipped);
|
||||
if(result == null) {
|
||||
return ConduitDisplayMode.ALL;
|
||||
@@ -252,7 +255,7 @@ public class ConduitUtil {
|
||||
if(equipped == null) {
|
||||
return false;
|
||||
}
|
||||
return equipped.itemID == ModObject.itemMJReader.actualId;
|
||||
return equipped.getItem() == EnderIO.itemMJReader;
|
||||
}
|
||||
|
||||
public static <T extends IConduit> T getConduit(IBlockAccess world, int x, int y, int z, Class<T> type) {
|
||||
@@ -300,7 +303,7 @@ public class ConduitUtil {
|
||||
conduit.writeToNBT(conduitBody);
|
||||
|
||||
conduitRoot.setString("conduitType", conduit.getClass().getCanonicalName());
|
||||
conduitRoot.setCompoundTag("conduit", conduitBody);
|
||||
conduitRoot.setTag("conduit", conduitBody);
|
||||
}
|
||||
|
||||
public static IConduit readConduitFromNBT(NBTTagCompound conduitRoot, short nbtVersion) {
|
||||
@@ -335,7 +338,7 @@ public class ConduitUtil {
|
||||
int signalStrength = getInternalSignalForColor(bundle, col);
|
||||
if(signalStrength < 15 && DyeColor.RED == col && bundle != null && bundle.getEntity() != null) {
|
||||
TileEntity te = bundle.getEntity();
|
||||
signalStrength = Math.max(signalStrength, te.worldObj.getStrongestIndirectPower(te.xCoord, te.yCoord, te.zCoord));
|
||||
signalStrength = Math.max(signalStrength, te.getWorldObj().getStrongestIndirectPower(te.xCoord, te.yCoord, te.zCoord));
|
||||
}
|
||||
return mode.isConditionMet(mode, signalStrength);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -118,6 +119,6 @@ public interface IConduit {
|
||||
|
||||
void updateEntity(World worldObj);
|
||||
|
||||
boolean onNeighborBlockChange(int blockId);
|
||||
boolean onNeighborBlockChange(Block blockId);
|
||||
|
||||
}
|
||||
@@ -4,10 +4,10 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import appeng.api.me.tiles.IGridMachine;
|
||||
import cofh.api.transport.IItemConduit;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -16,7 +16,7 @@ import crazypants.enderio.conduit.geom.Offset;
|
||||
import crazypants.enderio.power.IInternalPowerReceptor;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public interface IConduitBundle extends IInternalPowerReceptor, IFluidHandler, IItemConduit, IGridMachine {
|
||||
public interface IConduitBundle extends IInternalPowerReceptor, IFluidHandler, IItemConduit {
|
||||
|
||||
TileEntity getEntity();
|
||||
|
||||
@@ -54,7 +54,7 @@ public interface IConduitBundle extends IInternalPowerReceptor, IFluidHandler, I
|
||||
|
||||
// events
|
||||
|
||||
void onNeighborBlockChange(int blockId);
|
||||
void onNeighborBlockChange(Block blockId);
|
||||
|
||||
void onBlockRemoved();
|
||||
|
||||
@@ -80,11 +80,11 @@ public interface IConduitBundle extends IInternalPowerReceptor, IFluidHandler, I
|
||||
|
||||
boolean hasFacade();
|
||||
|
||||
void setFacadeId(int blockID);
|
||||
void setFacadeId(Block block);
|
||||
|
||||
void setFacadeId(int blockID, boolean triggerUpdate);
|
||||
void setFacadeId(Block block, boolean triggerUpdate);
|
||||
|
||||
int getFacadeId();
|
||||
Block getFacadeId();
|
||||
|
||||
void setFacadeMetadata(int meta);
|
||||
|
||||
|
||||
@@ -33,10 +33,10 @@ public class MpsUtil {
|
||||
}
|
||||
|
||||
public boolean isPowerFistEquiped(ItemStack equipped) {
|
||||
if(!isMpsInstalled || equipped == null || Item.itemsList[equipped.itemID] == null) {
|
||||
if(!isMpsInstalled || equipped == null || equipped.getItem() == null) {
|
||||
return false;
|
||||
}
|
||||
Item item = Item.itemsList[equipped.itemID];
|
||||
Item item = equipped.getItem();
|
||||
if(powerFistClass.isAssignableFrom(item.getClass())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -6,25 +6,22 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import appeng.api.WorldCoord;
|
||||
import appeng.api.me.util.IGridInterface;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.Config;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.PacketHandler;
|
||||
import crazypants.enderio.TileEntityEio;
|
||||
import crazypants.enderio.conduit.geom.CollidableCache;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.conduit.geom.ConduitConnectorType;
|
||||
@@ -34,19 +31,18 @@ import crazypants.enderio.conduit.geom.Offsets;
|
||||
import crazypants.enderio.conduit.geom.Offsets.Axis;
|
||||
import crazypants.enderio.conduit.item.IItemConduit;
|
||||
import crazypants.enderio.conduit.liquid.ILiquidConduit;
|
||||
import crazypants.enderio.conduit.me.IMeConduit;
|
||||
import crazypants.enderio.conduit.power.IPowerConduit;
|
||||
import crazypants.enderio.conduit.redstone.InsulatedRedstoneConduit;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
public class TileConduitBundle extends TileEntityEio implements IConduitBundle {
|
||||
|
||||
static final short NBT_VERSION = 1;
|
||||
|
||||
private final List<IConduit> conduits = new ArrayList<IConduit>();
|
||||
|
||||
private int facadeId = -1;
|
||||
private Block facadeId = null;
|
||||
private int facadeMeta = 0;
|
||||
|
||||
private boolean facadeChanged;
|
||||
@@ -79,9 +75,7 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtRoot) {
|
||||
super.writeToNBT(nbtRoot);
|
||||
|
||||
public void writeCustomNBT(NBTTagCompound nbtRoot) {
|
||||
NBTTagList conduitTags = new NBTTagList();
|
||||
for (IConduit conduit : conduits) {
|
||||
NBTTagCompound conduitRoot = new NBTTagCompound();
|
||||
@@ -89,28 +83,35 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
conduitTags.appendTag(conduitRoot);
|
||||
}
|
||||
nbtRoot.setTag("conduits", conduitTags);
|
||||
nbtRoot.setInteger("facadeId", facadeId);
|
||||
if(facadeId != null) {
|
||||
nbtRoot.setString("facadeId", Block.blockRegistry.getNameForObject(facadeId));
|
||||
} else {
|
||||
nbtRoot.setString("facadeId", "null");
|
||||
}
|
||||
nbtRoot.setInteger("facadeMeta", facadeMeta);
|
||||
nbtRoot.setShort("nbtVersion", NBT_VERSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtRoot) {
|
||||
super.readFromNBT(nbtRoot);
|
||||
|
||||
public void readCustomNBT(NBTTagCompound nbtRoot) {
|
||||
short nbtVersion = nbtRoot.getShort("nbtVersion");
|
||||
|
||||
conduits.clear();
|
||||
NBTTagList conduitTags = nbtRoot.getTagList("conduits");
|
||||
NBTTagList conduitTags = (NBTTagList) nbtRoot.getTag("conduits");
|
||||
for (int i = 0; i < conduitTags.tagCount(); i++) {
|
||||
NBTTagCompound conduitTag = (NBTTagCompound) conduitTags.tagAt(i);
|
||||
NBTTagCompound conduitTag = conduitTags.getCompoundTagAt(i);
|
||||
IConduit conduit = ConduitUtil.readConduitFromNBT(conduitTag, nbtVersion);
|
||||
if(conduit != null) {
|
||||
conduit.setBundle(this);
|
||||
conduits.add(conduit);
|
||||
}
|
||||
}
|
||||
facadeId = nbtRoot.getInteger("facadeId");
|
||||
String fs = nbtRoot.getString("facadeId");
|
||||
if(fs == null || "null".equals(fs)) {
|
||||
facadeId = null;
|
||||
} else {
|
||||
facadeId = Block.getBlockFromName(fs);
|
||||
}
|
||||
facadeMeta = nbtRoot.getInteger("facadeMeta");
|
||||
|
||||
if(worldObj != null && worldObj.isRemote) {
|
||||
@@ -121,11 +122,11 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
|
||||
@Override
|
||||
public boolean hasFacade() {
|
||||
return facadeId > 0;
|
||||
return facadeId != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacadeId(int blockID, boolean triggerUpdate) {
|
||||
public void setFacadeId(Block blockID, boolean triggerUpdate) {
|
||||
this.facadeId = blockID;
|
||||
if(triggerUpdate) {
|
||||
facadeChanged = true;
|
||||
@@ -133,12 +134,12 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacadeId(int blockID) {
|
||||
public void setFacadeId(Block blockID) {
|
||||
setFacadeId(blockID, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFacadeId() {
|
||||
public Block getFacadeId() {
|
||||
return facadeId;
|
||||
}
|
||||
|
||||
@@ -180,11 +181,6 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
lightOpacity = opacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
return PacketHandler.getPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
for (IConduit conduit : conduits) {
|
||||
@@ -213,8 +209,9 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
if(facadeChanged) {
|
||||
//force re-calc of lighting for both client and server
|
||||
ConduitUtil.forceSkylightRecalculation(worldObj, xCoord, yCoord, zCoord);
|
||||
worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
//worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
|
||||
worldObj.func_147451_t(xCoord, yCoord, zCoord);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
facadeChanged = false;
|
||||
}
|
||||
|
||||
@@ -237,7 +234,8 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
int shouldBeLO = rs == FacadeRenderState.FULL ? 255 : 0;
|
||||
if(curLO != shouldBeLO) {
|
||||
setLightOpacity(shouldBeLO);
|
||||
worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
|
||||
//worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
|
||||
worldObj.func_147451_t(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +253,7 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
|
||||
}
|
||||
if(markForUpdate) {
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -266,7 +264,7 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(int blockId) {
|
||||
public void onNeighborBlockChange(Block blockId) {
|
||||
boolean needsUpdate = false;
|
||||
for (IConduit conduit : conduits) {
|
||||
needsUpdate |= conduit.onNeighborBlockChange(blockId);
|
||||
@@ -793,74 +791,4 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldCoord getLocation() {
|
||||
return new WorldCoord(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return getConduit(IMeConduit.class) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPowerStatus(boolean hasPower) {
|
||||
IMeConduit ic = getConduit(IMeConduit.class);
|
||||
if(ic != null) {
|
||||
ic.setPoweredStatus(hasPower);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowered() {
|
||||
IMeConduit ic = getConduit(IMeConduit.class);
|
||||
if(ic != null) {
|
||||
return ic.isPowered();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridInterface getGrid() {
|
||||
IMeConduit ic = getConduit(IMeConduit.class);
|
||||
if(ic != null) {
|
||||
return ic.getGrid();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGrid(IGridInterface gi) {
|
||||
IMeConduit ic = getConduit(IMeConduit.class);
|
||||
if(ic != null) {
|
||||
ic.setGrid(gi);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPowerDrainPerTick() {
|
||||
IMeConduit ic = getConduit(IMeConduit.class);
|
||||
if(ic != null) {
|
||||
return ic.getPowerDrainPerTick();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetworkReady(boolean isReady) {
|
||||
IMeConduit ic = getConduit(IMeConduit.class);
|
||||
if(ic != null) {
|
||||
ic.setNetworkReady(isReady);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMachineActive() {
|
||||
IMeConduit ic = getConduit(IMeConduit.class);
|
||||
if(ic != null) {
|
||||
return ic.isMachineActive();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import net.minecraft.util.IIcon;
|
||||
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;
|
||||
@@ -26,38 +25,33 @@ public class BlockConduitFacade extends Block {
|
||||
private Block blockOverride;
|
||||
|
||||
private BlockConduitFacade() {
|
||||
super(ModObject.blockConduitFacade.id, new Material(MapColor.stoneColor));
|
||||
super(new Material(MapColor.stoneColor));
|
||||
setHardness(0.5F);
|
||||
setStepSound(Block.soundStoneFootstep);
|
||||
setUnlocalizedName(ModObject.blockConduitFacade.unlocalisedName);
|
||||
setStepSound(Block.soundTypeStone);
|
||||
setBlockName(ModObject.blockConduitFacade.unlocalisedName);
|
||||
setCreativeTab(null);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
LanguageRegistry.addName(this, "Utility for Rendering DO NOT USE");
|
||||
GameRegistry.registerBlock(this, ModObject.blockConduitFacade.unlocalisedName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister IIconRegister) {
|
||||
public void registerBlockIcons(IIconRegister IIconRegister) {
|
||||
blockIcon = IIconRegister.registerIcon("enderio:conduitFacade");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getBlockTexture(IBlockAccess ba, int x, int y, int z, int side) {
|
||||
public IIcon getIcon(IBlockAccess ba, int x, int y, int z, int side) {
|
||||
TileEntity te = ba.getTileEntity(x, y, z);
|
||||
if(!(te instanceof IConduitBundle)) {
|
||||
return blockIcon;
|
||||
}
|
||||
IConduitBundle cb = (IConduitBundle) te;
|
||||
int id = cb.getFacadeId();
|
||||
int meta = cb.getFacadeMetadata();
|
||||
if(id <= 0 || id == blockID) {
|
||||
return blockIcon;
|
||||
}
|
||||
Block block = Block.blocksList[id];
|
||||
Block block = cb.getFacadeId();
|
||||
if(block != null) {
|
||||
int meta = cb.getFacadeMetadata();
|
||||
return block.getIcon(side, meta);
|
||||
}
|
||||
return blockIcon;
|
||||
@@ -112,12 +106,12 @@ public class BlockConduitFacade extends Block {
|
||||
return;
|
||||
}
|
||||
|
||||
int id = cb.getFacadeId();
|
||||
Block block = cb.getFacadeId();
|
||||
int meta = cb.getFacadeMetadata();
|
||||
if(id <= 0 || id == blockID) {
|
||||
if(block == null || block == this) {
|
||||
return;
|
||||
}
|
||||
blockOverride = Block.blocksList[id];
|
||||
blockOverride = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,14 +126,13 @@ public class BlockConduitFacade extends Block {
|
||||
private Mimic getMimic(IBlockAccess ba, int x, int y, int z) {
|
||||
TileEntity te = ba.getTileEntity(x, y, z);
|
||||
if(!(te instanceof IConduitBundle)) {
|
||||
// System.out.println("BlockConduitFacade.getMimic: Not a conduit bundle");
|
||||
return null;
|
||||
}
|
||||
IConduitBundle cb = (IConduitBundle) te;
|
||||
int id = cb.getFacadeId();
|
||||
Block id = cb.getFacadeId();
|
||||
int meta = cb.getFacadeMetadata();
|
||||
|
||||
if(id <= 0) {
|
||||
if(id == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -147,15 +140,13 @@ public class BlockConduitFacade extends Block {
|
||||
}
|
||||
|
||||
class Mimic {
|
||||
int id;
|
||||
|
||||
int meta;
|
||||
Block block;
|
||||
|
||||
private Mimic(int id, int meta) {
|
||||
super();
|
||||
this.id = id;
|
||||
private Mimic(Block block, int meta) {
|
||||
this.block = block;
|
||||
this.meta = meta;
|
||||
this.block = Block.blocksList[id];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package crazypants.enderio.conduit.facade;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
@@ -82,7 +83,7 @@ public class FacadeRenderer implements IItemRenderer {
|
||||
|
||||
} else {
|
||||
renderBlocks.setOverrideBlockTexture(EnderIO.itemConduitFacade.getIconFromDamage(0));
|
||||
renderBlocks.renderBlockAsItem(Block.stone, 0, 1.0F);
|
||||
renderBlocks.renderBlockAsItem(Blocks.stone, 0, 1.0F);
|
||||
renderBlocks.clearOverrideBlockTexture();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package crazypants.enderio.conduit.facade;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -17,8 +17,6 @@ import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
import crazypants.enderio.crafting.IEnderIoRecipe;
|
||||
import crazypants.enderio.crafting.impl.EnderIoRecipe;
|
||||
import crazypants.enderio.machine.painter.BasicPainterTemplate;
|
||||
import crazypants.enderio.machine.painter.PainterUtil;
|
||||
|
||||
@@ -33,7 +31,6 @@ public class ItemConduitFacade extends Item {
|
||||
protected IIcon overlayIcon;
|
||||
|
||||
protected ItemConduitFacade() {
|
||||
super(ModObject.itemConduitFacade.id);
|
||||
setCreativeTab(EnderIOTab.tabEnderIO);
|
||||
setUnlocalizedName("enderio." + ModObject.itemConduitFacade.name());
|
||||
setMaxStackSize(64);
|
||||
@@ -67,11 +64,11 @@ public class ItemConduitFacade extends Item {
|
||||
int placeZ = z + dir.offsetZ;
|
||||
|
||||
if(player.canPlayerEdit(placeX, placeY, placeZ, side, itemStack) && world.isAirBlock(placeX, placeY, placeZ)
|
||||
&& PainterUtil.getSourceBlockId(itemStack) > 0) {
|
||||
&& PainterUtil.getSourceBlock(itemStack) != null) {
|
||||
|
||||
world.setBlock(placeX, placeY, placeZ, EnderIO.blockConduitBundle.blockID);
|
||||
world.setBlock(placeX, placeY, placeZ, EnderIO.blockConduitBundle);
|
||||
IConduitBundle bundle = (IConduitBundle) world.getTileEntity(placeX, placeY, placeZ);
|
||||
bundle.setFacadeId(PainterUtil.getSourceBlockId(itemStack));
|
||||
bundle.setFacadeId(PainterUtil.getSourceBlock(itemStack));
|
||||
bundle.setFacadeMetadata(PainterUtil.getSourceBlockMetadata(itemStack));
|
||||
if(!player.capabilities.isCreativeMode) {
|
||||
itemStack.stackSize--;
|
||||
@@ -91,15 +88,15 @@ public class ItemConduitFacade extends Item {
|
||||
@Override
|
||||
public void onCreated(ItemStack itemStack, World world, EntityPlayer player) {
|
||||
if(PainterUtil.getSourceBlock(itemStack) == null) {
|
||||
PainterUtil.setSourceBlock(itemStack, ModObject.itemConduitFacade.id, 0);
|
||||
PainterUtil.setSourceBlock(itemStack, EnderIO.blockConduitFacade, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack createItemStackForSourceBlock(int id, int itemDamage) {
|
||||
if(id < 1) {
|
||||
id = ModObject.blockConduitFacade.id;
|
||||
public ItemStack createItemStackForSourceBlock(Block id, int itemDamage) {
|
||||
if(id == null) {
|
||||
id = EnderIO.blockConduitFacade;
|
||||
}
|
||||
ItemStack result = new ItemStack(itemID, 1, 0);
|
||||
ItemStack result = new ItemStack(id, 1, 0);
|
||||
PainterUtil.setSourceBlock(result, id, itemDamage);
|
||||
return result;
|
||||
}
|
||||
@@ -114,16 +111,21 @@ public class ItemConduitFacade extends Item {
|
||||
public static final class FacadePainterRecipe extends BasicPainterTemplate {
|
||||
|
||||
public FacadePainterRecipe() {
|
||||
super(ModObject.itemConduitFacade.actualId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IEnderIoRecipe> getAllRecipes() {
|
||||
ItemStack is = new ItemStack(ModObject.itemConduitFacade.actualId, 1, 0);
|
||||
IEnderIoRecipe recipe = new EnderIoRecipe(IEnderIoRecipe.PAINTER_ID, DEFAULT_ENERGY_PER_TASK, is, is);
|
||||
return Collections.singletonList(recipe);
|
||||
public boolean isValidTarget(ItemStack target) {
|
||||
return target != null && target.getItem() == EnderIO.itemConduitFacade;
|
||||
}
|
||||
|
||||
//TODO:1.7
|
||||
// @Override
|
||||
// public List<IEnderIoRecipe> getAllRecipes() {
|
||||
// ItemStack is = new ItemStack(ModObject.itemConduitFacade.actualId, 1, 0);
|
||||
// IEnderIoRecipe recipe = new EnderIoRecipe(IEnderIoRecipe.PAINTER_ID, DEFAULT_ENERGY_PER_TASK, is, is);
|
||||
// return Collections.singletonList(recipe);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package crazypants.enderio.conduit.power;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -12,7 +11,7 @@ import java.util.Set;
|
||||
import net.minecraft.world.World;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
|
||||
import crazypants.enderio.Config;
|
||||
import crazypants.enderio.conduit.ConduitNetworkTickHandler;
|
||||
import crazypants.enderio.conduit.ConduitNetworkTickHandler.TickListener;
|
||||
@@ -154,7 +153,7 @@ public class NetworkPowerManager {
|
||||
if(r.emmiter.getPowerHandler() != null && r.emmiter.getPowerHandler().isPowerSource(r.direction)) {
|
||||
|
||||
// do a summy recieve or recieve energy counter will never tick down
|
||||
float es = r.emmiter.getPowerHandler().getEnergyStored();
|
||||
double es = r.emmiter.getPowerHandler().getEnergyStored();
|
||||
PowerReceiver pr = r.emmiter.getPowerReceiver(r.direction.getOpposite());
|
||||
pr.receiveEnergy(Type.STORAGE, 0, null);
|
||||
r.emmiter.getPowerHandler().setEnergy(es);
|
||||
@@ -242,7 +241,7 @@ public class NetworkPowerManager {
|
||||
for (IPowerConduit con : network.getConduits()) {
|
||||
if(con.hasExternalConnections()) {
|
||||
PowerTracker tracker = getOrCreateTracker(con);
|
||||
tracker.tickStart(con.getPowerHandler().getEnergyStored());
|
||||
tracker.tickStart((float) con.getPowerHandler().getEnergyStored());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -274,7 +273,7 @@ public class NetworkPowerManager {
|
||||
for (IPowerConduit con : network.getConduits()) {
|
||||
if(con.hasExternalConnections()) {
|
||||
PowerTracker tracker = getOrCreateTracker(con);
|
||||
tracker.tickEnd(con.getPowerHandler().getEnergyStored());
|
||||
tracker.tickEnd((float) con.getPowerHandler().getEnergyStored());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -582,11 +581,11 @@ public class NetworkPowerManager {
|
||||
private class InnerTickHandler implements TickListener {
|
||||
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData) {
|
||||
public void tickStart(ServerTickEvent evt) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
|
||||
public void tickEnd(ServerTickEvent evt) {
|
||||
doApplyRecievedPower();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -19,7 +20,7 @@ import net.minecraftforge.common.util.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.EnderIO;
|
||||
import crazypants.enderio.conduit.AbstractConduit;
|
||||
import crazypants.enderio.conduit.AbstractConduitNetwork;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
@@ -54,7 +55,7 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
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(EnderIO.itemPowerConduit, 1, subtype);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -129,7 +130,7 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
setSignalColor(res.component.dir, col);
|
||||
return true;
|
||||
} else if(ConduitUtil.isToolEquipped(player)) {
|
||||
if(!getBundle().getEntity().worldObj.isRemote) {
|
||||
if(!getBundle().getEntity().getWorldObj().isRemote) {
|
||||
if(res != null && res.component != null) {
|
||||
ForgeDirection connDir = res.component.dir;
|
||||
ForgeDirection faceHit = ForgeDirection.getOrientation(res.movingObjectPosition.sideHit);
|
||||
@@ -245,7 +246,7 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
@Override
|
||||
public void onTick() {
|
||||
if(powerHandler != null && powerHandler.getEnergyStored() > 0) {
|
||||
energyStored = Math.min(energyStored + powerHandler.getEnergyStored(), getCapacitor().getMaxEnergyStored());
|
||||
energyStored = (float) Math.min(energyStored + powerHandler.getEnergyStored(), getCapacitor().getMaxEnergyStored());
|
||||
powerHandler.setEnergy(0);
|
||||
}
|
||||
}
|
||||
@@ -324,7 +325,7 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
int result;
|
||||
if(cached == null) {
|
||||
TileEntity te = getBundle().getEntity();
|
||||
result = te.worldObj.getStrongestIndirectPower(te.xCoord, te.yCoord, te.zCoord);
|
||||
result = te.getWorldObj().getStrongestIndirectPower(te.xCoord, te.yCoord, te.zCoord);
|
||||
externalRedstoneSignals.put(dir, result);
|
||||
} else {
|
||||
result = cached;
|
||||
@@ -356,11 +357,11 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return getBundle().getEntity().worldObj;
|
||||
return getBundle().getEntity().getWorldObj();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNeighborBlockChange(int blockId) {
|
||||
public boolean onNeighborBlockChange(Block blockId) {
|
||||
redstoneStateDirty = true;
|
||||
if(network != null) {
|
||||
network.powerManager.receptorsChanged();
|
||||
@@ -440,7 +441,7 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
@Override
|
||||
public IPowerInterface getExternalPowerReceptor(ForgeDirection direction) {
|
||||
TileEntity te = bundle.getEntity();
|
||||
World world = te.worldObj;
|
||||
World world = te.getWorldObj();
|
||||
if(world == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class PowerConduitNetwork extends AbstractConduitNetwork<IPowerConduit, I
|
||||
|
||||
@Override
|
||||
public void onUpdateEntity(IConduit conduit) {
|
||||
World world = conduit.getBundle().getEntity().worldObj;
|
||||
World world = conduit.getBundle().getEntity().getWorldObj();
|
||||
if(world == null) {
|
||||
return;
|
||||
}
|
||||
@@ -158,20 +158,26 @@ public class PowerConduitNetwork extends AbstractConduitNetwork<IPowerConduit, I
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(this == obj)
|
||||
if(this == obj) {
|
||||
return true;
|
||||
if(obj == null)
|
||||
}
|
||||
if(obj == null) {
|
||||
return false;
|
||||
if(getClass() != obj.getClass())
|
||||
}
|
||||
if(getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ReceptorKey other = (ReceptorKey) obj;
|
||||
if(coord == null) {
|
||||
if(other.coord != null)
|
||||
if(other.coord != null) {
|
||||
return false;
|
||||
} else if(!coord.equals(other.coord))
|
||||
}
|
||||
} else if(!coord.equals(other.coord)) {
|
||||
return false;
|
||||
if(direction != other.direction)
|
||||
}
|
||||
if(direction != other.direction) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@ public class PowerTracker {
|
||||
private float recievedThisTick = 0;
|
||||
|
||||
public void tickStart(float storedEnergy) {
|
||||
float curStorage = storedEnergy;
|
||||
double curStorage = storedEnergy;
|
||||
|
||||
if(previousStorageLevel > -1) {
|
||||
float recieved = curStorage - previousStorageLevel;
|
||||
double recieved = curStorage - previousStorageLevel;
|
||||
recieved = Math.max(0, recieved);
|
||||
recievedThisTick += recieved;
|
||||
}
|
||||
|
||||
@@ -13,21 +13,18 @@ import java.util.Set;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import powercrystals.minefactoryreloaded.api.rednet.IConnectableRedNet;
|
||||
import powercrystals.minefactoryreloaded.api.rednet.IRedNetNoConnection;
|
||||
import powercrystals.minefactoryreloaded.api.rednet.RedNetConnectionType;
|
||||
import buildcraft.api.power.IPowerEmitter;
|
||||
import cofh.api.tileentity.IRedstoneControl;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.Log;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.conduit.ConnectionMode;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
@@ -63,9 +60,12 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
|
||||
});
|
||||
}
|
||||
|
||||
private static List<Integer> VANILLA_CONECTABLES = Arrays.asList(
|
||||
23, 25, 27, 28, 29, 33, 46, 55, 64, 69, 70, 71, 72, 75, 76, 77, 93, 94,
|
||||
96, 107, 123, 124, 131, 143, 147, 148, 149, 150, 151, 152, 154, 157, 158);
|
||||
private static List<Block> VANILLA_CONECTABLES = Arrays.asList(Blocks.redstone_lamp, Blocks.redstone_torch, Blocks.redstone_wire, Blocks.redstone_block,
|
||||
Blocks.dispenser, Blocks.lever, Blocks.wooden_button, Blocks.stone_button, Blocks.wooden_pressure_plate, Blocks.stone_pressure_plate,
|
||||
Blocks.dropper, Blocks.daylight_detector, Blocks.command_block, Blocks.golden_rail);
|
||||
//TODO:1.7 need to map all these
|
||||
// 23, 25, 27, 28, 29, 33, 46, 55, 64, 69, 70, 71, 72, 75, 76, 77, 93, 94,
|
||||
// 96, 107, 123, 124, 131, 143, 147, 148, 149, 150, 151, 152, 154, 157, 158);
|
||||
|
||||
private Map<ForgeDirection, ConnectionMode> forcedConnections = new HashMap<ForgeDirection, ConnectionMode>();
|
||||
|
||||
@@ -74,7 +74,7 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
|
||||
@Override
|
||||
public boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List<RaytraceResult> all) {
|
||||
|
||||
World world = getBundle().getEntity().worldObj;
|
||||
World world = getBundle().getEntity().getWorldObj();
|
||||
if(!world.isRemote) {
|
||||
|
||||
DyeColor col = DyeColor.getColorFromDye(player.getCurrentEquippedItem());
|
||||
@@ -103,8 +103,8 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
|
||||
} else if(connDir == ForgeDirection.UNKNOWN || connDir == faceHit) {
|
||||
|
||||
BlockCoord loc = getLocation().getLocation(faceHit);
|
||||
int id = world.getBlockId(loc.x, loc.y, loc.z);
|
||||
if(id == ModObject.blockConduitBundle.actualId) {
|
||||
Block id = world.getBlock(loc.x, loc.y, loc.z);
|
||||
if(id == EnderIO.blockConduitBundle) {
|
||||
IRedstoneConduit neighbour = ConduitUtil.getConduit(world, loc.x, loc.y, loc.z, IRedstoneConduit.class);
|
||||
if(neighbour != null && neighbour.getConectionMode(faceHit.getOpposite()) == ConnectionMode.DISABLED) {
|
||||
neighbour.setConnectionMode(faceHit.getOpposite(), ConnectionMode.NOT_SET);
|
||||
@@ -125,7 +125,7 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
|
||||
|
||||
} else if(containsConduitConnection(connDir)) {
|
||||
BlockCoord loc = getLocation().getLocation(connDir);
|
||||
IRedstoneConduit neighbour = ConduitUtil.getConduit(getBundle().getEntity().worldObj, loc.x, loc.y, loc.z, IRedstoneConduit.class);
|
||||
IRedstoneConduit neighbour = ConduitUtil.getConduit(getBundle().getEntity().getWorldObj(), loc.x, loc.y, loc.z, IRedstoneConduit.class);
|
||||
if(neighbour != null) {
|
||||
if(network != null) {
|
||||
network.destroyNetwork();
|
||||
@@ -193,7 +193,7 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
|
||||
|
||||
@Override
|
||||
public ItemStack createItem() {
|
||||
return new ItemStack(ModObject.itemRedstoneConduit.actualId, 1, 2);
|
||||
return new ItemStack(EnderIO.itemRedstoneConduit, 1, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -245,44 +245,29 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
|
||||
}
|
||||
//Not set so figure it out
|
||||
BlockCoord loc = getLocation().getLocation(direction);
|
||||
int id = getBundle().getEntity().worldObj.getBlockId(loc.x, loc.y, loc.z);
|
||||
Block block = getBundle().getEntity().getWorldObj().getBlock(loc.x, loc.y, loc.z);
|
||||
|
||||
if(VANILLA_CONECTABLES.contains(Integer.valueOf(id))) {
|
||||
if(VANILLA_CONECTABLES.contains(block)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(id == ModObject.blockConduitBundle.actualId) {
|
||||
if(block == EnderIO.blockConduitBundle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(id == ModObject.blockCapacitorBank.actualId) {
|
||||
if(block == EnderIO.blockCapacitorBank) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(id == ModObject.blockElectricLight.actualId) {
|
||||
if(block == EnderIO.blockElectricLight) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Block block = Block.blocksList[id];
|
||||
if(block == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(block instanceof IRedNetNoConnection) {
|
||||
return false;
|
||||
}
|
||||
|
||||
World world = getBundle().getEntity().worldObj;
|
||||
if(block instanceof IConnectableRedNet) {
|
||||
RedNetConnectionType conType = ((IConnectableRedNet) block).getConnectionType(world, loc.x, loc.y, loc.z, direction.getOpposite());
|
||||
try {
|
||||
return conType != null && (conType.isSingleSubnet || conType.isAllSubnets);
|
||||
} catch (NoSuchFieldError ex) {
|
||||
Log.error("InsulatedRedstoneConduit: An outdated version of the Rednet API has been found.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
World world = getBundle().getEntity().getWorldObj();
|
||||
TileEntity te = world.getTileEntity(loc.x, loc.y, loc.z);
|
||||
if(te instanceof IPowerEmitter || te instanceof IRedstoneControl) {
|
||||
return true;
|
||||
|
||||
@@ -8,13 +8,14 @@ import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.conduit.AbstractConduit;
|
||||
import crazypants.enderio.conduit.AbstractConduitNetwork;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
@@ -59,7 +60,7 @@ public class RedstoneConduit extends AbstractConduit implements IRedstoneConduit
|
||||
|
||||
@Override
|
||||
public ItemStack createItem() {
|
||||
return new ItemStack(ModObject.itemRedstoneConduit.actualId, 1, 0);
|
||||
return new ItemStack(EnderIO.itemRedstoneConduit, 1, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,7 +86,7 @@ public class RedstoneConduit extends AbstractConduit implements IRedstoneConduit
|
||||
|
||||
@Override
|
||||
public void updateNetwork() {
|
||||
World world = getBundle().getEntity().worldObj;
|
||||
World world = getBundle().getEntity().getWorldObj();
|
||||
if(world != null) {
|
||||
updateNetwork(world);
|
||||
}
|
||||
@@ -141,8 +142,8 @@ public class RedstoneConduit extends AbstractConduit implements IRedstoneConduit
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNeighborBlockChange(int blockId) {
|
||||
World world = getBundle().getEntity().worldObj;
|
||||
public boolean onNeighborBlockChange(Block blockId) {
|
||||
World world = getBundle().getEntity().getWorldObj();
|
||||
if(world.isRemote) {
|
||||
return false;
|
||||
}
|
||||
@@ -166,7 +167,7 @@ public class RedstoneConduit extends AbstractConduit implements IRedstoneConduit
|
||||
|
||||
//returns 16 for string power inputs
|
||||
protected int getExternalPowerLevel(ForgeDirection dir) {
|
||||
World world = getBundle().getEntity().worldObj;
|
||||
World world = getBundle().getEntity().getWorldObj();
|
||||
BlockCoord loc = getLocation();
|
||||
loc = loc.getLocation(dir);
|
||||
|
||||
@@ -176,7 +177,7 @@ public class RedstoneConduit extends AbstractConduit implements IRedstoneConduit
|
||||
}
|
||||
|
||||
int res = world.getIndirectPowerLevelTo(loc.x, loc.y, loc.z, dir.ordinal());
|
||||
if(res < 15 && world.getBlockId(loc.x, loc.y, loc.z) == Block.redstoneWire.blockID) {
|
||||
if(res < 15 && world.getBlock(loc.x, loc.y, loc.z) == Blocks.redstone_wire) {
|
||||
int wireIn = world.getBlockMetadata(loc.x, loc.y, loc.z);
|
||||
res = Math.max(res, wireIn);
|
||||
}
|
||||
|
||||
@@ -7,15 +7,10 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import powercrystals.minefactoryreloaded.api.rednet.IRedNetNetworkContainer;
|
||||
import crazypants.enderio.conduit.AbstractConduitNetwork;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.Util;
|
||||
|
||||
public class RedstoneConduitNetwork extends AbstractConduitNetwork<IRedstoneConduit, IRedstoneConduit> {
|
||||
|
||||
@@ -186,31 +181,21 @@ public class RedstoneConduitNetwork extends AbstractConduitNetwork<IRedstoneCond
|
||||
}
|
||||
TileEntity te = con.getBundle().getEntity();
|
||||
|
||||
te.worldObj.notifyBlocksOfNeighborChange(te.xCoord, te.yCoord, te.zCoord, te.worldObj.getBlockId(te.xCoord, te.yCoord, te.zCoord));
|
||||
World worldObj = te.getWorldObj();
|
||||
worldObj.notifyBlocksOfNeighborChange(te.xCoord, te.yCoord, te.zCoord, worldObj.getBlock(te.xCoord, te.yCoord, te.zCoord));
|
||||
|
||||
// Need to notify neighbours neighbours for changes to string signals
|
||||
if(signal != null && signal.strength >= 15 && signal.x == te.xCoord && signal.y == te.yCoord && signal.z == te.zCoord) {
|
||||
|
||||
te.worldObj.notifyBlocksOfNeighborChange(te.xCoord + 1, te.yCoord, te.zCoord, te.worldObj.getBlockId(te.xCoord + 1, te.yCoord, te.zCoord));
|
||||
te.worldObj.notifyBlocksOfNeighborChange(te.xCoord - 1, te.yCoord, te.zCoord, te.worldObj.getBlockId(te.xCoord - 1, te.yCoord, te.zCoord));
|
||||
te.worldObj.notifyBlocksOfNeighborChange(te.xCoord, te.yCoord + 1, te.zCoord, te.worldObj.getBlockId(te.xCoord, te.yCoord + 1, te.zCoord));
|
||||
te.worldObj.notifyBlocksOfNeighborChange(te.xCoord, te.yCoord - 1, te.zCoord, te.worldObj.getBlockId(te.xCoord, te.yCoord - 1, te.zCoord));
|
||||
te.worldObj.notifyBlocksOfNeighborChange(te.xCoord, te.yCoord, te.zCoord + 1, te.worldObj.getBlockId(te.xCoord, te.yCoord, te.zCoord + 1));
|
||||
te.worldObj.notifyBlocksOfNeighborChange(te.xCoord, te.yCoord, te.zCoord - 1, te.worldObj.getBlockId(te.xCoord, te.yCoord, te.zCoord - 1));
|
||||
worldObj.notifyBlocksOfNeighborChange(te.xCoord + 1, te.yCoord, te.zCoord, worldObj.getBlock(te.xCoord + 1, te.yCoord, te.zCoord));
|
||||
worldObj.notifyBlocksOfNeighborChange(te.xCoord - 1, te.yCoord, te.zCoord, worldObj.getBlock(te.xCoord - 1, te.yCoord, te.zCoord));
|
||||
worldObj.notifyBlocksOfNeighborChange(te.xCoord, te.yCoord + 1, te.zCoord, worldObj.getBlock(te.xCoord, te.yCoord + 1, te.zCoord));
|
||||
worldObj.notifyBlocksOfNeighborChange(te.xCoord, te.yCoord - 1, te.zCoord, worldObj.getBlock(te.xCoord, te.yCoord - 1, te.zCoord));
|
||||
worldObj.notifyBlocksOfNeighborChange(te.xCoord, te.yCoord, te.zCoord + 1, worldObj.getBlock(te.xCoord, te.yCoord, te.zCoord + 1));
|
||||
worldObj.notifyBlocksOfNeighborChange(te.xCoord, te.yCoord, te.zCoord - 1, worldObj.getBlock(te.xCoord, te.yCoord, te.zCoord - 1));
|
||||
|
||||
}
|
||||
broadcastRednetUpdate(con);
|
||||
}
|
||||
|
||||
private void broadcastRednetUpdate(IRedstoneConduit con) {
|
||||
World worldObj = con.getBundle().getEntity().worldObj;
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
BlockCoord to = con.getLocation().getLocation(dir);
|
||||
Block b = Util.getBlock(worldObj.getBlockId(to.x, to.y, to.z));
|
||||
if(b instanceof IRedNetNetworkContainer) {
|
||||
((IRedNetNetworkContainer) b).updateNetwork(worldObj, to.x, to.y, to.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.conduit.RaytraceResult;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.conduit.geom.ConduitGeometryUtil;
|
||||
@@ -48,7 +48,7 @@ public class RedstoneSwitch extends RedstoneConduit {
|
||||
|
||||
@Override
|
||||
public ItemStack createItem() {
|
||||
return new ItemStack(ModObject.itemRedstoneConduit.actualId, 1, 1);
|
||||
return new ItemStack(EnderIO.itemRedstoneConduit, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.lwjgl.opengl.GL12;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import crazypants.enderio.Config;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.BlockConduitBundle;
|
||||
import crazypants.enderio.conduit.ConduitDisplayMode;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
@@ -59,7 +58,7 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements
|
||||
if(renderer.isDynamic()) {
|
||||
if(brightness == -1) {
|
||||
BlockCoord loc = bundle.getBlockCoord();
|
||||
brightness = bundle.getEntity().worldObj.getLightBrightnessForSkyBlocks(loc.x, loc.y, loc.z, 0);
|
||||
brightness = bundle.getEntity().getWorldObj().getLightBrightnessForSkyBlocks(loc.x, loc.y, loc.z, 0);
|
||||
|
||||
RenderUtil.bindBlockTexture();
|
||||
|
||||
@@ -101,16 +100,16 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements
|
||||
boolean renderConduit = true;
|
||||
if(bundle.hasFacade()) {
|
||||
|
||||
int facadeId = bundle.getFacadeId();
|
||||
Block facadeId = bundle.getFacadeId();
|
||||
if(ConduitUtil.isFacadeHidden(bundle, player)) {
|
||||
bundle.setFacadeId(0, false);
|
||||
bundle.setFacadeId(null, false);
|
||||
bundle.setFacadeRenderAs(FacadeRenderState.WIRE_FRAME);
|
||||
} else {
|
||||
bundle.setFacadeRenderAs(FacadeRenderState.FULL);
|
||||
renderConduit = false;
|
||||
}
|
||||
|
||||
BlockConduitFacade facb = (BlockConduitFacade) Block.blocksList[ModObject.blockConduitFacade.actualId];
|
||||
BlockConduitFacade facb = EnderIO.blockConduitFacade;
|
||||
facb.setBlockOverride(bundle);
|
||||
facb.setBlockBounds(0, 0, 0, 1, 1, 1);
|
||||
rb.setRenderBoundsFromBlock(facb);
|
||||
@@ -129,7 +128,7 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements
|
||||
if(!Config.updateLightingWhenHidingFacades && bundle.hasFacade() && ConduitUtil.isFacadeHidden(bundle, player)) {
|
||||
brightness = 15 << 20 | 15 << 4;
|
||||
} else {
|
||||
brightness = bundle.getEntity().worldObj.getLightBrightnessForSkyBlocks(loc.x, loc.y, loc.z, 0);
|
||||
brightness = bundle.getEntity().getWorldObj().getLightBrightnessForSkyBlocks(loc.x, loc.y, loc.z, 0);
|
||||
}
|
||||
renderConduits(bundle, x, y, z, 0, brightness);
|
||||
}
|
||||
@@ -214,7 +213,7 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory() {
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@ package crazypants.enderio.conduit.render;
|
||||
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 static net.minecraftforge.common.util.ForgeDirection.DOWN;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.EAST;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.NORTH;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.SOUTH;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.UP;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.WEST;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package crazypants.enderio.conduit.render;
|
||||
|
||||
import static crazypants.util.ForgeDirectionOffsets.offsetScaled;
|
||||
import static net.minecraftforge.common.ForgeDirection.SOUTH;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.SOUTH;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -2,16 +2,16 @@ package crazypants.enderio.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.material.Alloy;
|
||||
import crazypants.enderio.material.MachinePart;
|
||||
|
||||
public class ItemRecipes {
|
||||
|
||||
public static void addRecipes() {
|
||||
ItemStack basicGear = new ItemStack(ModObject.itemMachinePart.actualId, 1, MachinePart.BASIC_GEAR.ordinal());
|
||||
ItemStack electricalSteel = new ItemStack(ModObject.itemAlloy.actualId, 1, Alloy.ELECTRICAL_STEEL.ordinal());
|
||||
ItemStack wrench = new ItemStack(ModObject.itemYetaWrench.actualId, 1, 0);
|
||||
ItemStack basicGear = new ItemStack(EnderIO.itemMachinePart, 1, MachinePart.BASIC_GEAR.ordinal());
|
||||
ItemStack electricalSteel = new ItemStack(EnderIO.itemAlloy, 1, Alloy.ELECTRICAL_STEEL.ordinal());
|
||||
ItemStack wrench = new ItemStack(EnderIO.itemYetaWench, 1, 0);
|
||||
|
||||
// Wrench
|
||||
GameRegistry.addShapedRecipe(wrench, "s s", " b ", " s ", 's', electricalSteel, 'b', basicGear);
|
||||
|
||||
@@ -12,16 +12,16 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.Config;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.PacketHandler;
|
||||
import crazypants.enderio.conduit.ConduitDisplayMode;
|
||||
|
||||
public class ItemYetaWrench extends Item implements IToolWrench {
|
||||
|
||||
public static ItemYetaWrench create() {
|
||||
if(Config.useSneakMouseWheelYetaWrench) {
|
||||
PacketHandler.instance.addPacketProcessor(new YetaWrenchPacketProcessor());
|
||||
EnderIO.packetPipeline.registerPacket(YetaWrenchPacketProcessor.class);
|
||||
}
|
||||
ItemYetaWrench result = new ItemYetaWrench();
|
||||
result.init();
|
||||
@@ -29,9 +29,8 @@ public class ItemYetaWrench extends Item implements IToolWrench {
|
||||
}
|
||||
|
||||
protected ItemYetaWrench() {
|
||||
super(ModObject.itemYetaWrench.id);
|
||||
setCreativeTab(EnderIOTab.tabEnderIO);
|
||||
setUnlocalizedName("enderio." + ModObject.itemYetaWrench.name());
|
||||
setUnlocalizedName(ModObject.itemYetaWrench.unlocalisedName);
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@@ -47,8 +46,7 @@ public class ItemYetaWrench extends Item implements IToolWrench {
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
|
||||
int blockId = world.getBlockId(x, y, z);
|
||||
Block block = Block.blocksList[blockId];
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if(block != null && block.rotateBlock(world, x, y, z, ForgeDirection.getOrientation(side))) {
|
||||
player.swingItem();
|
||||
return !world.isRemote;
|
||||
@@ -83,9 +81,10 @@ public class ItemYetaWrench extends Item implements IToolWrench {
|
||||
player.swingItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldPassSneakingClickToBlock(World par2World, int par4, int par5, int par6) {
|
||||
return true;
|
||||
}
|
||||
//TODO:1.7 is this still needed?
|
||||
// @Override
|
||||
// public boolean shouldPassSneakingClickToBlock(World par2World, int par4, int par5, int par6) {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -6,11 +6,10 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.EventPriority;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import crazypants.enderio.conduit.ConduitDisplayMode;
|
||||
import crazypants.enderio.gui.IconEIO;
|
||||
|
||||
@@ -23,7 +22,7 @@ public class YetaWrenchOverlayRenderer {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@ForgeSubscribe(priority = EventPriority.NORMAL)
|
||||
@SubscribeEvent
|
||||
public void renderOverlay(RenderGameOverlayEvent event) {
|
||||
ItemStack equippedWrench = getEquippedWrench();
|
||||
if(equippedWrench != null && event.type == ElementType.ALL) {
|
||||
@@ -33,7 +32,7 @@ public class YetaWrenchOverlayRenderer {
|
||||
|
||||
private ItemStack getEquippedWrench() {
|
||||
ItemStack equipped = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem();
|
||||
if(equipped != null && equipped.itemID == wrench.itemID) {
|
||||
if(equipped != null && equipped.getItem() == wrench) {
|
||||
return equipped;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,59 +1,44 @@
|
||||
package crazypants.enderio.item;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import crazypants.enderio.IPacketProcessor;
|
||||
import crazypants.enderio.PacketHandler;
|
||||
import crazypants.enderio.conduit.ConduitDisplayMode;
|
||||
import crazypants.enderio.network.IPacketEio;
|
||||
|
||||
public class YetaWrenchPacketProcessor implements IPacketProcessor {
|
||||
public class YetaWrenchPacketProcessor implements IPacketEio {
|
||||
|
||||
public static Packet getWrenchModePacket(int slot, ConduitDisplayMode mode) {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(140);
|
||||
DataOutputStream dos = new DataOutputStream(bos);
|
||||
try {
|
||||
dos.writeInt(PacketHandler.ID_YETA_WRENCH_MODE_PACKET);
|
||||
dos.writeInt(slot);
|
||||
dos.writeShort(mode.ordinal());
|
||||
} catch (IOException e) {
|
||||
// never thrown
|
||||
}
|
||||
private int slot;
|
||||
private ConduitDisplayMode mode;
|
||||
|
||||
Packet250CustomPayload pkt = new Packet250CustomPayload();
|
||||
pkt.channel = PacketHandler.CHANNEL;
|
||||
pkt.data = bos.toByteArray();
|
||||
pkt.length = bos.size();
|
||||
pkt.isChunkDataPacket = true;
|
||||
return pkt;
|
||||
public YetaWrenchPacketProcessor() {
|
||||
}
|
||||
|
||||
public YetaWrenchPacketProcessor(int slot, ConduitDisplayMode mode) {
|
||||
this.slot = slot;
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ChannelHandlerContext ctx, ByteBuf buffer) {
|
||||
buffer.writeInt(slot);
|
||||
buffer.writeShort(mode.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(ChannelHandlerContext ctx, ByteBuf buffer) {
|
||||
slot = buffer.readShort();
|
||||
mode = ConduitDisplayMode.values()[buffer.readShort()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleClientSide(EntityPlayer player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProcessPacket(int packetID) {
|
||||
return packetID == PacketHandler.ID_YETA_WRENCH_MODE_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPacket(int packetID, INetworkManager manager, DataInputStream data, Player playerIn) throws IOException {
|
||||
|
||||
int slot = -1;
|
||||
if(!(playerIn instanceof EntityPlayerMP)) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayerMP player = (EntityPlayerMP) playerIn;
|
||||
slot = data.readInt();
|
||||
short ordinal = data.readShort();
|
||||
|
||||
public void handleServerSide(EntityPlayer player) {
|
||||
ItemStack stack = null;
|
||||
if(slot > -1 && slot < 9) {
|
||||
stack = player.inventory.getStackInSlot(slot);
|
||||
@@ -61,7 +46,7 @@ public class YetaWrenchPacketProcessor implements IPacketProcessor {
|
||||
if(stack == null) {
|
||||
return;
|
||||
}
|
||||
ConduitDisplayMode.setDisplayMode(stack, ConduitDisplayMode.values()[ordinal]);
|
||||
|
||||
ConduitDisplayMode.setDisplayMode(stack, mode);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +1,25 @@
|
||||
package crazypants.enderio.item;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import crazypants.enderio.conduit.ConduitDisplayMode;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.conduit.ConduitDisplayMode;
|
||||
|
||||
public class YetaWrenchTickHandler {
|
||||
protected int slotSelected = -1;
|
||||
public static int dWheel;
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onClientTick(TickEvent.ClientTickEvent event) {
|
||||
if(event.phase == TickEvent.Phase.START) {
|
||||
tickStart();
|
||||
} else {
|
||||
tickEnd();
|
||||
}
|
||||
}
|
||||
|
||||
public void tickStart() {
|
||||
dWheel = Mouse.getDWheel() / 120;
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
if(player != null && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemYetaWrench
|
||||
&& player.isSneaking()) {
|
||||
slotSelected = player.inventory.currentItem;
|
||||
} else {
|
||||
slotSelected = -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void tickEnd() {
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
if(player != null) {
|
||||
if(slotSelected > -1 && dWheel != Mouse.getDWheel()) {
|
||||
@@ -57,8 +42,7 @@ public class YetaWrenchTickHandler {
|
||||
ConduitDisplayMode.setDisplayMode(stack, newMode);
|
||||
}
|
||||
if(newMode != null) {
|
||||
//TODO:1.7
|
||||
//player.sendQueue.addToSendQueue(YetaWrenchPacketProcessor.getWrenchModePacket(slotSelected, newMode));
|
||||
EnderIO.packetPipeline.sendToServer(new YetaWrenchPacketProcessor(slotSelected, newMode));
|
||||
}
|
||||
}
|
||||
slotSelected = -1;
|
||||
@@ -66,14 +50,4 @@ public class YetaWrenchTickHandler {
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public EnumSet<TickType> ticks() {
|
||||
// return EnumSet.of(TickType.CLIENT);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getLabel() {
|
||||
// return "YetaWrenchTickHandler: Client Tick";
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -1,9 +1,24 @@
|
||||
package crazypants.enderio.machine.monitor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import crazypants.enderio.conduit.ConnectionMode;
|
||||
import crazypants.enderio.conduit.TileConduitBundle;
|
||||
import crazypants.enderio.conduit.item.IItemConduit;
|
||||
import crazypants.enderio.conduit.item.ItemConduitNetwork;
|
||||
import crazypants.enderio.conduit.power.IPowerConduit;
|
||||
import crazypants.enderio.conduit.power.NetworkPowerManager;
|
||||
import crazypants.enderio.conduit.power.PowerConduitNetwork;
|
||||
import crazypants.enderio.conduit.power.PowerTracker;
|
||||
import crazypants.enderio.machine.power.PowerDisplayUtil;
|
||||
import crazypants.enderio.power.IInternalPowerReceptor;
|
||||
import crazypants.util.Lang;
|
||||
|
||||
@@ -38,12 +53,10 @@ public class MJReaderPacketHandler {
|
||||
return false;
|
||||
}
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
//TODO: 1.7
|
||||
|
||||
// if(te instanceof TileConduitBundle) {
|
||||
// TileConduitBundle tcb = (TileConduitBundle) te;
|
||||
// return tcb.getConduit(IPowerConduit.class) != null || tcb.getConduit(IItemConduit.class) != null;
|
||||
// }
|
||||
if(te instanceof TileConduitBundle) {
|
||||
TileConduitBundle tcb = (TileConduitBundle) te;
|
||||
return tcb.getConduit(IPowerConduit.class) != null || tcb.getConduit(IItemConduit.class) != null;
|
||||
}
|
||||
if(te instanceof IInternalPowerReceptor) {
|
||||
return true;
|
||||
}
|
||||
@@ -53,6 +66,7 @@ public class MJReaderPacketHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
//TODO:1.7
|
||||
// public static Packet createInfoRequestPacket(int x, int y, int z, int side) {
|
||||
//
|
||||
// dos.writeInt(x);
|
||||
@@ -62,268 +76,268 @@ public class MJReaderPacketHandler {
|
||||
//
|
||||
// }
|
||||
|
||||
// private void sendInfoMessage(DataInputStream data, EntityPlayer player) throws IOException {
|
||||
// int x = data.readInt();
|
||||
// int y = data.readInt();
|
||||
// int z = data.readInt();
|
||||
// int side = data.readInt();
|
||||
//
|
||||
// World world = player.worldObj;
|
||||
// if(world == null) {
|
||||
// Log.warn("MJReaderPacketHandler.sendInfoMessage: Could not handle packet as player world was null.");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Block block = world.getBlock(x, y, z);
|
||||
//
|
||||
// if(block == null) {
|
||||
// Log.warn("MJReaderPacketHandler.sendInfoMessage: Null block for is " + id);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// TileEntity te = world.getTileEntity(x, y, z);
|
||||
//
|
||||
// if(te instanceof TileConduitBundle) {
|
||||
//
|
||||
// sendInfoMessage(player, (TileConduitBundle) te);
|
||||
//
|
||||
// } else
|
||||
//
|
||||
// if(te instanceof IInternalPowerReceptor) {
|
||||
//
|
||||
// IInternalPowerReceptor pr = (IInternalPowerReceptor) te;
|
||||
// PowerHandler ph = pr.getPowerHandler();
|
||||
// if(ph == null) {
|
||||
// player.sendChatToPlayer(ChatMessageComponent.createFromText(block.getLocalizedName() + " " + Lang.localize("gui.mjReader.noPowerFromSide")));
|
||||
// private void sendInfoMessage(DataInputStream data, EntityPlayer player) throws IOException {
|
||||
// int x = data.readInt();
|
||||
// int y = data.readInt();
|
||||
// int z = data.readInt();
|
||||
// int side = data.readInt();
|
||||
//
|
||||
// World world = player.worldObj;
|
||||
// if(world == null) {
|
||||
// Log.warn("MJReaderPacketHandler.sendInfoMessage: Could not handle packet as player world was null.");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// sendPowerReciptorInfo(player, block, ph.getEnergyStored(), ph.getMaxEnergyStored(), ph.getMinEnergyReceived(), ph.getMaxEnergyReceived(), ph
|
||||
// .getPowerReceiver().powerRequest());
|
||||
//
|
||||
// } else if(te instanceof IPowerReceptor) {
|
||||
//
|
||||
// IPowerReceptor pr = (IPowerReceptor) te;
|
||||
// PowerReceiver rec = pr.getPowerReceiver(ForgeDirection.values()[side]);
|
||||
// if(rec == null) {
|
||||
// player.sendChatToPlayer(ChatMessageComponent.createFromText(block.getLocalizedName() + " " + Lang.localize("gui.mjReader.noPowerFromSide")));
|
||||
// } else {
|
||||
// sendPowerReciptorInfo(player, block, rec.getEnergyStored(), rec.getMaxEnergyStored(), rec.getMinEnergyReceived(), rec.getMaxEnergyReceived(),
|
||||
// rec.powerRequest());
|
||||
//
|
||||
// Block block = world.getBlock(x, y, z);
|
||||
//
|
||||
// if(block == null) {
|
||||
// Log.warn("MJReaderPacketHandler.sendInfoMessage: Null block for is " + id);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public void sendInfoMessage(EntityPlayer player, TileConduitBundle tcb) {
|
||||
//
|
||||
// if(tcb.getConduit(IItemConduit.class) != null) {
|
||||
// sendInfoMessage(player, tcb.getConduit(IItemConduit.class), null);
|
||||
// }
|
||||
// IPowerConduit conduit = tcb.getConduit(IPowerConduit.class);
|
||||
// if(conduit != null) {
|
||||
// sendInfoMessage(player, conduit);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void sendInfoMessage(EntityPlayer player, IPowerConduit conduit) {
|
||||
// PowerConduitNetwork pcn = (PowerConduitNetwork) conduit.getNetwork();
|
||||
// NetworkPowerManager pm = pcn.getPowerManager();
|
||||
// PowerTracker tracker = pm.getTracker(conduit);
|
||||
// if(tracker != null) {
|
||||
// sendPowerConduitInfo(player, conduit, tracker);
|
||||
// } else {
|
||||
// sendInfoMessage(player, pm);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void sendInfoMessage(EntityPlayer player, IItemConduit conduit, ItemStack input) {
|
||||
// String color = "\u00A7a ";
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// sb.append(color);
|
||||
//
|
||||
// if(conduit.getExternalConnections().isEmpty()) {
|
||||
// sb.append(ITEM_HEADING);
|
||||
// sb.append(" ");
|
||||
// sb.append(ITEM_NO_CONNECTIONS);
|
||||
// sb.append("\n");
|
||||
// player.sendChatToPlayer(ChatMessageComponent.createFromText(sb.toString()));
|
||||
// return;
|
||||
// }
|
||||
// for (ForgeDirection dir : conduit.getExternalConnections()) {
|
||||
// ConnectionMode mode = conduit.getConectionMode(dir);
|
||||
//
|
||||
// sb.append(ITEM_HEADING);
|
||||
// sb.append(" ");
|
||||
// sb.append(Lang.localize("gui.mjReader.connectionDir"));
|
||||
// sb.append(" ");
|
||||
// sb.append(dir);
|
||||
// sb.append("\n");
|
||||
//
|
||||
// ItemConduitNetwork icn = (ItemConduitNetwork) conduit.getNetwork();
|
||||
// if(mode.acceptsInput()) {
|
||||
// color = "\u00A79 ";
|
||||
// sb.append(color);
|
||||
//
|
||||
// if(input == null) {
|
||||
// sb.append(Lang.localize("gui.mjReader.extractedItems"));
|
||||
// } else {
|
||||
// sb.append(Lang.localize("gui.mjReader.extractedItem"));
|
||||
// sb.append(" ");
|
||||
// sb.append(input.getDisplayName());
|
||||
//
|
||||
// TileEntity te = world.getTileEntity(x, y, z);
|
||||
//
|
||||
// if(te instanceof TileConduitBundle) {
|
||||
//
|
||||
// sendInfoMessage(player, (TileConduitBundle) te);
|
||||
//
|
||||
// } else
|
||||
//
|
||||
// if(te instanceof IInternalPowerReceptor) {
|
||||
//
|
||||
// IInternalPowerReceptor pr = (IInternalPowerReceptor) te;
|
||||
// PowerHandler ph = pr.getPowerHandler();
|
||||
// if(ph == null) {
|
||||
// player.sendChatToPlayer(ChatMessageComponent.createFromText(block.getLocalizedName() + " " + Lang.localize("gui.mjReader.noPowerFromSide")));
|
||||
// }
|
||||
// sb.append(" ");
|
||||
// List<String> targets = icn.getTargetsForExtraction(conduit.getLocation().getLocation(dir), input);
|
||||
// if(targets.isEmpty()) {
|
||||
// sb.append(" ");
|
||||
// sb.append(Lang.localize("gui.mjReader.noOutputs"));
|
||||
// sb.append(".\n");
|
||||
//
|
||||
// sendPowerReciptorInfo(player, block, ph.getEnergyStored(), ph.getMaxEnergyStored(), ph.getMinEnergyReceived(), ph.getMaxEnergyReceived(), ph
|
||||
// .getPowerReceiver().powerRequest());
|
||||
//
|
||||
// } else if(te instanceof IPowerReceptor) {
|
||||
//
|
||||
// IPowerReceptor pr = (IPowerReceptor) te;
|
||||
// PowerReceiver rec = pr.getPowerReceiver(ForgeDirection.values()[side]);
|
||||
// if(rec == null) {
|
||||
// player.sendChatToPlayer(ChatMessageComponent.createFromText(block.getLocalizedName() + " " + Lang.localize("gui.mjReader.noPowerFromSide")));
|
||||
// } else {
|
||||
// sb.append(" ");
|
||||
// sb.append(Lang.localize("gui.mjReader.insertedInto"));
|
||||
// sb.append("\n");
|
||||
// for (String str : targets) {
|
||||
// sb.append(" - ");
|
||||
// sb.append(str);
|
||||
// sb.append("\n");
|
||||
// }
|
||||
// sendPowerReciptorInfo(player, block, rec.getEnergyStored(), rec.getMaxEnergyStored(), rec.getMinEnergyReceived(), rec.getMaxEnergyReceived(),
|
||||
// rec.powerRequest());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// if(mode.acceptsOutput()) {
|
||||
// color = "\u00A79 ";
|
||||
// sb.append(color);
|
||||
//
|
||||
// List<String> targets = icn.getInputSourcesFor(conduit, dir, input);
|
||||
// if(targets.isEmpty()) {
|
||||
// if(input == null) {
|
||||
// sb.append(Lang.localize("gui.mjReader.noItems"));
|
||||
// } else {
|
||||
// sb.append(Lang.localize("gui.mjReader.noItem"));
|
||||
// sb.append(" ");
|
||||
// sb.append(input.getDisplayName());
|
||||
// }
|
||||
// } else {
|
||||
// if(input == null) {
|
||||
// sb.append(Lang.localize("gui.mjReader.receiveItems"));
|
||||
// } else {
|
||||
// sb.append(Lang.localize("gui.mjReader.receiveItem1"));
|
||||
// sb.append(" ");
|
||||
// sb.append(input.getDisplayName());
|
||||
// sb.append(" ");
|
||||
// sb.append(Lang.localize("gui.mjReader.receiveItem2"));
|
||||
// }
|
||||
// sb.append("\n");
|
||||
// for (String str : targets) {
|
||||
// sb.append(" - ");
|
||||
// sb.append(str);
|
||||
// sb.append("\n");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// player.sendChatToPlayer(ChatMessageComponent.createFromText(sb.toString()));
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public void sendInfoMessage(EntityPlayer player, NetworkPowerManager pm) {
|
||||
// PowerTracker tracker = pm.getNetworkPowerTracker();
|
||||
// String color = "\u00A7a ";
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// sb.append(color);
|
||||
// sb.append(NET_HEADING);
|
||||
// player.sendChatToPlayer(ChatMessageComponent.createFromText(sb.toString()));
|
||||
//
|
||||
// color = "\u00A79 ";
|
||||
// sb = new StringBuilder();
|
||||
// sb.append(color);
|
||||
// sb.append(CON_STORAGE);
|
||||
// sb.append(PowerDisplayUtil.formatPower(pm.getPowerInConduits()));
|
||||
// sb.append(OF);
|
||||
// sb.append(PowerDisplayUtil.formatPower(pm.getMaxPowerInConduits()));
|
||||
// sb.append(" ");
|
||||
// sb.append(PowerDisplayUtil.abrevation());
|
||||
// sb.append("\n");
|
||||
// sb.append(CAP_BANK_STOR);
|
||||
// sb.append(PowerDisplayUtil.formatPower(pm.getPowerInCapacitorBanks()));
|
||||
// sb.append(OF);
|
||||
// sb.append(PowerDisplayUtil.formatPower(pm.getMaxPowerInCapacitorBanks()));
|
||||
// sb.append(" ");
|
||||
// sb.append(PowerDisplayUtil.abrevation());
|
||||
// sb.append("\n");
|
||||
// sb.append(MACH_BUF_STOR);
|
||||
// sb.append(PowerDisplayUtil.formatPower(pm.getPowerInReceptors()));
|
||||
// sb.append(OF);
|
||||
// sb.append(PowerDisplayUtil.formatPower(pm.getMaxPowerInReceptors()));
|
||||
// sb.append(" ");
|
||||
// sb.append(PowerDisplayUtil.abrevation());
|
||||
// sb.append("\n");
|
||||
// sb.append(AVE_OUT);
|
||||
// sb.append(PowerDisplayUtil.formatPowerFloat(tracker.getAverageMjTickSent()));
|
||||
// sb.append("\n");
|
||||
// sb.append(AVE_IN);
|
||||
// sb.append(PowerDisplayUtil.formatPowerFloat(tracker.getAverageMjTickRecieved()));
|
||||
// player.sendChatToPlayer(ChatMessageComponent.createFromText(sb.toString()));
|
||||
// }
|
||||
//
|
||||
// private void sendPowerConduitInfo(EntityPlayer player, IPowerConduit con, PowerTracker tracker) {
|
||||
// String color = "\u00A7a ";
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// sb.append(color);
|
||||
// sb.append(ENERGY_CONDUIT);
|
||||
// player.sendChatToPlayer(ChatMessageComponent.createFromText(sb.toString()));
|
||||
//
|
||||
// color = "\u00A79 ";
|
||||
// sb = new StringBuilder();
|
||||
// sb.append(color);
|
||||
// sb.append(CON_BUF);
|
||||
// sb.append(PowerDisplayUtil.formatPower(con.getPowerHandler().getEnergyStored()));
|
||||
// sb.append(OF);
|
||||
// sb.append(PowerDisplayUtil.formatPower(con.getPowerHandler().getMaxEnergyStored()));
|
||||
// sb.append(" ");
|
||||
// sb.append(PowerDisplayUtil.abrevation());
|
||||
// sb.append("\n");
|
||||
// sb.append(AVE_OUT);
|
||||
// sb.append(PowerDisplayUtil.formatPowerFloat(tracker.getAverageMjTickSent()));
|
||||
// sb.append("\n");
|
||||
// sb.append(AVE_IN);
|
||||
// sb.append(PowerDisplayUtil.formatPowerFloat(tracker.getAverageMjTickRecieved()));
|
||||
// player.sendChatToPlayer(ChatMessageComponent.createFromText(sb.toString()));
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private void sendPowerReciptorInfo(EntityPlayer player, Block block, float stored, float maxStored, float minRec, float maxRec, float request) {
|
||||
// String color = "\u00A7a ";
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// sb.append(color);
|
||||
// sb.append(block.getLocalizedName());
|
||||
// player.sendChatToPlayer(ChatMessageComponent.createFromText(sb.toString()));
|
||||
//
|
||||
// color = "\u00A79 ";
|
||||
// sb = new StringBuilder();
|
||||
// sb.append(color);
|
||||
// sb.append(CON_BUF);
|
||||
// sb.append(PowerDisplayUtil.formatPower(stored));
|
||||
// sb.append(OF);
|
||||
// sb.append(PowerDisplayUtil.formatPower(maxStored));
|
||||
// sb.append(" ");
|
||||
// sb.append(PowerDisplayUtil.abrevation());
|
||||
// sb.append("\n");
|
||||
//
|
||||
// sb.append(REQUEST_RANGE);
|
||||
// sb.append(PowerDisplayUtil.formatPower(minRec));
|
||||
// sb.append(" - ");
|
||||
// sb.append(PowerDisplayUtil.formatPower(maxRec));
|
||||
// sb.append(" ");
|
||||
// sb.append(PowerDisplayUtil.abrevation());
|
||||
// sb.append("\n");
|
||||
//
|
||||
// sb.append(CUR_REQUEST);
|
||||
// sb.append(PowerDisplayUtil.formatPower(request));
|
||||
// sb.append(" ");
|
||||
// sb.append(PowerDisplayUtil.abrevation());
|
||||
//
|
||||
// player.sendChatToPlayer(ChatMessageComponent.createFromText(sb.toString()));
|
||||
// }
|
||||
|
||||
public void sendInfoMessage(EntityPlayer player, TileConduitBundle tcb) {
|
||||
|
||||
if(tcb.getConduit(IItemConduit.class) != null) {
|
||||
sendInfoMessage(player, tcb.getConduit(IItemConduit.class), null);
|
||||
}
|
||||
IPowerConduit conduit = tcb.getConduit(IPowerConduit.class);
|
||||
if(conduit != null) {
|
||||
sendInfoMessage(player, conduit);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendInfoMessage(EntityPlayer player, IPowerConduit conduit) {
|
||||
PowerConduitNetwork pcn = (PowerConduitNetwork) conduit.getNetwork();
|
||||
NetworkPowerManager pm = pcn.getPowerManager();
|
||||
PowerTracker tracker = pm.getTracker(conduit);
|
||||
if(tracker != null) {
|
||||
sendPowerConduitInfo(player, conduit, tracker);
|
||||
} else {
|
||||
sendInfoMessage(player, pm);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendInfoMessage(EntityPlayer player, IItemConduit conduit, ItemStack input) {
|
||||
String color = "\u00A7a ";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(color);
|
||||
|
||||
if(conduit.getExternalConnections().isEmpty()) {
|
||||
sb.append(ITEM_HEADING);
|
||||
sb.append(" ");
|
||||
sb.append(ITEM_NO_CONNECTIONS);
|
||||
sb.append("\n");
|
||||
player.addChatComponentMessage(new ChatComponentText(sb.toString()));
|
||||
return;
|
||||
}
|
||||
for (ForgeDirection dir : conduit.getExternalConnections()) {
|
||||
ConnectionMode mode = conduit.getConectionMode(dir);
|
||||
|
||||
sb.append(ITEM_HEADING);
|
||||
sb.append(" ");
|
||||
sb.append(Lang.localize("gui.mjReader.connectionDir"));
|
||||
sb.append(" ");
|
||||
sb.append(dir);
|
||||
sb.append("\n");
|
||||
|
||||
ItemConduitNetwork icn = (ItemConduitNetwork) conduit.getNetwork();
|
||||
if(mode.acceptsInput()) {
|
||||
color = "\u00A79 ";
|
||||
sb.append(color);
|
||||
|
||||
if(input == null) {
|
||||
sb.append(Lang.localize("gui.mjReader.extractedItems"));
|
||||
} else {
|
||||
sb.append(Lang.localize("gui.mjReader.extractedItem"));
|
||||
sb.append(" ");
|
||||
sb.append(input.getDisplayName());
|
||||
}
|
||||
sb.append(" ");
|
||||
List<String> targets = icn.getTargetsForExtraction(conduit.getLocation().getLocation(dir), input);
|
||||
if(targets.isEmpty()) {
|
||||
sb.append(" ");
|
||||
sb.append(Lang.localize("gui.mjReader.noOutputs"));
|
||||
sb.append(".\n");
|
||||
} else {
|
||||
sb.append(" ");
|
||||
sb.append(Lang.localize("gui.mjReader.insertedInto"));
|
||||
sb.append("\n");
|
||||
for (String str : targets) {
|
||||
sb.append(" - ");
|
||||
sb.append(str);
|
||||
sb.append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(mode.acceptsOutput()) {
|
||||
color = "\u00A79 ";
|
||||
sb.append(color);
|
||||
|
||||
List<String> targets = icn.getInputSourcesFor(conduit, dir, input);
|
||||
if(targets.isEmpty()) {
|
||||
if(input == null) {
|
||||
sb.append(Lang.localize("gui.mjReader.noItems"));
|
||||
} else {
|
||||
sb.append(Lang.localize("gui.mjReader.noItem"));
|
||||
sb.append(" ");
|
||||
sb.append(input.getDisplayName());
|
||||
}
|
||||
} else {
|
||||
if(input == null) {
|
||||
sb.append(Lang.localize("gui.mjReader.receiveItems"));
|
||||
} else {
|
||||
sb.append(Lang.localize("gui.mjReader.receiveItem1"));
|
||||
sb.append(" ");
|
||||
sb.append(input.getDisplayName());
|
||||
sb.append(" ");
|
||||
sb.append(Lang.localize("gui.mjReader.receiveItem2"));
|
||||
}
|
||||
sb.append("\n");
|
||||
for (String str : targets) {
|
||||
sb.append(" - ");
|
||||
sb.append(str);
|
||||
sb.append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
player.addChatComponentMessage(new ChatComponentText(sb.toString()));
|
||||
|
||||
}
|
||||
|
||||
public void sendInfoMessage(EntityPlayer player, NetworkPowerManager pm) {
|
||||
PowerTracker tracker = pm.getNetworkPowerTracker();
|
||||
String color = "\u00A7a ";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(color);
|
||||
sb.append(NET_HEADING);
|
||||
player.addChatComponentMessage(new ChatComponentText(sb.toString()));
|
||||
|
||||
color = "\u00A79 ";
|
||||
sb = new StringBuilder();
|
||||
sb.append(color);
|
||||
sb.append(CON_STORAGE);
|
||||
sb.append(PowerDisplayUtil.formatPower(pm.getPowerInConduits()));
|
||||
sb.append(OF);
|
||||
sb.append(PowerDisplayUtil.formatPower(pm.getMaxPowerInConduits()));
|
||||
sb.append(" ");
|
||||
sb.append(PowerDisplayUtil.abrevation());
|
||||
sb.append("\n");
|
||||
sb.append(CAP_BANK_STOR);
|
||||
sb.append(PowerDisplayUtil.formatPower(pm.getPowerInCapacitorBanks()));
|
||||
sb.append(OF);
|
||||
sb.append(PowerDisplayUtil.formatPower(pm.getMaxPowerInCapacitorBanks()));
|
||||
sb.append(" ");
|
||||
sb.append(PowerDisplayUtil.abrevation());
|
||||
sb.append("\n");
|
||||
sb.append(MACH_BUF_STOR);
|
||||
sb.append(PowerDisplayUtil.formatPower(pm.getPowerInReceptors()));
|
||||
sb.append(OF);
|
||||
sb.append(PowerDisplayUtil.formatPower(pm.getMaxPowerInReceptors()));
|
||||
sb.append(" ");
|
||||
sb.append(PowerDisplayUtil.abrevation());
|
||||
sb.append("\n");
|
||||
sb.append(AVE_OUT);
|
||||
sb.append(PowerDisplayUtil.formatPowerFloat(tracker.getAverageMjTickSent()));
|
||||
sb.append("\n");
|
||||
sb.append(AVE_IN);
|
||||
sb.append(PowerDisplayUtil.formatPowerFloat(tracker.getAverageMjTickRecieved()));
|
||||
player.addChatComponentMessage(new ChatComponentText(sb.toString()));
|
||||
}
|
||||
|
||||
private void sendPowerConduitInfo(EntityPlayer player, IPowerConduit con, PowerTracker tracker) {
|
||||
String color = "\u00A7a ";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(color);
|
||||
sb.append(ENERGY_CONDUIT);
|
||||
player.addChatComponentMessage(new ChatComponentText(sb.toString()));
|
||||
|
||||
color = "\u00A79 ";
|
||||
sb = new StringBuilder();
|
||||
sb.append(color);
|
||||
sb.append(CON_BUF);
|
||||
sb.append(PowerDisplayUtil.formatPower(con.getPowerHandler().getEnergyStored()));
|
||||
sb.append(OF);
|
||||
sb.append(PowerDisplayUtil.formatPower(con.getPowerHandler().getMaxEnergyStored()));
|
||||
sb.append(" ");
|
||||
sb.append(PowerDisplayUtil.abrevation());
|
||||
sb.append("\n");
|
||||
sb.append(AVE_OUT);
|
||||
sb.append(PowerDisplayUtil.formatPowerFloat(tracker.getAverageMjTickSent()));
|
||||
sb.append("\n");
|
||||
sb.append(AVE_IN);
|
||||
sb.append(PowerDisplayUtil.formatPowerFloat(tracker.getAverageMjTickRecieved()));
|
||||
player.addChatComponentMessage(new ChatComponentText(sb.toString()));
|
||||
|
||||
}
|
||||
|
||||
private void sendPowerReciptorInfo(EntityPlayer player, Block block, float stored, float maxStored, float minRec, float maxRec, float request) {
|
||||
String color = "\u00A7a ";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(color);
|
||||
sb.append(block.getLocalizedName());
|
||||
player.addChatComponentMessage(new ChatComponentText(sb.toString()));
|
||||
|
||||
color = "\u00A79 ";
|
||||
sb = new StringBuilder();
|
||||
sb.append(color);
|
||||
sb.append(CON_BUF);
|
||||
sb.append(PowerDisplayUtil.formatPower(stored));
|
||||
sb.append(OF);
|
||||
sb.append(PowerDisplayUtil.formatPower(maxStored));
|
||||
sb.append(" ");
|
||||
sb.append(PowerDisplayUtil.abrevation());
|
||||
sb.append("\n");
|
||||
|
||||
sb.append(REQUEST_RANGE);
|
||||
sb.append(PowerDisplayUtil.formatPower(minRec));
|
||||
sb.append(" - ");
|
||||
sb.append(PowerDisplayUtil.formatPower(maxRec));
|
||||
sb.append(" ");
|
||||
sb.append(PowerDisplayUtil.abrevation());
|
||||
sb.append("\n");
|
||||
|
||||
sb.append(CUR_REQUEST);
|
||||
sb.append(PowerDisplayUtil.formatPower(request));
|
||||
sb.append(" ");
|
||||
sb.append(PowerDisplayUtil.abrevation());
|
||||
|
||||
player.addChatComponentMessage(new ChatComponentText(sb.toString()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
package crazypants.render;
|
||||
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class IconUtil {
|
||||
|
||||
@@ -44,6 +45,7 @@ public class IconUtil {
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
@SubscribeEvent
|
||||
public void onIconLoad(TextureStitchEvent.Pre event) {
|
||||
for (IIconProvider reg : iconProviders) {
|
||||
if(reg.getTextureType() == event.map.getTextureType()) {
|
||||
|
||||
@@ -65,7 +65,7 @@ public class Util {
|
||||
}
|
||||
|
||||
// derived from ItemBlock.onItemUse
|
||||
public static BlockCoord canPlaceItem(ItemStack itemUsed, int blockIdToBePlaced, EntityPlayer player, World world, int x, int y, int z, int side) {
|
||||
public static BlockCoord canPlaceItem(ItemStack itemUsed, Block blockIdToBePlaced, EntityPlayer player, World world, int x, int y, int z, int side) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
if(block == Blocks.snow_layer && (world.getBlockMetadata(x, y, z) & 7) < 1) {
|
||||
@@ -92,9 +92,9 @@ public class Util {
|
||||
return null;
|
||||
} else if(!player.canPlayerEdit(x, y, z, side, itemUsed)) {
|
||||
return null;
|
||||
} else if(y == 255 && Block.getBlockById(blockIdToBePlaced).getMaterial().isSolid()) {
|
||||
} else if(y == 255 && blockIdToBePlaced.getMaterial().isSolid()) {
|
||||
return null;
|
||||
} else if(world.canPlaceEntityOnSide(Block.getBlockById(blockIdToBePlaced), x, y, z, false, side, player, itemUsed)) {
|
||||
} else if(world.canPlaceEntityOnSide(blockIdToBePlaced, x, y, z, false, side, player, itemUsed)) {
|
||||
return new BlockCoord(x, y, z);
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user