guh?
@ -133,9 +133,10 @@ public class BlockPileDevice extends BlockContainer implements IBlockMulti, ILoo
|
||||
@Override
|
||||
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if(meta < BLOCK_META_CONTROL) return false;
|
||||
|
||||
return side.ordinal() == meta % 4 + 2;
|
||||
if(meta >= BLOCK_META_CONTROL) return side.ordinal() == meta % 4 + 2;
|
||||
if(meta >= BLOCK_META_VENT) return false;
|
||||
if(meta >= BLOCK_META_LOADER) return side.ordinal() == meta % 4 + 2;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -153,6 +154,7 @@ public class BlockPileDevice extends BlockContainer implements IBlockMulti, ILoo
|
||||
if(tile instanceof TileEntityPileLoader) {
|
||||
TileEntityPileLoader device = (TileEntityPileLoader) tile;
|
||||
text.add("Index: " + device.chanNum);
|
||||
if(device.syncStack != null) text.add("Loading: " + device.syncStack.getDisplayName());
|
||||
}
|
||||
|
||||
if(tile instanceof TileEntityPileVent) {
|
||||
@ -162,8 +164,8 @@ public class BlockPileDevice extends BlockContainer implements IBlockMulti, ILoo
|
||||
|
||||
if(tile instanceof TileEntityPileControl) {
|
||||
TileEntityPileControl device = (TileEntityPileControl) tile;
|
||||
text.add("Extraction level: " + (int) + (device.level * 100) + "%");
|
||||
text.add("Index: " + device.chanNum);
|
||||
text.add("Extraction level: " + (int) + (device.level * 100) + "%");
|
||||
}
|
||||
|
||||
if(!text.isEmpty())
|
||||
|
||||
@ -973,13 +973,15 @@ public class ModItems {
|
||||
public static Item waste_plate_ra226be;
|
||||
public static Item waste_plate_pu238be;
|
||||
|
||||
public static Item pile_rod_uranium;
|
||||
public static Item pile_rod_pu239;
|
||||
public static Item pile_rod_plutonium;
|
||||
public static Item pile_rod_source;
|
||||
public static Item pile_rod_boron;
|
||||
public static Item pile_rod_lithium;
|
||||
public static Item pile_rod_detector;
|
||||
@Deprecated public static Item pile_rod_uranium;
|
||||
@Deprecated public static Item pile_rod_pu239;
|
||||
@Deprecated public static Item pile_rod_plutonium;
|
||||
@Deprecated public static Item pile_rod_source;
|
||||
@Deprecated public static Item pile_rod_boron;
|
||||
@Deprecated public static Item pile_rod_lithium;
|
||||
@Deprecated public static Item pile_rod_detector;
|
||||
|
||||
public static Item pile_rod;
|
||||
|
||||
public static Item plate_fuel_u233;
|
||||
public static Item plate_fuel_u235;
|
||||
@ -2998,13 +3000,15 @@ public class ModItems {
|
||||
waste_plate_ra226be = new ItemDepletedFuel().setUnlocalizedName("waste_plate_ra226be").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":waste_plate_ra226be");
|
||||
waste_plate_pu238be = new ItemDepletedFuel().setUnlocalizedName("waste_plate_pu238be").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":waste_plate_pu238be");
|
||||
|
||||
pile_rod_uranium = new ItemPileRod().setUnlocalizedName("pile_rod_uranium").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pile_rod_uranium");
|
||||
pile_rod_pu239 = new ItemPileRod().setUnlocalizedName("pile_rod_pu239").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pile_rod_pu239");
|
||||
pile_rod_plutonium = new ItemPileRod().setUnlocalizedName("pile_rod_plutonium").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pile_rod_plutonium");
|
||||
pile_rod_source = new ItemPileRod().setUnlocalizedName("pile_rod_source").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pile_rod_source");
|
||||
pile_rod_boron = new ItemPileRod().setUnlocalizedName("pile_rod_boron").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pile_rod_boron");
|
||||
pile_rod_lithium = new ItemPileRod().setUnlocalizedName("pile_rod_lithium").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pile_rod_lithium");
|
||||
pile_rod_detector = new ItemPileRod().setUnlocalizedName("pile_rod_detector").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pile_rod_detector");
|
||||
pile_rod_uranium = new ItemPileRod().setUnlocalizedName("pile_rod_uranium").setCreativeTab(null).setTextureName(RefStrings.MODID + ":pile_rod_uranium");
|
||||
pile_rod_pu239 = new ItemPileRod().setUnlocalizedName("pile_rod_pu239").setCreativeTab(null).setTextureName(RefStrings.MODID + ":pile_rod_pu239");
|
||||
pile_rod_plutonium = new ItemPileRod().setUnlocalizedName("pile_rod_plutonium").setCreativeTab(null).setTextureName(RefStrings.MODID + ":pile_rod_plutonium");
|
||||
pile_rod_source = new ItemPileRod().setUnlocalizedName("pile_rod_source").setCreativeTab(null).setTextureName(RefStrings.MODID + ":pile_rod_source");
|
||||
pile_rod_boron = new ItemPileRod().setUnlocalizedName("pile_rod_boron").setCreativeTab(null).setTextureName(RefStrings.MODID + ":pile_rod_boron");
|
||||
pile_rod_lithium = new ItemPileRod().setUnlocalizedName("pile_rod_lithium").setCreativeTab(null).setTextureName(RefStrings.MODID + ":pile_rod_lithium");
|
||||
pile_rod_detector = new ItemPileRod().setUnlocalizedName("pile_rod_detector").setCreativeTab(null).setTextureName(RefStrings.MODID + ":pile_rod_detector");
|
||||
|
||||
pile_rod = new ItemPileRodMK2().setUnlocalizedName("pile_rod").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pile_rod");
|
||||
|
||||
plate_fuel_u233 = new ItemPlateFuel(2200000).setFunction(FunctionEnum.SQUARE_ROOT, 50).setUnlocalizedName("plate_fuel_u233").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":plate_fuel_u233");
|
||||
plate_fuel_u235 = new ItemPlateFuel(2200000).setFunction(FunctionEnum.SQUARE_ROOT, 40).setUnlocalizedName("plate_fuel_u235").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":plate_fuel_u235");
|
||||
@ -5357,6 +5361,8 @@ public class ModItems {
|
||||
GameRegistry.registerItem(pile_rod_boron, pile_rod_boron.getUnlocalizedName());
|
||||
GameRegistry.registerItem(pile_rod_lithium, pile_rod_lithium.getUnlocalizedName());
|
||||
GameRegistry.registerItem(pile_rod_detector, pile_rod_detector.getUnlocalizedName());
|
||||
|
||||
GameRegistry.registerItem(pile_rod, pile_rod.getUnlocalizedName());
|
||||
|
||||
//Plate Fuels
|
||||
GameRegistry.registerItem(plate_fuel_u233, plate_fuel_u233.getUnlocalizedName());
|
||||
|
||||
90
src/main/java/com/hbm/items/machine/ItemPileRodMK2.java
Normal file
@ -0,0 +1,90 @@
|
||||
package com.hbm.items.machine;
|
||||
|
||||
import com.hbm.items.ItemEnumMulti;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
import com.hbm.util.EnumUtil;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ItemPileRodMK2 extends ItemEnumMulti {
|
||||
|
||||
/* _____
|
||||
* / \
|
||||
* \_____/
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* \_____/
|
||||
*
|
||||
* Not terribly sophisticated,
|
||||
* it's a cylinder.
|
||||
*/
|
||||
|
||||
public static final String KEY_NBT_DEPLETION = "depletion";
|
||||
|
||||
public ItemPileRodMK2() {
|
||||
super(EnumPileRod.class, true, true);
|
||||
}
|
||||
|
||||
public static enum EnumPileRod {
|
||||
RA226BE(1D),
|
||||
PO210BE(1D),
|
||||
ZR( 0D, 0D, 0D),
|
||||
NU( 1D, 1_000D, 1D),
|
||||
RGP( 1D, 1_000D, 1D),
|
||||
PU239( 1D, 1_000D, 1D),
|
||||
WASTE( 1D, 1_000D, 1D);
|
||||
|
||||
public double reactionMult = 1.0D;
|
||||
public double life = 1_000D;
|
||||
public double heatMult = 1.0D;
|
||||
public double neutronSource = 0D;
|
||||
|
||||
private EnumPileRod(double neutronSource) {
|
||||
this.neutronSource = neutronSource;
|
||||
this.reactionMult = 0;
|
||||
this.life = 0;
|
||||
this.heatMult = 0;
|
||||
}
|
||||
|
||||
private EnumPileRod(double reaction, double life, double heat) {
|
||||
this.reactionMult = reaction;
|
||||
this.life = life;
|
||||
this.heatMult = heat;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDurabilityBar(ItemStack stack) {
|
||||
return getDurabilityForDisplay(stack) > 0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack stack) {
|
||||
EnumPileRod rod = EnumUtil.grabEnumSafely(EnumPileRod.class, stack.getItemDamage());
|
||||
double life = rod.life;
|
||||
if(life <= 0) return 0D;
|
||||
return getDepletion(stack) / life;
|
||||
}
|
||||
|
||||
public static double getDepletion(ItemStack stack) {
|
||||
if(!stack.hasTagCompound()) return 0D;
|
||||
return stack.stackTagCompound.getDouble(KEY_NBT_DEPLETION);
|
||||
}
|
||||
|
||||
public static void setDepletion(ItemStack stack, double depletion) {
|
||||
if(!stack.hasTagCompound()) stack.stackTagCompound = new NBTTagCompound();
|
||||
stack.stackTagCompound.setDouble(KEY_NBT_DEPLETION, depletion);
|
||||
}
|
||||
|
||||
public static double getReactivity(ItemStack stack, double inFlux) {
|
||||
EnumPileRod rod = EnumUtil.grabEnumSafely(EnumPileRod.class, stack.getItemDamage());
|
||||
double outFlux = rod.neutronSource;
|
||||
if(rod.reactionMult > 0) {
|
||||
outFlux += BobMathUtil.squirt(inFlux) * rod.reactionMult;
|
||||
}
|
||||
return outFlux;
|
||||
}
|
||||
}
|
||||
@ -44,7 +44,7 @@ public class RenderPileLoader extends TileEntitySpecialRenderer implements IItem
|
||||
|
||||
GL11.glTranslated(position * -0.5, 0, 0);
|
||||
ResourceManager.pile_loader.renderPart("Slider");
|
||||
if(loader.hasRod) ResourceManager.pile_loader.renderPart("Rod");
|
||||
if(loader.syncStack != null) ResourceManager.pile_loader.renderPart("Rod");
|
||||
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
@ -15,9 +15,11 @@ import com.hbm.tileentity.TileEntityTickingBase;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@NotableComments
|
||||
@ -246,6 +248,7 @@ public class TileEntityPileCore extends TileEntityTickingBase {
|
||||
public final PileChannelType type;
|
||||
|
||||
public final ItemStack[] rods;
|
||||
public double heat = 0D;
|
||||
public int air;
|
||||
public double control = 1D; // pulled out by default, unlike me who never pulls out
|
||||
|
||||
@ -255,7 +258,7 @@ public class TileEntityPileCore extends TileEntityTickingBase {
|
||||
this.length =
|
||||
type == PileChannelType.CONTROL ? height :
|
||||
type == PileChannelType.FUEL ? depth : width;
|
||||
|
||||
|
||||
this.rods = new ItemStack[length];
|
||||
}
|
||||
|
||||
@ -271,6 +274,47 @@ public class TileEntityPileCore extends TileEntityTickingBase {
|
||||
nbt.setInteger(name + "_y", entry.getY());
|
||||
nbt.setInteger(name + "_z", entry.getZ());
|
||||
nbt.setByte(name + "_d", (byte) entry.getDir().ordinal());
|
||||
|
||||
if(type == type.FUEL) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(int i = 0; i < rods.length; i++) {
|
||||
if(rods[i] != null) {
|
||||
NBTTagCompound nbt1 = new NBTTagCompound();
|
||||
nbt1.setByte("slot", (byte)i);
|
||||
rods[i].writeToNBT(nbt1);
|
||||
list.appendTag(nbt1);
|
||||
}
|
||||
}
|
||||
nbt.setTag("items", list);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadItem(ItemStack stack) {
|
||||
if(stack == null) return;
|
||||
if(rods.length <= 0) { dropItem(stack, -1); return; }
|
||||
|
||||
for(int i = 0; i < rods.length; i++) {
|
||||
if(rods[i] == null) {
|
||||
rods[i] = stack;
|
||||
return;
|
||||
|
||||
} else {
|
||||
ItemStack prev = rods[i];
|
||||
rods[i] = stack;
|
||||
stack = prev;
|
||||
}
|
||||
}
|
||||
|
||||
if(stack != null) dropItem(stack, length);
|
||||
}
|
||||
|
||||
public void dropItem(ItemStack stack, int depth) {
|
||||
int x = entry.getX() + entry.getDir().offsetX * depth;
|
||||
int y = entry.getY();
|
||||
int z = entry.getZ() + entry.getDir().offsetZ * depth;
|
||||
|
||||
EntityItem item = new EntityItem(worldObj, x + 0.5, y + 0.5, z + 0.5, stack);
|
||||
worldObj.spawnEntityInWorld(item);
|
||||
}
|
||||
}
|
||||
|
||||
@ -279,7 +323,21 @@ public class TileEntityPileCore extends TileEntityTickingBase {
|
||||
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);
|
||||
|
||||
PileChannel chan = new PileChannel(x, y, z, dir);
|
||||
|
||||
if(chan.type == chan.type.FUEL) {
|
||||
NBTTagList list = nbt.getTagList("fuel", 10);
|
||||
for(int i = 0; i < list.tagCount(); i++) {
|
||||
NBTTagCompound nbt1 = list.getCompoundTagAt(i);
|
||||
byte b0 = nbt1.getByte("slot");
|
||||
if(b0 >= 0 && b0 < chan.rods.length) {
|
||||
chan.rods[b0] = ItemStack.loadItemStackFromNBT(nbt1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return chan;
|
||||
}
|
||||
|
||||
public static enum PileChannelType {
|
||||
|
||||
@ -2,6 +2,7 @@ package com.hbm.tileentity.machine.pile;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.blocks.machine.pile.BlockPile;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.main.NTMSounds;
|
||||
import com.hbm.tileentity.machine.pile.TileEntityPileCore.PileChannel;
|
||||
import com.hbm.util.Compat;
|
||||
@ -9,6 +10,7 @@ import com.hbm.util.Compat;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@ -25,17 +27,17 @@ public class TileEntityPileLoader extends TileEntityPileDeviceBase implements IS
|
||||
|
||||
public boolean loading = false;
|
||||
public int delay = 0;
|
||||
public boolean hasRod = false;
|
||||
public ItemStack syncStack;
|
||||
public ItemStack stack;
|
||||
public boolean wasRedstone;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
this.hasRod = this.stack != null;
|
||||
|
||||
ForgeDirection dir = getOrientation();
|
||||
PileChannel fuelChan = null;
|
||||
|
||||
int x = xCoord - dir.offsetX;
|
||||
int y = yCoord;
|
||||
@ -49,7 +51,7 @@ public class TileEntityPileLoader extends TileEntityPileDeviceBase implements IS
|
||||
TileEntityPileCore core = pile.getCore();
|
||||
|
||||
if(core != null) {
|
||||
PileChannel fuelChan = core.getFuelChannel(x, y, z);
|
||||
fuelChan = core.getFuelChannel(x, y, z);
|
||||
|
||||
if(fuelChan != null) {
|
||||
this.chanNum = core.getFuelChannelNum(fuelChan);
|
||||
@ -58,6 +60,10 @@ public class TileEntityPileLoader extends TileEntityPileDeviceBase implements IS
|
||||
}
|
||||
}
|
||||
|
||||
boolean redstone = worldObj.getIndirectPowerOutput(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ, dir.getOpposite().ordinal());
|
||||
if(redstone && !wasRedstone && this.delay <= 0 && this.level <= 0) this.loading = true;
|
||||
this.wasRedstone = redstone;
|
||||
|
||||
if(this.delay > 0) {
|
||||
this.delay--;
|
||||
} else {
|
||||
@ -76,7 +82,10 @@ public class TileEntityPileLoader extends TileEntityPileDeviceBase implements IS
|
||||
|
||||
if(this.level == 1) {
|
||||
worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, NTMSounds.GUN_BOLT_OPEN, this.getVolume(1F), 0.75F);
|
||||
this.setInventorySlotContents(0, null);
|
||||
if(fuelChan != null) {
|
||||
fuelChan.loadItem(stack);
|
||||
this.setInventorySlotContents(0, null);
|
||||
}
|
||||
}
|
||||
|
||||
if(this.level > 0D) {
|
||||
@ -105,7 +114,12 @@ public class TileEntityPileLoader extends TileEntityPileDeviceBase implements IS
|
||||
public void serialize(ByteBuf buf) {
|
||||
super.serialize(buf);
|
||||
buf.writeDouble(this.level);
|
||||
buf.writeBoolean(this.hasRod);
|
||||
if(this.stack != null) {
|
||||
buf.writeInt(Item.getIdFromItem(this.stack.getItem()));
|
||||
buf.writeShort(this.stack.getItemDamage());
|
||||
} else {
|
||||
buf.writeInt(-1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -113,13 +127,15 @@ public class TileEntityPileLoader extends TileEntityPileDeviceBase implements IS
|
||||
super.deserialize(buf);
|
||||
double lastSync = this.syncLevel;
|
||||
this.syncLevel = buf.readDouble();
|
||||
this.hasRod = buf.readBoolean();
|
||||
int itemId = buf.readInt();
|
||||
if(itemId != -1) this.syncStack = new ItemStack(Item.getItemById(itemId), 1, buf.readShort());
|
||||
else this.syncStack = null;
|
||||
|
||||
if(this.syncLevel != lastSync) this.turnProgress = 2;
|
||||
}
|
||||
|
||||
public static boolean isItemLoadable(ItemStack stack) {
|
||||
return true;
|
||||
return stack.getItem() == ModItems.pile_rod;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
BIN
src/main/resources/assets/hbm/textures/items/pile_rod.nu.png
Normal file
|
After Width: | Height: | Size: 274 B |
|
After Width: | Height: | Size: 274 B |
BIN
src/main/resources/assets/hbm/textures/items/pile_rod.pu239.png
Normal file
|
After Width: | Height: | Size: 279 B |
|
After Width: | Height: | Size: 274 B |
BIN
src/main/resources/assets/hbm/textures/items/pile_rod.rgp.png
Normal file
|
After Width: | Height: | Size: 275 B |
BIN
src/main/resources/assets/hbm/textures/items/pile_rod.waste.png
Normal file
|
After Width: | Height: | Size: 231 B |
BIN
src/main/resources/assets/hbm/textures/items/pile_rod.zr.png
Normal file
|
After Width: | Height: | Size: 271 B |