diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachineRadarNT.java b/src/main/java/com/hbm/inventory/gui/GUIMachineRadarNT.java new file mode 100644 index 000000000..3c91249bf --- /dev/null +++ b/src/main/java/com/hbm/inventory/gui/GUIMachineRadarNT.java @@ -0,0 +1,63 @@ +package com.hbm.inventory.gui; + +import java.util.Arrays; + +import org.lwjgl.opengl.GL11; + +import com.hbm.lib.RefStrings; +import com.hbm.tileentity.machine.TileEntityMachineRadarNT; +import com.hbm.util.I18nUtil; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.util.ResourceLocation; + +public class GUIMachineRadarNT extends GuiScreen { + + protected static final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/machine/gui_radar_nt.png"); + + protected TileEntityMachineRadarNT radar; + protected int xSize = 216; + protected int ySize = 234; + protected int guiLeft; + protected int guiTop; + + public GUIMachineRadarNT(TileEntityMachineRadarNT tile) { + this.radar = tile; + } + + @Override + public void initGui() { + super.initGui(); + this.guiLeft = (this.width - this.xSize) / 2; + this.guiTop = (this.height - this.ySize) / 2; + } + + @Override + public void drawScreen(int mouseX, int mouseY, float f) { + this.drawDefaultBackground(); + this.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + GL11.glDisable(GL11.GL_LIGHTING); + this.drawGuiContainerForegroundLayer(mouseX, mouseY); + GL11.glEnable(GL11.GL_LIGHTING); + } + + private void drawGuiContainerForegroundLayer(int x, int y) { + if(checkClick(x, y, -10, 88, 8, 8)) this.func_146283_a(Arrays.asList(I18nUtil.resolveKeyArray("radar.detectMissiles")), x, y); + if(checkClick(x, y, -10, 98, 8, 8)) this.func_146283_a(Arrays.asList(I18nUtil.resolveKeyArray("radar.detectShells")), x, y); + if(checkClick(x, y, -10, 108, 8, 8)) this.func_146283_a(Arrays.asList(I18nUtil.resolveKeyArray("radar.detectPlayers")), x, y); + if(checkClick(x, y, -10, 118, 8, 8)) this.func_146283_a(Arrays.asList(I18nUtil.resolveKeyArray("radar.smartMode")), x, y); + if(checkClick(x, y, -10, 128, 8, 8)) this.func_146283_a(Arrays.asList(I18nUtil.resolveKeyArray("radar.redMode")), x, y); + if(checkClick(x, y, -10, 138, 8, 8)) this.func_146283_a(Arrays.asList(I18nUtil.resolveKeyArray("radar.showMap")), x, y); + } + + private void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + } + + protected boolean checkClick(int x, int y, int left, int top, int sizeX, int sizeY) { + return guiLeft + left <= x && guiLeft + left + sizeX > x && guiTop + top < y && guiTop + top + sizeY >= y; + } +} diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityCustomMachine.java b/src/main/java/com/hbm/tileentity/machine/TileEntityCustomMachine.java index 4803e6e38..9c906623d 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityCustomMachine.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityCustomMachine.java @@ -185,7 +185,7 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IF /** Only accepts inputs in a fixed order, saves a ton of performance because there's no permutations to check for */ public CustomMachineRecipe getMatchingRecipe() { - List recipes = CustomMachineRecipes.recipes.get(this.machineType); + List recipes = CustomMachineRecipes.recipes.get(this.config.recipeKey); if(recipes == null || recipes.isEmpty()) return null; outer: @@ -391,11 +391,11 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IF for(int i = 0; i < outputTanks.length; i++) outputTanks[i].readFromNBT(nbt, "o" + i); this.matcher.readFromNBT(nbt); - } - - int index = nbt.getInteger("cachedIndex"); - if(index != -1) { - this.cachedRecipe = CustomMachineRecipes.recipes.get(this.machineType).get(index); + + int index = nbt.getInteger("cachedIndex"); + if(index != -1) { + this.cachedRecipe = CustomMachineRecipes.recipes.get(this.config.recipeKey).get(index); + } } } @@ -417,7 +417,7 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IF this.matcher.writeToNBT(nbt); if(this.cachedRecipe != null) { - int index = CustomMachineRecipes.recipes.get(this.machineType).indexOf(this.cachedRecipe); + int index = CustomMachineRecipes.recipes.get(this.config.recipeKey).indexOf(this.cachedRecipe); nbt.setInteger("cachedIndex", index); } else { nbt.setInteger("cachedIndex", -1); diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineRadarNT.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineRadarNT.java index e9d80203b..d5911b2a2 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineRadarNT.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineRadarNT.java @@ -8,31 +8,41 @@ import java.util.function.Function; import com.google.gson.JsonObject; import com.google.gson.stream.JsonWriter; import com.hbm.extprop.HbmLivingProps; +import com.hbm.inventory.gui.GUIMachineRadarNT; import com.hbm.lib.Library; import com.hbm.tileentity.IConfigurableMachine; +import com.hbm.tileentity.IGUIProvider; import com.hbm.tileentity.TileEntityMachineBase; import com.hbm.util.Tuple.Pair; import api.hbm.entity.IRadarDetectable; import api.hbm.entity.IRadarDetectableNT; import api.hbm.entity.RadarEntry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; import net.minecraft.world.WorldServer; /** * Now with SmЯt™ lag-free entity detection! (patent pending) * @author hbm */ -public class TileEntityMachineRadarNT extends TileEntityMachineBase implements IConfigurableMachine { - +public class TileEntityMachineRadarNT extends TileEntityMachineBase implements IGUIProvider, IConfigurableMachine { + public boolean scanMissiles = true; + public boolean scanShells = true; public boolean scanPlayers = true; public boolean smartMode = true; public boolean redMode = true; + public boolean showMap = false; public boolean jammed = false; @@ -133,9 +143,11 @@ public class TileEntityMachineRadarNT extends TileEntityMachineBase implements I public void serialize(ByteBuf buf) { buf.writeLong(this.power); buf.writeBoolean(this.scanMissiles); + buf.writeBoolean(this.scanShells); buf.writeBoolean(this.scanPlayers); buf.writeBoolean(this.smartMode); buf.writeBoolean(this.redMode); + buf.writeBoolean(this.showMap); buf.writeBoolean(this.jammed); buf.writeInt(entries.size()); for(RadarEntry entry : entries) entry.toBytes(buf); @@ -145,9 +157,11 @@ public class TileEntityMachineRadarNT extends TileEntityMachineBase implements I public void deserialize(ByteBuf buf) { this.power = buf.readLong(); this.scanMissiles = buf.readBoolean(); + this.scanShells = buf.readBoolean(); this.scanPlayers = buf.readBoolean(); this.smartMode = buf.readBoolean(); this.redMode = buf.readBoolean(); + this.showMap = buf.readBoolean(); this.jammed = buf.readBoolean(); int count = buf.readInt(); for(int i = 0; i < count; i++) { @@ -157,6 +171,40 @@ public class TileEntityMachineRadarNT extends TileEntityMachineBase implements I } } + AxisAlignedBB bb = null; + + @Override + public AxisAlignedBB getRenderBoundingBox() { + + if(bb == null) { + bb = AxisAlignedBB.getBoundingBox( + xCoord - 1, + yCoord, + zCoord - 1, + xCoord + 2, + yCoord + 3, + zCoord + 2 + ); + } + + return bb; + } + + @Override + @SideOnly(Side.CLIENT) + public double getMaxRenderDistanceSquared() + { + return 65536.0D; + } + + @Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { + return new GUIMachineRadarNT(this); + } + /** List of lambdas that are supplied a Pair with the entity and radar in question to generate a RadarEntry The converters coming first have the highest priority */ public static List, RadarEntry>> converters = new ArrayList(); diff --git a/src/main/resources/assets/hbm/textures/gui/machine/gui_radar_nt.png b/src/main/resources/assets/hbm/textures/gui/machine/gui_radar_nt.png index a6a4d1745..690e1b5f5 100644 Binary files a/src/main/resources/assets/hbm/textures/gui/machine/gui_radar_nt.png and b/src/main/resources/assets/hbm/textures/gui/machine/gui_radar_nt.png differ