diff --git a/src/main/java/mekanism/api/lasers/LaserManager.java b/src/main/java/mekanism/api/lasers/LaserManager.java index e61db4776..1bfd1d134 100644 --- a/src/main/java/mekanism/api/lasers/LaserManager.java +++ b/src/main/java/mekanism/api/lasers/LaserManager.java @@ -15,8 +15,9 @@ public class LaserManager public static void fireLaser(Coord4D from, ForgeDirection direction, double energy, World world) { + Coord4D rangeFrom = from.getFromSide(direction, 1); Coord4D to = from.getFromSide(direction, range); - MovingObjectPosition mop = world.rayTraceBlocks(Vec3.createVectorHelper(from.xCoord, from.yCoord, from.zCoord), Vec3.createVectorHelper(to.xCoord, to.yCoord, to.zCoord)); + MovingObjectPosition mop = world.rayTraceBlocks(Vec3.createVectorHelper(rangeFrom.xCoord, rangeFrom.yCoord, rangeFrom.zCoord), Vec3.createVectorHelper(to.xCoord, to.yCoord, to.zCoord)); if(mop != null) { diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index 550d18e3a..36091f6b8 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -191,7 +191,8 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer icons[5][2] = register.registerIcon("mekanism:SteelCasing"); icons[9][0] = register.registerIcon("mekanism:SteelBlock"); icons[9][1] = register.registerIcon("mekanism:SeismicVibrator"); - icons[13][0] = register.registerIcon("Mekanism:Laser"); + icons[13][0] = register.registerIcon("Mekanism:SteelCasing"); + icons[13][1] = register.registerIcon("Mekanism:Laser"); } } @@ -467,6 +468,16 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer return icons[meta][0]; } } + else if(meta == 13) + { + if(side == 3) + { + return icons[meta][0]; + } + else { + return icons[meta][1]; + } + } } return null; @@ -600,7 +611,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer return icons[metadata][2]; } } - else if(metadata == 9) + else if(metadata == 9 || metadata == 13) { if(side == tileEntity.facing) { @@ -834,7 +845,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer } @Override - public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) + public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) { if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) { diff --git a/src/main/java/mekanism/common/tile/TileEntityLaser.java b/src/main/java/mekanism/common/tile/TileEntityLaser.java index ca209fed6..e4981dca2 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLaser.java +++ b/src/main/java/mekanism/common/tile/TileEntityLaser.java @@ -3,6 +3,7 @@ package mekanism.common.tile; import mekanism.api.Coord4D; import mekanism.api.lasers.LaserManager; +import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; public class TileEntityLaser extends TileEntityElectricBlock @@ -12,14 +13,18 @@ public class TileEntityLaser extends TileEntityElectricBlock public TileEntityLaser() { super("Laser", 100000); + inventory = new ItemStack[0]; } @Override public void onUpdate() { + super.onUpdate(); + if(getEnergy() >= LASER_ENERGY) { LaserManager.fireLaser(Coord4D.get(this), ForgeDirection.getOrientation(facing), LASER_ENERGY, worldObj); + setEnergy(getEnergy()-LASER_ENERGY); } } } diff --git a/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java b/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java index cb833cfb9..26c63f7c9 100644 --- a/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java +++ b/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java @@ -12,6 +12,13 @@ import mekanism.generators.common.tile.TileEntityHeatGenerator; import mekanism.generators.common.tile.TileEntityGasGenerator; import mekanism.generators.common.tile.TileEntitySolarGenerator; import mekanism.generators.common.tile.TileEntityWindTurbine; +import mekanism.generators.common.tile.reactor.TileEntityReactorController; +import mekanism.generators.common.tile.reactor.TileEntityReactorFrame; +import mekanism.generators.common.tile.reactor.TileEntityReactorGlass; +import mekanism.generators.common.tile.reactor.TileEntityReactorLaserFocusMatrix; +import mekanism.generators.common.tile.reactor.TileEntityReactorNeutronCapture; +import mekanism.generators.common.tile.reactor.TileEntityReactorPort; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.tileentity.TileEntity; @@ -25,6 +32,19 @@ import cpw.mods.fml.common.registry.GameRegistry; */ public class GeneratorsCommonProxy { + /** + * Register normal tile entities + */ + public void registerRegularTileEntities() + { + GameRegistry.registerTileEntity(TileEntityReactorController.class, "ReactorController"); + GameRegistry.registerTileEntity(TileEntityReactorFrame.class, "ReactorFrame"); + GameRegistry.registerTileEntity(TileEntityReactorGlass.class, "ReactorGlass"); + GameRegistry.registerTileEntity(TileEntityReactorLaserFocusMatrix.class, "ReactorLaserFocus"); + GameRegistry.registerTileEntity(TileEntityReactorNeutronCapture.class, "ReactorNeutronCapture"); + GameRegistry.registerTileEntity(TileEntityReactorPort.class, "ReactorPort"); + } + /** * Register tile entities that have special models. Overwritten in client to register TESRs. */ diff --git a/src/main/java/mekanism/generators/common/MekanismGenerators.java b/src/main/java/mekanism/generators/common/MekanismGenerators.java index 4df497504..496f9ca7b 100644 --- a/src/main/java/mekanism/generators/common/MekanismGenerators.java +++ b/src/main/java/mekanism/generators/common/MekanismGenerators.java @@ -15,6 +15,8 @@ import mekanism.common.recipe.MekanismRecipe; import mekanism.generators.common.block.BlockGenerator; import mekanism.generators.common.block.BlockReactor; import mekanism.generators.common.item.ItemBlockGenerator; +import mekanism.generators.common.item.ItemBlockReactor; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -96,6 +98,7 @@ public class MekanismGenerators implements IModule //Load the proxy proxy.loadConfiguration(); + proxy.registerRegularTileEntities(); proxy.registerSpecialTileEntities(); proxy.registerRenderInformation(); @@ -143,7 +146,7 @@ public class MekanismGenerators implements IModule Reactor = new BlockReactor().setBlockName("Reactor"); GameRegistry.registerBlock(Generator, ItemBlockGenerator.class, "Generator"); - GameRegistry.registerBlock(Reactor, "Reactor"); + GameRegistry.registerBlock(Reactor, ItemBlockReactor.class, "Reactor"); } public void addItems() diff --git a/src/main/java/mekanism/generators/common/block/BlockReactor.java b/src/main/java/mekanism/generators/common/block/BlockReactor.java index ddd522711..71b486c7f 100644 --- a/src/main/java/mekanism/generators/common/block/BlockReactor.java +++ b/src/main/java/mekanism/generators/common/block/BlockReactor.java @@ -16,6 +16,7 @@ import mekanism.common.util.MekanismUtils; import mekanism.generators.client.GeneratorsClientProxy; import mekanism.generators.common.MekanismGenerators; import mekanism.generators.common.tile.TileEntitySolarGenerator; +import mekanism.generators.common.tile.reactor.TileEntityReactorBlock; import mekanism.generators.common.tile.reactor.TileEntityReactorController; import mekanism.generators.common.tile.reactor.TileEntityReactorFrame; import mekanism.generators.common.tile.reactor.TileEntityReactorGlass; @@ -34,6 +35,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; @@ -47,6 +49,8 @@ import buildcraft.api.tools.IToolWrench; public class BlockReactor extends BlockContainer { + public IIcon[][] icons = new IIcon[16][16]; + public BlockReactor() { super(Material.iron); @@ -55,6 +59,70 @@ public class BlockReactor extends BlockContainer setCreativeTab(Mekanism.tabMekanism); } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister register) + { + if(this == MekanismGenerators.Reactor) + { + icons[0][0] = register.registerIcon("mekanism:ReactorControllerOff"); + icons[0][1] = register.registerIcon("mekanism:ReactorControllerOn"); + icons[0][2] = register.registerIcon("mekanism:ReactorFrame"); + icons[1][0] = register.registerIcon("mekanism:ReactorFrame"); + icons[2][0] = register.registerIcon("mekanism:ReactorGlass"); + icons[3][0] = register.registerIcon("mekanism:ReactorLaserFocus"); + icons[4][0] = register.registerIcon("mekanism:ReactorNeutronCapture"); + icons[5][0] = register.registerIcon("mekanism:ReactorPort"); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) + { + if(this == MekanismGenerators.Reactor) + { + if(meta == 0) + { + return icons[0][side == 6 ? 0 : 2]; + } + else + { + return icons[meta][0]; + } + } + + return null; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) + { + int metadata = world.getBlockMetadata(x, y, z); + TileEntityReactorBlock tileEntity = (TileEntityReactorBlock)world.getTileEntity(x, y, z); + + if(this == MekanismGenerators.Reactor) + { + if(metadata == 0) + { + if(side == 1) + { + return MekanismUtils.isActive(world, x, y, z) ? icons[0][1] : icons[0][0]; + } + else { + return icons[0][2]; + } + } + else + { + return icons[metadata][0]; + } + } + + return null; + } + @Override public int damageDropped(int i) { diff --git a/src/main/java/mekanism/generators/common/item/ItemBlockReactor.java b/src/main/java/mekanism/generators/common/item/ItemBlockReactor.java new file mode 100644 index 000000000..af0fd857e --- /dev/null +++ b/src/main/java/mekanism/generators/common/item/ItemBlockReactor.java @@ -0,0 +1,61 @@ +package mekanism.generators.common.item; + +import java.util.List; + +import mekanism.api.EnumColor; +import mekanism.common.util.MekanismUtils; +import mekanism.generators.common.block.BlockReactor.ReactorBlockType; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import org.lwjgl.input.Keyboard; + +public class ItemBlockReactor extends ItemBlock +{ + public Block metaBlock; + + public ItemBlockReactor(Block block) + { + super(block); + metaBlock = block; + setHasSubtypes(true); + } + + @Override + public int getMetadata(int i) + { + return i; + } + + @Override + public IIcon getIconFromDamage(int i) + { + return metaBlock.getIcon(2, i); + } + + @Override + public String getUnlocalizedName(ItemStack itemstack) + { + return getUnlocalizedName() + "." + ReactorBlockType.getFromMetadata(itemstack.getItemDamage()).name; + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) + { + ReactorBlockType type = ReactorBlockType.getFromMetadata(itemstack.getItemDamage()); + + if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) + { + list.add(MekanismUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + "shift" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.forDetails") + "."); + } + else { + list.addAll(MekanismUtils.splitLines(type.getDescription())); + } + } +} diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java index 92af05136..174e653f2 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java @@ -4,6 +4,7 @@ import io.netty.buffer.ByteBuf; import java.util.ArrayList; +import mekanism.api.lasers.ILaserReceptor; import mekanism.common.Mekanism; import mekanism.common.util.ChargeUtils; import mekanism.common.util.FluidContainerUtils; @@ -27,7 +28,7 @@ import cpw.mods.fml.common.Optional.Method; import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; -public class TileEntityHeatGenerator extends TileEntityGenerator implements IFluidHandler +public class TileEntityHeatGenerator extends TileEntityGenerator implements IFluidHandler, ILaserReceptor { /** The FluidTank for this generator. */ public FluidTank lavaTank = new FluidTank(24000); @@ -335,4 +336,22 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu { return new FluidTankInfo[] {lavaTank.getInfo()}; } + + @Override + public void receiveLaserEnergy(double energy, ForgeDirection side) + { + setEnergy(getEnergy()+energy); + } + + @Override + public boolean canLasersDig() + { + return false; + } + + @Override + public double energyToDig() + { + return 0; + } } diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java index cc6d3ed32..1c1e4226e 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java @@ -4,6 +4,7 @@ import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; import mekanism.api.gas.IGasHandler; +import mekanism.api.gas.ITubeConnection; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; @@ -12,7 +13,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityReactorPort extends TileEntityReactorBlock implements IFluidHandler, IGasHandler +public class TileEntityReactorPort extends TileEntityReactorBlock implements IFluidHandler, IGasHandler, ITubeConnection { @Override public boolean isFrame() @@ -118,4 +119,10 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl { return (type == GasRegistry.getGas("steam")); } + + @Override + public boolean canTubeConnect(ForgeDirection side) + { + return true; + } } \ No newline at end of file diff --git a/src/main/resources/assets/mekanism/textures/blocks/ReactorControllerOff.png b/src/main/resources/assets/mekanism/textures/blocks/ReactorControllerOff.png new file mode 100644 index 000000000..e2f20767e Binary files /dev/null and b/src/main/resources/assets/mekanism/textures/blocks/ReactorControllerOff.png differ diff --git a/src/main/resources/assets/mekanism/textures/blocks/ReactorControllerOn.png b/src/main/resources/assets/mekanism/textures/blocks/ReactorControllerOn.png new file mode 100644 index 000000000..0de13b514 Binary files /dev/null and b/src/main/resources/assets/mekanism/textures/blocks/ReactorControllerOn.png differ diff --git a/src/main/resources/assets/mekanism/textures/blocks/ReactorFrame.png b/src/main/resources/assets/mekanism/textures/blocks/ReactorFrame.png new file mode 100644 index 000000000..dd31e613d Binary files /dev/null and b/src/main/resources/assets/mekanism/textures/blocks/ReactorFrame.png differ diff --git a/src/main/resources/assets/mekanism/textures/blocks/ReactorGlass.png b/src/main/resources/assets/mekanism/textures/blocks/ReactorGlass.png new file mode 100644 index 000000000..8a7b4dcde Binary files /dev/null and b/src/main/resources/assets/mekanism/textures/blocks/ReactorGlass.png differ diff --git a/src/main/resources/assets/mekanism/textures/blocks/ReactorLaserFocus.png b/src/main/resources/assets/mekanism/textures/blocks/ReactorLaserFocus.png new file mode 100644 index 000000000..464779cb9 Binary files /dev/null and b/src/main/resources/assets/mekanism/textures/blocks/ReactorLaserFocus.png differ diff --git a/src/main/resources/assets/mekanism/textures/blocks/ReactorPort.png b/src/main/resources/assets/mekanism/textures/blocks/ReactorPort.png new file mode 100644 index 000000000..bafa1a584 Binary files /dev/null and b/src/main/resources/assets/mekanism/textures/blocks/ReactorPort.png differ