mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-08-10 17:55:44 +00:00
Merge branch 'HbmMods:master' into gui
This commit is contained in:
commit
f11c95e444
@ -7,6 +7,8 @@
|
||||
* Finally removed the old terra drill items after being deprecated for almost a year
|
||||
* The electrolysis machine now instantly annihilates all buffered fluid output when changing recipe
|
||||
* This is a straight downgrade but people for some reason wanted it so sure why not
|
||||
* Cable diodes now have a GUI for configuration instead of requiring tools
|
||||
* The throughput can now be configured more precisely instead of increments of powers of 10
|
||||
|
||||
## Fixed
|
||||
* Fixed burner press GUI offsets being incorrect
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package api.hbm.block;
|
||||
|
||||
@Deprecated
|
||||
public interface IPileNeutronReceiver {
|
||||
|
||||
public void receiveNeutrons(int n);
|
||||
|
||||
@ -1,41 +1,12 @@
|
||||
package com.hbm.blocks.machine.pile;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.blocks.generic.BlockFlammable;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.toclient.ParticleBurstPacket;
|
||||
|
||||
import api.hbm.block.IToolable;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockGraphite extends BlockFlammable implements IToolable {
|
||||
public class BlockGraphite extends BlockFlammable {
|
||||
|
||||
public BlockGraphite(Material mat, int en, int flam) {
|
||||
super(mat, en, flam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
||||
|
||||
if(tool != ToolType.HAND_DRILL)
|
||||
return false;
|
||||
|
||||
if(!world.isRemote) {
|
||||
world.setBlock(x, y, z, ModBlocks.block_graphite_drilled, side / 2, 3);
|
||||
PacketDispatcher.wrapper.sendToAllAround(new ParticleBurstPacket(x, y, z, Block.getIdFromBlock(this), 0), new TargetPoint(world.provider.dimensionId, x, y, z, 50));
|
||||
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, this.stepSound.func_150496_b(), (this.stepSound.getVolume() + 1.0F) / 2.0F, this.stepSound.getPitch() * 0.8F);
|
||||
|
||||
BlockGraphiteRod.ejectItem(world, x, y, z, ForgeDirection.getOrientation(side), new ItemStack(ModItems.ingot_graphite));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@Deprecated
|
||||
public class BlockGraphiteBreedingFuel extends BlockGraphiteDrilledTE implements IToolable {
|
||||
|
||||
@Override
|
||||
|
||||
@ -9,6 +9,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
@Deprecated
|
||||
public class BlockGraphiteBreedingProduct extends BlockGraphiteDrilledBase implements IToolable {
|
||||
|
||||
@Override
|
||||
|
||||
@ -12,6 +12,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@Deprecated
|
||||
public class BlockGraphiteDrilled extends BlockGraphiteDrilledBase implements IToolable {
|
||||
|
||||
@Override
|
||||
|
||||
@ -26,6 +26,7 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@Deprecated
|
||||
public abstract class BlockGraphiteDrilledBase extends BlockFlammable implements IToolable, IInsertable {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@ -4,6 +4,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@Deprecated
|
||||
public abstract class BlockGraphiteDrilledTE extends BlockGraphiteDrilledBase implements ITileEntityProvider {
|
||||
|
||||
public BlockGraphiteDrilledTE() {
|
||||
|
||||
@ -21,6 +21,7 @@ import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@Deprecated
|
||||
public class BlockGraphiteFuel extends BlockGraphiteDrilledTE implements IToolable, IBlowable {
|
||||
|
||||
@Override
|
||||
|
||||
@ -19,6 +19,7 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@Deprecated
|
||||
public class BlockGraphiteNeutronDetector extends BlockGraphiteDrilledTE {
|
||||
|
||||
@Override
|
||||
|
||||
@ -13,6 +13,7 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@Deprecated
|
||||
public class BlockGraphiteRod extends BlockGraphiteDrilledBase implements IToolable {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@ -13,6 +13,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@Deprecated
|
||||
public class BlockGraphiteSource extends BlockGraphiteDrilledTE implements IToolable {
|
||||
|
||||
@Override
|
||||
|
||||
@ -2,36 +2,63 @@ package com.hbm.blocks.machine.pile;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.blocks.machine.MachinePWRController;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.render.block.ct.CT;
|
||||
import com.hbm.render.block.ct.CTStitchReceiver;
|
||||
import com.hbm.render.block.ct.IBlockCT;
|
||||
import com.hbm.tileentity.machine.pile.TileEntityPileBaseMK2;
|
||||
import com.hbm.tileentity.machine.pile.TileEntityPileCore;
|
||||
|
||||
import api.hbm.block.IToolable;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockPile extends BlockContainer implements IBlockCT {
|
||||
public class BlockPile extends BlockContainer implements IBlockCT, IToolable {
|
||||
|
||||
/** Blank dummy, the pile is mostly composed of that */
|
||||
public static final int META_DUMMY = 0;
|
||||
/** The core, gets its own TE and runs the simulation, only one per pile */
|
||||
public static final int META_CORE = 1;
|
||||
/** Channel mid segment for channel intersect checks */
|
||||
public static final int META_CHANNEL = 2;
|
||||
/** Startpoint of the channel */
|
||||
public static final int META_FUEL_IN = 3;
|
||||
/** Endpoint of the fuel channel */
|
||||
public static final int META_FUEL_OUT = 4;
|
||||
/** Startpoint of the ventilation channel */
|
||||
public static final int META_AIR_IN = 5;
|
||||
/** Endpoint of the ventilation channel */
|
||||
public static final int META_AIR_OUT = 6;
|
||||
/** Control rod channel */
|
||||
public static final int META_CONTROL = 7;
|
||||
/** Edge of our pile "cube" to prevent channels from being drilled there */
|
||||
public static final int META_EDGE = 8;
|
||||
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconTop;
|
||||
|
||||
public BlockPile() {
|
||||
super(Material.iron);
|
||||
public BlockPile() { super(Material.iron); }
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
if(meta == META_CORE) return new TileEntityPileCore();
|
||||
return new TileEntityPileBaseMK2();
|
||||
}
|
||||
|
||||
@Override public int getRenderType() { return CT.renderID; }
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int i, Random rand, int j) {
|
||||
return null;
|
||||
}
|
||||
@Override public Item getItemDropped(int i, Random rand, int j) { return null; }
|
||||
|
||||
@SideOnly(Side.CLIENT) public CTStitchReceiver rec;
|
||||
@SideOnly(Side.CLIENT) public CTStitchReceiver recTop;
|
||||
@ -40,19 +67,51 @@ public class BlockPile extends BlockContainer implements IBlockCT {
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
super.registerBlockIcons(reg);
|
||||
this.iconTop = reg.registerIcon(RefStrings.MODID + ":pile_block_top");
|
||||
|
||||
this.rec = IBlockCT.primeReceiver(reg, this.blockIcon.getIconName(), this.blockIcon);
|
||||
this.recTop = IBlockCT.primeReceiver(reg, this.iconTop.getIconName(), this.iconTop);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon[] getFragments(IBlockAccess world, int x, int y, int z, int side) {
|
||||
if(side == 0 || side == 1) return recTop.fragCache;
|
||||
return rec.fragCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if(tile instanceof TileEntityPileBaseMK2) {
|
||||
TileEntityPileBaseMK2 pile = (TileEntityPileBaseMK2) tile;
|
||||
world.removeTileEntity(x, y, z);
|
||||
if(pile.coreY >= 0) world.setBlock(x, y, z, ModBlocks.pile_brick);
|
||||
|
||||
TileEntityPileCore core = pile.getCore();
|
||||
if(core != null && !core.isInvalid()) core.destroy();
|
||||
|
||||
} else {
|
||||
world.removeTileEntity(x, y, z);
|
||||
world.setBlock(x, y, z, ModBlocks.pile_brick);
|
||||
}
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
||||
|
||||
if(tool == tool.HAND_DRILL) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile instanceof TileEntityPileBaseMK2) {
|
||||
TileEntityPileCore core = ((TileEntityPileBaseMK2) tile).getCore();
|
||||
if(core != null) {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(side).getOpposite();
|
||||
return core.drillChannel(x, y, z, dir, player);
|
||||
}
|
||||
}
|
||||
MachinePWRController.sendError(world, x, y, z, "No core found", player);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,9 @@ package com.hbm.blocks.machine.pile;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.blocks.machine.MachinePWRController;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.machine.pile.TileEntityPileBaseMK2;
|
||||
import com.hbm.tileentity.machine.pile.TileEntityPileCore;
|
||||
import com.hbm.tileentity.machine.pile.TileEntityPileCore.PileOrientation;
|
||||
|
||||
import api.hbm.block.IToolable;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@ -19,8 +22,6 @@ public class BlockPileBrick extends Block implements IToolable {
|
||||
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconTop;
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconSide;
|
||||
|
||||
public static int MAX_SIZE = 15;
|
||||
|
||||
public BlockPileBrick() {
|
||||
super(Material.rock);
|
||||
@ -42,6 +43,12 @@ public class BlockPileBrick extends Block implements IToolable {
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
|
||||
public static final int MIN_V_SIZE = 5;
|
||||
public static final int MIN_H_SIZE = 5;
|
||||
public static final int MAX_V_SIZE = 15;
|
||||
public static final int MAX_H_SIZE = 15;
|
||||
|
||||
@Override
|
||||
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
||||
|
||||
@ -50,6 +57,7 @@ public class BlockPileBrick extends Block implements IToolable {
|
||||
if(world.isRemote) return true;
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(side).getOpposite();
|
||||
ForgeDirection dirLeft = dir.getRotation(ForgeDirection.DOWN);
|
||||
|
||||
int negHeight = 0;
|
||||
int posHeight = 0;
|
||||
@ -57,32 +65,41 @@ public class BlockPileBrick extends Block implements IToolable {
|
||||
int right = 0;
|
||||
int depth = 0;
|
||||
|
||||
for(int i = 1; i <= MAX_SIZE; i++) { if(world.getBlock(x, y + i, z) != this) break; posHeight = i; }
|
||||
for(int i = 1; i <= MAX_SIZE - posHeight - 1; i++) { if(world.getBlock(x, y - i, z) != this) break; negHeight = i; }
|
||||
/// PROBE DIMENSIONS ///
|
||||
// height
|
||||
for(int i = 1; i <= MAX_V_SIZE - 1; i++) { if(world.getBlock(x, y + i, z) != this) break; posHeight = i; }
|
||||
for(int i = 1; i <= MAX_V_SIZE - posHeight - 1; i++) { if(world.getBlock(x, y - i, z) != this) break; negHeight = i; }
|
||||
// side width
|
||||
for(int i = 1; i <= MAX_H_SIZE - 1; i++) { if(world.getBlock(x + dirLeft.offsetX * i, y, z + dirLeft.offsetZ * i) != this) break; left = i; }
|
||||
for(int i = 1; i <= MAX_H_SIZE - left - 1; i++) { if(world.getBlock(x - dirLeft.offsetX * i, y, z - dirLeft.offsetZ * i) != this) break; right = i; }
|
||||
// depth
|
||||
for(int i = 1; i <= MAX_H_SIZE; i++) { if(world.getBlock(x + dir.offsetX * i, y, z + dir.offsetZ * i) != this) break; depth = i; }
|
||||
|
||||
ForgeDirection dirLeft = dir.getRotation(ForgeDirection.DOWN);
|
||||
for(int i = 1; i <= MAX_SIZE; i++) { if(world.getBlock(x + dirLeft.offsetX * i, y, z + dirLeft.offsetZ * i) != this) break; left = i; }
|
||||
for(int i = 1; i <= MAX_SIZE - left - 1; i++) { if(world.getBlock(x - dirLeft.offsetX * i, y, z - dirLeft.offsetZ * i) != this) break; right = i; }
|
||||
/// SIZE CHECKS ///
|
||||
if(posHeight + negHeight + 1 < MIN_V_SIZE) {
|
||||
MachinePWRController.sendError(world, x, y + posHeight, z, "Height too low (<" + MIN_V_SIZE + ")", player);
|
||||
MachinePWRController.sendError(world, x, y - negHeight, z, "Height too low (<" + MIN_V_SIZE + ")", player);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(left + right + 1 < MIN_H_SIZE) {
|
||||
MachinePWRController.sendError(world, x + dirLeft.offsetX * left, y, z + dirLeft.offsetZ * right, "Width too low (<" + MIN_H_SIZE + ")", player);
|
||||
MachinePWRController.sendError(world, x - dirLeft.offsetX * right, y, z - dirLeft.offsetZ * right, "Width too low (<" + MIN_H_SIZE + ")", player);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(depth + 1 < MIN_H_SIZE) {
|
||||
MachinePWRController.sendError(world, x + dir.offsetX * depth, y, z + dir.offsetZ * depth, "Depth too low (<" + MIN_H_SIZE + ")", player);
|
||||
return true;
|
||||
}
|
||||
|
||||
for(int i = 1; i <= MAX_SIZE; i++) { if(world.getBlock(x + dir.offsetX * i, y, z + dir.offsetZ * i) != this) break; depth = i; }
|
||||
|
||||
if(posHeight + negHeight + 1 < 5) {
|
||||
MachinePWRController.sendError(world, x, y + posHeight, z, "Height too low (<5)", player);
|
||||
MachinePWRController.sendError(world, x, y - negHeight, z, "Height too low (<5)", player);
|
||||
/// CORE EDGE CHECK ///
|
||||
if(posHeight == 0 || negHeight == 0 || left == 0 || right == 0) {
|
||||
MachinePWRController.sendError(world, x, y, z, "Core cannot be on an edge", player);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(left + right + 1 < 5) {
|
||||
MachinePWRController.sendError(world, x + dirLeft.offsetX * left, y, z + dirLeft.offsetZ * right, "Width too low (<5)", player);
|
||||
MachinePWRController.sendError(world, x - dirLeft.offsetX * right, y, z - dirLeft.offsetZ * right, "Width too low (<5)", player);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(depth + 1 < 5) {
|
||||
MachinePWRController.sendError(world, x + dir.offsetX * depth, y, z + dir.offsetZ * depth, "Depth too low (<5)", player);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// VOLUME CHECK ///
|
||||
for(int h = -negHeight; h <= posHeight; h++) {
|
||||
for(int v = -left; v <= right; v++) {
|
||||
for(int d = 0; d <= depth; d++) {
|
||||
@ -97,14 +114,26 @@ public class BlockPileBrick extends Block implements IToolable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// BUILD ///
|
||||
for(int h = -negHeight; h <= posHeight; h++) {
|
||||
for(int v = -left; v <= right; v++) {
|
||||
for(int d = 0; d <= depth; d++) {
|
||||
int iX = x - dirLeft.offsetX * v + dir.offsetX * d;
|
||||
int iY = y + h;
|
||||
int iZ = z - dirLeft.offsetZ * v + dir.offsetZ * d;
|
||||
world.setBlock(iX, iY, iZ, ModBlocks.pile_block);
|
||||
|
||||
if(x == iX && y == iY && z == iZ) {
|
||||
world.setBlock(iX, iY, iZ, ModBlocks.pile_block, BlockPile.META_CORE, 3);
|
||||
TileEntityPileCore core = (TileEntityPileCore) world.getTileEntity(iX, iY, iZ);
|
||||
core.orientation = PileOrientation.getOrientation(dir);
|
||||
} else {
|
||||
world.setBlock(iX, iY, iZ, ModBlocks.pile_block, BlockPile.META_DUMMY, 3);
|
||||
TileEntityPileBaseMK2 pile = (TileEntityPileBaseMK2) world.getTileEntity(iX, iY, iZ);
|
||||
pile.coreX = x;
|
||||
pile.coreY = y;
|
||||
pile.coreZ = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,34 +1,36 @@
|
||||
package com.hbm.blocks.network;
|
||||
|
||||
import api.hbm.block.IToolable;
|
||||
import api.hbm.energymk2.IEnergyConnectorBlock;
|
||||
import api.hbm.energymk2.IEnergyConnectorMK2;
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2;
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2.ConnectionPriority;
|
||||
import api.hbm.energymk2.Nodespace;
|
||||
import api.hbm.energymk2.Nodespace.PowerNode;
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
import com.hbm.blocks.ITooltipProvider;
|
||||
import com.hbm.interfaces.IControlReceiver;
|
||||
import com.hbm.inventory.gui.GUIDiode;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
import com.hbm.util.Compat;
|
||||
import com.hbm.util.EnumUtil;
|
||||
import com.hbm.util.i18n.I18nUtil;
|
||||
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.BlockPistonBase;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||
@ -37,28 +39,16 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CableDiode extends BlockContainer implements IEnergyConnectorBlock, ILookOverlay, IToolable, ITooltipProvider {
|
||||
public class CableDiode extends BlockContainer implements IEnergyConnectorBlock, ILookOverlay, ITooltipProvider {
|
||||
|
||||
public CableDiode(Material mat) {
|
||||
super(mat);
|
||||
}
|
||||
|
||||
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return renderID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
@Override public int getRenderType() { return renderID; }
|
||||
@Override public boolean isOpaqueCube() { return false; }
|
||||
@Override public boolean renderAsNormalBlock() { return false; }
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@ -76,57 +66,16 @@ public class CableDiode extends BlockContainer implements IEnergyConnectorBlock,
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
||||
|
||||
TileEntityDiode te = (TileEntityDiode)world.getTileEntity(x, y, z);
|
||||
|
||||
if(world.isRemote)
|
||||
return true;
|
||||
|
||||
if(tool == ToolType.SCREWDRIVER) {
|
||||
if(te.level < 11)
|
||||
te.level++;
|
||||
te.markDirty();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(tool == ToolType.HAND_DRILL) {
|
||||
if(te.level > 1)
|
||||
te.level--;
|
||||
te.markDirty();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(tool == ToolType.DEFUSER) {
|
||||
int p = te.priority.ordinal() + 1;
|
||||
if(p > 4) p = 0;
|
||||
te.priority = ConnectionPriority.values()[p];
|
||||
te.markDirty();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
|
||||
list.add(EnumChatFormatting.GOLD + "Limits throughput and restricts flow direction");
|
||||
list.add(EnumChatFormatting.YELLOW + "Use screwdriver to increase throughput");
|
||||
list.add(EnumChatFormatting.YELLOW + "Use hand drill to decrease throughput");
|
||||
list.add(EnumChatFormatting.YELLOW + "Use defuser to change network priority");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(!(te instanceof TileEntityDiode))
|
||||
return;
|
||||
if(!(te instanceof TileEntityDiode)) return;
|
||||
|
||||
TileEntityDiode diode = (TileEntityDiode) te;
|
||||
|
||||
@ -142,36 +91,47 @@ public class CableDiode extends BlockContainer implements IEnergyConnectorBlock,
|
||||
return new TileEntityDiode();
|
||||
}
|
||||
|
||||
public static class TileEntityDiode extends TileEntityLoadedBase implements IEnergyReceiverMK2 {
|
||||
public static class TileEntityDiode extends TileEntityLoadedBase implements IEnergyReceiverMK2, IControlReceiver, IGUIProvider {
|
||||
|
||||
/** Used as an intra-tick tracker for how much energy has been transmitted, resets to 0 each tick and maxes out based on transfer */
|
||||
private long power;
|
||||
private boolean recursionBrake = false;
|
||||
private int pulses = 0;
|
||||
public ConnectionPriority priority = ConnectionPriority.NORMAL;
|
||||
public long limit = 1_000;
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
level = nbt.getInteger("level");
|
||||
priority = ConnectionPriority.values()[nbt.getByte("p")];
|
||||
if(nbt.hasKey("level")) {
|
||||
this.limit = (long) Math.pow(10, nbt.getInteger("level"));
|
||||
} else {
|
||||
this.limit = nbt.getLong("limit");
|
||||
}
|
||||
this.priority = ConnectionPriority.values()[nbt.getByte("p")];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("level", level);
|
||||
nbt.setLong("limit", limit);
|
||||
nbt.setByte("p", (byte) this.priority.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
this.writeToNBT(nbt);
|
||||
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt);
|
||||
public void serialize(ByteBuf buf) {
|
||||
super.serialize(buf);
|
||||
buf.writeByte((byte) priority.ordinal());
|
||||
buf.writeLong(limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
this.readFromNBT(pkt.func_148857_g());
|
||||
public void deserialize(ByteBuf buf) {
|
||||
super.deserialize(buf);
|
||||
priority = EnumUtil.grabEnumSafely(ConnectionPriority.class, buf.readByte());
|
||||
limit = buf.readLong();
|
||||
}
|
||||
|
||||
int level = 1;
|
||||
|
||||
private ForgeDirection getDir() {
|
||||
return ForgeDirection.getOrientation(this.getBlockMetadata()).getOpposite();
|
||||
}
|
||||
@ -181,34 +141,22 @@ public class CableDiode extends BlockContainer implements IEnergyConnectorBlock,
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
|
||||
if(dir == getDir())
|
||||
continue;
|
||||
|
||||
if(dir == getDir()) continue;
|
||||
this.trySubscribe(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||
}
|
||||
|
||||
pulses = 0;
|
||||
this.setPower(0); //tick is over, reset our allowed transfe
|
||||
this.setPower(0); //tick is over, reset our allowed transfer
|
||||
this.networkPackNT(15);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection dir) {
|
||||
return dir != getDir();
|
||||
}
|
||||
|
||||
/** Used as an intra-tick tracker for how much energy has been transmitted, resets to 0 each tick and maxes out based on transfer */
|
||||
private long power;
|
||||
private boolean recursionBrake = false;
|
||||
private int pulses = 0;
|
||||
public ConnectionPriority priority = ConnectionPriority.NORMAL;
|
||||
@Override public boolean canConnect(ForgeDirection dir) { return dir != getDir(); }
|
||||
|
||||
@Override
|
||||
public long transferPower(long power) {
|
||||
|
||||
if(recursionBrake)
|
||||
return power;
|
||||
if(recursionBrake) return power;
|
||||
|
||||
pulses++;
|
||||
if(this.getPower() >= this.getMaxPower() || pulses > 10) return power; //if we have already maxed out transfer or max pulses, abort
|
||||
@ -241,29 +189,25 @@ public class CableDiode extends BlockContainer implements IEnergyConnectorBlock,
|
||||
return power;
|
||||
}
|
||||
|
||||
@Override public long getReceiverSpeed() { return this.getMaxPower() - this.getPower(); }
|
||||
@Override public long getMaxPower() { return this.limit; }
|
||||
@Override public long getPower() { return Math.min(power, this.getMaxPower()); }
|
||||
@Override public void setPower(long power) { this.power = power; }
|
||||
@Override public ConnectionPriority getPriority() { return this.priority; }
|
||||
|
||||
@Override
|
||||
public long getReceiverSpeed() {
|
||||
return this.getMaxPower() - this.getPower();
|
||||
public boolean hasPermission(EntityPlayer player) {
|
||||
return player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 128;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxPower() {
|
||||
return (long) Math.pow(10, level);
|
||||
public void receiveControl(NBTTagCompound data) {
|
||||
if(data.hasKey("capacity")) this.limit = MathHelper.clamp_int(data.getInteger("limit"), 0, 1_000_000_000);
|
||||
if(data.hasKey("priority")) this.priority = EnumUtil.grabEnumSafely(ConnectionPriority.class, data.getByte("priority"));
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPower() {
|
||||
return Math.min(power, this.getMaxPower());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPower(long power) {
|
||||
this.power = power;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConnectionPriority getPriority() {
|
||||
return this.priority;
|
||||
}
|
||||
@Override public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return new GUIDiode(this); }
|
||||
@Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; }
|
||||
}
|
||||
}
|
||||
|
||||
95
src/main/java/com/hbm/inventory/gui/GUIDiode.java
Normal file
95
src/main/java/com/hbm/inventory/gui/GUIDiode.java
Normal file
@ -0,0 +1,95 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.hbm.blocks.network.CableDiode.TileEntityDiode;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.toserver.NBTControlPacket;
|
||||
import com.hbm.util.EnumUtil;
|
||||
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2.ConnectionPriority;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GUIDiode extends GuiScreen {
|
||||
|
||||
protected final TileEntityDiode diode;
|
||||
|
||||
private GuiTextField textThroughput;
|
||||
private GuiButton buttonPriority;
|
||||
private int priority;
|
||||
|
||||
public GUIDiode(TileEntityDiode diode) {
|
||||
this.diode = diode;
|
||||
this.priority = diode.priority.ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
|
||||
textThroughput = new GuiTextField(fontRendererObj, this.width / 2 - 150, 100, 90, 20);
|
||||
textThroughput.setText("" + diode.limit);
|
||||
textThroughput.setMaxStringLength(10);
|
||||
|
||||
buttonPriority = new GuiButton(0, this.width / 2 + 50, 100, 90, 20, diode.priority.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
drawDefaultBackground();
|
||||
|
||||
drawString(fontRendererObj, "Throughput:", this.width / 2 - 150, 80, 0xA0A0A0);
|
||||
drawString(fontRendererObj, "(max. 1,000,000,000 HE)", this.width / 2 - 150, 90, 0xA0A0A0);
|
||||
textThroughput.drawTextBox();
|
||||
|
||||
drawString(fontRendererObj, "Priority:", this.width / 2 + 50, 80, 0xA0A0A0);
|
||||
buttonPriority.drawButton(mc, mouseX, mouseY);
|
||||
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
Keyboard.enableRepeatEvents(false);
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setByte("priority", (byte) priority);
|
||||
|
||||
try { data.setInteger("limit", Integer.parseInt(textThroughput.getText())); } catch(Exception ex) {}
|
||||
|
||||
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, diode.xCoord, diode.yCoord, diode.zCoord));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) {
|
||||
super.keyTyped(typedChar, keyCode);
|
||||
if(textThroughput.textboxKeyTyped(typedChar, keyCode)) return;
|
||||
|
||||
if(keyCode == 1 || keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode()) {
|
||||
this.mc.thePlayer.closeScreen();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
textThroughput.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
if(buttonPriority.mousePressed(mc, mouseX, mouseY)) {
|
||||
this.priority++;
|
||||
if(priority >= ConnectionPriority.values().length) priority = 0;
|
||||
buttonPriority.displayString = EnumUtil.grabEnumSafely(ConnectionPriority.class, priority).name();
|
||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
}
|
||||
}
|
||||
|
||||
@Override public boolean doesGuiPauseGame() { return false; }
|
||||
}
|
||||
@ -5,7 +5,6 @@ import com.hbm.entity.mob.EntityDuck;
|
||||
import com.hbm.interfaces.NotableComments;
|
||||
import com.hbm.items.weapon.ItemCustomMissilePart.PartSize;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
import com.hbm.tileentity.TileEntityTickingBase;
|
||||
import com.hbm.tileentity.bomb.TileEntityLaunchTable;
|
||||
import com.hbm.tileentity.machine.TileEntityCoreEmitter;
|
||||
import com.hbm.tileentity.machine.TileEntityCoreStabilizer;
|
||||
@ -146,10 +145,6 @@ public class AuxButtonPacket implements IMessage {
|
||||
TileEntityMachineBase base = (TileEntityMachineBase)te;
|
||||
base.handleButtonPacket(m.value, m.id);
|
||||
}
|
||||
if(te instanceof TileEntityTickingBase) {
|
||||
TileEntityTickingBase base = (TileEntityTickingBase)te;
|
||||
base.handleButtonPacket(m.value, m.id);
|
||||
}
|
||||
|
||||
//why make new packets when you can just abuse and uglify the existing ones?
|
||||
if(te == null && m.value == 999) {
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
package com.hbm.tileentity;
|
||||
|
||||
import com.hbm.interfaces.NotableComments;
|
||||
|
||||
@NotableComments
|
||||
public abstract class TileEntityTickingBase extends TileEntityLoadedBase {
|
||||
|
||||
public TileEntityTickingBase() { }
|
||||
|
||||
public abstract String getInventoryName();
|
||||
|
||||
//abstracting this method forces child classes to implement it
|
||||
//so i don't have to remember the fucking method name
|
||||
//was it update? onUpdate? updateTile? did it have any args?
|
||||
@ -13,7 +14,4 @@ public abstract class TileEntityTickingBase extends TileEntityLoadedBase {
|
||||
@Override
|
||||
public abstract void updateEntity();
|
||||
|
||||
@Deprecated
|
||||
public void handleButtonPacket(int value, int meta) { }
|
||||
|
||||
}
|
||||
|
||||
@ -388,6 +388,9 @@ public class TileMappings {
|
||||
put(TileEntityPileSource.class, "tileentity_pile_source");
|
||||
put(TileEntityPileBreedingFuel.class, "tileentity_pile_breedingfuel");
|
||||
put(TileEntityPileNeutronDetector.class, "tileentity_pile_neutrondetector");
|
||||
|
||||
put(TileEntityPileCore.class, "tileentity_pile_core");
|
||||
put(TileEntityPileBaseMK2.class, "tileentity_pile_block");
|
||||
}
|
||||
|
||||
private static void putRBMK() {
|
||||
|
||||
@ -102,11 +102,6 @@ public class TileEntityICFController extends TileEntityTickingBase implements IE
|
||||
this.ports.addAll(ports);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "container.icfController";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
|
||||
@ -18,11 +18,6 @@ public class TileEntitySolarMirror extends TileEntityTickingBase {
|
||||
public int tZ;
|
||||
public boolean isOn;
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
@Deprecated
|
||||
public abstract class TileEntityPileBase extends TileEntity {
|
||||
|
||||
@Override
|
||||
|
||||
@ -0,0 +1,69 @@
|
||||
package com.hbm.tileentity.machine.pile;
|
||||
|
||||
import com.hbm.tileentity.TileEntityTickingBase;
|
||||
import com.hbm.util.Compat;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
/** Base class for all tile entities used by the Chicago Pile, except for the core tile. */
|
||||
public class TileEntityPileBaseMK2 extends TileEntityTickingBase {
|
||||
|
||||
public TileEntityPileCore cachedCore;
|
||||
public int coreX;
|
||||
public int coreY = -999;
|
||||
public int coreZ;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
if(coreY >= 0) {
|
||||
|
||||
TileEntityPileCore controller = getCore();
|
||||
|
||||
if((controller == null || controller.isInvalid()) && worldObj.getChunkProvider().chunkExists(coreX >> 4, coreZ >> 4)) {
|
||||
this.getBlockType().breakBlock(worldObj, xCoord, yCoord, zCoord, this.getBlockType(), this.getBlockMetadata());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
coreX = nbt.getInteger("cX");
|
||||
coreY = nbt.getInteger("cY");
|
||||
coreZ = nbt.getInteger("cZ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("cX", coreX);
|
||||
nbt.setInteger("cY", coreY);
|
||||
nbt.setInteger("cZ", coreZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
if(this.worldObj != null) {
|
||||
this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this);
|
||||
}
|
||||
}
|
||||
|
||||
public TileEntityPileCore getCore() {
|
||||
if(cachedCore != null && !cachedCore.isInvalid()) return cachedCore;
|
||||
|
||||
if(worldObj.getChunkProvider().chunkExists(coreX >> 4, coreZ >> 4)) {
|
||||
|
||||
TileEntity tile = Compat.getTileStandard(worldObj, coreX, coreY, coreZ);
|
||||
if(tile instanceof TileEntityPileCore) {
|
||||
TileEntityPileCore core = (TileEntityPileCore) tile;
|
||||
cachedCore = core;
|
||||
return core;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,7 @@ import com.hbm.config.GeneralConfig;
|
||||
import api.hbm.block.IPileNeutronReceiver;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@Deprecated
|
||||
public class TileEntityPileBreedingFuel extends TileEntityPileBase implements IPileNeutronReceiver {
|
||||
|
||||
public int neutrons;
|
||||
|
||||
@ -0,0 +1,150 @@
|
||||
package com.hbm.tileentity.machine.pile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.blocks.machine.MachinePWRController;
|
||||
import com.hbm.blocks.machine.pile.BlockPile;
|
||||
import com.hbm.interfaces.NotableComments;
|
||||
import com.hbm.tileentity.TileEntityTickingBase;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@NotableComments
|
||||
public class TileEntityPileCore extends TileEntityTickingBase {
|
||||
|
||||
/**
|
||||
* Orientation is kind of important now. The "direction" the pile is facing in is now decided
|
||||
* by the side the core is on, i.e. the side it was assembled from. Any channel that goes along
|
||||
* with the orientation is automatically considered a fuel channel. Any channel perpendicular
|
||||
* to the orientation is for ventilation. Vertical channels are always for control rods.
|
||||
*/
|
||||
public PileOrientation orientation = PileOrientation.NEITHER;
|
||||
|
||||
public int height;
|
||||
public int width;
|
||||
public int depth;
|
||||
|
||||
public List<PileChannel> fuelChannels = new ArrayList();
|
||||
public List<PileChannel> ventilationChannels = new ArrayList();
|
||||
public List<PileChannel> controlChannels = new ArrayList();
|
||||
|
||||
public TileEntityPileCore setupSize(int h, int w, int d) {
|
||||
this.height = h;
|
||||
this.width = w;
|
||||
this.depth = d;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<PileChannel> getChannelList(PileChannelType type) {
|
||||
if(type == PileChannelType.FUEL) return this.fuelChannels;
|
||||
if(type == PileChannelType.VENTILATION) return this.ventilationChannels;
|
||||
return this.controlChannels;
|
||||
}
|
||||
|
||||
public boolean drillChannel(int x, int y, int z, ForgeDirection dir, EntityPlayer player) {
|
||||
PileChannelType type = PileChannelType.getChannelType(dir, orientation);
|
||||
int size =
|
||||
type == PileChannelType.CONTROL ? height :
|
||||
type == PileChannelType.FUEL ? depth : width;
|
||||
|
||||
boolean error = false;
|
||||
for(int i = 0; i <= size; i++) {
|
||||
int iX = x + dir.offsetX * i;
|
||||
int iY = y + dir.offsetY * i;
|
||||
int iZ = z + dir.offsetZ * i;
|
||||
if(worldObj.getBlock(iX, iY, iZ) != ModBlocks.pile_block) { MachinePWRController.sendError(worldObj, iX, iY, iZ, "Foreign block in reactor", player); error = true; }
|
||||
int meta = worldObj.getBlockMetadata(iX, iY, iZ);
|
||||
if(meta == BlockPile.META_EDGE) { MachinePWRController.sendError(worldObj, iX, iY, iZ, "Cannot drill along edge", player); error = true; }
|
||||
if(meta == BlockPile.META_CORE) { MachinePWRController.sendError(worldObj, iX, iY, iZ, "Cannot intersect core", player); error = true; }
|
||||
if(meta == BlockPile.META_CHANNEL) { MachinePWRController.sendError(worldObj, iX, iY, iZ, "Cannot intersect channel", player); error = true; }
|
||||
if(meta != BlockPile.META_DUMMY) { MachinePWRController.sendError(worldObj, iX, iY, iZ, "Cannot intersect channel IO", player); error = true; }
|
||||
}
|
||||
|
||||
if(error) return false;
|
||||
|
||||
for(int i = 0; i <= size; i++) {
|
||||
int iX = x + dir.offsetX * i;
|
||||
int iY = y + dir.offsetY * i;
|
||||
int iZ = z + dir.offsetZ * i;
|
||||
if(i == 0) {
|
||||
if(type == PileChannelType.FUEL) worldObj.setBlockMetadataWithNotify(iX, iY, iZ, BlockPile.META_FUEL_IN, 3);
|
||||
if(type == PileChannelType.VENTILATION) worldObj.setBlockMetadataWithNotify(iX, iY, iZ, BlockPile.META_AIR_IN, 3);
|
||||
if(type == PileChannelType.CONTROL) worldObj.setBlockMetadataWithNotify(iX, iY, iZ, BlockPile.META_CONTROL, 3);
|
||||
} else if(i == size) {
|
||||
if(type == PileChannelType.FUEL) worldObj.setBlockMetadataWithNotify(iX, iY, iZ, BlockPile.META_FUEL_OUT, 3);
|
||||
if(type == PileChannelType.VENTILATION) worldObj.setBlockMetadataWithNotify(iX, iY, iZ, BlockPile.META_AIR_OUT, 3);
|
||||
if(type == PileChannelType.CONTROL) worldObj.setBlockMetadataWithNotify(iX, iY, iZ, BlockPile.META_CONTROL, 3);
|
||||
} else {
|
||||
worldObj.setBlockMetadataWithNotify(iX, iY, iZ, BlockPile.META_DUMMY, 3);
|
||||
}
|
||||
}
|
||||
|
||||
List<PileChannel> list = getChannelList(type);
|
||||
list.add(new PileChannel(x, y, z, dir, size, type));
|
||||
|
||||
this.markChanged();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.pile_brick);
|
||||
}
|
||||
|
||||
public static enum PileOrientation {
|
||||
NORTH_SOUTH,
|
||||
EAST_WEST,
|
||||
NEITHER;
|
||||
|
||||
public static PileOrientation getOrientation(ForgeDirection dir) {
|
||||
if(dir == ForgeDirection.NORTH || dir == ForgeDirection.SOUTH) return NORTH_SOUTH;
|
||||
if(dir == ForgeDirection.EAST || dir == ForgeDirection.WEST) return EAST_WEST;
|
||||
return NEITHER;
|
||||
}
|
||||
}
|
||||
|
||||
public class PileChannel { // originally called "PileHole", however i didn't want it sounding too sexual
|
||||
|
||||
public final DirPos entry; // first channel block plus direction it faces inward
|
||||
public final int length; // length of the channel, always equal to the h/w/d size of that axis
|
||||
public final PileChannelType type;
|
||||
|
||||
public PileChannel(int x, int y, int z, ForgeDirection dir) {
|
||||
this.entry = new DirPos(x, y, z, dir);
|
||||
this.type = PileChannelType.getChannelType(dir, orientation);
|
||||
this.length =
|
||||
type == PileChannelType.CONTROL ? height :
|
||||
type == PileChannelType.FUEL ? depth : width;
|
||||
}
|
||||
|
||||
public PileChannel(int x, int y, int z, ForgeDirection dir, int length, PileChannelType type) {
|
||||
this.entry = new DirPos(x, y, z, dir);
|
||||
this.type = type;
|
||||
this.length = length;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum PileChannelType {
|
||||
FUEL, VENTILATION, CONTROL;
|
||||
|
||||
public static PileChannelType getChannelType(ForgeDirection channelDir, PileOrientation pileOrientation) {
|
||||
|
||||
if(channelDir == ForgeDirection.UP || channelDir == ForgeDirection.DOWN) {
|
||||
return PileChannelType.CONTROL;
|
||||
} else if(PileOrientation.getOrientation(channelDir) == pileOrientation) {
|
||||
return PileChannelType.FUEL;
|
||||
} else {
|
||||
return PileChannelType.VENTILATION;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -10,6 +10,7 @@ import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
@Deprecated
|
||||
public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutronReceiver {
|
||||
|
||||
public int heat;
|
||||
|
||||
@ -6,6 +6,7 @@ import com.hbm.blocks.machine.pile.BlockGraphiteNeutronDetector;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
@Deprecated
|
||||
public class TileEntityPileNeutronDetector extends TileEntity implements IPileNeutronReceiver {
|
||||
|
||||
public int lastNeutrons;
|
||||
|
||||
@ -2,6 +2,7 @@ package com.hbm.tileentity.machine.pile;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
|
||||
@Deprecated
|
||||
public class TileEntityPileSource extends TileEntityPileBase {
|
||||
|
||||
@Override
|
||||
|
||||
@ -33,11 +33,6 @@ public class TileEntityRadioAUTOCAL extends TileEntityTickingBase implements ICo
|
||||
|
||||
public String[] history = new String[] {"", "", "", "", "", ""};
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "container.autocal";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user