diff --git a/src/main/java/mekanism/client/gui/GuiAdvancedElectricMachine.java b/src/main/java/mekanism/client/gui/GuiAdvancedElectricMachine.java index 346eca1c0..57281f836 100644 --- a/src/main/java/mekanism/client/gui/GuiAdvancedElectricMachine.java +++ b/src/main/java/mekanism/client/gui/GuiAdvancedElectricMachine.java @@ -8,6 +8,7 @@ import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiProgress; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler; import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.client.gui.element.GuiSideConfigurationTab; diff --git a/src/main/java/mekanism/client/gui/GuiChanceMachine.java b/src/main/java/mekanism/client/gui/GuiChanceMachine.java index bfed56ba8..08eea6e7e 100644 --- a/src/main/java/mekanism/client/gui/GuiChanceMachine.java +++ b/src/main/java/mekanism/client/gui/GuiChanceMachine.java @@ -7,6 +7,7 @@ import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiProgress; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler; import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.client.gui.element.GuiSideConfigurationTab; diff --git a/src/main/java/mekanism/client/gui/GuiChemicalCrystallizer.java b/src/main/java/mekanism/client/gui/GuiChemicalCrystallizer.java index 6e55dc3fa..2847f58f9 100644 --- a/src/main/java/mekanism/client/gui/GuiChemicalCrystallizer.java +++ b/src/main/java/mekanism/client/gui/GuiChemicalCrystallizer.java @@ -15,6 +15,7 @@ import mekanism.client.gui.element.GuiGasGauge.IGasInfoHandler; import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiProgress; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler; import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.client.gui.element.GuiSideConfigurationTab; diff --git a/src/main/java/mekanism/client/gui/GuiChemicalDissolutionChamber.java b/src/main/java/mekanism/client/gui/GuiChemicalDissolutionChamber.java index 17665b0a7..daeefd2e3 100644 --- a/src/main/java/mekanism/client/gui/GuiChemicalDissolutionChamber.java +++ b/src/main/java/mekanism/client/gui/GuiChemicalDissolutionChamber.java @@ -8,6 +8,7 @@ import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiGasGauge; import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiProgress; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiUpgradeTab; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; diff --git a/src/main/java/mekanism/client/gui/GuiChemicalInfuser.java b/src/main/java/mekanism/client/gui/GuiChemicalInfuser.java index 3c016e6f7..a71ad9311 100644 --- a/src/main/java/mekanism/client/gui/GuiChemicalInfuser.java +++ b/src/main/java/mekanism/client/gui/GuiChemicalInfuser.java @@ -10,6 +10,7 @@ import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiGasGauge; import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiProgress; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiUpgradeTab; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; diff --git a/src/main/java/mekanism/client/gui/GuiChemicalOxidizer.java b/src/main/java/mekanism/client/gui/GuiChemicalOxidizer.java index deaa00c89..63744b83b 100644 --- a/src/main/java/mekanism/client/gui/GuiChemicalOxidizer.java +++ b/src/main/java/mekanism/client/gui/GuiChemicalOxidizer.java @@ -8,6 +8,7 @@ import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiGasGauge; import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiProgress; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiUpgradeTab; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; diff --git a/src/main/java/mekanism/client/gui/GuiChemicalWasher.java b/src/main/java/mekanism/client/gui/GuiChemicalWasher.java index 7d8cdbf37..d82de7fa1 100644 --- a/src/main/java/mekanism/client/gui/GuiChemicalWasher.java +++ b/src/main/java/mekanism/client/gui/GuiChemicalWasher.java @@ -12,6 +12,7 @@ import mekanism.client.gui.element.GuiFluidGauge; import mekanism.client.gui.element.GuiGasGauge; import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiProgress; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiUpgradeTab; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; diff --git a/src/main/java/mekanism/client/gui/GuiDigitalMiner.java b/src/main/java/mekanism/client/gui/GuiDigitalMiner.java index 7d46c2f28..646273383 100644 --- a/src/main/java/mekanism/client/gui/GuiDigitalMiner.java +++ b/src/main/java/mekanism/client/gui/GuiDigitalMiner.java @@ -8,6 +8,7 @@ import mekanism.api.EnumColor; import mekanism.api.util.ListUtils; import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiPowerBar; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiUpgradeTab; import mekanism.client.gui.element.GuiVisualsTab; diff --git a/src/main/java/mekanism/client/gui/GuiElectricMachine.java b/src/main/java/mekanism/client/gui/GuiElectricMachine.java index 34aa4641c..3e7680eb6 100644 --- a/src/main/java/mekanism/client/gui/GuiElectricMachine.java +++ b/src/main/java/mekanism/client/gui/GuiElectricMachine.java @@ -3,6 +3,7 @@ package mekanism.client.gui; import java.util.List; import mekanism.api.util.ListUtils; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiSideConfigurationTab; import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; diff --git a/src/main/java/mekanism/client/gui/GuiElectricPump.java b/src/main/java/mekanism/client/gui/GuiElectricPump.java index 97c1d8c0f..105d96f2d 100644 --- a/src/main/java/mekanism/client/gui/GuiElectricPump.java +++ b/src/main/java/mekanism/client/gui/GuiElectricPump.java @@ -3,6 +3,7 @@ package mekanism.client.gui; import mekanism.client.gui.element.GuiFluidGauge; import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiPowerBar; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiUpgradeTab; import mekanism.client.gui.element.GuiFluidGauge.IFluidInfoHandler; diff --git a/src/main/java/mekanism/client/gui/GuiEnergyCube.java b/src/main/java/mekanism/client/gui/GuiEnergyCube.java index 7d0821e14..b9f79f285 100644 --- a/src/main/java/mekanism/client/gui/GuiEnergyCube.java +++ b/src/main/java/mekanism/client/gui/GuiEnergyCube.java @@ -6,6 +6,7 @@ import mekanism.api.energy.IStrictEnergyStorage; import mekanism.api.util.ListUtils; import mekanism.client.gui.element.GuiEnergyGauge; import mekanism.client.gui.element.GuiEnergyInfo; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiEnergyGauge.IEnergyInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; diff --git a/src/main/java/mekanism/client/gui/GuiFactory.java b/src/main/java/mekanism/client/gui/GuiFactory.java index db0180296..38ba6dea0 100644 --- a/src/main/java/mekanism/client/gui/GuiFactory.java +++ b/src/main/java/mekanism/client/gui/GuiFactory.java @@ -7,6 +7,7 @@ import mekanism.api.util.ListUtils; import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiRecipeType; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiSideConfigurationTab; import mekanism.client.gui.element.GuiSortingTab; import mekanism.client.gui.element.GuiTransporterConfigTab; diff --git a/src/main/java/mekanism/client/gui/GuiGasTank.java b/src/main/java/mekanism/client/gui/GuiGasTank.java index 6a185a353..9115014c2 100644 --- a/src/main/java/mekanism/client/gui/GuiGasTank.java +++ b/src/main/java/mekanism/client/gui/GuiGasTank.java @@ -3,6 +3,7 @@ package mekanism.client.gui; import java.util.ArrayList; import mekanism.api.Coord4D; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; import mekanism.common.inventory.container.ContainerGasTank; diff --git a/src/main/java/mekanism/client/gui/GuiLaserAmplifier.java b/src/main/java/mekanism/client/gui/GuiLaserAmplifier.java index d89cb5569..fd1263f48 100644 --- a/src/main/java/mekanism/client/gui/GuiLaserAmplifier.java +++ b/src/main/java/mekanism/client/gui/GuiLaserAmplifier.java @@ -3,9 +3,11 @@ package mekanism.client.gui; import java.util.ArrayList; import mekanism.api.Coord4D; -import mekanism.client.gui.element.GuiNumberGauge; +import mekanism.client.gui.element.GuiDetectionTab; import mekanism.client.gui.element.GuiGauge.Type; +import mekanism.client.gui.element.GuiNumberGauge; import mekanism.client.gui.element.GuiNumberGauge.INumberInfoHandler; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.render.MekanismRenderer; import mekanism.common.Mekanism; import mekanism.common.inventory.container.ContainerLaserAmplifier; @@ -16,12 +18,13 @@ import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.IIcon; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + @SideOnly(Side.CLIENT) public class GuiLaserAmplifier extends GuiMekanism { @@ -63,6 +66,7 @@ public class GuiLaserAmplifier extends GuiMekanism } }, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 6, 10)); guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); + guiElements.add(new GuiDetectionTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); } @Override diff --git a/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java b/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java index a88a1361a..125a20faa 100644 --- a/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java +++ b/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java @@ -9,6 +9,7 @@ import java.util.Set; import mekanism.api.Coord4D; import mekanism.api.EnumColor; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.render.MekanismRenderer; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; @@ -25,7 +26,6 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.tile.TileEntityLogisticalSorter; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; - import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; diff --git a/src/main/java/mekanism/client/gui/GuiMetallurgicInfuser.java b/src/main/java/mekanism/client/gui/GuiMetallurgicInfuser.java index ae6ec0abe..b17a879db 100644 --- a/src/main/java/mekanism/client/gui/GuiMetallurgicInfuser.java +++ b/src/main/java/mekanism/client/gui/GuiMetallurgicInfuser.java @@ -9,6 +9,7 @@ import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiProgress; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler; import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.client.gui.element.GuiSideConfigurationTab; diff --git a/src/main/java/mekanism/client/gui/GuiPRC.java b/src/main/java/mekanism/client/gui/GuiPRC.java index d77c914ca..6d90109da 100644 --- a/src/main/java/mekanism/client/gui/GuiPRC.java +++ b/src/main/java/mekanism/client/gui/GuiPRC.java @@ -13,6 +13,7 @@ import mekanism.client.gui.element.GuiGasGauge.IGasInfoHandler; import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiProgress; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler; import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.client.gui.element.GuiSideConfigurationTab; diff --git a/src/main/java/mekanism/client/gui/GuiRotaryCondensentrator.java b/src/main/java/mekanism/client/gui/GuiRotaryCondensentrator.java index bd905ec15..ef4634f37 100644 --- a/src/main/java/mekanism/client/gui/GuiRotaryCondensentrator.java +++ b/src/main/java/mekanism/client/gui/GuiRotaryCondensentrator.java @@ -11,6 +11,7 @@ import mekanism.client.gui.element.GuiFluidGauge; import mekanism.client.gui.element.GuiGasGauge; import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiProgress; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiUpgradeTab; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; diff --git a/src/main/java/mekanism/client/gui/GuiSeismicVibrator.java b/src/main/java/mekanism/client/gui/GuiSeismicVibrator.java index 31e658fec..3e4daf9c1 100644 --- a/src/main/java/mekanism/client/gui/GuiSeismicVibrator.java +++ b/src/main/java/mekanism/client/gui/GuiSeismicVibrator.java @@ -1,6 +1,7 @@ package mekanism.client.gui; import mekanism.client.gui.element.GuiPowerBar; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot.SlotOverlay; import mekanism.client.gui.element.GuiSlot.SlotType; diff --git a/src/main/java/mekanism/client/gui/GuiSolarNeutronActivator.java b/src/main/java/mekanism/client/gui/GuiSolarNeutronActivator.java index 951bceaf6..0e9245213 100644 --- a/src/main/java/mekanism/client/gui/GuiSolarNeutronActivator.java +++ b/src/main/java/mekanism/client/gui/GuiSolarNeutronActivator.java @@ -4,6 +4,7 @@ import mekanism.api.gas.GasTank; import mekanism.client.gui.element.GuiGasGauge; import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiProgress; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiGasGauge.IGasInfoHandler; import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler; diff --git a/src/main/java/mekanism/client/gui/element/GuiDetectionTab.java b/src/main/java/mekanism/client/gui/element/GuiDetectionTab.java new file mode 100644 index 000000000..beb5134ca --- /dev/null +++ b/src/main/java/mekanism/client/gui/element/GuiDetectionTab.java @@ -0,0 +1,88 @@ +package mekanism.client.gui.element; + +import java.util.ArrayList; + +import mekanism.api.Coord4D; +import mekanism.client.gui.IGuiWrapper; +import mekanism.client.sound.SoundHandler; +import mekanism.common.Mekanism; +import mekanism.common.network.PacketTileEntity.TileEntityMessage; +import mekanism.common.tile.TileEntityLaserAmplifier; +import mekanism.common.util.LangUtils; +import mekanism.common.util.MekanismUtils; +import mekanism.common.util.MekanismUtils.ResourceType; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class GuiDetectionTab extends GuiElement +{ + public TileEntity tileEntity; + + public GuiDetectionTab(IGuiWrapper gui, TileEntity tile, ResourceLocation def) + { + super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiDetectionTab.png"), gui, def); + + tileEntity = tile; + } + + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) + { + return new Rectangle4i(guiWidth - 26, guiHeight + 138, 26, 26); + } + + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) + { + mc.renderEngine.bindTexture(RESOURCE); + + guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 138, 0, 0, 26, 26); + + if(xAxis >= -21 && xAxis <= -3 && yAxis >= 142 && yAxis <= 160) + { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 142, 26, 0, 18, 18); + } + else { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 142, 26, 18, 18, 18); + } + + mc.renderEngine.bindTexture(defaultLocation); + } + + @Override + public void renderForeground(int xAxis, int yAxis) + { + mc.renderEngine.bindTexture(RESOURCE); + + if(xAxis >= -21 && xAxis <= -3 && yAxis >= 142 && yAxis <= 160) + { + String text = LangUtils.transOnOff(((TileEntityLaserAmplifier)tileEntity).entityDetection); + displayTooltip(MekanismUtils.localize("gui.entityDetection") + ": " + text, xAxis, yAxis); + } + + mc.renderEngine.bindTexture(defaultLocation); + } + + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) + { + if(button == 0) + { + if(xAxis >= -21 && xAxis <= -3 && yAxis >= 142 && yAxis <= 160) + { + ArrayList data = new ArrayList(); + data.add(3); + + Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); + SoundHandler.playSound("gui.button.press"); + } + } + } +} diff --git a/src/main/java/mekanism/client/gui/GuiRedstoneControl.java b/src/main/java/mekanism/client/gui/element/GuiRedstoneControl.java similarity index 97% rename from src/main/java/mekanism/client/gui/GuiRedstoneControl.java rename to src/main/java/mekanism/client/gui/element/GuiRedstoneControl.java index 9659fc3e4..8f1018b11 100644 --- a/src/main/java/mekanism/client/gui/GuiRedstoneControl.java +++ b/src/main/java/mekanism/client/gui/element/GuiRedstoneControl.java @@ -1,7 +1,7 @@ -package mekanism.client.gui; +package mekanism.client.gui.element; import mekanism.api.Coord4D; -import mekanism.client.gui.element.GuiElement; +import mekanism.client.gui.IGuiWrapper; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; import mekanism.common.base.IRedstoneControl; diff --git a/src/main/java/mekanism/common/LaserManager.java b/src/main/java/mekanism/common/LaserManager.java index 08a6718ea..ba6222777 100644 --- a/src/main/java/mekanism/common/LaserManager.java +++ b/src/main/java/mekanism/common/LaserManager.java @@ -2,6 +2,8 @@ package mekanism.common; import java.util.List; +import com.mojang.realmsclient.util.Pair; + import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; import mekanism.api.Pos3D; @@ -18,12 +20,12 @@ import net.minecraftforge.common.util.ForgeDirection; public class LaserManager { - public static MovingObjectPosition fireLaser(TileEntity from, ForgeDirection direction, double energy, World world) + public static LaserInfo fireLaser(TileEntity from, ForgeDirection direction, double energy, World world) { return fireLaser(new Pos3D(from).centre().translate(direction, 0.501), direction, energy, world); } - public static MovingObjectPosition fireLaser(Pos3D from, ForgeDirection direction, double energy, World world) + public static LaserInfo fireLaser(Pos3D from, ForgeDirection direction, double energy, World world) { Pos3D to = from.clone().translate(direction, general.laserRange - 0.002); @@ -46,17 +48,25 @@ public class LaserManager from.translateExcludingSide(direction, -0.1); to.translateExcludingSide(direction, 0.1); + + boolean foundEntity = false; for(Entity e : (List)world.getEntitiesWithinAABB(Entity.class, Pos3D.getAABB(from, to))) { + foundEntity = true; + if(!e.isImmuneToFire()) { e.setFire((int)(energy / 1000)); - e.attackEntityFrom(DamageSource.onFire, (float)energy/1000F); + + if(energy > 256) + { + e.attackEntityFrom(DamageSource.onFire, (float)energy/1000F); + } } } - - return mop; + + return new LaserInfo(mop, foundEntity); } public static List breakBlock(Coord4D blockCoord, boolean dropAtBlock, World world) @@ -96,6 +106,20 @@ public class LaserManager from.translate(direction, -0.501); Mekanism.proxy.renderLaser(world, from, to, direction, energy); + return mop; } + + public static class LaserInfo + { + public MovingObjectPosition movingPos; + + public boolean foundEntity; + + public LaserInfo(MovingObjectPosition mop, boolean b) + { + movingPos = mop; + foundEntity = b; + } + } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/Mekanism.java b/src/main/java/mekanism/common/Mekanism.java index 9db17a8c5..d150fc5d5 100644 --- a/src/main/java/mekanism/common/Mekanism.java +++ b/src/main/java/mekanism/common/Mekanism.java @@ -488,7 +488,7 @@ public class Mekanism "RE ", "RCD", "RE ", Character.valueOf('R'), "alloyElite", Character.valueOf('E'), MekanismItems.EnergyTablet.getUnchargedItem(), Character.valueOf('C'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8), Character.valueOf('D'), "gemDiamond" })); MachineType.LASER_AMPLIFIER.addRecipe(new MekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock2, 1, 14), new Object[] { - "SSS", "SED", "SSS", Character.valueOf('S'), "ingotSteel", Character.valueOf('E'), MekanismUtils.getInductionCell(InductionCellTier.ADVANCED), Character.valueOf('D'), "gemDiamond" + "SSS", "SED", "SSS", Character.valueOf('S'), "ingotSteel", Character.valueOf('E'), MekanismUtils.getEnergyCube(EnergyCubeTier.BASIC), Character.valueOf('D'), "gemDiamond" })); MachineType.LASER_TRACTOR_BEAM.addRecipe(new MekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock2, 1, 15), new Object[] { "C", "F", Character.valueOf('C'), new ItemStack(MekanismBlocks.MachineBlock, 1, 13), Character.valueOf('F'), new ItemStack(MekanismBlocks.MachineBlock2, 1, 14) diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index 3b072a1af..8e30fecfd 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -1390,6 +1390,19 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer return false; } + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) + { + TileEntity tile = world.getTileEntity(x, y, z); + + if(tile instanceof TileEntityLaserAmplifier) + { + return ((TileEntityLaserAmplifier)tile).emittingRedstone ? 15 : 0; + } + + return 0; + } + @Override public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta) { diff --git a/src/main/java/mekanism/common/tile/TileEntityLaser.java b/src/main/java/mekanism/common/tile/TileEntityLaser.java index ce7ddcfb5..ad331ced4 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLaser.java +++ b/src/main/java/mekanism/common/tile/TileEntityLaser.java @@ -11,12 +11,12 @@ import mekanism.api.MekanismConfig.usage; import mekanism.api.Range4D; import mekanism.api.lasers.ILaserReceptor; import mekanism.common.LaserManager; +import mekanism.common.LaserManager.LaserInfo; import mekanism.common.Mekanism; import mekanism.common.base.IActiveState; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.util.MekanismUtils; import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -79,8 +79,8 @@ public class TileEntityLaser extends TileEntityNoisyElectricBlock implements IAc { setActive(true); - MovingObjectPosition mop = LaserManager.fireLaser(this, ForgeDirection.getOrientation(facing), usage.laserUsage, worldObj); - Coord4D hitCoord = mop == null ? null : new Coord4D(mop.blockX, mop.blockY, mop.blockZ); + LaserInfo info = LaserManager.fireLaser(this, ForgeDirection.getOrientation(facing), usage.laserUsage, worldObj); + Coord4D hitCoord = info.movingPos == null ? null : new Coord4D(info.movingPos.blockX, info.movingPos.blockY, info.movingPos.blockZ); if(hitCoord == null || !hitCoord.equals(digging)) { diff --git a/src/main/java/mekanism/common/tile/TileEntityLaserAmplifier.java b/src/main/java/mekanism/common/tile/TileEntityLaserAmplifier.java index 5c7f3c584..1fa647a69 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLaserAmplifier.java +++ b/src/main/java/mekanism/common/tile/TileEntityLaserAmplifier.java @@ -10,6 +10,7 @@ import mekanism.api.energy.ICableOutputter; import mekanism.api.energy.IStrictEnergyStorage; import mekanism.api.lasers.ILaserReceptor; import mekanism.common.LaserManager; +import mekanism.common.LaserManager.LaserInfo; import mekanism.common.Mekanism; import mekanism.common.base.IRedstoneControl; import mekanism.common.network.PacketTileEntity.TileEntityMessage; @@ -38,6 +39,9 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement public Coord4D digging; public double diggingProgress; + + public boolean emittingRedstone; + public boolean entityDetection; public TileEntityLaserAmplifier() { @@ -93,6 +97,10 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement } } else { + boolean prevRedstone = emittingRedstone; + + emittingRedstone = false; + if(ticks < time) { ticks++; @@ -112,8 +120,8 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); } - MovingObjectPosition mop = LaserManager.fireLaser(this, ForgeDirection.getOrientation(facing), firing, worldObj); - Coord4D hitCoord = mop == null ? null : new Coord4D(mop.blockX, mop.blockY, mop.blockZ); + LaserInfo info = LaserManager.fireLaser(this, ForgeDirection.getOrientation(facing), firing, worldObj); + Coord4D hitCoord = info.movingPos == null ? null : new Coord4D(info.movingPos.blockX, info.movingPos.blockY, info.movingPos.blockZ); if(hitCoord == null || !hitCoord.equals(digging)) { @@ -138,6 +146,8 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement } } } + + emittingRedstone = info.foundEntity; setEnergy(getEnergy() - firing); } @@ -147,6 +157,16 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement diggingProgress = 0; Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); } + + if(!entityDetection) + { + emittingRedstone = false; + } + + if(emittingRedstone != prevRedstone) + { + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType()); + } } } @@ -184,6 +204,8 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement data.add(collectedEnergy); data.add(lastFired); data.add(controlType.ordinal()); + data.add(emittingRedstone); + data.add(entityDetection); return data; } @@ -203,6 +225,8 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement collectedEnergy = dataStream.readDouble(); lastFired = dataStream.readDouble(); controlType = RedstoneControl.values()[dataStream.readInt()]; + emittingRedstone = dataStream.readBoolean(); + entityDetection = dataStream.readBoolean(); return; } @@ -218,6 +242,9 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement case 2: time = dataStream.readInt(); break; + case 3: + entityDetection = !entityDetection; + break; } } @@ -234,6 +261,7 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement collectedEnergy = nbtTags.getDouble("collectedEnergy"); lastFired = nbtTags.getDouble("lastFired"); controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + entityDetection = nbtTags.getBoolean("entityDetection"); } @Override @@ -249,6 +277,7 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement nbtTags.setDouble("collectedEnergy", collectedEnergy); nbtTags.setDouble("lastFired", lastFired); nbtTags.setInteger("controlType", controlType.ordinal()); + nbtTags.setBoolean("entityDetection", entityDetection); } @Override diff --git a/src/main/java/mekanism/common/tile/TileEntityLaserTractorBeam.java b/src/main/java/mekanism/common/tile/TileEntityLaserTractorBeam.java index 7858a1098..48d0599d9 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLaserTractorBeam.java +++ b/src/main/java/mekanism/common/tile/TileEntityLaserTractorBeam.java @@ -1,5 +1,7 @@ package mekanism.common.tile; +import io.netty.buffer.ByteBuf; + import java.util.ArrayList; import java.util.List; @@ -8,20 +10,17 @@ import mekanism.api.MekanismConfig.general; import mekanism.api.lasers.ILaserReceptor; import mekanism.api.util.StackUtils; import mekanism.common.LaserManager; +import mekanism.common.LaserManager.LaserInfo; import mekanism.common.Mekanism; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.util.InventoryUtils; - import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; import net.minecraftforge.common.util.ForgeDirection; -import io.netty.buffer.ByteBuf; - public class TileEntityLaserTractorBeam extends TileEntityContainerBlock implements ILaserReceptor { public static final double MAX_ENERGY = 5E9; @@ -100,8 +99,8 @@ public class TileEntityLaserTractorBeam extends TileEntityContainerBlock impleme Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); } - MovingObjectPosition mop = LaserManager.fireLaser(this, ForgeDirection.getOrientation(facing), firing, worldObj); - Coord4D hitCoord = mop == null ? null : new Coord4D(mop.blockX, mop.blockY, mop.blockZ); + LaserInfo info = LaserManager.fireLaser(this, ForgeDirection.getOrientation(facing), firing, worldObj); + Coord4D hitCoord = info.movingPos == null ? null : new Coord4D(info.movingPos.blockX, info.movingPos.blockY, info.movingPos.blockZ); if(hitCoord == null || !hitCoord.equals(digging)) { diff --git a/src/main/java/mekanism/generators/client/gui/GuiBioGenerator.java b/src/main/java/mekanism/generators/client/gui/GuiBioGenerator.java index cfdf814c0..13a423220 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiBioGenerator.java +++ b/src/main/java/mekanism/generators/client/gui/GuiBioGenerator.java @@ -5,9 +5,9 @@ import java.util.List; import mekanism.api.MekanismConfig.generators; import mekanism.api.util.ListUtils; import mekanism.client.gui.GuiMekanism; -import mekanism.client.gui.GuiRedstoneControl; import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiPowerBar; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiSlot.SlotOverlay; diff --git a/src/main/java/mekanism/generators/client/gui/GuiGasGenerator.java b/src/main/java/mekanism/generators/client/gui/GuiGasGenerator.java index a8a13ec16..ed4978a04 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiGasGenerator.java +++ b/src/main/java/mekanism/generators/client/gui/GuiGasGenerator.java @@ -5,10 +5,10 @@ import java.util.List; import mekanism.api.gas.GasTank; import mekanism.api.util.ListUtils; import mekanism.client.gui.GuiMekanism; -import mekanism.client.gui.GuiRedstoneControl; import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiGasGauge; import mekanism.client.gui.element.GuiPowerBar; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiGasGauge.IGasInfoHandler; diff --git a/src/main/java/mekanism/generators/client/gui/GuiHeatGenerator.java b/src/main/java/mekanism/generators/client/gui/GuiHeatGenerator.java index 0bedd4a95..95300c274 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiHeatGenerator.java +++ b/src/main/java/mekanism/generators/client/gui/GuiHeatGenerator.java @@ -5,10 +5,10 @@ import java.util.List; import mekanism.api.MekanismConfig.generators; import mekanism.api.util.ListUtils; import mekanism.client.gui.GuiMekanism; -import mekanism.client.gui.GuiRedstoneControl; import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiFluidGauge; import mekanism.client.gui.element.GuiPowerBar; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiFluidGauge.IFluidInfoHandler; diff --git a/src/main/java/mekanism/generators/client/gui/GuiNeutronCapture.java b/src/main/java/mekanism/generators/client/gui/GuiNeutronCapture.java index 1efc5dbc2..2de0e60f9 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiNeutronCapture.java +++ b/src/main/java/mekanism/generators/client/gui/GuiNeutronCapture.java @@ -4,9 +4,9 @@ import java.util.List; import mekanism.api.util.ListUtils; import mekanism.client.gui.GuiMekanism; -import mekanism.client.gui.GuiRedstoneControl; import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiPowerBar; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiSlot.SlotOverlay; diff --git a/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java b/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java index 18823d257..be54e249e 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java +++ b/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java @@ -4,9 +4,9 @@ import java.util.List; import mekanism.api.util.ListUtils; import mekanism.client.gui.GuiMekanism; -import mekanism.client.gui.GuiRedstoneControl; import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiPowerBar; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiSlot.SlotOverlay; diff --git a/src/main/java/mekanism/generators/client/gui/GuiWindTurbine.java b/src/main/java/mekanism/generators/client/gui/GuiWindTurbine.java index 645d57f6c..e5a6cb91a 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiWindTurbine.java +++ b/src/main/java/mekanism/generators/client/gui/GuiWindTurbine.java @@ -7,9 +7,9 @@ import mekanism.api.EnumColor; import mekanism.api.MekanismConfig.generators; import mekanism.api.util.ListUtils; import mekanism.client.gui.GuiMekanism; -import mekanism.client.gui.GuiRedstoneControl; import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiPowerBar; +import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiSlot.SlotOverlay; diff --git a/src/main/resources/assets/mekanism/gui/elements/GuiDetectionTab.png b/src/main/resources/assets/mekanism/gui/elements/GuiDetectionTab.png new file mode 100644 index 000000000..3a46a5286 Binary files /dev/null and b/src/main/resources/assets/mekanism/gui/elements/GuiDetectionTab.png differ diff --git a/src/main/resources/assets/mekanism/lang/en_US.lang b/src/main/resources/assets/mekanism/lang/en_US.lang index 4292d19d9..074b0bc07 100644 --- a/src/main/resources/assets/mekanism/lang/en_US.lang +++ b/src/main/resources/assets/mekanism/lang/en_US.lang @@ -468,6 +468,7 @@ gui.oreDictCompat=Compatible OreDict Key gui.toggleCooling=Toggle Cooling Measurements gui.coolingMeasurements=Active cooling gui.redstoneOutputMode=Redstone mode +gui.entityDetection=Entity Detection gui.reactor.injectionRate=Injection Rate