Entity Detection mode for Laser Amplifier

This commit is contained in:
Aidan C. Brady 2015-03-30 20:18:08 -04:00
parent e4d624d8ab
commit c85bdcd8ab
36 changed files with 205 additions and 29 deletions

View file

@ -8,6 +8,7 @@ import mekanism.client.gui.element.GuiEnergyInfo;
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;
import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiPowerBar;
import mekanism.client.gui.element.GuiProgress; 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.IProgressInfoHandler;
import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.client.gui.element.GuiProgress.ProgressBar;
import mekanism.client.gui.element.GuiSideConfigurationTab; import mekanism.client.gui.element.GuiSideConfigurationTab;

View file

@ -7,6 +7,7 @@ import mekanism.client.gui.element.GuiEnergyInfo;
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;
import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiPowerBar;
import mekanism.client.gui.element.GuiProgress; 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.IProgressInfoHandler;
import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.client.gui.element.GuiProgress.ProgressBar;
import mekanism.client.gui.element.GuiSideConfigurationTab; import mekanism.client.gui.element.GuiSideConfigurationTab;

View file

@ -15,6 +15,7 @@ import mekanism.client.gui.element.GuiGasGauge.IGasInfoHandler;
import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiGauge;
import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiPowerBar;
import mekanism.client.gui.element.GuiProgress; 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.IProgressInfoHandler;
import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.client.gui.element.GuiProgress.ProgressBar;
import mekanism.client.gui.element.GuiSideConfigurationTab; import mekanism.client.gui.element.GuiSideConfigurationTab;

View file

@ -8,6 +8,7 @@ import mekanism.client.gui.element.GuiEnergyInfo;
import mekanism.client.gui.element.GuiGasGauge; import mekanism.client.gui.element.GuiGasGauge;
import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiGauge;
import mekanism.client.gui.element.GuiProgress; import mekanism.client.gui.element.GuiProgress;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiUpgradeTab; import mekanism.client.gui.element.GuiUpgradeTab;
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;

View file

@ -10,6 +10,7 @@ import mekanism.client.gui.element.GuiEnergyInfo;
import mekanism.client.gui.element.GuiGasGauge; import mekanism.client.gui.element.GuiGasGauge;
import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiGauge;
import mekanism.client.gui.element.GuiProgress; import mekanism.client.gui.element.GuiProgress;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiUpgradeTab; import mekanism.client.gui.element.GuiUpgradeTab;
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;

View file

@ -8,6 +8,7 @@ import mekanism.client.gui.element.GuiEnergyInfo;
import mekanism.client.gui.element.GuiGasGauge; import mekanism.client.gui.element.GuiGasGauge;
import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiGauge;
import mekanism.client.gui.element.GuiProgress; import mekanism.client.gui.element.GuiProgress;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiUpgradeTab; import mekanism.client.gui.element.GuiUpgradeTab;
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;

View file

@ -12,6 +12,7 @@ import mekanism.client.gui.element.GuiFluidGauge;
import mekanism.client.gui.element.GuiGasGauge; import mekanism.client.gui.element.GuiGasGauge;
import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiGauge;
import mekanism.client.gui.element.GuiProgress; import mekanism.client.gui.element.GuiProgress;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiUpgradeTab; import mekanism.client.gui.element.GuiUpgradeTab;
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;

View file

@ -8,6 +8,7 @@ import mekanism.api.EnumColor;
import mekanism.api.util.ListUtils; import mekanism.api.util.ListUtils;
import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiEnergyInfo;
import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiPowerBar;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiUpgradeTab; import mekanism.client.gui.element.GuiUpgradeTab;
import mekanism.client.gui.element.GuiVisualsTab; import mekanism.client.gui.element.GuiVisualsTab;

View file

@ -3,6 +3,7 @@ package mekanism.client.gui;
import java.util.List; import java.util.List;
import mekanism.api.util.ListUtils; import mekanism.api.util.ListUtils;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.gui.element.GuiSideConfigurationTab; import mekanism.client.gui.element.GuiSideConfigurationTab;
import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiEnergyInfo;
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;

View file

@ -3,6 +3,7 @@ package mekanism.client.gui;
import mekanism.client.gui.element.GuiFluidGauge; import mekanism.client.gui.element.GuiFluidGauge;
import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiGauge;
import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiPowerBar;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiUpgradeTab; import mekanism.client.gui.element.GuiUpgradeTab;
import mekanism.client.gui.element.GuiFluidGauge.IFluidInfoHandler; import mekanism.client.gui.element.GuiFluidGauge.IFluidInfoHandler;

View file

@ -6,6 +6,7 @@ import mekanism.api.energy.IStrictEnergyStorage;
import mekanism.api.util.ListUtils; import mekanism.api.util.ListUtils;
import mekanism.client.gui.element.GuiEnergyGauge; import mekanism.client.gui.element.GuiEnergyGauge;
import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiEnergyInfo;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiEnergyGauge.IEnergyInfoHandler; import mekanism.client.gui.element.GuiEnergyGauge.IEnergyInfoHandler;
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;

View file

@ -7,6 +7,7 @@ import mekanism.api.util.ListUtils;
import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiEnergyInfo;
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;
import mekanism.client.gui.element.GuiRecipeType; import mekanism.client.gui.element.GuiRecipeType;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.gui.element.GuiSideConfigurationTab; import mekanism.client.gui.element.GuiSideConfigurationTab;
import mekanism.client.gui.element.GuiSortingTab; import mekanism.client.gui.element.GuiSortingTab;
import mekanism.client.gui.element.GuiTransporterConfigTab; import mekanism.client.gui.element.GuiTransporterConfigTab;

View file

@ -3,6 +3,7 @@ package mekanism.client.gui;
import java.util.ArrayList; import java.util.ArrayList;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.sound.SoundHandler; import mekanism.client.sound.SoundHandler;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.inventory.container.ContainerGasTank; import mekanism.common.inventory.container.ContainerGasTank;

View file

@ -3,9 +3,11 @@ package mekanism.client.gui;
import java.util.ArrayList; import java.util.ArrayList;
import mekanism.api.Coord4D; 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.GuiGauge.Type;
import mekanism.client.gui.element.GuiNumberGauge;
import mekanism.client.gui.element.GuiNumberGauge.INumberInfoHandler; import mekanism.client.gui.element.GuiNumberGauge.INumberInfoHandler;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.render.MekanismRenderer; import mekanism.client.render.MekanismRenderer;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.inventory.container.ContainerLaserAmplifier; 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.client.gui.GuiTextField;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.IIcon; 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.input.Keyboard;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class GuiLaserAmplifier extends GuiMekanism 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)); }, 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 GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")));
guiElements.add(new GuiDetectionTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")));
} }
@Override @Override

View file

@ -9,6 +9,7 @@ import java.util.Set;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.api.EnumColor; import mekanism.api.EnumColor;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.render.MekanismRenderer; import mekanism.client.render.MekanismRenderer;
import mekanism.client.sound.SoundHandler; import mekanism.client.sound.SoundHandler;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
@ -25,7 +26,6 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.tile.TileEntityLogisticalSorter; import mekanism.common.tile.TileEntityLogisticalSorter;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View file

@ -9,6 +9,7 @@ import mekanism.client.gui.element.GuiEnergyInfo;
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;
import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiPowerBar;
import mekanism.client.gui.element.GuiProgress; 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.IProgressInfoHandler;
import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.client.gui.element.GuiProgress.ProgressBar;
import mekanism.client.gui.element.GuiSideConfigurationTab; import mekanism.client.gui.element.GuiSideConfigurationTab;

View file

@ -13,6 +13,7 @@ import mekanism.client.gui.element.GuiGasGauge.IGasInfoHandler;
import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiGauge;
import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiPowerBar;
import mekanism.client.gui.element.GuiProgress; 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.IProgressInfoHandler;
import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.client.gui.element.GuiProgress.ProgressBar;
import mekanism.client.gui.element.GuiSideConfigurationTab; import mekanism.client.gui.element.GuiSideConfigurationTab;

View file

@ -11,6 +11,7 @@ import mekanism.client.gui.element.GuiFluidGauge;
import mekanism.client.gui.element.GuiGasGauge; import mekanism.client.gui.element.GuiGasGauge;
import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiGauge;
import mekanism.client.gui.element.GuiProgress; import mekanism.client.gui.element.GuiProgress;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiUpgradeTab; import mekanism.client.gui.element.GuiUpgradeTab;
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;

View file

@ -1,6 +1,7 @@
package mekanism.client.gui; package mekanism.client.gui;
import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiPowerBar;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiSlot.SlotOverlay; import mekanism.client.gui.element.GuiSlot.SlotOverlay;
import mekanism.client.gui.element.GuiSlot.SlotType; import mekanism.client.gui.element.GuiSlot.SlotType;

View file

@ -4,6 +4,7 @@ import mekanism.api.gas.GasTank;
import mekanism.client.gui.element.GuiGasGauge; import mekanism.client.gui.element.GuiGasGauge;
import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiGauge;
import mekanism.client.gui.element.GuiProgress; import mekanism.client.gui.element.GuiProgress;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiGasGauge.IGasInfoHandler; import mekanism.client.gui.element.GuiGasGauge.IGasInfoHandler;
import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler; import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler;

View file

@ -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");
}
}
}
}

View file

@ -1,7 +1,7 @@
package mekanism.client.gui; package mekanism.client.gui.element;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.client.gui.element.GuiElement; import mekanism.client.gui.IGuiWrapper;
import mekanism.client.sound.SoundHandler; import mekanism.client.sound.SoundHandler;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.base.IRedstoneControl; import mekanism.common.base.IRedstoneControl;

View file

@ -2,6 +2,8 @@ package mekanism.common;
import java.util.List; import java.util.List;
import com.mojang.realmsclient.util.Pair;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.general;
import mekanism.api.Pos3D; import mekanism.api.Pos3D;
@ -18,12 +20,12 @@ import net.minecraftforge.common.util.ForgeDirection;
public class LaserManager 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); 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); Pos3D to = from.clone().translate(direction, general.laserRange - 0.002);
@ -46,17 +48,25 @@ public class LaserManager
from.translateExcludingSide(direction, -0.1); from.translateExcludingSide(direction, -0.1);
to.translateExcludingSide(direction, 0.1); to.translateExcludingSide(direction, 0.1);
boolean foundEntity = false;
for(Entity e : (List<Entity>)world.getEntitiesWithinAABB(Entity.class, Pos3D.getAABB(from, to))) for(Entity e : (List<Entity>)world.getEntitiesWithinAABB(Entity.class, Pos3D.getAABB(from, to)))
{ {
foundEntity = true;
if(!e.isImmuneToFire()) if(!e.isImmuneToFire())
{ {
e.setFire((int)(energy / 1000)); 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<ItemStack> breakBlock(Coord4D blockCoord, boolean dropAtBlock, World world) public static List<ItemStack> breakBlock(Coord4D blockCoord, boolean dropAtBlock, World world)
@ -96,6 +106,20 @@ public class LaserManager
from.translate(direction, -0.501); from.translate(direction, -0.501);
Mekanism.proxy.renderLaser(world, from, to, direction, energy); Mekanism.proxy.renderLaser(world, from, to, direction, energy);
return mop; return mop;
} }
public static class LaserInfo
{
public MovingObjectPosition movingPos;
public boolean foundEntity;
public LaserInfo(MovingObjectPosition mop, boolean b)
{
movingPos = mop;
foundEntity = b;
}
}
} }

View file

@ -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" "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[] { 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[] { 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) "C", "F", Character.valueOf('C'), new ItemStack(MekanismBlocks.MachineBlock, 1, 13), Character.valueOf('F'), new ItemStack(MekanismBlocks.MachineBlock2, 1, 14)

View file

@ -1390,6 +1390,19 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
return false; 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 @Override
public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta) public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta)
{ {

View file

@ -11,12 +11,12 @@ import mekanism.api.MekanismConfig.usage;
import mekanism.api.Range4D; import mekanism.api.Range4D;
import mekanism.api.lasers.ILaserReceptor; import mekanism.api.lasers.ILaserReceptor;
import mekanism.common.LaserManager; import mekanism.common.LaserManager;
import mekanism.common.LaserManager.LaserInfo;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.base.IActiveState; import mekanism.common.base.IActiveState;
import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@ -79,8 +79,8 @@ public class TileEntityLaser extends TileEntityNoisyElectricBlock implements IAc
{ {
setActive(true); setActive(true);
MovingObjectPosition mop = LaserManager.fireLaser(this, ForgeDirection.getOrientation(facing), usage.laserUsage, worldObj); LaserInfo info = LaserManager.fireLaser(this, ForgeDirection.getOrientation(facing), usage.laserUsage, worldObj);
Coord4D hitCoord = mop == null ? null : new Coord4D(mop.blockX, mop.blockY, mop.blockZ); Coord4D hitCoord = info.movingPos == null ? null : new Coord4D(info.movingPos.blockX, info.movingPos.blockY, info.movingPos.blockZ);
if(hitCoord == null || !hitCoord.equals(digging)) if(hitCoord == null || !hitCoord.equals(digging))
{ {

View file

@ -10,6 +10,7 @@ import mekanism.api.energy.ICableOutputter;
import mekanism.api.energy.IStrictEnergyStorage; import mekanism.api.energy.IStrictEnergyStorage;
import mekanism.api.lasers.ILaserReceptor; import mekanism.api.lasers.ILaserReceptor;
import mekanism.common.LaserManager; import mekanism.common.LaserManager;
import mekanism.common.LaserManager.LaserInfo;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.base.IRedstoneControl; import mekanism.common.base.IRedstoneControl;
import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.network.PacketTileEntity.TileEntityMessage;
@ -38,6 +39,9 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement
public Coord4D digging; public Coord4D digging;
public double diggingProgress; public double diggingProgress;
public boolean emittingRedstone;
public boolean entityDetection;
public TileEntityLaserAmplifier() public TileEntityLaserAmplifier()
{ {
@ -93,6 +97,10 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement
} }
} }
else { else {
boolean prevRedstone = emittingRedstone;
emittingRedstone = false;
if(ticks < time) if(ticks < time)
{ {
ticks++; 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)); 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); LaserInfo info = LaserManager.fireLaser(this, ForgeDirection.getOrientation(facing), firing, worldObj);
Coord4D hitCoord = mop == null ? null : new Coord4D(mop.blockX, mop.blockY, mop.blockZ); Coord4D hitCoord = info.movingPos == null ? null : new Coord4D(info.movingPos.blockX, info.movingPos.blockY, info.movingPos.blockZ);
if(hitCoord == null || !hitCoord.equals(digging)) if(hitCoord == null || !hitCoord.equals(digging))
{ {
@ -138,6 +146,8 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement
} }
} }
} }
emittingRedstone = info.foundEntity;
setEnergy(getEnergy() - firing); setEnergy(getEnergy() - firing);
} }
@ -147,6 +157,16 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement
diggingProgress = 0; diggingProgress = 0;
Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); 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(collectedEnergy);
data.add(lastFired); data.add(lastFired);
data.add(controlType.ordinal()); data.add(controlType.ordinal());
data.add(emittingRedstone);
data.add(entityDetection);
return data; return data;
} }
@ -203,6 +225,8 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement
collectedEnergy = dataStream.readDouble(); collectedEnergy = dataStream.readDouble();
lastFired = dataStream.readDouble(); lastFired = dataStream.readDouble();
controlType = RedstoneControl.values()[dataStream.readInt()]; controlType = RedstoneControl.values()[dataStream.readInt()];
emittingRedstone = dataStream.readBoolean();
entityDetection = dataStream.readBoolean();
return; return;
} }
@ -218,6 +242,9 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement
case 2: case 2:
time = dataStream.readInt(); time = dataStream.readInt();
break; break;
case 3:
entityDetection = !entityDetection;
break;
} }
} }
@ -234,6 +261,7 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement
collectedEnergy = nbtTags.getDouble("collectedEnergy"); collectedEnergy = nbtTags.getDouble("collectedEnergy");
lastFired = nbtTags.getDouble("lastFired"); lastFired = nbtTags.getDouble("lastFired");
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
entityDetection = nbtTags.getBoolean("entityDetection");
} }
@Override @Override
@ -249,6 +277,7 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement
nbtTags.setDouble("collectedEnergy", collectedEnergy); nbtTags.setDouble("collectedEnergy", collectedEnergy);
nbtTags.setDouble("lastFired", lastFired); nbtTags.setDouble("lastFired", lastFired);
nbtTags.setInteger("controlType", controlType.ordinal()); nbtTags.setInteger("controlType", controlType.ordinal());
nbtTags.setBoolean("entityDetection", entityDetection);
} }
@Override @Override

View file

@ -1,5 +1,7 @@
package mekanism.common.tile; package mekanism.common.tile;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -8,20 +10,17 @@ import mekanism.api.MekanismConfig.general;
import mekanism.api.lasers.ILaserReceptor; import mekanism.api.lasers.ILaserReceptor;
import mekanism.api.util.StackUtils; import mekanism.api.util.StackUtils;
import mekanism.common.LaserManager; import mekanism.common.LaserManager;
import mekanism.common.LaserManager.LaserInfo;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.util.InventoryUtils; import mekanism.common.util.InventoryUtils;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import io.netty.buffer.ByteBuf;
public class TileEntityLaserTractorBeam extends TileEntityContainerBlock implements ILaserReceptor public class TileEntityLaserTractorBeam extends TileEntityContainerBlock implements ILaserReceptor
{ {
public static final double MAX_ENERGY = 5E9; 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)); 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); LaserInfo info = LaserManager.fireLaser(this, ForgeDirection.getOrientation(facing), firing, worldObj);
Coord4D hitCoord = mop == null ? null : new Coord4D(mop.blockX, mop.blockY, mop.blockZ); Coord4D hitCoord = info.movingPos == null ? null : new Coord4D(info.movingPos.blockX, info.movingPos.blockY, info.movingPos.blockZ);
if(hitCoord == null || !hitCoord.equals(digging)) if(hitCoord == null || !hitCoord.equals(digging))
{ {

View file

@ -5,9 +5,9 @@ import java.util.List;
import mekanism.api.MekanismConfig.generators; import mekanism.api.MekanismConfig.generators;
import mekanism.api.util.ListUtils; import mekanism.api.util.ListUtils;
import mekanism.client.gui.GuiMekanism; import mekanism.client.gui.GuiMekanism;
import mekanism.client.gui.GuiRedstoneControl;
import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiEnergyInfo;
import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiPowerBar;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;
import mekanism.client.gui.element.GuiSlot.SlotOverlay; import mekanism.client.gui.element.GuiSlot.SlotOverlay;

View file

@ -5,10 +5,10 @@ import java.util.List;
import mekanism.api.gas.GasTank; import mekanism.api.gas.GasTank;
import mekanism.api.util.ListUtils; import mekanism.api.util.ListUtils;
import mekanism.client.gui.GuiMekanism; import mekanism.client.gui.GuiMekanism;
import mekanism.client.gui.GuiRedstoneControl;
import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiEnergyInfo;
import mekanism.client.gui.element.GuiGasGauge; import mekanism.client.gui.element.GuiGasGauge;
import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiPowerBar;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;
import mekanism.client.gui.element.GuiGasGauge.IGasInfoHandler; import mekanism.client.gui.element.GuiGasGauge.IGasInfoHandler;

View file

@ -5,10 +5,10 @@ import java.util.List;
import mekanism.api.MekanismConfig.generators; import mekanism.api.MekanismConfig.generators;
import mekanism.api.util.ListUtils; import mekanism.api.util.ListUtils;
import mekanism.client.gui.GuiMekanism; import mekanism.client.gui.GuiMekanism;
import mekanism.client.gui.GuiRedstoneControl;
import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiEnergyInfo;
import mekanism.client.gui.element.GuiFluidGauge; import mekanism.client.gui.element.GuiFluidGauge;
import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiPowerBar;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;
import mekanism.client.gui.element.GuiFluidGauge.IFluidInfoHandler; import mekanism.client.gui.element.GuiFluidGauge.IFluidInfoHandler;

View file

@ -4,9 +4,9 @@ import java.util.List;
import mekanism.api.util.ListUtils; import mekanism.api.util.ListUtils;
import mekanism.client.gui.GuiMekanism; import mekanism.client.gui.GuiMekanism;
import mekanism.client.gui.GuiRedstoneControl;
import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiEnergyInfo;
import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiPowerBar;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;
import mekanism.client.gui.element.GuiSlot.SlotOverlay; import mekanism.client.gui.element.GuiSlot.SlotOverlay;

View file

@ -4,9 +4,9 @@ import java.util.List;
import mekanism.api.util.ListUtils; import mekanism.api.util.ListUtils;
import mekanism.client.gui.GuiMekanism; import mekanism.client.gui.GuiMekanism;
import mekanism.client.gui.GuiRedstoneControl;
import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiEnergyInfo;
import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiPowerBar;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;
import mekanism.client.gui.element.GuiSlot.SlotOverlay; import mekanism.client.gui.element.GuiSlot.SlotOverlay;

View file

@ -7,9 +7,9 @@ import mekanism.api.EnumColor;
import mekanism.api.MekanismConfig.generators; import mekanism.api.MekanismConfig.generators;
import mekanism.api.util.ListUtils; import mekanism.api.util.ListUtils;
import mekanism.client.gui.GuiMekanism; import mekanism.client.gui.GuiMekanism;
import mekanism.client.gui.GuiRedstoneControl;
import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiEnergyInfo;
import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiPowerBar;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;
import mekanism.client.gui.element.GuiSlot.SlotOverlay; import mekanism.client.gui.element.GuiSlot.SlotOverlay;

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View file

@ -468,6 +468,7 @@ gui.oreDictCompat=Compatible OreDict Key
gui.toggleCooling=Toggle Cooling Measurements gui.toggleCooling=Toggle Cooling Measurements
gui.coolingMeasurements=Active cooling gui.coolingMeasurements=Active cooling
gui.redstoneOutputMode=Redstone mode gui.redstoneOutputMode=Redstone mode
gui.entityDetection=Entity Detection
gui.reactor.injectionRate=Injection Rate gui.reactor.injectionRate=Injection Rate