Revert "Fusion reactor fixes & rewrite, energy fixes."
This reverts commit 06fad2264f
.
This commit is contained in:
parent
22fd152ec9
commit
8a0d981018
13 changed files with 386 additions and 279 deletions
|
@ -7,22 +7,21 @@ import net.minecraftforge.fml.relauncher.Side;
|
|||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import reborncore.client.gui.SlotOutput;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.api.reactor.FusionReactorRecipe;
|
||||
import techreborn.tiles.fusionReactor.TileEntityFusionController;
|
||||
|
||||
public class ContainerFusionReactor extends RebornContainer {
|
||||
public class ContainerFusionReactor extends RebornContainer
|
||||
{
|
||||
|
||||
public int coilStatus;
|
||||
public int energy;
|
||||
public int tickTime;
|
||||
public int finalTickTime;
|
||||
|
||||
public int neededEnergy;
|
||||
public int energy;
|
||||
|
||||
public boolean hasCoils;
|
||||
public int neededEU;
|
||||
|
||||
TileEntityFusionController fusionController;
|
||||
|
||||
public ContainerFusionReactor(TileEntityFusionController tileEntityFusionController, EntityPlayer player) {
|
||||
public ContainerFusionReactor(TileEntityFusionController tileEntityFusionController, EntityPlayer player)
|
||||
{
|
||||
super();
|
||||
this.fusionController = tileEntityFusionController;
|
||||
|
||||
|
@ -32,73 +31,105 @@ public class ContainerFusionReactor extends RebornContainer {
|
|||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
this.addSlotToContainer(new BaseSlot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i) {
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
FusionReactorRecipe rec = fusionController.recipe;
|
||||
for (int i = 0; i < this.listeners.size(); i++) {
|
||||
IContainerListener listener = this.listeners.get(i);
|
||||
listener.sendProgressBarUpdate(this, 0, fusionController.hasCoils ? 1 : 0);
|
||||
listener.sendProgressBarUpdate(this, 1, (int) fusionController.getEnergy());
|
||||
listener.sendProgressBarUpdate(this, 2, rec == null ? 0 : (int) rec.getStartEU());
|
||||
listener.sendProgressBarUpdate(this, 3, rec == null ? -1 : fusionController.recipeTickTime);
|
||||
listener.sendProgressBarUpdate(this, 4, rec == null ? 0 : rec.getTickTime());
|
||||
for (int i = 0; i < this.listeners.size(); i++)
|
||||
{
|
||||
IContainerListener IContainerListener = this.listeners.get(i);
|
||||
if (this.coilStatus != fusionController.coilStatus)
|
||||
{
|
||||
IContainerListener.sendProgressBarUpdate(this, 0, fusionController.coilStatus);
|
||||
}
|
||||
if (this.energy != (int) fusionController.getEnergy())
|
||||
{
|
||||
IContainerListener.sendProgressBarUpdate(this, 1, (int) fusionController.getEnergy());
|
||||
}
|
||||
if (this.tickTime != fusionController.crafingTickTime)
|
||||
{
|
||||
IContainerListener.sendProgressBarUpdate(this, 2, fusionController.crafingTickTime);
|
||||
}
|
||||
if (this.finalTickTime != fusionController.finalTickTime)
|
||||
{
|
||||
IContainerListener.sendProgressBarUpdate(this, 3, fusionController.finalTickTime);
|
||||
}
|
||||
if (this.neededEU != fusionController.neededPower)
|
||||
{
|
||||
IContainerListener.sendProgressBarUpdate(this, 4, fusionController.neededPower);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(IContainerListener listener) {
|
||||
super.addListener(listener);
|
||||
FusionReactorRecipe rec = fusionController.recipe;
|
||||
listener.sendProgressBarUpdate(this, 0, fusionController.hasCoils ? 1 : 0);
|
||||
listener.sendProgressBarUpdate(this, 1, (int) fusionController.getEnergy());
|
||||
listener.sendProgressBarUpdate(this, 2, rec == null ? 0 : (int) rec.getStartEU());
|
||||
listener.sendProgressBarUpdate(this, 3, rec == null ? -1 : fusionController.recipeTickTime);
|
||||
listener.sendProgressBarUpdate(this, 4, rec == null ? 0 : rec.getTickTime());
|
||||
public void addListener(IContainerListener crafting)
|
||||
{
|
||||
super.addListener(crafting);
|
||||
crafting.sendProgressBarUpdate(this, 0, fusionController.coilStatus);
|
||||
crafting.sendProgressBarUpdate(this, 1, (int) fusionController.getEnergy());
|
||||
crafting.sendProgressBarUpdate(this, 2, fusionController.crafingTickTime);
|
||||
crafting.sendProgressBarUpdate(this, 3, fusionController.finalTickTime);
|
||||
crafting.sendProgressBarUpdate(this, 4, fusionController.neededPower);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void updateProgressBar(int id, int value) {
|
||||
switch (id) {
|
||||
case 0:
|
||||
this.hasCoils = value == 1;
|
||||
break;
|
||||
case 1:
|
||||
this.energy = value;
|
||||
break;
|
||||
case 2:
|
||||
this.neededEnergy = value;
|
||||
break;
|
||||
case 3:
|
||||
this.tickTime = value;
|
||||
break;
|
||||
case 4:
|
||||
this.finalTickTime = value;
|
||||
break;
|
||||
public void updateProgressBar(int id, int value)
|
||||
{
|
||||
if (id == 0)
|
||||
{
|
||||
this.coilStatus = value;
|
||||
} else if (id == 1)
|
||||
{
|
||||
this.energy = value;
|
||||
} else if (id == 2)
|
||||
{
|
||||
this.tickTime = value;
|
||||
} else if (id == 3)
|
||||
{
|
||||
this.finalTickTime = value;
|
||||
} else if (id == 4)
|
||||
{
|
||||
this.neededEU = value;
|
||||
}
|
||||
if (tickTime == -1)
|
||||
{
|
||||
tickTime = 0;
|
||||
}
|
||||
if (finalTickTime == -1)
|
||||
{
|
||||
finalTickTime = 0;
|
||||
}
|
||||
if (neededEU == -1)
|
||||
{
|
||||
neededEU = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int getProgressScaled() {
|
||||
public int getProgressScaled()
|
||||
{
|
||||
return Math.max(0, Math.min(24,
|
||||
(this.tickTime > 0 ? 1 : 0) + this.tickTime * 24 / (this.finalTickTime < 1 ? 1 : this.finalTickTime)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue