Aw yeah! Better GUI packets for Miner. Heading to bed guys, see ya tomorrow!

This commit is contained in:
Aidan Brady 2013-11-21 22:30:01 -05:00
parent 0e2d2917d1
commit ace1365d0f
22 changed files with 147 additions and 35 deletions

View file

@ -143,14 +143,15 @@ public class GuiDigitalMiner extends GuiMekanism
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040);
fontRenderer.drawString(tileEntity.fullName, 69, 6, 0x404040);
fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040);
fontRenderer.drawString(tileEntity.running ? "Running" : "Idle", 9, 19, 0x00CD00);
fontRenderer.drawString(tileEntity.searcher.state.desc, 9, 28, 0x00CD00);
fontRenderer.drawString(tileEntity.running ? "Running" : "Idle", 9, 10, 0x00CD00);
fontRenderer.drawString(tileEntity.searcher.state.desc, 9, 19, 0x00CD00);
fontRenderer.drawString("Eject: " + (tileEntity.doEject ? "On" : "Off"), 9, 39, 0x00CD00);
fontRenderer.drawString("Pull: " + (tileEntity.doPull ? "On" : "Off"), 9, 48, 0x00CD00);
fontRenderer.drawString("Eject: " + (tileEntity.doEject ? "On" : "Off"), 9, 30, 0x00CD00);
fontRenderer.drawString("Pull: " + (tileEntity.doPull ? "On" : "Off"), 9, 39, 0x00CD00);
fontRenderer.drawString("Silk: " + (tileEntity.silkTouch ? "On" : "Off"), 9, 48, 0x00CD00);
fontRenderer.drawString("To mine:", 9, 59, 0x00CD00);
fontRenderer.drawString("" + tileEntity.clientToMine, 9, 68, 0x00CD00);
@ -189,6 +190,11 @@ public class GuiDigitalMiner extends GuiMekanism
drawCreativeTabHoveringText("Reset", xAxis, yAxis);
}
if(xAxis >= 131 && xAxis <= 145 && yAxis >= 63 && yAxis <= 77)
{
drawCreativeTabHoveringText("Silk touch", xAxis, yAxis);
}
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@ -235,6 +241,14 @@ public class GuiDigitalMiner extends GuiMekanism
drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 4 + 28, 14, 14, 14);
}
if(xAxis >= 131 && xAxis <= 145 && yAxis >= 63 && yAxis <= 77)
{
drawTexturedModalRect(guiWidth + 131, guiHeight + 63, 176 + 4 + 42, 0, 14, 14);
}
else {
drawTexturedModalRect(guiWidth + 131, guiHeight + 63, 176 + 4 + 42, 14, 14, 14);
}
if(xAxis >= 144 && xAxis <= 160 && yAxis >= 27 && yAxis <= 43)
{
GL11.glPushMatrix();
@ -291,6 +305,16 @@ public class GuiDigitalMiner extends GuiMekanism
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
}
if(xAxis >= 131 && xAxis <= 145 && yAxis >= 63 && yAxis <= 77)
{
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
ArrayList data = new ArrayList();
data.add(9);
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
}
if(xAxis >= 144 && xAxis <= 160 && yAxis >= 27 && yAxis <= 43)
{
boolean doNull = false;

View file

@ -184,7 +184,7 @@ public class GuiDigitalMinerConfig extends GuiMekanism
if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16)
{
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
PacketHandler.sendPacket(Transmission.SERVER, new PacketSimpleGui().setParams(Object3D.get(tileEntity), 2));
PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitalMinerGui().setParams(MinerGuiPacket.SERVER, Object3D.get(tileEntity), 3));
}
if(xAxis >= 39 && xAxis <= 50 && yAxis >= 67 && yAxis <= 78)

View file

@ -823,6 +823,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
itemStack.stackTagCompound.setInteger("maxY", miner.maxY);
itemStack.stackTagCompound.setBoolean("doEject", miner.doEject);
itemStack.stackTagCompound.setBoolean("doPull", miner.doPull);
itemStack.stackTagCompound.setBoolean("silkTouch", miner.silkTouch);
if(miner.replaceStack != null)
{

View file

@ -43,16 +43,17 @@ public class ContainerAdvancedElectricMachine extends Container
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
}
tileEntity.openChest();
tileEntity.playersUsing.add(inventory.player);
tileEntity.openChest();
}
@Override
public void onContainerClosed(EntityPlayer entityplayer)
{
super.onContainerClosed(entityplayer);
tileEntity.closeChest();
tileEntity.playersUsing.remove(entityplayer);
tileEntity.closeChest();
}
@Override

View file

@ -47,8 +47,8 @@ public class ContainerDigitalMiner extends Container
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 206));
}
tileEntity.openChest();
tileEntity.playersUsing.add(inventory.player);
tileEntity.openChest();
}
@Override
@ -56,8 +56,8 @@ public class ContainerDigitalMiner extends Container
{
super.onContainerClosed(entityplayer);
tileEntity.closeChest();
tileEntity.playersUsing.remove(entityplayer);
tileEntity.closeChest();
}
@Override

View file

@ -41,6 +41,7 @@ public class ContainerDynamicTank extends Container
public void onContainerClosed(EntityPlayer entityplayer)
{
super.onContainerClosed(entityplayer);
tileEntity.playersUsing.remove(entityplayer);
tileEntity.closeChest();
}

View file

@ -26,8 +26,8 @@ public class ContainerElectricChest extends Container
if(isBlock)
{
tileEntity.openChest();
tileEntity.playersUsing.add(inventory.player);
tileEntity.openChest();
}
else {
itemInventory.openChest();
@ -77,8 +77,8 @@ public class ContainerElectricChest extends Container
if(isBlock)
{
tileEntity.closeChest();
tileEntity.playersUsing.remove(entityplayer);
tileEntity.closeChest();
}
else {
itemInventory.closeChest();

View file

@ -39,16 +39,17 @@ public class ContainerElectricMachine extends Container
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
}
tileEntity.openChest();
tileEntity.playersUsing.add(inventory.player);
tileEntity.openChest();
}
@Override
public void onContainerClosed(EntityPlayer entityplayer)
{
super.onContainerClosed(entityplayer);
tileEntity.closeChest();
tileEntity.playersUsing.remove(entityplayer);
tileEntity.closeChest();
}
@Override

View file

@ -36,8 +36,8 @@ public class ContainerElectricPump extends Container
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
}
tileEntity.openChest();
tileEntity.playersUsing.add(inventory.player);
tileEntity.openChest();
}
@Override
@ -45,8 +45,8 @@ public class ContainerElectricPump extends Container
{
super.onContainerClosed(entityplayer);
tileEntity.closeChest();
tileEntity.playersUsing.remove(entityplayer);
tileEntity.closeChest();
}
@Override

View file

@ -38,16 +38,17 @@ public class ContainerEnergyCube extends Container
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
}
tileEntity.openChest();
tileEntity.playersUsing.add(inventory.player);
tileEntity.openChest();
}
@Override
public void onContainerClosed(EntityPlayer entityplayer)
{
super.onContainerClosed(entityplayer);
tileEntity.closeChest();
tileEntity.playersUsing.remove(entityplayer);
tileEntity.closeChest();
}
@Override

View file

@ -94,16 +94,17 @@ public class ContainerFactory extends Container
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
}
tileEntity.openChest();
tileEntity.playersUsing.add(inventory.player);
tileEntity.openChest();
}
@Override
public void onContainerClosed(EntityPlayer entityplayer)
{
super.onContainerClosed(entityplayer);
tileEntity.closeChest();
tileEntity.playersUsing.remove(entityplayer);
tileEntity.closeChest();
}
@Override

View file

@ -30,8 +30,8 @@ public class ContainerFilter extends Container
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
}
tileEntity.openChest();
tileEntity.playersUsing.add(inventory.player);
tileEntity.openChest();
}
@Override
@ -39,8 +39,8 @@ public class ContainerFilter extends Container
{
super.onContainerClosed(entityplayer);
tileEntity.closeChest();
tileEntity.playersUsing.remove(entityplayer);
tileEntity.closeChest();
}
@Override

View file

@ -35,16 +35,17 @@ public class ContainerGasTank extends Container
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
}
tileEntity.openChest();
tileEntity.playersUsing.add(inventory.player);
tileEntity.openChest();
}
@Override
public void onContainerClosed(EntityPlayer entityplayer)
{
super.onContainerClosed(entityplayer);
tileEntity.closeChest();
tileEntity.playersUsing.remove(entityplayer);
tileEntity.closeChest();
}
@Override

View file

@ -43,16 +43,17 @@ public class ContainerMetallurgicInfuser extends Container
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
}
tileEntity.openChest();
tileEntity.playersUsing.add(inventory.player);
tileEntity.openChest();
}
@Override
public void onContainerClosed(EntityPlayer entityplayer)
{
super.onContainerClosed(entityplayer);
tileEntity.closeChest();
tileEntity.playersUsing.remove(entityplayer);
tileEntity.closeChest();
}
@Override

View file

@ -12,8 +12,8 @@ public class ContainerNull extends Container
{
tileEntity = tile;
tileEntity.openChest();
tileEntity.playersUsing.add(player);
tileEntity.openChest();
}
@Override
@ -21,8 +21,8 @@ public class ContainerNull extends Container
{
super.onContainerClosed(entityplayer);
tileEntity.closeChest();
tileEntity.playersUsing.remove(entityplayer);
tileEntity.closeChest();
}
@Override

View file

@ -32,8 +32,8 @@ public class ContainerTeleporter extends Container
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
}
tileEntity.openChest();
tileEntity.playersUsing.add(inventory.player);
tileEntity.openChest();
}
@Override
@ -41,8 +41,8 @@ public class ContainerTeleporter extends Container
{
super.onContainerClosed(entityplayer);
tileEntity.closeChest();
tileEntity.playersUsing.remove(entityplayer);
tileEntity.closeChest();
}
@Override

View file

@ -221,6 +221,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
miner.maxY = stack.stackTagCompound.getInteger("maxY");
miner.doEject = stack.stackTagCompound.getBoolean("doEject");
miner.doPull = stack.stackTagCompound.getBoolean("doPull");
miner.silkTouch = stack.stackTagCompound.getBoolean("silkTouch");
if(stack.stackTagCompound.hasKey("replaceStack"))
{

View file

@ -8,6 +8,7 @@ import mekanism.api.Object3D;
import mekanism.common.ITileNetwork;
import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.tileentity.TileEntityBasicBlock;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.TransporterUtils;
import net.minecraft.entity.player.EntityPlayer;
@ -91,6 +92,11 @@ public class PacketConfigurationUpdate implements IMekanismPacket
{
config.getEjector().setStrictInput(!config.getEjector().hasStrictInput());
}
for(EntityPlayer p : ((TileEntityBasicBlock)config).playersUsing)
{
PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(object3D, ((ITileNetwork)tile).getNetworkedData(new ArrayList())), p);
}
}
}

View file

@ -4,11 +4,13 @@ import java.io.DataOutputStream;
import java.util.ArrayList;
import mekanism.api.Object3D;
import mekanism.client.gui.GuiDigitalMiner;
import mekanism.client.gui.GuiDigitalMinerConfig;
import mekanism.client.gui.GuiMItemStackFilter;
import mekanism.client.gui.GuiMOreDictFilter;
import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.inventory.container.ContainerDigitalMiner;
import mekanism.common.inventory.container.ContainerFilter;
import mekanism.common.inventory.container.ContainerNull;
import mekanism.common.tileentity.TileEntityContainerBlock;
@ -127,6 +129,10 @@ public class PacketDigitalMinerGui implements IMekanismPacket
{
container = new ContainerNull(playerMP, (TileEntityContainerBlock)obj.getTileEntity(world));
}
else if(guiType == 3)
{
container = new ContainerDigitalMiner(playerMP.inventory, (TileEntityDigitalMiner)obj.getTileEntity(world));
}
else if(guiType == 1 || guiType == 2)
{
container = new ContainerFilter(playerMP.inventory, (TileEntityContainerBlock)obj.getTileEntity(world));
@ -166,6 +172,10 @@ public class PacketDigitalMinerGui implements IMekanismPacket
{
return new GuiDigitalMinerConfig(player, (TileEntityDigitalMiner)world.getBlockTileEntity(x, y, z));
}
else if(type == 3)
{
return new GuiDigitalMiner(player.inventory, (TileEntityDigitalMiner)world.getBlockTileEntity(x, y, z));
}
else {
if(packetType == MinerGuiPacket.CLIENT)
{

View file

@ -53,7 +53,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
public ThreadMinerSearch searcher = new ThreadMinerSearch(this);
public final double ENERGY_USAGE = 50;
public final double ENERGY_USAGE = 100;
public int radius;
@ -72,6 +72,8 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
public boolean isActive;
public boolean clientActive;
public boolean silkTouch;
public boolean running;
public double prevEnergy;
@ -108,7 +110,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
{
ChargeUtils.discharge(27, this);
if(running && getEnergy() >= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_USAGE) && searcher.state == State.FINISHED && oresToMine.size() > 0)
if(running && getEnergy() >= getPerTick() && searcher.state == State.FINISHED && oresToMine.size() > 0)
{
setActive(true);
@ -117,7 +119,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
delay--;
}
setEnergy(getEnergy()-MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_USAGE));
setEnergy(getEnergy()-getPerTick());
if(delay == 0)
{
@ -202,7 +204,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
{
for(EntityPlayer player : playersUsing)
{
PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Object3D.get(this), getGenericPacket(new ArrayList())), player);
PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Object3D.get(this), getSmallPacket(new ArrayList())), player);
}
}
@ -210,6 +212,18 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
}
}
public double getPerTick()
{
double ret = MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_USAGE);
if(silkTouch)
{
ret *= 6;
}
return ret;
}
public int getDelay()
{
return (int)Math.pow((9-getSpeedMultiplier()), 2);
@ -420,6 +434,20 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
MekanismUtils.saveChunk(this);
}
@Override
public void openChest()
{
super.openChest();
if(!worldObj.isRemote)
{
for(EntityPlayer player : playersUsing)
{
PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())), player);
}
}
}
@Override
public void readFromNBT(NBTTagCompound nbtTags)
{
@ -433,6 +461,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
isActive = nbtTags.getBoolean("isActive");
running = nbtTags.getBoolean("running");
delay = nbtTags.getInteger("delay");
silkTouch = nbtTags.getBoolean("silkTouch");
searcher.state = State.values()[nbtTags.getInteger("state")];
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
@ -480,6 +509,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
nbtTags.setBoolean("isActive", isActive);
nbtTags.setBoolean("running", running);
nbtTags.setInteger("delay", delay);
nbtTags.setBoolean("silkTouch", silkTouch);
nbtTags.setInteger("state", searcher.state.ordinal());
nbtTags.setInteger("controlType", controlType.ordinal());
@ -564,6 +594,15 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
{
maxY = dataStream.readInt();
}
else if(type == 9)
{
silkTouch = !silkTouch;
}
for(EntityPlayer player : playersUsing)
{
PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Object3D.get(this), getGenericPacket(new ArrayList())), player);
}
return;
}
@ -581,6 +620,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
doPull = dataStream.readBoolean();
isActive = dataStream.readBoolean();
running = dataStream.readBoolean();
silkTouch = dataStream.readBoolean();
searcher.state = State.values()[dataStream.readInt()];
if(dataStream.readBoolean())
@ -612,6 +652,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
doPull = dataStream.readBoolean();
isActive = dataStream.readBoolean();
running = dataStream.readBoolean();
silkTouch = dataStream.readBoolean();
searcher.state = State.values()[dataStream.readInt()];
if(dataStream.readBoolean())
@ -636,6 +677,12 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
filters.add(MinerFilter.readFromPacket(dataStream));
}
}
else if(type == 3)
{
isActive = dataStream.readBoolean();
running = dataStream.readBoolean();
clientToMine = dataStream.readInt();
}
}
@Override
@ -652,6 +699,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
data.add(doPull);
data.add(isActive);
data.add(running);
data.add(silkTouch);
data.add(searcher.state.ordinal());
if(replaceStack != null)
@ -677,6 +725,19 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
return data;
}
public ArrayList getSmallPacket(ArrayList data)
{
super.getNetworkedData(data);
data.add(3);
data.add(isActive);
data.add(running);
data.add(oresToMine.size());
return data;
}
public ArrayList getGenericPacket(ArrayList data)
{
super.getNetworkedData(data);
@ -690,6 +751,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
data.add(doPull);
data.add(isActive);
data.add(running);
data.add(silkTouch);
data.add(searcher.state.ordinal());
if(replaceStack != null)

View file

@ -5,6 +5,7 @@ package mekanism.induction.client.render;
import java.util.Random;
import mekanism.common.Mekanism;
import mekanism.induction.client.model.ModelBattery;
import mekanism.induction.common.MekanismInduction;
import mekanism.induction.common.tileentity.TileEntityBattery;
@ -71,7 +72,7 @@ public class RenderBattery extends TileEntitySpecialRenderer
{
if (this.fakeBattery == null)
{
this.fakeBattery = new EntityItem(t.worldObj, 0, 0, 0, new ItemStack(MekanismInduction.Capacitor));
this.fakeBattery = new EntityItem(t.worldObj, 0, 0, 0, new ItemStack(Mekanism.EnergyTablet));
this.fakeBattery.age = 10;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB