mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-22 13:10:13 +00:00
Adding stuff back in.
This commit is contained in:
1 parent
b264131cf8
commit
a4c3993e6d
18 files changed
+232
-345
No files matched your search
@@ -115,14 +115,9 @@ public class ItemConduitNetwork extends AbstractConduitNetwork<IItemConduit, IIt
|
||||
for (NetworkedInventory inv : invs) {
|
||||
|
||||
if(inv.con.getLocation().equals(loc)) {
|
||||
|
||||
int numInserted = inv.insertIntoTargets(item.copy());
|
||||
if(numInserted >= item.stackSize) {
|
||||
//TODO: I was returning null here as per the API but quarries plus
|
||||
//was interpreting this as nothing being taken
|
||||
result = item.copy();
|
||||
result.stackSize = 0;
|
||||
return result;
|
||||
return null;
|
||||
}
|
||||
if(result == null) {
|
||||
result = item.copy();
|
||||
|
||||
@@ -37,17 +37,4 @@ public class ItemLiquidConduit extends AbstractItemConduit {
|
||||
return new LiquidConduit();
|
||||
}
|
||||
|
||||
//TODO
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List list, boolean par4) {
|
||||
// if(PREFIX == null) {
|
||||
// POSTFIX = " " + PowerDisplayUtil.abrevation() + PowerDisplayUtil.perTick();
|
||||
// PREFIX = Lang.localize("power.maxOutput") + " ";
|
||||
// }
|
||||
// super.addInformation(itemStack, par2EntityPlayer, list, par4);
|
||||
// ICapacitor cap = PowerConduit.CAPACITORS[itemStack.getItemDamage()];
|
||||
// list.add(PREFIX + PowerDisplayUtil.formatPower(cap.getMaxEnergyExtracted()) + POSTFIX);
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -1,14 +1,20 @@
|
||||
package crazypants.enderio.enderface;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.material.Alloy;
|
||||
|
||||
public class EnderfaceRecipes {
|
||||
|
||||
public static void addRecipes() {
|
||||
//TODO:1.7
|
||||
// ItemStack phasedGold = new ItemStack(EnderIO.itemAlloy, 1, Alloy.PHASED_GOLD.ordinal());
|
||||
// ItemStack fusedQuartz = new ItemStack(EnderIO.blockFusedQuartz, 1, 0);
|
||||
// ItemStack electricalSteel = new ItemStack(EnderIO.itemAlloy, 1, Alloy.ELECTRICAL_STEEL.ordinal());
|
||||
// GameRegistry.addRecipe(new ItemStack(EnderIO.blockEnderIo), "sqs", "qeq", "sqs", 's', electricalSteel, 'q', fusedQuartz, 'e', new ItemStack(
|
||||
// Items.ender_eye));
|
||||
|
||||
ItemStack phasedGold = new ItemStack(EnderIO.itemAlloy, 1, Alloy.PHASED_GOLD.ordinal());
|
||||
ItemStack fusedQuartz = new ItemStack(EnderIO.blockFusedQuartz, 1, 0);
|
||||
ItemStack electricalSteel = new ItemStack(EnderIO.itemAlloy, 1, Alloy.ELECTRICAL_STEEL.ordinal());
|
||||
GameRegistry.addRecipe(new ItemStack(EnderIO.blockEnderIo), "sqs", "qeq", "sqs", 's', electricalSteel, 'q', fusedQuartz, 'e', new ItemStack(
|
||||
Items.ender_eye));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -216,12 +216,11 @@ public class GuiEnderface extends GuiScreen {
|
||||
MovingObjectPosition hit = getClosestHit(Vec3.createVectorHelper(start.x, start.y, start.z), hits);
|
||||
if(hit != null) {
|
||||
Block block = world.getBlock(hit.blockX, hit.blockY, hit.blockZ);
|
||||
//TODO:1.7
|
||||
// if(block == EnderIO.blockHyperCube || block == EnderIO.blockCapacitorBank) {
|
||||
// block.onBlockActivated(world, hit.blockX, hit.blockY, hit.blockZ, player, 0, 0, 0, 0);
|
||||
// } else {
|
||||
openInterface(hit.blockX, hit.blockY, hit.blockZ);
|
||||
// }
|
||||
if(block == EnderIO.blockHyperCube || block == EnderIO.blockCapacitorBank) {
|
||||
block.onBlockActivated(world, hit.blockX, hit.blockY, hit.blockZ, player, 0, 0, 0, 0);
|
||||
} else {
|
||||
openInterface(hit.blockX, hit.blockY, hit.blockZ);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -555,18 +554,6 @@ public class GuiEnderface extends GuiScreen {
|
||||
}
|
||||
|
||||
void openInterface(int x, int y, int z) {
|
||||
|
||||
///TODO: Applied Energistics
|
||||
// if(MeProxy.instance.isMeAccessTerminal(player, x, y, z)) {
|
||||
// if(Config.enderIoMeAccessEnabled) {
|
||||
// Packet250CustomPayload pkt = EnderfacePacketProcessor.createMePacket(x, y, z);
|
||||
// PacketDispatcher.sendPacketToServer(pkt);
|
||||
// }
|
||||
// } else {
|
||||
// Packet250CustomPayload pkt = EnderfacePacketProcessor.createPacketEnderface(x, y, z);
|
||||
// PacketDispatcher.sendPacketToServer(pkt);
|
||||
// }
|
||||
|
||||
PacketOpenRemoteUi p = new PacketOpenRemoteUi(x, y, z);
|
||||
EnderIO.packetPipeline.sendToServer(p);
|
||||
}
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
package crazypants.enderio.enderface;
|
||||
|
||||
//TODO: Applied Energistics
|
||||
public class PacketOpenMeGui {
|
||||
|
||||
// private void handleMeTerminalPacket(DataInputStream data, INetworkManager manager, Player p) throws IOException {
|
||||
// if(!(p instanceof EntityPlayerMP)) {
|
||||
// return;
|
||||
// }
|
||||
// EntityPlayerMP player = (EntityPlayerMP) p;
|
||||
// int x = data.readInt();
|
||||
// int y = data.readInt();
|
||||
// int z = data.readInt();
|
||||
//
|
||||
// Container container = null;
|
||||
// try {
|
||||
// container = MeProxy.createMeTerminalContainer(player, x, y, z, false);
|
||||
// } catch (Exception e) {
|
||||
// Log.warn("EnderfacePacketProcessor.openRemoteGui: Could not open remote AE GUI. " + e);
|
||||
// }
|
||||
// openRemoteGui(player, GuiHandler.GUI_ID_ME_ACCESS_TERMINAL, player.worldObj, x, y, z, container);
|
||||
// }
|
||||
//
|
||||
// public static Packet250CustomPayload createMePacket(int x, int y, int z) {
|
||||
// ByteArrayOutputStream bos = new ByteArrayOutputStream(16);
|
||||
// DataOutputStream dos = new DataOutputStream(bos);
|
||||
// try {
|
||||
// dos.writeInt(PacketHandler.ID_ME_TERMINAL);
|
||||
// dos.writeInt(x);
|
||||
// dos.writeInt(y);
|
||||
// dos.writeInt(z);
|
||||
// } catch (IOException e) {
|
||||
// // never thrown
|
||||
// }
|
||||
// Packet250CustomPayload pkt = new Packet250CustomPayload();
|
||||
// pkt.channel = PacketHandler.CHANNEL;
|
||||
// pkt.data = bos.toByteArray();
|
||||
// pkt.length = bos.size();
|
||||
// pkt.isChunkDataPacket = true;
|
||||
// return pkt;
|
||||
// }
|
||||
//
|
||||
// public static Packet250CustomPayload createPacketEnderface(int x, int y, int z) {
|
||||
// ByteArrayOutputStream bos = new ByteArrayOutputStream(16);
|
||||
// DataOutputStream dos = new DataOutputStream(bos);
|
||||
// try {
|
||||
// dos.writeInt(PacketHandler.ID_ENDERFACE);
|
||||
// dos.writeInt(x);
|
||||
// dos.writeInt(y);
|
||||
// dos.writeInt(z);
|
||||
// } catch (IOException e) {
|
||||
// // never thrown
|
||||
// }
|
||||
// Packet250CustomPayload pkt = new Packet250CustomPayload();
|
||||
// pkt.channel = PacketHandler.CHANNEL;
|
||||
// pkt.data = bos.toByteArray();
|
||||
// pkt.length = bos.size();
|
||||
// pkt.isChunkDataPacket = true;
|
||||
// return pkt;
|
||||
// }
|
||||
//
|
||||
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public class PacketOpenRemoteUi implements IPacketEio {
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
// TODO: Move to config?
|
||||
// TODO: Move to config? or use reflectioon helper?
|
||||
this.realObj = obj;
|
||||
interceptNames.add("openGui");
|
||||
interceptNames.add("func_146100_a");
|
||||
|
||||
@@ -81,10 +81,4 @@ public class ItemYetaWrench extends Item implements IToolWrench {
|
||||
player.swingItem();
|
||||
}
|
||||
|
||||
//TODO:1.7 is this still needed?
|
||||
// @Override
|
||||
// public boolean shouldPassSneakingClickToBlock(World par2World, int par4, int par5, int par6) {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -228,8 +228,6 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements IIn
|
||||
if(worldObj.isRemote) {
|
||||
// check if the block on the client needs to update its texture
|
||||
if(isActive() != lastActive) {
|
||||
//TODO:1.7 is this ok?
|
||||
//worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
lastActive = isActive();
|
||||
@@ -291,10 +289,7 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements IIn
|
||||
// read in the inventories contents
|
||||
inventory = new ItemStack[slotDefinition.getNumSlots()];
|
||||
|
||||
//TODO:1.7
|
||||
//NBTTagList itemList = nbtRoot.getTagList("Items");
|
||||
NBTTagList itemList = (NBTTagList) nbtRoot.getTag("Items");
|
||||
|
||||
for (int i = 0; i < itemList.tagCount(); i++) {
|
||||
NBTTagCompound itemStack = itemList.getCompoundTagAt(i);
|
||||
byte slot = itemStack.getByte("Slot");
|
||||
|
||||
@@ -6,6 +6,10 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import crazypants.enderio.crafting.RecipeReigistry;
|
||||
|
||||
public class MachineRecipeRegistry {
|
||||
|
||||
public static final MachineRecipeRegistry instance = new MachineRecipeRegistry();
|
||||
@@ -14,11 +18,10 @@ public class MachineRecipeRegistry {
|
||||
|
||||
public void registerRecipe(String machine, IMachineRecipe recipe) {
|
||||
getRecipesForMachine(machine).put(recipe.getUid(), recipe);
|
||||
//TODO:1.7
|
||||
// Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
// if(side == Side.CLIENT) {
|
||||
// RecipeReigistry.instance.registerRecipes(recipe.getAllRecipes());
|
||||
// }
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if(side == Side.CLIENT) {
|
||||
RecipeReigistry.instance.registerRecipes(recipe.getAllRecipes());
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, IMachineRecipe> getRecipesForMachine(String machineName) {
|
||||
|
||||
@@ -74,14 +74,13 @@ public class MachineRecipes {
|
||||
}
|
||||
|
||||
//MJ Monitor
|
||||
//TODO:1.7
|
||||
// ItemStack mJReader = new ItemStack(EnderIO.itemMJReader, 1, 0);
|
||||
// ItemStack powerConduit = new ItemStack(EnderIO.itemPowerConduit, 1, 0);
|
||||
// ItemStack redstoneConduit = new ItemStack(EnderIO.itemRedstoneConduit, 1, 2);
|
||||
// ItemStack mJMonitor = new ItemStack(EnderIO.blockPowerMonitor, 1, 0);
|
||||
// GameRegistry
|
||||
// .addShapedRecipe(mJMonitor, "bmb", "bMb", "bcb", 'b', Blocks.stonebrick, 'e', Items.ender_eye, 'M', machineChassi, 'm', mJReader, 'p', powerConduit,
|
||||
// 'r', redstoneConduit, 'c', capacitor);
|
||||
ItemStack mJReader = new ItemStack(EnderIO.itemMJReader, 1, 0);
|
||||
ItemStack powerConduit = new ItemStack(EnderIO.itemPowerConduit, 1, 0);
|
||||
ItemStack redstoneConduit = new ItemStack(EnderIO.itemRedstoneConduit, 1, 2);
|
||||
ItemStack mJMonitor = new ItemStack(EnderIO.blockPowerMonitor, 1, 0);
|
||||
GameRegistry
|
||||
.addShapedRecipe(mJMonitor, "bmb", "bMb", "bcb", 'b', Blocks.stonebrick, 'e', Items.ender_eye, 'M', machineChassi, 'm', mJReader, 'p', powerConduit,
|
||||
'r', redstoneConduit, 'c', capacitor);
|
||||
|
||||
}
|
||||
|
||||
@@ -152,15 +151,14 @@ public class MachineRecipes {
|
||||
|
||||
}
|
||||
|
||||
//TODO:1.7
|
||||
// //MJ Reader
|
||||
// ItemStack mJReader = new ItemStack(EnderIO.itemMJReader, 1, 0);
|
||||
// ItemStack electricalSteel = new ItemStack(EnderIO.itemAlloy, 1, Alloy.ELECTRICAL_STEEL.ordinal());
|
||||
// ItemStack powerConduit = new ItemStack(EnderIO.itemPowerConduit, 1, 0);
|
||||
// ItemStack redstoneConduit = new ItemStack(EnderIO.itemRedstoneConduit, 1, 2);
|
||||
//
|
||||
// GameRegistry.addRecipe(new ShapedOreRecipe(mJReader, "epe", "gcg", "srs", 'p', powerConduit, 'r', redstoneConduit, 'c', Items.comparator, 'g',
|
||||
// Blocks.glass_pane, 's', silicon, 'e',
|
||||
// electricalSteel));
|
||||
//MJ Reader
|
||||
ItemStack mJReader = new ItemStack(EnderIO.itemMJReader, 1, 0);
|
||||
ItemStack electricalSteel = new ItemStack(EnderIO.itemAlloy, 1, Alloy.ELECTRICAL_STEEL.ordinal());
|
||||
ItemStack powerConduit = new ItemStack(EnderIO.itemPowerConduit, 1, 0);
|
||||
ItemStack redstoneConduit = new ItemStack(EnderIO.itemRedstoneConduit, 1, 2);
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(mJReader, "epe", "gcg", "srs", 'p', powerConduit, 'r', redstoneConduit, 'c', Items.comparator, 'g',
|
||||
Blocks.glass_pane, 's', silicon, 'e',
|
||||
electricalSteel));
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,14 @@ package crazypants.enderio.machine.alloy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.crafting.IEnderIoRecipe;
|
||||
import crazypants.enderio.crafting.IRecipeComponent;
|
||||
import crazypants.enderio.crafting.impl.EnderIoRecipe;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
import crazypants.enderio.machine.recipe.Recipe;
|
||||
import crazypants.enderio.machine.recipe.RecipeInput;
|
||||
@@ -18,7 +22,7 @@ public class BasicAlloyRecipe implements IAlloyRecipe {
|
||||
private float energyRequired = DEFAULT_ENERGY_USE;
|
||||
private ItemStack output;
|
||||
|
||||
//private final List<IEnderIoRecipe> recipeEIO;
|
||||
private final List<IEnderIoRecipe> recipeEIO;
|
||||
|
||||
private float expPerItem;
|
||||
|
||||
@@ -30,15 +34,14 @@ public class BasicAlloyRecipe implements IAlloyRecipe {
|
||||
expPerItem = recipe.getOutputs()[0].getExperiance();
|
||||
energyRequired = recipe.getEnergyRequired();
|
||||
|
||||
//TODO:1.7
|
||||
// List<IRecipeComponent> reipceComps = new ArrayList<IRecipeComponent>(recipe.getInputs().length);
|
||||
// for (RecipeInput input : recipe.getInputs()) {
|
||||
// crazypants.enderio.crafting.impl.RecipeInput ri = new crazypants.enderio.crafting.impl.RecipeInput(input.getInput(), -1, input.getEquivelentInputs());
|
||||
// reipceComps.add(ri);
|
||||
// }
|
||||
// reipceComps.add(new crazypants.enderio.crafting.impl.RecipeOutput(output));
|
||||
// IEnderIoRecipe rec = new EnderIoRecipe(IEnderIoRecipe.ALLOY_SMELTER_ID, energyRequired, reipceComps);
|
||||
// this.recipeEIO = Collections.singletonList(rec);
|
||||
List<IRecipeComponent> reipceComps = new ArrayList<IRecipeComponent>(recipe.getInputs().length);
|
||||
for (RecipeInput input : recipe.getInputs()) {
|
||||
crazypants.enderio.crafting.impl.RecipeInput ri = new crazypants.enderio.crafting.impl.RecipeInput(input.getInput(), -1, input.getEquivelentInputs());
|
||||
reipceComps.add(ri);
|
||||
}
|
||||
reipceComps.add(new crazypants.enderio.crafting.impl.RecipeOutput(output));
|
||||
IEnderIoRecipe rec = new EnderIoRecipe(IEnderIoRecipe.ALLOY_SMELTER_ID, energyRequired, reipceComps);
|
||||
this.recipeEIO = Collections.singletonList(rec);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -153,9 +156,9 @@ public class BasicAlloyRecipe implements IAlloyRecipe {
|
||||
return result.toArray(new MachineRecipeInput[result.size()]);
|
||||
}
|
||||
|
||||
// public List<IEnderIoRecipe> getAllRecipes() {
|
||||
// return recipeEIO;
|
||||
// }
|
||||
public List<IEnderIoRecipe> getAllRecipes() {
|
||||
return recipeEIO;
|
||||
}
|
||||
|
||||
static class InputKey {
|
||||
|
||||
|
||||
@@ -18,11 +18,13 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.enderface.BlockEio;
|
||||
import crazypants.enderio.machine.hypercube.TileHyperCube.IoMode;
|
||||
import crazypants.enderio.machine.hypercube.TileHyperCube.SubChannel;
|
||||
@@ -250,19 +252,18 @@ public class BlockHyperCube extends BlockEio implements IGuiHandler {
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) {
|
||||
//TODO:1.7
|
||||
// if(ConduitUtil.isToolEquipped(entityPlayer) && entityPlayer.isSneaking()) {
|
||||
// if(entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
// IToolWrench wrench = (IToolWrench) entityPlayer.getCurrentEquippedItem().getItem();
|
||||
// if(wrench.canWrench(entityPlayer, x, y, z)) {
|
||||
// removeBlockByPlayer(world, entityPlayer, x, y, z);
|
||||
// if(entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
// ((IToolWrench) entityPlayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityPlayer, x, y, z);
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if(ConduitUtil.isToolEquipped(entityPlayer) && entityPlayer.isSneaking()) {
|
||||
if(entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
IToolWrench wrench = (IToolWrench) entityPlayer.getCurrentEquippedItem().getItem();
|
||||
if(wrench.canWrench(entityPlayer, x, y, z)) {
|
||||
removedByPlayer(world, entityPlayer, x, y, z);
|
||||
if(entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
((IToolWrench) entityPlayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityPlayer, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(entityPlayer.isSneaking()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,11 +18,9 @@ public class ElectricLightRenderer implements ISimpleBlockRenderingHandler {
|
||||
|
||||
BoundingBox bb = new BoundingBox(0, 0, 0, 1, 0.2, 1);
|
||||
boolean doDraw = false;
|
||||
//TODO:1.7
|
||||
// if(!Tessellator.instance.isDrawing) {
|
||||
// doDraw = true;
|
||||
|
||||
Tessellator.instance.startDrawingQuads();
|
||||
// }
|
||||
|
||||
IIcon[] textures = new IIcon[6];
|
||||
textures[0] = block.getBlockTextureFromSide(ForgeDirection.NORTH.ordinal());
|
||||
textures[1] = block.getBlockTextureFromSide(ForgeDirection.SOUTH.ordinal());
|
||||
@@ -30,12 +28,9 @@ public class ElectricLightRenderer implements ISimpleBlockRenderingHandler {
|
||||
textures[3] = block.getBlockTextureFromSide(ForgeDirection.UP.ordinal());
|
||||
textures[4] = block.getBlockTextureFromSide(ForgeDirection.WEST.ordinal());
|
||||
textures[5] = block.getBlockTextureFromSide(ForgeDirection.EAST.ordinal());
|
||||
|
||||
CubeRenderer.render(bb, textures, null);
|
||||
|
||||
//if(doDraw) {
|
||||
Tessellator.instance.draw();
|
||||
//}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.client.gui.GuiTextField;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.gui.CheckBoxEIO;
|
||||
import crazypants.enderio.machine.power.PowerDisplayUtil;
|
||||
import crazypants.gui.GuiScreenBase;
|
||||
@@ -203,9 +204,7 @@ public class GuiPowerMonitor extends GuiScreenBase {
|
||||
if(i >= 0) {
|
||||
te.stopLevel = te.asPercentFloat(i);
|
||||
}
|
||||
//TODO:1.7
|
||||
// Packet pkt = PowerMonitorPacketHandler.createPowerMonitotPacket(te);
|
||||
// PacketDispatcher.sendPacketToServer(pkt);
|
||||
EnderIO.packetPipeline.sendToServer(new PacketPowerMonitor(te));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +1,25 @@
|
||||
package crazypants.enderio.machine.monitor;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
|
||||
public class ItemMJReader extends Item {
|
||||
|
||||
@@ -19,8 +27,7 @@ public class ItemMJReader extends Item {
|
||||
|
||||
public static ItemMJReader create() {
|
||||
|
||||
//TODO:1.7
|
||||
// PacketHandler.instance.addPacketProcessor(MJReaderPacketHandler.getInstance());
|
||||
EnderIO.packetPipeline.registerPacket(MJReaderPacketHandler.class);
|
||||
|
||||
ItemMJReader result = new ItemMJReader();
|
||||
result.init();
|
||||
@@ -38,36 +45,35 @@ public class ItemMJReader extends Item {
|
||||
float par9, float par10) {
|
||||
|
||||
if(player.isSneaking()) {
|
||||
//TODO:1.7
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof IConduitBundle) {
|
||||
IConduitBundle cb = (IConduitBundle) te;
|
||||
Set<ForgeDirection> cons = new HashSet<ForgeDirection>();
|
||||
for (IConduit con : cb.getConduits()) {
|
||||
cons.addAll(con.getExternalConnections());
|
||||
}
|
||||
|
||||
if(cons.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if(cons.size() == 1) {
|
||||
player.openGui(EnderIO.instance, GuiHandler.GUI_ID_EXTERNAL_CONNECTION_BASE + cons.iterator().next().ordinal(), world, x, y, z);
|
||||
return true;
|
||||
}
|
||||
player.openGui(EnderIO.instance, GuiHandler.GUI_ID_EXTERNAL_CONNECTION_SELECTOR, world, x, y, z);
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(!(te instanceof IConduitBundle) && MJReaderPacketHandler.canCreatePacket(world, x, y, z)) {
|
||||
if(world.isRemote) {
|
||||
EnderIO.packetPipeline.sendToServer(new MJReaderPacketHandler(x, y, z, side));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// TileEntity te = world.getTileEntity(x, y, z);
|
||||
// if(te instanceof IConduitBundle) {
|
||||
// IConduitBundle cb = (IConduitBundle) te;
|
||||
// Set<ForgeDirection> cons = new HashSet<ForgeDirection>();
|
||||
// for (IConduit con : cb.getConduits()) {
|
||||
// cons.addAll(con.getExternalConnections());
|
||||
// }
|
||||
//
|
||||
// if(cons.isEmpty()) {
|
||||
// return false;
|
||||
// }
|
||||
// if(cons.size() == 1) {
|
||||
// player.openGui(EnderIO.instance, GuiHandler.GUI_ID_EXTERNAL_CONNECTION_BASE + cons.iterator().next().ordinal(), world, x, y, z);
|
||||
// return true;
|
||||
// }
|
||||
// player.openGui(EnderIO.instance, GuiHandler.GUI_ID_EXTERNAL_CONNECTION_SELECTOR, world, x, y, z);
|
||||
//
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// TileEntity te = world.getTileEntity(x, y, z);
|
||||
// if(!(te instanceof IConduitBundle) && MJReaderPacketHandler.canCreatePacket(world, x, y, z)) {
|
||||
// if(world.isRemote) {
|
||||
// PacketDispatcher.sendPacketToServer(MJReaderPacketHandler.createInfoRequestPacket(x, y, z, side));
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package crazypants.enderio.machine.monitor;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -7,9 +10,13 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import crazypants.enderio.Log;
|
||||
import crazypants.enderio.conduit.ConnectionMode;
|
||||
import crazypants.enderio.conduit.TileConduitBundle;
|
||||
import crazypants.enderio.conduit.item.IItemConduit;
|
||||
@@ -19,16 +26,11 @@ 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.network.IPacketEio;
|
||||
import crazypants.enderio.power.IInternalPowerReceptor;
|
||||
import crazypants.util.Lang;
|
||||
|
||||
public class MJReaderPacketHandler {
|
||||
|
||||
static final MJReaderPacketHandler instance = new MJReaderPacketHandler();
|
||||
|
||||
public static MJReaderPacketHandler getInstance() {
|
||||
return instance;
|
||||
}
|
||||
public class MJReaderPacketHandler implements IPacketEio {
|
||||
|
||||
private static final String OF = " " + Lang.localize("gui.powerMonitor.of") + " ";
|
||||
private static final String CON_STORAGE = " " + Lang.localize("gui.powerMonitor.monHeading1") + ": ";
|
||||
@@ -66,68 +68,93 @@ public class MJReaderPacketHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
//TODO:1.7
|
||||
// public static Packet createInfoRequestPacket(int x, int y, int z, int side) {
|
||||
//
|
||||
// dos.writeInt(x);
|
||||
// dos.writeInt(y);
|
||||
// dos.writeInt(z);
|
||||
// dos.writeInt(side);
|
||||
//
|
||||
// }
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private ForgeDirection side;
|
||||
|
||||
// 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")));
|
||||
// }
|
||||
//
|
||||
// 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());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
public MJReaderPacketHandler() {
|
||||
}
|
||||
|
||||
public MJReaderPacketHandler(int x2, int y2, int z2, int side2) {
|
||||
this(x2, y2, z2, ForgeDirection.getOrientation(side2));
|
||||
}
|
||||
|
||||
public MJReaderPacketHandler(int x, int y, int z, ForgeDirection side) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ChannelHandlerContext ctx, ByteBuf buf) {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeShort(side.ordinal());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(ChannelHandlerContext ctx, ByteBuf buffer) {
|
||||
x = buffer.readInt();
|
||||
y = buffer.readInt();
|
||||
z = buffer.readInt();
|
||||
side = ForgeDirection.getOrientation(buffer.readShort());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleClientSide(EntityPlayer player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerSide(EntityPlayer player) {
|
||||
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) {
|
||||
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.addChatComponentMessage(new ChatComponentTranslation(block.getLocalizedName() + " " + Lang.localize("gui.mjReader.noPowerFromSide")));
|
||||
}
|
||||
|
||||
sendPowerReciptorInfo(player, block, (float) ph.getEnergyStored(), (float) ph.getMaxEnergyStored(), (float) ph.getMinEnergyReceived(),
|
||||
(float) ph.getMaxEnergyReceived(), (float) ph
|
||||
.getPowerReceiver().powerRequest());
|
||||
|
||||
} else if(te instanceof IPowerReceptor) {
|
||||
|
||||
IPowerReceptor pr = (IPowerReceptor) te;
|
||||
PowerReceiver rec = pr.getPowerReceiver(side);
|
||||
if(rec == null) {
|
||||
player.addChatComponentMessage(new ChatComponentTranslation(block.getLocalizedName() + " " + Lang.localize("gui.mjReader.noPowerFromSide")));
|
||||
} else {
|
||||
sendPowerReciptorInfo(player, block, (float) rec.getEnergyStored(), (float) rec.getMaxEnergyStored(), (float) rec.getMinEnergyReceived(),
|
||||
(float) rec.getMaxEnergyReceived(),
|
||||
(float) rec.powerRequest());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void sendInfoMessage(EntityPlayer player, TileConduitBundle tcb) {
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import crazypants.enderio.Log;
|
||||
import crazypants.enderio.network.IPacketEio;
|
||||
import crazypants.util.DyeColor;
|
||||
|
||||
public class PacketPowerMonitor implements IPacketEio {
|
||||
|
||||
@@ -15,9 +16,16 @@ public class PacketPowerMonitor implements IPacketEio {
|
||||
boolean engineControlEnabled;
|
||||
float startLevel;
|
||||
float stopLevel;
|
||||
DyeColor signalColor;
|
||||
|
||||
//TODO:1.7
|
||||
//SignalColor
|
||||
public PacketPowerMonitor() {
|
||||
}
|
||||
|
||||
public PacketPowerMonitor(TilePowerMonitor pm) {
|
||||
x = pm.xCoord;
|
||||
y = pm.yCoord;
|
||||
z = pm.zCoord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ChannelHandlerContext ctx, ByteBuf buf) {
|
||||
@@ -27,7 +35,7 @@ public class PacketPowerMonitor implements IPacketEio {
|
||||
buf.writeBoolean(engineControlEnabled);
|
||||
buf.writeFloat(startLevel);
|
||||
buf.writeFloat(stopLevel);
|
||||
// dos.writeShort(pm.signalColor.ordinal());
|
||||
buf.writeShort(signalColor.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,8 +46,7 @@ public class PacketPowerMonitor implements IPacketEio {
|
||||
engineControlEnabled = buffer.readBoolean();
|
||||
startLevel = buffer.readFloat();
|
||||
stopLevel = buffer.readFloat();
|
||||
|
||||
//signal color = DyeColor.fromIndex(data.readShort());
|
||||
signalColor = DyeColor.fromIndex(buffer.readShort());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,59 +69,8 @@ public class PacketPowerMonitor implements IPacketEio {
|
||||
pm.engineControlEnabled = engineControlEnabled;
|
||||
pm.startLevel = startLevel;
|
||||
pm.stopLevel = stopLevel;
|
||||
//pm.signalColor = signal;
|
||||
pm.signalColor = signalColor;
|
||||
player.worldObj.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
|
||||
//
|
||||
// public static Packet createPowerMonitotPacket(TilePowerMonitor pm) {
|
||||
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
// DataOutputStream dos = new DataOutputStream(bos);
|
||||
// try {
|
||||
// dos.writeInt(PacketHandler.ID_POWER_MONITOR_PACKET);
|
||||
// dos.writeInt(pm.xCoord);
|
||||
// dos.writeInt(pm.yCoord);
|
||||
// dos.writeInt(pm.zCoord);
|
||||
// dos.writeBoolean(pm.engineControlEnabled);
|
||||
// dos.writeFloat(pm.startLevel);
|
||||
// dos.writeFloat(pm.stopLevel);
|
||||
// dos.writeShort(pm.signalColor.ordinal());
|
||||
//
|
||||
// } catch (IOException e) {
|
||||
// // never thrown
|
||||
// }
|
||||
// Packet250CustomPayload pkt = new Packet250CustomPayload();
|
||||
// pkt.channel = PacketHandler.CHANNEL;
|
||||
// pkt.data = bos.toByteArray();
|
||||
// pkt.length = bos.size();
|
||||
// pkt.isChunkDataPacket = true;
|
||||
// return pkt;
|
||||
// }
|
||||
//
|
||||
// private void handlPacket(DataInputStream data, INetworkManager manager, Player player) throws IOException {
|
||||
// if(!(player instanceof EntityPlayer)) {
|
||||
// Log.warn("createPowerMonitotPacket: Could not handle packet as player not an entity player.");
|
||||
// return;
|
||||
// }
|
||||
// World world = ((EntityPlayer) player).worldObj;
|
||||
// if(world == null) {
|
||||
// Log.warn("createPowerMonitotPacket: Could not handle packet as player world was null.");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// int x = data.readInt();
|
||||
// int y = data.readInt();
|
||||
// int z = data.readInt();
|
||||
// TileEntity te = world.getTileEntity(x, y, z);
|
||||
// if(!(te instanceof TilePowerMonitor)) {
|
||||
// Log.warn("createPowerMonitotPacket: Could not handle packet as TileEntity was not a TilePowerMonitor.");
|
||||
// return;
|
||||
// }
|
||||
// TilePowerMonitor pm = (TilePowerMonitor) te;
|
||||
// pm.engineControlEnabled = data.readBoolean();
|
||||
// pm.startLevel = data.readFloat();
|
||||
// pm.stopLevel = data.readFloat();
|
||||
// pm.signalColor = DyeColor.fromIndex(data.readShort());
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -37,27 +37,25 @@ public class TilePowerMonitor extends AbstractMachineEntity implements IInternal
|
||||
|
||||
private Signal currentlyEmmittedSignal;
|
||||
|
||||
//Signal currentlyEmmittedSignal;
|
||||
|
||||
public TilePowerMonitor() {
|
||||
super(new SlotDefinition(0, 0));
|
||||
}
|
||||
|
||||
public int[] getRednetOutputValues(ForgeDirection side) {
|
||||
// if(currentlyEmmittedSignal == null) {
|
||||
// return new int[16];
|
||||
// }
|
||||
if(currentlyEmmittedSignal == null) {
|
||||
return new int[16];
|
||||
}
|
||||
int[] res = new int[DyeColor.values().length];
|
||||
// for (DyeColor col : DyeColor.values()) {
|
||||
// res[col.ordinal()] = currentlyEmmittedSignal.color == col ? 15 : 0;
|
||||
// }
|
||||
for (DyeColor col : DyeColor.values()) {
|
||||
res[col.ordinal()] = currentlyEmmittedSignal.color == col ? 15 : 0;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public int getRednetOutputValue(ForgeDirection side, int subnet) {
|
||||
// if(currentlyEmmittedSignal != null) {
|
||||
// return 15;
|
||||
// }
|
||||
if(currentlyEmmittedSignal != null) {
|
||||
return 15;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user