mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-08-10 17:55:44 +00:00
DEVICE_PILE
This commit is contained in:
parent
7d635bfc0d
commit
d1593aecb9
@ -225,14 +225,14 @@ public class ModBlocks {
|
||||
public static Block block_foam;
|
||||
public static Block block_coke;
|
||||
public static Block block_graphite;
|
||||
public static Block block_graphite_drilled;
|
||||
public static Block block_graphite_fuel;
|
||||
public static Block block_graphite_plutonium;
|
||||
public static Block block_graphite_rod;
|
||||
public static Block block_graphite_source;
|
||||
public static Block block_graphite_lithium;
|
||||
public static Block block_graphite_tritium;
|
||||
public static Block block_graphite_detector;
|
||||
@Deprecated public static Block block_graphite_drilled;
|
||||
@Deprecated public static Block block_graphite_fuel;
|
||||
@Deprecated public static Block block_graphite_plutonium;
|
||||
@Deprecated public static Block block_graphite_rod;
|
||||
@Deprecated public static Block block_graphite_source;
|
||||
@Deprecated public static Block block_graphite_lithium;
|
||||
@Deprecated public static Block block_graphite_tritium;
|
||||
@Deprecated public static Block block_graphite_detector;
|
||||
public static Block block_boron;
|
||||
public static Block block_lanthanium;
|
||||
public static Block block_ra226;
|
||||
@ -853,6 +853,7 @@ public class ModBlocks {
|
||||
|
||||
public static Block pile_brick;
|
||||
public static Block pile_block;
|
||||
public static Block pile_device;
|
||||
|
||||
public static Block pwr_fuel;
|
||||
public static Block pwr_control;
|
||||
@ -1962,8 +1963,9 @@ public class ModBlocks {
|
||||
custom_machine = new BlockCustomMachine().setBlockName("custom_machine").setCreativeTab(MainRegistry.machineTab).setLightLevel(1F).setHardness(5.0F).setResistance(10.0F);
|
||||
cm_anchor = new BlockCMAnchor().setBlockName("custom_machine_anchor").setCreativeTab(MainRegistry.machineTab).setHardness(5.0F).setResistance(10.0F);
|
||||
|
||||
pile_brick = new BlockPileBrick().setBlockName("pile_brick").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pile_brick");
|
||||
pile_block = new BlockPile().setBlockName("pile_block").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pile_block");
|
||||
pile_brick = new BlockPileBrick().setBlockName("pile_brick").setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pile_brick");
|
||||
pile_device = new BlockPileDevice().setBlockName("pile_device").setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
|
||||
pile_block = new BlockPile().setBlockName("pile_block").setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pile_block");
|
||||
|
||||
pwr_fuel = new BlockPillarPWR(Material.iron, RefStrings.MODID + ":pwr_fuel_top").setBlockName("pwr_fuel").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pwr_fuel_side");
|
||||
pwr_control = new BlockPillarPWR(Material.iron, RefStrings.MODID + ":pwr_control_top").setBlockName("pwr_control").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pwr_control_side");
|
||||
@ -3326,6 +3328,7 @@ public class ModBlocks {
|
||||
|
||||
//Chicago Pile
|
||||
register(pile_brick);
|
||||
register(pile_device);
|
||||
register(pile_block);
|
||||
|
||||
//PWR
|
||||
|
||||
@ -101,7 +101,14 @@ public class BlockPile extends BlockContainer implements IBlockCT, IToolable {
|
||||
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 TileEntityPileCore || world.getBlockMetadata(x, y, z) == META_CORE) {
|
||||
MachinePWRController.sendError(world, x, y, z, "Cannot intersect core", player);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(tile instanceof TileEntityPileBaseMK2) {
|
||||
TileEntityPileCore core = ((TileEntityPileBaseMK2) tile).getCore();
|
||||
if(core != null) {
|
||||
@ -109,6 +116,7 @@ public class BlockPile extends BlockContainer implements IBlockCT, IToolable {
|
||||
return core.drillChannel(x, y, z, dir, player);
|
||||
}
|
||||
}
|
||||
|
||||
MachinePWRController.sendError(world, x, y, z, "No core found", player);
|
||||
}
|
||||
|
||||
|
||||
@ -127,12 +127,12 @@ public class BlockPileBrick extends Block implements IToolable {
|
||||
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);
|
||||
core.setupSize(posHeight + negHeight + 1, left + right + 1, depth + 1);
|
||||
} else {
|
||||
world.setBlock(iX, iY, iZ, ModBlocks.pile_block, BlockPile.META_DUMMY, 3);
|
||||
boolean isEdge = h == -negHeight || h == posHeight || v == -left || v == right || d == 0 || d == depth;
|
||||
world.setBlock(iX, iY, iZ, ModBlocks.pile_block, isEdge ? BlockPile.META_EDGE : BlockPile.META_DUMMY, 3);
|
||||
TileEntityPileBaseMK2 pile = (TileEntityPileBaseMK2) world.getTileEntity(iX, iY, iZ);
|
||||
pile.coreX = x;
|
||||
pile.coreY = y;
|
||||
pile.coreZ = z;
|
||||
pile.setCore(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,60 @@
|
||||
package com.hbm.blocks.machine.pile;
|
||||
|
||||
import com.hbm.tileentity.machine.pile.TileEntityPileControl;
|
||||
import com.hbm.tileentity.machine.pile.TileEntityPileLoader;
|
||||
import com.hbm.tileentity.machine.pile.TileEntityPileVent;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockPileDevice extends BlockContainer {
|
||||
|
||||
public static final int ITEM_META_LOADER = 0;
|
||||
public static final int ITEM_META_VENT = 1;
|
||||
public static final int ITEM_META_CONTROL = 2;
|
||||
|
||||
public static final int BLOCK_META_LOADER = 0;
|
||||
public static final int BLOCK_META_VENT = 4;
|
||||
public static final int BLOCK_META_CONTROL = 8;
|
||||
|
||||
public BlockPileDevice() {
|
||||
super(Material.iron);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
if(meta == BLOCK_META_LOADER) return new TileEntityPileLoader();
|
||||
if(meta == BLOCK_META_VENT) return new TileEntityPileVent();
|
||||
if(meta == BLOCK_META_CONTROL) return new TileEntityPileControl();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public int getRenderType() { return -1; }
|
||||
@Override public boolean isOpaqueCube() { return false; }
|
||||
@Override public boolean renderAsNormalBlock() { return false; }
|
||||
|
||||
@Override
|
||||
public int onBlockPlaced(World world, int x, int y, int z, int side, float fx, float fy, float fz, int meta) {
|
||||
int metaOffset = itemMetaToBlockMeta(meta);
|
||||
// side is reduced by 2 because UP and DOWN (0 and 1) aren't relevant
|
||||
// therefore, all item metas (device subtypes) are neatly packed into 4 metas each
|
||||
side = MathHelper.clamp_int(side - 2, 0, 3);
|
||||
return metaOffset + side;
|
||||
}
|
||||
|
||||
public static int itemMetaToBlockMeta(int meta) {
|
||||
if(meta >= ITEM_META_CONTROL) return BLOCK_META_CONTROL;
|
||||
if(meta == ITEM_META_VENT) return BLOCK_META_VENT;
|
||||
return BLOCK_META_LOADER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int meta) {
|
||||
if(meta >= BLOCK_META_CONTROL) return ITEM_META_CONTROL;
|
||||
if(meta >= BLOCK_META_VENT) return ITEM_META_VENT;
|
||||
return ITEM_META_LOADER;
|
||||
}
|
||||
}
|
||||
@ -391,6 +391,9 @@ public class TileMappings {
|
||||
|
||||
put(TileEntityPileCore.class, "tileentity_pile_core");
|
||||
put(TileEntityPileBaseMK2.class, "tileentity_pile_block");
|
||||
put(TileEntityPileLoader.class, "tileentity_pile_loader");
|
||||
put(TileEntityPileVent.class, "tileentity_pile_vent");
|
||||
put(TileEntityPileControl.class, "tileentity_pile_control");
|
||||
}
|
||||
|
||||
private static void putRBMK() {
|
||||
@ -510,10 +513,6 @@ public class TileMappings {
|
||||
private static void put(Class<? extends TileEntity> clazz, String... names) {
|
||||
map.put(clazz, names);
|
||||
|
||||
/*if((IFluidSource.class.isAssignableFrom(clazz) || IFluidAcceptor.class.isAssignableFrom(clazz)) && !IFluidConnector.class.isAssignableFrom(clazz)) {
|
||||
LoggingUtil.errorWithHighlight(clazz.getCanonicalName() + " implements the old interfaces but not IFluidConnector!");
|
||||
}*/
|
||||
|
||||
if(IConfigurableMachine.class.isAssignableFrom(clazz)) {
|
||||
configurables.add((Class<? extends IConfigurableMachine>) clazz);
|
||||
}
|
||||
|
||||
@ -14,6 +14,13 @@ public class TileEntityPileBaseMK2 extends TileEntityTickingBase {
|
||||
public int coreY = -999;
|
||||
public int coreZ;
|
||||
|
||||
public TileEntityPileBaseMK2 setCore(int x, int y, int z) {
|
||||
this.coreX = x;
|
||||
this.coreY = y;
|
||||
this.coreZ = z;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
package com.hbm.tileentity.machine.pile;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TileEntityPileControl extends TileEntity {
|
||||
|
||||
}
|
||||
@ -11,11 +11,27 @@ import com.hbm.tileentity.TileEntityTickingBase;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@NotableComments
|
||||
public class TileEntityPileCore extends TileEntityTickingBase {
|
||||
|
||||
/*
|
||||
* ____,__,___
|
||||
* |\ I, I, \
|
||||
* | \ I I \
|
||||
* -- \___________\
|
||||
* |--| |
|
||||
* -- | U U U |
|
||||
* \--| X |
|
||||
* \ | U U U |
|
||||
* \|___________|
|
||||
*
|
||||
* BEHOLD
|
||||
* THE CUBE
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -32,6 +48,46 @@ public class TileEntityPileCore extends TileEntityTickingBase {
|
||||
public List<PileChannel> ventilationChannels = new ArrayList();
|
||||
public List<PileChannel> controlChannels = new ArrayList();
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
height = nbt.getInteger("height");
|
||||
width = nbt.getInteger("width");
|
||||
depth = nbt.getInteger("depth");
|
||||
|
||||
int fuelCount = nbt.getByte("fc");
|
||||
int ventCount = nbt.getByte("vc");
|
||||
int contCount = nbt.getByte("cc");
|
||||
|
||||
fuelChannels.clear();
|
||||
ventilationChannels.clear();
|
||||
controlChannels.clear();
|
||||
|
||||
for(int i = 0; i < fuelCount; i++) fuelChannels.add(readChannelFromNBT(nbt, "f" + i));
|
||||
for(int i = 0; i < ventCount; i++) ventilationChannels.add(readChannelFromNBT(nbt, "v" + i));
|
||||
for(int i = 0; i < contCount; i++) controlChannels.add(readChannelFromNBT(nbt, "c" + i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("height", height);
|
||||
nbt.setInteger("width", width);
|
||||
nbt.setInteger("depth", depth);
|
||||
|
||||
int fuelCount = fuelChannels.size();
|
||||
int ventCount = ventilationChannels.size();
|
||||
int contCount = controlChannels.size();
|
||||
|
||||
nbt.setByte("fc", (byte) fuelCount);
|
||||
nbt.setByte("vc", (byte) ventCount);
|
||||
nbt.setByte("cc", (byte) contCount);
|
||||
|
||||
for(int i = 0; i < fuelCount; i++) fuelChannels.get(i).writeChannelToNBT(nbt, "f" + i);
|
||||
for(int i = 0; i < ventCount; i++) ventilationChannels.get(i).writeChannelToNBT(nbt, "v" + i);
|
||||
for(int i = 0; i < contCount; i++) controlChannels.get(i).writeChannelToNBT(nbt, "c" + i);
|
||||
}
|
||||
|
||||
public TileEntityPileCore setupSize(int h, int w, int d) {
|
||||
this.height = h;
|
||||
this.width = w;
|
||||
@ -131,6 +187,21 @@ public class TileEntityPileCore extends TileEntityTickingBase {
|
||||
this.type = type;
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
public void writeChannelToNBT(NBTTagCompound nbt, String name) {
|
||||
nbt.setInteger(name + "_x", entry.getX());
|
||||
nbt.setInteger(name + "_y", entry.getY());
|
||||
nbt.setInteger(name + "_z", entry.getZ());
|
||||
nbt.setByte(name + "_d", (byte) entry.getDir().ordinal());
|
||||
}
|
||||
}
|
||||
|
||||
public PileChannel readChannelFromNBT(NBTTagCompound nbt, String name) {
|
||||
int x = nbt.getInteger(name + "_x");
|
||||
int y = nbt.getInteger(name + "_y");
|
||||
int z = nbt.getInteger(name + "_z");
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(nbt.getByte(name + "_d"));
|
||||
return new PileChannel(x, y, z, dir);
|
||||
}
|
||||
|
||||
public static enum PileChannelType {
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
package com.hbm.tileentity.machine.pile;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TileEntityPileLoader extends TileEntity {
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package com.hbm.tileentity.machine.pile;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TileEntityPileVent extends TileEntity {
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user