Add larger fusion reactor sizes

This commit is contained in:
modmuss50 2018-04-18 15:46:56 +01:00
parent 10106715d3
commit 09a75893e4
6 changed files with 111 additions and 2 deletions

View file

@ -179,6 +179,7 @@ public class Core {
event.registerPacket(PacketIdsu.class, Side.SERVER);
event.registerPacket(PacketSetRecipe.class, Side.SERVER);
event.registerPacket(PacketRollingMachineLock.class, Side.SERVER);
event.registerPacket(PacketFusionControlSize.class, Side.SERVER);
}
@Mod.EventHandler

View file

@ -69,7 +69,9 @@ public class BlockFusionControlComputer extends BlockMachineBase {
}
if(world.isAirBlock(coil) && !tileFusionControlComputer.isCoil(coil)){
world.setBlockState(coil, ModBlocks.FUSION_COIL.getDefaultState());
if(!player.isCreative()){
player.getHeldItem(hand).shrink(1);
}
placed = true;
}
}

View file

@ -31,9 +31,12 @@ import net.minecraft.util.math.BlockPos;
import reborncore.client.multiblock.Multiblock;
import reborncore.client.multiblock.MultiblockRenderEvent;
import reborncore.client.multiblock.MultiblockSet;
import reborncore.common.network.NetworkManager;
import reborncore.common.util.Torus;
import techreborn.client.gui.widget.GuiButtonHologram;
import techreborn.client.gui.widget.GuiButtonUpDown;
import techreborn.init.ModBlocks;
import techreborn.packets.PacketFusionControlSize;
import techreborn.proxies.ClientProxy;
import techreborn.tiles.fusionReactor.TileFusionControlComputer;
@ -48,6 +51,12 @@ public class GuiFusionReactor extends GuiBase {
this.tile = tile;
}
@Override
public void initGui() {
super.initGui();
}
@Override
protected void drawGuiContainerBackgroundLayer(final float partialTicks, final int mouseX, final int mouseY) {
super.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY);
@ -58,6 +67,7 @@ public class GuiFusionReactor extends GuiBase {
this.drawOutputSlot(80, 47, layer);
this.builder.drawJEIButton(this, 150, 4, layer);
}
@Override
@ -76,6 +86,13 @@ public class GuiFusionReactor extends GuiBase {
addHologramButton(76, 56, 212, layer);
builder.drawHologramButton(this, 76, 56, mouseX, mouseY, layer);
}
this.builder.drawUpDownButtons(this, 121, 79, layer);
drawString("Size: " + tile.size, 83, 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));
buttonList.add(new GuiButtonUpDown(302, 121 + 24, 79, this, GuiBase.Layer.FOREGROUND));
buttonList.add(new GuiButtonUpDown(303, 121 + 36, 79, this, GuiBase.Layer.FOREGROUND));
}
public void addHologramButton(int x, int y, int id, Layer layer) {
@ -110,9 +127,23 @@ public class GuiFusionReactor extends GuiBase {
} else {
ClientProxy.multiblockRenderEvent.setMultiblock(null);
}
} else if (button.id == 300){
sendSizeChange(5);
} else if (button.id == 301){
sendSizeChange(1);
} else if (button.id == 302){
sendSizeChange(-1);
} else if (button.id == 303){
sendSizeChange(-5);
}
}
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);
}
public void addComponent(final int x, final int y, final int z, final IBlockState blockState, final Multiblock multiblock) {
multiblock.addComponent(new BlockPos(x, y, z), blockState);
}

View file

@ -294,6 +294,21 @@ public class TRBuilder extends GuiBuilder {
gui.drawTexturedModalRect(x + 36, y, 150, 106, 12, 12);
}
public void drawUpDownButtonsSmall(GuiBase gui, int x, int y, GuiBase.Layer layer){
if(GuiBase.showSlotConfig){
return;
}
if (layer == GuiBase.Layer.BACKGROUND) {
x += gui.getGuiLeft();
y += gui.getGuiTop();
}
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
//gui.drawTexturedModalRect(x, y, 150, 70, 12, 12);
gui.drawTexturedModalRect(x + 12, y, 150, 82, 12, 12);
gui.drawTexturedModalRect(x + 24, y, 150, 94, 12, 12);
//gui.drawTexturedModalRect(x + 36, y, 150, 106, 12, 12);
}
public void drawEnergyOutput(GuiBase gui, int right, int top, int maxOutput, GuiBase.Layer layer){
if(GuiBase.showSlotConfig){
return;

View file

@ -0,0 +1,44 @@
package techreborn.packets;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import reborncore.common.network.ExtendedPacketBuffer;
import reborncore.common.network.INetworkPacket;
import techreborn.tiles.fusionReactor.TileFusionControlComputer;
import java.io.IOException;
public class PacketFusionControlSize implements INetworkPacket<PacketFusionControlSize> {
int sizeDelta;
BlockPos pos;
public PacketFusionControlSize(int sizeDelta, BlockPos pos) {
this.sizeDelta = sizeDelta;
this.pos = pos;
}
public PacketFusionControlSize() {
}
@Override
public void writeData(ExtendedPacketBuffer buffer) throws IOException {
buffer.writeInt(sizeDelta);
buffer.writeBlockPos(pos);
}
@Override
public void readData(ExtendedPacketBuffer buffer) throws IOException {
sizeDelta = buffer.readInt();
pos = buffer.readBlockPos();
}
@Override
public void processData(PacketFusionControlSize message, MessageContext context) {
TileEntity tile = context.getServerHandler().player.world.getTileEntity(message.pos);
if(tile instanceof TileFusionControlComputer){
((TileFusionControlComputer) tile).changeSize(sizeDelta);
}
}
}

View file

@ -57,6 +57,8 @@ public class TileFusionControlComputer extends TilePowerAcceptor
public static int maxOutput = 1_000_000;
@ConfigRegistry(config = "machines", category = "fusion_reactor", key = "FusionReactorMaxEnergy", comment = "Fusion Reactor Max Energy (Value in EU)")
public static int maxEnergy = 100_000_000;
@ConfigRegistry(config = "machines", category = "fusion_reactor", key = "FusionReactorMaxCoilSize", comment = "Fusion Reactor Max Coil size (Radius)")
public static int maxCoilSize = 50;
public Inventory inventory;
@ -352,6 +354,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor
.syncIntegerValue(this::getCoilStatus, this::setCoilStatus)
.syncIntegerValue(this::getCrafingTickTime, this::setCrafingTickTime)
.syncIntegerValue(this::getFinalTickTime, this::setFinalTickTime)
.syncIntegerValue(this::getSize, this::setSize)
.syncIntegerValue(this::getNeededPower, this::setNeededPower).addInventory().create(this);
}
@ -386,4 +389,17 @@ public class TileFusionControlComputer extends TilePowerAcceptor
public void setNeededPower(final int neededPower) {
this.neededPower = neededPower;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
public void changeSize(int sizeDelta){
int newSize = size + sizeDelta;
this.size = Math.max(6, Math.min(maxCoilSize, newSize));
}
}