Finish off the reactor changes, feel free to suggest some more tweaks to it.
This commit is contained in:
parent
90e0ea23b9
commit
5c81430c4c
2 changed files with 73 additions and 16 deletions
|
@ -40,6 +40,7 @@ import techreborn.packets.PacketFusionControlSize;
|
|||
import techreborn.proxies.ClientProxy;
|
||||
import techreborn.tiles.fusionReactor.TileFusionControlComputer;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -81,6 +82,10 @@ public class GuiFusionReactor extends GuiBase {
|
|||
if (tile.getCoilStatus() > 0) {
|
||||
addHologramButton(6, 4, 212, layer);
|
||||
builder.drawHologramButton(this, 6, 4, mouseX, mouseY, layer);
|
||||
drawCentredString(tile.getStateString(), 20, Color.BLUE.darker().getRGB(), layer);
|
||||
if(tile.state == 2){
|
||||
drawCentredString( tile.getLocaliszedPowerFormatted((int) tile.getPowerChange()) + "/t", 30, Color.GREEN.darker().getRGB(), layer);
|
||||
}
|
||||
} else {
|
||||
builder.drawMultiblockMissingBar(this, layer);
|
||||
addHologramButton(76, 56, 212, layer);
|
||||
|
@ -88,6 +93,7 @@ public class GuiFusionReactor extends GuiBase {
|
|||
}
|
||||
this.builder.drawUpDownButtons(this, 121, 79, layer);
|
||||
drawString("Size: " + tile.size, 83, 81, 0xFFFFFF, layer);
|
||||
drawString("" + tile.getPowerMultiplier() + "x", 10, 81, 0xFFFFFF, layer);
|
||||
|
||||
buttonList.add(new GuiButtonUpDown(300, 121, 79, this, GuiBase.Layer.FOREGROUND));
|
||||
buttonList.add(new GuiButtonUpDown(301, 121 + 12, 79, this, GuiBase.Layer.FOREGROUND));
|
||||
|
@ -112,18 +118,7 @@ public class GuiFusionReactor extends GuiBase {
|
|||
super.actionPerformed(button);
|
||||
if (button.id == 212 && !GuiBase.showSlotConfig) {
|
||||
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
|
||||
// This code here makes a basic multiblock and then sets to the selected one.
|
||||
final Multiblock multiblock = new Multiblock();
|
||||
IBlockState coil = ModBlocks.FUSION_COIL.getDefaultState();
|
||||
|
||||
List<BlockPos> coils = Torus.generate(new BlockPos(0, 0, 0), tile.size);
|
||||
coils.forEach(pos -> addComponent(pos.getX(), pos.getY(), pos.getZ(), coil, multiblock));
|
||||
|
||||
final MultiblockSet set = new MultiblockSet(multiblock);
|
||||
ClientProxy.multiblockRenderEvent.setMultiblock(set);
|
||||
ClientProxy.multiblockRenderEvent.parent = this.tile.getPos();
|
||||
MultiblockRenderEvent.anchor = new BlockPos(this.tile.getPos().getX(), this.tile.getPos().getY() - 1,
|
||||
this.tile.getPos().getZ());
|
||||
updateMultiBlockRender();
|
||||
} else {
|
||||
ClientProxy.multiblockRenderEvent.setMultiblock(null);
|
||||
}
|
||||
|
@ -141,7 +136,23 @@ public class GuiFusionReactor extends GuiBase {
|
|||
private void sendSizeChange(int sizeDelta){
|
||||
NetworkManager.sendToServer(new PacketFusionControlSize(sizeDelta, tile.getPos()));
|
||||
//Reset the multiblock as it will be wrong now.
|
||||
ClientProxy.multiblockRenderEvent.setMultiblock(null);
|
||||
if(ClientProxy.multiblockRenderEvent.currentMultiblock != null){
|
||||
updateMultiBlockRender();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMultiBlockRender(){
|
||||
final Multiblock multiblock = new Multiblock();
|
||||
IBlockState coil = ModBlocks.FUSION_COIL.getDefaultState();
|
||||
|
||||
List<BlockPos> coils = Torus.generate(new BlockPos(0, 0, 0), tile.size);
|
||||
coils.forEach(pos -> addComponent(pos.getX(), pos.getY(), pos.getZ(), coil, multiblock));
|
||||
|
||||
final MultiblockSet set = new MultiblockSet(multiblock);
|
||||
ClientProxy.multiblockRenderEvent.setMultiblock(set);
|
||||
ClientProxy.multiblockRenderEvent.parent = this.tile.getPos();
|
||||
MultiblockRenderEvent.anchor = new BlockPos(this.tile.getPos().getX(), this.tile.getPos().getY() - 1,
|
||||
this.tile.getPos().getZ());
|
||||
}
|
||||
|
||||
public void addComponent(final int x, final int y, final int z, final IBlockState blockState, final Multiblock multiblock) {
|
||||
|
|
|
@ -31,6 +31,7 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.RebornCoreConfig;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
|
@ -67,6 +68,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
|||
public int finalTickTime = 0;
|
||||
public int neededPower = 0;
|
||||
public int size = 6;
|
||||
public int state = -1;
|
||||
int topStackSlot = 0;
|
||||
int bottomStackSlot = 1;
|
||||
int outputStackSlot = 2;
|
||||
|
@ -75,6 +77,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
|||
|
||||
public TileFusionControlComputer() {
|
||||
super();
|
||||
checkOverfill = false;
|
||||
this.inventory = new Inventory(3, "TileFusionControlComputer", 64, this);
|
||||
}
|
||||
|
||||
|
@ -232,7 +235,8 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
|||
// Power gen
|
||||
if (this.currentRecipe.getEuTick() > 0) {
|
||||
// Waste power if it has no where to go
|
||||
this.addEnergy(this.currentRecipe.getEuTick());
|
||||
this.addEnergy(this.currentRecipe.getEuTick() * getPowerMultiplier());
|
||||
this.powerChange = this.currentRecipe.getEuTick() * getPowerMultiplier();
|
||||
} else { // Power user
|
||||
if (this.canUseEnergy(this.currentRecipe.getEuTick() * -1)) {
|
||||
this.setEnergy(this.getEnergy() - this.currentRecipe.getEuTick() * -1);
|
||||
|
@ -264,9 +268,15 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getPowerMultiplier() {
|
||||
return Math.round(Math.pow(size - 5, 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return maxEnergy;
|
||||
return Math.min(maxEnergy * getPowerMultiplier(), Integer.MAX_VALUE / RebornCoreConfig.euPerFU);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -284,7 +294,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
|||
if (!this.hasStartedCrafting) {
|
||||
return 0;
|
||||
}
|
||||
return maxOutput;
|
||||
return Integer.MAX_VALUE / RebornCoreConfig.euPerFU;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -309,6 +319,10 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
|||
}
|
||||
}
|
||||
}
|
||||
if(tagCompound.hasKey("size")){
|
||||
this.size = tagCompound.getInteger("size");
|
||||
}
|
||||
this.size = Math.min(size, maxCoilSize);//Done here to force the samller size, will be useful if people lag out on a large one.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -319,6 +333,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
|||
tagCompound.setInteger("neededPower", this.neededPower);
|
||||
tagCompound.setBoolean("hasStartedCrafting", this.hasStartedCrafting);
|
||||
tagCompound.setBoolean("hasActiveRecipe", this.currentRecipe != null);
|
||||
tagCompound.setInteger("size", size);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
|
@ -355,6 +370,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
|||
.syncIntegerValue(this::getCrafingTickTime, this::setCrafingTickTime)
|
||||
.syncIntegerValue(this::getFinalTickTime, this::setFinalTickTime)
|
||||
.syncIntegerValue(this::getSize, this::setSize)
|
||||
.syncIntegerValue(this::getState, this::setState)
|
||||
.syncIntegerValue(this::getNeededPower, this::setNeededPower).addInventory().create(this);
|
||||
}
|
||||
|
||||
|
@ -402,4 +418,34 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
|||
int newSize = size + sizeDelta;
|
||||
this.size = Math.max(6, Math.min(maxCoilSize, newSize));
|
||||
}
|
||||
|
||||
public int getState(){
|
||||
if(currentRecipe == null ){
|
||||
return 0; //No Recipe
|
||||
}
|
||||
if(!hasStartedCrafting){
|
||||
return 1; //Waiting on power
|
||||
}
|
||||
if(hasStartedCrafting){
|
||||
return 2; //Crafting
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void setState(int state){
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getStateString(){
|
||||
if(state == -1){
|
||||
return "";
|
||||
} else if (state == 0){
|
||||
return "No recipe";
|
||||
} else if (state == 1){
|
||||
return "Charging";
|
||||
} else if (state == 2){
|
||||
return "Crafting";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue