Added Factory input slot distribution, configurable voice ports, fixed several bugs
This commit is contained in:
parent
cac520876a
commit
f55d3ac874
13 changed files with 147 additions and 91 deletions
|
@ -35,7 +35,7 @@ public class ClientConnectionHandler implements IConnectionHandler
|
|||
if(Mekanism.voiceServerEnabled)
|
||||
{
|
||||
try {
|
||||
voiceClient = new VoiceClient(server, 36123);
|
||||
voiceClient = new VoiceClient(server, Mekanism.VOICE_PORT);
|
||||
voiceClient.run();
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class ClientConnectionHandler implements IConnectionHandler
|
|||
if(Mekanism.voiceServerEnabled)
|
||||
{
|
||||
try {
|
||||
voiceClient = new VoiceClient(InetAddress.getLocalHost().getHostAddress(), 36123);
|
||||
voiceClient = new VoiceClient(InetAddress.getLocalHost().getHostAddress(), Mekanism.VOICE_PORT);
|
||||
voiceClient.run();
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package mekanism.client.gui;
|
|||
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.common.IRedstoneControl;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.network.PacketSimpleGui;
|
||||
|
@ -26,8 +25,6 @@ public class GuiConfigurationTab extends GuiElement
|
|||
|
||||
guiObj.drawTexturedModalRect(guiWidth - 26, guiHeight + 6, 0, 0, 26, 26);
|
||||
|
||||
IRedstoneControl control = (IRedstoneControl)tileEntity;
|
||||
|
||||
if(xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28)
|
||||
{
|
||||
guiObj.drawTexturedModalRect(guiWidth - 21, guiHeight + 10, 26, 0, 18, 18);
|
||||
|
@ -44,8 +41,6 @@ public class GuiConfigurationTab extends GuiElement
|
|||
{
|
||||
mc.renderEngine.bindTexture(RESOURCE);
|
||||
|
||||
IRedstoneControl control = (IRedstoneControl)tileEntity;
|
||||
|
||||
if(xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28)
|
||||
{
|
||||
displayTooltip(MekanismUtils.localize("gui.configuration"), xAxis, yAxis);
|
||||
|
|
|
@ -28,6 +28,7 @@ public class GuiFactory extends GuiMekanism
|
|||
guiElements.add(new GuiUpgradeManagement(this, tileEntity, tileEntity.tier.guiLocation));
|
||||
guiElements.add(new GuiRecipeType(this, tileEntity, tileEntity.tier.guiLocation));
|
||||
guiElements.add(new GuiConfigurationTab(this, tileEntity, tileEntity.tier.guiLocation));
|
||||
guiElements.add(new GuiSortingTab(this, tileEntity, tileEntity.tier.guiLocation));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
73
common/mekanism/client/gui/GuiSortingTab.java
Normal file
73
common/mekanism/client/gui/GuiSortingTab.java
Normal file
|
@ -0,0 +1,73 @@
|
|||
package mekanism.client.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.tileentity.TileEntityFactory;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GuiSortingTab extends GuiElement
|
||||
{
|
||||
public GuiSortingTab(GuiScreen gui, TileEntity tile, ResourceLocation def)
|
||||
{
|
||||
super(MekanismUtils.getResource(ResourceType.GUI, "GuiSortingTab.png"), gui, tile, def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight)
|
||||
{
|
||||
mc.renderEngine.bindTexture(RESOURCE);
|
||||
|
||||
guiObj.drawTexturedModalRect(guiWidth - 26, guiHeight + 34, 0, 0, 26, 35);
|
||||
|
||||
if(xAxis >= -21 && xAxis <= -3 && yAxis >= 38 && yAxis <= 56)
|
||||
{
|
||||
guiObj.drawTexturedModalRect(guiWidth - 21, guiHeight + 38, 26, 0, 18, 18);
|
||||
}
|
||||
else {
|
||||
guiObj.drawTexturedModalRect(guiWidth - 21, guiHeight + 38, 26, 18, 18, 18);
|
||||
}
|
||||
|
||||
mc.renderEngine.bindTexture(defaultLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderForeground(int xAxis, int yAxis)
|
||||
{
|
||||
mc.renderEngine.bindTexture(RESOURCE);
|
||||
|
||||
getFontRenderer().drawString(((TileEntityFactory)tileEntity).sorting ? "On" : "Off", -21, 58, 0x0404040);
|
||||
|
||||
if(xAxis >= -21 && xAxis <= -3 && yAxis >= 38 && yAxis <= 56)
|
||||
{
|
||||
displayTooltip(MekanismUtils.localize("gui.factory.autoSort"), xAxis, yAxis);
|
||||
}
|
||||
|
||||
mc.renderEngine.bindTexture(defaultLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preMouseClicked(int xAxis, int yAxis, int button) {}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int xAxis, int yAxis, int button)
|
||||
{
|
||||
if(button == 0)
|
||||
{
|
||||
if(xAxis >= -21 && xAxis <= -3 && yAxis >= 38 && yAxis <= 56)
|
||||
{
|
||||
ArrayList data = new ArrayList();
|
||||
data.add(0);
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
|
||||
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -174,6 +174,7 @@ public class CommonProxy
|
|||
Mekanism.FROM_BC = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "JoulesToMJ", 25).getDouble(25);
|
||||
Mekanism.TO_BC = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MJToJoules", .04).getDouble(.04);
|
||||
Mekanism.ENERGY_PER_REDSTONE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnergyPerRedstone", 10000).getDouble(10000);
|
||||
Mekanism.VOICE_PORT = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoicePort", 36123).getInt();
|
||||
|
||||
Mekanism.TO_TE = Mekanism.TO_BC*10;
|
||||
Mekanism.FROM_TE = Mekanism.FROM_BC/10;
|
||||
|
|
|
@ -238,6 +238,7 @@ public class Mekanism
|
|||
public static int obsidianTNTBlastRadius = 12;
|
||||
public static int obsidianTNTDelay = 100;
|
||||
public static int UPDATE_DELAY = 10;
|
||||
public static int VOICE_PORT = 36123;
|
||||
public static double ENERGY_PER_REDSTONE = 10000;
|
||||
|
||||
public static double TO_IC2;
|
||||
|
|
|
@ -84,6 +84,8 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
|||
/** This machine's previous amount of energy. */
|
||||
public double prevEnergy;
|
||||
|
||||
public boolean sorting;
|
||||
|
||||
public int secondaryEnergyStored;
|
||||
|
||||
/** This machine's current RedstoneControl type. */
|
||||
|
@ -152,7 +154,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
|||
ChargeUtils.discharge(1, this);
|
||||
|
||||
handleSecondaryFuel();
|
||||
//sortInventory();
|
||||
sortInventory();
|
||||
|
||||
if(inventory[2] != null && inventory[3] == null)
|
||||
{
|
||||
|
@ -248,63 +250,52 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
|||
|
||||
public void sortInventory()
|
||||
{
|
||||
boolean didOp = false;
|
||||
|
||||
int[] inputSlots = null;
|
||||
|
||||
List<InvID> invStacks = new ArrayList<InvID>();
|
||||
|
||||
List<Integer> nullSlots = new ArrayList<Integer>();
|
||||
List<Integer> fullSlots = new ArrayList<Integer>();
|
||||
|
||||
if(tier == FactoryTier.BASIC)
|
||||
if(sorting)
|
||||
{
|
||||
inputSlots = new int[] {5, 6, 7};
|
||||
}
|
||||
else if(tier == FactoryTier.ADVANCED)
|
||||
{
|
||||
inputSlots = new int[] {5, 6, 7, 8, 9};
|
||||
}
|
||||
else if(tier == FactoryTier.ELITE)
|
||||
{
|
||||
inputSlots = new int[] {5, 6, 7, 8, 9, 10, 11};
|
||||
}
|
||||
|
||||
for(int id : inputSlots)
|
||||
{
|
||||
invStacks.add(InvID.get(id, inventory));
|
||||
boolean didOp = false;
|
||||
|
||||
if(inventory[id] == null)
|
||||
int[] inputSlots = null;
|
||||
|
||||
List<InvID> invStacks = new ArrayList<InvID>();
|
||||
|
||||
if(tier == FactoryTier.BASIC)
|
||||
{
|
||||
nullSlots.add(id);
|
||||
inputSlots = new int[] {5, 6, 7};
|
||||
}
|
||||
else if(inventory[id].stackSize > 1)
|
||||
else if(tier == FactoryTier.ADVANCED)
|
||||
{
|
||||
fullSlots.add(id);
|
||||
inputSlots = new int[] {5, 6, 7, 8, 9};
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(invStacks);
|
||||
|
||||
for(InvID invID1 : invStacks)
|
||||
{
|
||||
for(InvID invID2 : invStacks)
|
||||
else if(tier == FactoryTier.ELITE)
|
||||
{
|
||||
if(invID1.ID == invID2.ID || StackUtils.diffIgnoreNull(invID1.stack, invID2.stack) || Math.abs(invID1.size()-invID2.size()) < 2) continue;
|
||||
|
||||
List<ItemStack> evened = StackUtils.even(inventory[invID1.ID], inventory[invID2.ID]);
|
||||
inventory[invID1.ID] = evened.get(0);
|
||||
inventory[invID2.ID] = evened.get(1);
|
||||
|
||||
didOp = true;
|
||||
break;
|
||||
inputSlots = new int[] {5, 6, 7, 8, 9, 10, 11};
|
||||
}
|
||||
|
||||
if(didOp) break;
|
||||
for(int id : inputSlots)
|
||||
{
|
||||
invStacks.add(InvID.get(id, inventory));
|
||||
}
|
||||
|
||||
for(InvID invID1 : invStacks)
|
||||
{
|
||||
for(InvID invID2 : invStacks)
|
||||
{
|
||||
if(invID1.ID == invID2.ID || StackUtils.diffIgnoreNull(invID1.stack, invID2.stack) || Math.abs(invID1.size()-invID2.size()) < 2) continue;
|
||||
|
||||
List<ItemStack> evened = StackUtils.even(inventory[invID1.ID], inventory[invID2.ID]);
|
||||
inventory[invID1.ID] = evened.get(0);
|
||||
inventory[invID2.ID] = evened.get(1);
|
||||
|
||||
didOp = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(didOp) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class InvID implements Comparable<InvID>
|
||||
public static class InvID
|
||||
{
|
||||
public ItemStack stack;
|
||||
public int ID;
|
||||
|
@ -324,29 +315,6 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
|||
{
|
||||
return stack != null ? stack.itemID : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(InvID arg0)
|
||||
{
|
||||
if(arg0.id() < id())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if(arg0.id() > id())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if(arg0.size() < size())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if(arg0.size() > size())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static InvID get(int id, ItemStack[] inv)
|
||||
{
|
||||
|
@ -572,6 +540,18 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
|||
@Override
|
||||
public void handlePacketData(ByteArrayDataInput dataStream)
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
int type = dataStream.readInt();
|
||||
|
||||
if(type == 0)
|
||||
{
|
||||
sorting = !sorting;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
super.handlePacketData(dataStream);
|
||||
|
||||
clientActive = dataStream.readBoolean();
|
||||
|
@ -579,6 +559,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
|||
recipeTicks = dataStream.readInt();
|
||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
secondaryEnergyStored = dataStream.readInt();
|
||||
sorting = dataStream.readBoolean();
|
||||
|
||||
for(int i = 0; i < tier.processes; i++)
|
||||
{
|
||||
|
@ -608,6 +589,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
|||
recipeTicks = nbtTags.getInteger("recipeTicks");
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
secondaryEnergyStored = nbtTags.getInteger("secondaryEnergyStored");
|
||||
sorting = nbtTags.getBoolean("sorting");
|
||||
|
||||
for(int i = 0; i < tier.processes; i++)
|
||||
{
|
||||
|
@ -633,6 +615,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
|||
nbtTags.setInteger("recipeTicks", recipeTicks);
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
nbtTags.setInteger("secondaryEnergyStored", secondaryEnergyStored);
|
||||
nbtTags.setBoolean("sorting", sorting);
|
||||
|
||||
for(int i = 0; i < tier.processes; i++)
|
||||
{
|
||||
|
@ -657,6 +640,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
|||
data.add(recipeTicks);
|
||||
data.add(controlType.ordinal());
|
||||
data.add(secondaryEnergyStored);
|
||||
data.add(sorting);
|
||||
data.add(progress);
|
||||
data.add(sideConfig);
|
||||
|
||||
|
|
|
@ -23,10 +23,10 @@ public final class StackUtils
|
|||
}
|
||||
|
||||
int remain = stack.stackSize % 2;
|
||||
int split = (int)((float)stack.stackSize/2F);
|
||||
int split = (int)((float)(stack.stackSize)/2F);
|
||||
|
||||
ret.add(MekanismUtils.size(stack, split+remain));
|
||||
ret.add(MekanismUtils.size(stack, split));
|
||||
ret.add(size(stack, split+remain));
|
||||
ret.add(size(stack, split));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public final class StackUtils
|
|||
List<ItemStack> split = split(size(stack1, diff));
|
||||
|
||||
ret.add(subtract(stack1, split.get(0)));
|
||||
ret.add(add(stack2, split.get(1)));
|
||||
ret.add(add(stack2, split.get(0)));
|
||||
}
|
||||
else if(getSize(stack2) > getSize(stack1))
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ public final class StackUtils
|
|||
List<ItemStack> split = split(size(stack2, diff));
|
||||
|
||||
ret.add(subtract(stack2, split.get(0)));
|
||||
ret.add(add(stack1, split.get(1)));
|
||||
ret.add(add(stack1, split.get(0)));
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -6,13 +6,7 @@ import java.net.SocketException;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.NetLoginHandler;
|
||||
import net.minecraft.network.packet.NetHandler;
|
||||
import net.minecraft.network.packet.Packet1Login;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import cpw.mods.fml.common.network.IConnectionHandler;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import mekanism.common.Mekanism;
|
||||
|
||||
public class VoiceServerManager
|
||||
{
|
||||
|
@ -31,7 +25,7 @@ public class VoiceServerManager
|
|||
System.out.println("[Mekanism] VoiceServer: Starting up server...");
|
||||
|
||||
try {
|
||||
serverSocket = new ServerSocket(36123);
|
||||
serverSocket = new ServerSocket(Mekanism.VOICE_PORT);
|
||||
(listenThread = new ListenThread()).start();
|
||||
} catch(Exception e) {}
|
||||
|
||||
|
|
|
@ -68,7 +68,14 @@ public class GuiMultimeter extends GuiContainer
|
|||
|
||||
ArrayList data = new ArrayList();
|
||||
data.add((byte)3);
|
||||
data.add(Float.parseFloat(textFieldLimit.getText()));
|
||||
|
||||
if(!textFieldLimit.getText().isEmpty())
|
||||
{
|
||||
data.add(Float.parseFloat(textFieldLimit.getText()));
|
||||
}
|
||||
else {
|
||||
data.add(0);
|
||||
}
|
||||
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
|
||||
}
|
||||
|
|
|
@ -165,7 +165,6 @@ public class TileEntityBattery extends TileEntityElectricBlock
|
|||
//Main inventory
|
||||
if(nbtTags.hasKey("CellItems"))
|
||||
{
|
||||
System.out.println("yay");
|
||||
NBTTagList tagList = nbtTags.getTagList("CellItems");
|
||||
structure.inventory = new ArrayList<ItemStack>();
|
||||
|
||||
|
|
BIN
resources/assets/mekanism/gui/GuiSortingTab.png
Normal file
BIN
resources/assets/mekanism/gui/GuiSortingTab.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
|
@ -166,6 +166,7 @@ gui.factory.crushing=Crushing
|
|||
gui.factory.compressing=Compressing
|
||||
gui.factory.combining=Combining
|
||||
gui.factory.purifying=Purifying
|
||||
gui.factory.autoSort=Auto-sort
|
||||
|
||||
gui.oredictFilter=OreDict Filter
|
||||
gui.oredictFilter.noKey=No key entered
|
||||
|
|
Loading…
Reference in a new issue