Fixes #275 and added world placement helper for reactor
This commit is contained in:
parent
8c85aeb4d3
commit
9283e46a1f
4 changed files with 98 additions and 1 deletions
49
src/main/java/techreborn/client/ClientMultiBlocks.java
Normal file
49
src/main/java/techreborn/client/ClientMultiBlocks.java
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
package techreborn.client;
|
||||||
|
|
||||||
|
|
||||||
|
import reborncore.client.multiblock.Multiblock;
|
||||||
|
import techreborn.init.ModBlocks;
|
||||||
|
|
||||||
|
public class ClientMultiBlocks {
|
||||||
|
|
||||||
|
public static Multiblock reactor;
|
||||||
|
|
||||||
|
public static void init(){
|
||||||
|
reactor = new Multiblock();
|
||||||
|
checkCoils();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void checkCoils() {
|
||||||
|
if ((isCoil(3, 0, 1)) &&
|
||||||
|
(isCoil(3, 0, 0)) &&
|
||||||
|
(isCoil(3, 0, 0 - 1)) &&
|
||||||
|
(isCoil(0 - 3, 0, 1)) &&
|
||||||
|
(isCoil(0 - 3, 0, 0)) &&
|
||||||
|
(isCoil(0 - 3, 0, 0 - 1)) &&
|
||||||
|
(isCoil(2, 0, 2)) &&
|
||||||
|
(isCoil(2, 0, 1)) &&
|
||||||
|
(isCoil(2, 0, 0 - 1)) &&
|
||||||
|
(isCoil(2, 0, 0 - 2)) &&
|
||||||
|
(isCoil(0 - 2, 0, 2)) &&
|
||||||
|
(isCoil(0 - 2, 0, 1)) &&
|
||||||
|
(isCoil(0 - 2, 0, 0 - 1)) &&
|
||||||
|
(isCoil(0 - 2, 0, 0 - 2)) &&
|
||||||
|
(isCoil(1, 0, 3)) &&
|
||||||
|
(isCoil(1, 0, 2)) &&
|
||||||
|
(isCoil(1, 0, 0 - 2)) &&
|
||||||
|
(isCoil(1, 0, 0 - 3)) &&
|
||||||
|
(isCoil(0 - 1, 0, 3)) &&
|
||||||
|
(isCoil(0 - 1, 0, 2)) &&
|
||||||
|
(isCoil(0 - 1, 0, 0 - 2)) &&
|
||||||
|
(isCoil(0 - 1, 0, 0 - 3)) &&
|
||||||
|
(isCoil(0, 0, 3)) &&
|
||||||
|
(isCoil(0, 0, 0 - 3))) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isCoil(int x, int y, int z) {
|
||||||
|
reactor.addComponent(x, y, z, ModBlocks.FusionCoil, 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,11 +1,20 @@
|
||||||
package techreborn.client.gui;
|
package techreborn.client.gui;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.util.ChunkCoordinates;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import reborncore.client.multiblock.Multiblock;
|
||||||
|
import reborncore.client.multiblock.MultiblockSet;
|
||||||
|
import reborncore.common.misc.Location;
|
||||||
|
import techreborn.client.ClientMultiBlocks;
|
||||||
import techreborn.client.container.ContainerFusionReactor;
|
import techreborn.client.container.ContainerFusionReactor;
|
||||||
|
import techreborn.init.ModBlocks;
|
||||||
|
import techreborn.proxies.ClientProxy;
|
||||||
import techreborn.tiles.fusionReactor.TileEntityFusionController;
|
import techreborn.tiles.fusionReactor.TileEntityFusionController;
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,11 +23,13 @@ public class GuiFusionReactor extends GuiContainer {
|
||||||
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/fusion_reactor.png");
|
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/fusion_reactor.png");
|
||||||
|
|
||||||
ContainerFusionReactor containerFusionReactor;
|
ContainerFusionReactor containerFusionReactor;
|
||||||
|
TileEntityFusionController fusionController;
|
||||||
|
|
||||||
public GuiFusionReactor(EntityPlayer player,
|
public GuiFusionReactor(EntityPlayer player,
|
||||||
TileEntityFusionController tileaesu) {
|
TileEntityFusionController tileaesu) {
|
||||||
super(new ContainerFusionReactor(tileaesu, player));
|
super(new ContainerFusionReactor(tileaesu, player));
|
||||||
containerFusionReactor = (ContainerFusionReactor) this.inventorySlots;
|
containerFusionReactor = (ContainerFusionReactor) this.inventorySlots;
|
||||||
|
this.fusionController = tileaesu;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
|
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
|
||||||
|
@ -32,6 +43,22 @@ public class GuiFusionReactor extends GuiContainer {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui() {
|
||||||
|
int k = (this.width - this.xSize) / 2;
|
||||||
|
int l = (this.height - this.ySize) / 2;
|
||||||
|
GuiButton button = new GuiButton(212, k + this.xSize - 24, l + 4, 20, 20, "");
|
||||||
|
buttonList.add(button);
|
||||||
|
super.initGui();
|
||||||
|
ChunkCoordinates coordinates = new ChunkCoordinates(fusionController.xCoord - (ForgeDirection.getOrientation(fusionController.getRotation()).offsetX * 2), fusionController.yCoord - 1, fusionController.zCoord - (ForgeDirection.getOrientation(fusionController.getRotation()).offsetZ * 2));
|
||||||
|
if(coordinates.equals(ClientProxy.multiblockRenderEvent.anchor)){
|
||||||
|
ClientProxy.multiblockRenderEvent.setMultiblock(null);
|
||||||
|
button.displayString = "B";
|
||||||
|
} else {
|
||||||
|
button.displayString = "A";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||||
this.mc.getTextureManager().bindTexture(texture);
|
this.mc.getTextureManager().bindTexture(texture);
|
||||||
|
@ -51,4 +78,23 @@ public class GuiFusionReactor extends GuiContainer {
|
||||||
return 0;
|
return 0;
|
||||||
return (int) ((CurrentValue * 100.0f) / MaxValue);
|
return (int) ((CurrentValue * 100.0f) / MaxValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(GuiButton button) {
|
||||||
|
super.actionPerformed(button);
|
||||||
|
if(button.id == 212){
|
||||||
|
if(ClientProxy.multiblockRenderEvent.currentMultiblock == null){
|
||||||
|
{//This code here makes a basic multiblock and then sets to the selected one.
|
||||||
|
MultiblockSet set = new MultiblockSet(ClientMultiBlocks.reactor);
|
||||||
|
ClientProxy.multiblockRenderEvent.setMultiblock(set);
|
||||||
|
ClientProxy.multiblockRenderEvent.partent = new Location(fusionController.xCoord, fusionController.yCoord, fusionController.zCoord, fusionController.getWorldObj());
|
||||||
|
ClientProxy.multiblockRenderEvent.anchor = new ChunkCoordinates(fusionController.xCoord , fusionController.yCoord -1 , fusionController.zCoord);
|
||||||
|
}
|
||||||
|
button.displayString = "A";
|
||||||
|
} else {
|
||||||
|
ClientProxy.multiblockRenderEvent.setMultiblock(null);
|
||||||
|
button.displayString = "B";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,7 +231,7 @@ public abstract class TilePowerAcceptor extends RFProviderTile implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double useEnergy(double extract, boolean simulate) {
|
public double useEnergy(double extract, boolean simulate) {
|
||||||
double energyExtracted = Math.min(extract, Math.min(this.getMaxOutput(), extract));
|
double energyExtracted = Math.min(getMaxPower() - energy, Math.min(getMaxPower(), extract));
|
||||||
|
|
||||||
if (!simulate) {
|
if (!simulate) {
|
||||||
setEnergy(energy - energyExtracted);
|
setEnergy(energy - energyExtracted);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package techreborn.proxies;
|
||||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import reborncore.client.multiblock.MultiblockRenderEvent;
|
import reborncore.client.multiblock.MultiblockRenderEvent;
|
||||||
|
import techreborn.client.ClientMultiBlocks;
|
||||||
import techreborn.client.IconSupplier;
|
import techreborn.client.IconSupplier;
|
||||||
import techreborn.client.StackToolTipEvent;
|
import techreborn.client.StackToolTipEvent;
|
||||||
import techreborn.client.VersionCheckerClient;
|
import techreborn.client.VersionCheckerClient;
|
||||||
|
@ -23,5 +24,6 @@ public class ClientProxy extends CommonProxy {
|
||||||
multiblockRenderEvent = new MultiblockRenderEvent();
|
multiblockRenderEvent = new MultiblockRenderEvent();
|
||||||
MinecraftForge.EVENT_BUS.register(multiblockRenderEvent);
|
MinecraftForge.EVENT_BUS.register(multiblockRenderEvent);
|
||||||
ClientRegistry.registerKeyBinding(KeyBindings.config);
|
ClientRegistry.registerKeyBinding(KeyBindings.config);
|
||||||
|
ClientMultiBlocks.init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue