straight up piling it and by it i mean, hehe, my peanits

This commit is contained in:
HbmMods 2026-07-23 18:41:12 +02:00
parent 7805bacbd0
commit 11668d2412
11 changed files with 227 additions and 88 deletions

View File

@ -9,7 +9,6 @@ import com.hbm.main.MainRegistry;
import com.hbm.tileentity.TileEntityProxyCombo; import com.hbm.tileentity.TileEntityProxyCombo;
import com.hbm.tileentity.machine.albion.TileEntityPASource; import com.hbm.tileentity.machine.albion.TileEntityPASource;
import com.hbm.util.fauxpointtwelve.DirPos;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -53,7 +52,8 @@ public class BlockPASource extends BlockDummyable implements ITooltipProvider {
this.makeExtra(world, x - dir.offsetX, y, z - dir.offsetZ); this.makeExtra(world, x - dir.offsetX, y, z - dir.offsetZ);
this.makeExtra(world, x - dir.offsetX + rot.offsetX * 2, y, z - dir.offsetZ + rot.offsetZ * 2); this.makeExtra(world, x - dir.offsetX + rot.offsetX * 2, y, z - dir.offsetZ + rot.offsetZ * 2);
this.makeExtra(world, x - dir.offsetX - rot.offsetX * 2, y, z - dir.offsetZ - rot.offsetZ * 2); this.makeExtra(world, x - dir.offsetX - rot.offsetX * 2, y, z - dir.offsetZ - rot.offsetZ * 2);
this.makeExtra(world, x,y - 1, z);
this.makeExtra(world, x, y - 1, z);
this.makeExtra(world, x + rot.offsetX * 2, y - 1, z + rot.offsetZ * 2); this.makeExtra(world, x + rot.offsetX * 2, y - 1, z + rot.offsetZ * 2);
this.makeExtra(world, x - rot.offsetX * 2, y - 1, z - rot.offsetZ * 2); this.makeExtra(world, x - rot.offsetX * 2, y - 1, z - rot.offsetZ * 2);
} }

View File

@ -98,19 +98,21 @@ public class BlockPile extends BlockContainer implements IBlockCT, IToolable, IL
@Override @Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) { public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileEntity tile = world.getTileEntity(x, y, z); if(!TileEntityPileCore.meltingDown) {
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(tile instanceof TileEntityPileBaseMK2) {
if(core != null && !core.isInvalid()) core.destroy(); TileEntityPileBaseMK2 pile = (TileEntityPileBaseMK2) tile;
world.removeTileEntity(x, y, z);
} else { if(pile.coreY >= 0) world.setBlock(x, y, z, ModBlocks.pile_brick);
world.removeTileEntity(x, y, z);
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); super.breakBlock(world, x, y, z, block, meta);
} }
@ -151,6 +153,15 @@ public class BlockPile extends BlockContainer implements IBlockCT, IToolable, IL
if(meta == META_AIR_IN) text.add("Air Inlet"); if(meta == META_AIR_IN) text.add("Air Inlet");
if(meta == META_AIR_OUT) text.add("Air Outlet"); if(meta == META_AIR_OUT) text.add("Air Outlet");
if(meta == META_CONTROL) text.add("Control Rod Channel"); if(meta == META_CONTROL) text.add("Control Rod Channel");
if(meta == META_CORE) {
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileEntityPileCore) {
TileEntityPileCore core = (TileEntityPileCore) tile;
text.add("Max Temp: " + (int) Math.round(core.highestHeat) + " / " + core.MAX_HEAT + "°C");
}
}
if(!text.isEmpty()) ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text); if(!text.isEmpty()) ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
} }
} }

View File

@ -1,6 +1,7 @@
package com.hbm.blocks.machine.pile; package com.hbm.blocks.machine.pile;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.generic.BlockFlammable;
import com.hbm.blocks.machine.MachinePWRController; import com.hbm.blocks.machine.MachinePWRController;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import com.hbm.tileentity.machine.pile.TileEntityPileBaseMK2; import com.hbm.tileentity.machine.pile.TileEntityPileBaseMK2;
@ -10,7 +11,6 @@ import com.hbm.tileentity.machine.pile.TileEntityPileCore.PileOrientation;
import api.hbm.block.IToolable; import api.hbm.block.IToolable;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -18,13 +18,13 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
public class BlockPileBrick extends Block implements IToolable { public class BlockPileBrick extends BlockFlammable implements IToolable {
@SideOnly(Side.CLIENT) protected IIcon iconTop; @SideOnly(Side.CLIENT) protected IIcon iconTop;
@SideOnly(Side.CLIENT) protected IIcon iconSide; @SideOnly(Side.CLIENT) protected IIcon iconSide;
public BlockPileBrick() { public BlockPileBrick() {
super(Material.rock); super(Material.rock, 30, 5);
} }
@Override @Override
@ -127,7 +127,7 @@ public class BlockPileBrick extends Block implements IToolable {
world.setBlock(iX, iY, iZ, ModBlocks.pile_block, BlockPile.META_CORE, 3); world.setBlock(iX, iY, iZ, ModBlocks.pile_block, BlockPile.META_CORE, 3);
TileEntityPileCore core = (TileEntityPileCore) world.getTileEntity(iX, iY, iZ); TileEntityPileCore core = (TileEntityPileCore) world.getTileEntity(iX, iY, iZ);
core.orientation = PileOrientation.getOrientation(dir); core.orientation = PileOrientation.getOrientation(dir);
core.setupSize(posHeight + negHeight + 1, left, right, depth + 1); core.setupSize(posHeight, negHeight, left, right, depth + 1);
} else { } else {
int edgeCount = 0; int edgeCount = 0;
if(h == -negHeight || h == posHeight) edgeCount++; if(h == -negHeight || h == posHeight) edgeCount++;

View File

@ -9,7 +9,7 @@ import com.hbm.blocks.ITooltipProvider;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.main.NTMSounds; import com.hbm.main.NTMSounds;
import com.hbm.tileentity.machine.pile.TileEntityPileControl; import com.hbm.tileentity.machine.pile.TileEntityPileControl;
import com.hbm.tileentity.machine.pile.TileEntityPileDeviceBase; import com.hbm.tileentity.machine.pile.TileEntityPileCore;
import com.hbm.tileentity.machine.pile.TileEntityPileLoader; import com.hbm.tileentity.machine.pile.TileEntityPileLoader;
import com.hbm.tileentity.machine.pile.TileEntityPileVent; import com.hbm.tileentity.machine.pile.TileEntityPileVent;
import com.hbm.util.i18n.I18nUtil; import com.hbm.util.i18n.I18nUtil;
@ -157,14 +157,20 @@ public class BlockPileDevice extends BlockContainer implements IBlockMulti, ILoo
List<String> text = new ArrayList(); List<String> text = new ArrayList();
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileEntityPileDeviceBase) { /*if(tile instanceof TileEntityPileDeviceBase) {
TileEntityPileDeviceBase device = (TileEntityPileDeviceBase) tile; TileEntityPileDeviceBase device = (TileEntityPileDeviceBase) tile;
text.add("#" + (device.chanNum + 1)); text.add("#" + (device.chanNum + 1));
} }*/
if(tile instanceof TileEntityPileLoader) { if(tile instanceof TileEntityPileLoader) {
TileEntityPileLoader device = (TileEntityPileLoader) tile; TileEntityPileLoader device = (TileEntityPileLoader) tile;
text.add("Temp: " + (int) Math.round(device.channelTemp) + " / " + TileEntityPileCore.MAX_HEAT + "°C");
if(device.syncStack != null) text.add("Loading: " + device.syncStack.getDisplayName()); if(device.syncStack != null) text.add("Loading: " + device.syncStack.getDisplayName());
if(device.channelStack != null) {
text.add("Last rod: " + device.channelStack.getDisplayName());
if(device.channelDepletion > 0) text.add("Depletion: " + (int) Math.round(device.channelDepletion) + "%");
}
} }
if(tile instanceof TileEntityPileControl) { if(tile instanceof TileEntityPileControl) {

View File

@ -37,11 +37,11 @@ public class ItemPileRodMK2 extends ItemEnumMulti {
public static enum EnumPileRod { public static enum EnumPileRod {
/* 0 */ RA226BE(1D), /* 0 */ RA226BE(1D),
/* 1 */ PO210BE(1D), /* 1 */ PO210BE(1D),
/* 2 */ ZR( 0D, 0D, 0D, 2), /* 2 */ ZR( 0D, 0D, 0D, 2),
/* 3 */ NU( 1D, 1_000D, 1D, 4), /* 3 */ NU( 1D, 25_000D, 0.25D, 4),
/* 4 */ PU239( 1D, 1_000D, 1D, 5), /* 4 */ PU239( 1D, 500D, 0.5D, 5),
/* 5 */ RGP( 1D, 1_000D, 1D, 6), /* 5 */ RGP( 1D, 1_000D, 0.5D, 6),
/* 6 */ WASTE( 1D, 0D, 1D, 6); /* 6 */ WASTE( 1D, 0D, 1.5D, 6);
public double reactionMult = 1.0D; public double reactionMult = 1.0D;
public double life = 1_000D; public double life = 1_000D;
@ -66,6 +66,13 @@ public class ItemPileRodMK2 extends ItemEnumMulti {
@Override @Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) {
EnumPileRod rod = EnumUtil.grabEnumSafely(EnumPileRod.class, stack.getItemDamage());
if(rod.life > 0) {
list.add("Lifetime: " + (int) Math.round(rod.life));
double depletion = getDepletionPercent(stack);
if(depletion > 0) list.add("Depletion: " + (int) Math.round(depletion) + "%");
}
for(String loc : I18nUtil.autoBreak(Minecraft.getMinecraft().fontRenderer, I18nUtil.resolveKey(this.getUnlocalizedName(stack) + ".desc"), 225)) { for(String loc : I18nUtil.autoBreak(Minecraft.getMinecraft().fontRenderer, I18nUtil.resolveKey(this.getUnlocalizedName(stack) + ".desc"), 225)) {
list.add(EnumChatFormatting.YELLOW + loc); list.add(EnumChatFormatting.YELLOW + loc);
@ -85,6 +92,14 @@ public class ItemPileRodMK2 extends ItemEnumMulti {
return getDepletion(stack) / life; return getDepletion(stack) / life;
} }
public static double getDepletionPercent(ItemStack stack) {
if(stack == null) return 0D;
EnumPileRod rod = EnumUtil.grabEnumSafely(EnumPileRod.class, stack.getItemDamage());
double life = rod.life;
if(life <= 0) return 0D;
return (getDepletion(stack) / life) * 100;
}
public static double getDepletion(ItemStack stack) { public static double getDepletion(ItemStack stack) {
if(!stack.hasTagCompound()) return 0D; if(!stack.hasTagCompound()) return 0D;
return stack.stackTagCompound.getDouble(KEY_NBT_DEPLETION); return stack.stackTagCompound.getDouble(KEY_NBT_DEPLETION);

View File

@ -134,7 +134,6 @@ public class CraftingManager {
addRecipeAuto(new ItemStack(ModItems.gas_empty, 2), new Object[] { "S ", "AA", "AA", 'A', STEEL.plate(), 'S', CU.plate() }); addRecipeAuto(new ItemStack(ModItems.gas_empty, 2), new Object[] { "S ", "AA", "AA", 'A', STEEL.plate(), 'S', CU.plate() });
addShapelessAuto(new ItemStack(ModBlocks.block_waste_painted, 1), new Object[] { KEY_YELLOW, ModBlocks.block_waste }); addShapelessAuto(new ItemStack(ModBlocks.block_waste_painted, 1), new Object[] { KEY_YELLOW, ModBlocks.block_waste });
addRecipeAuto(new ItemStack(ModItems.ingot_aluminium, 1), new Object[] { "###", "###", "###", '#', AL.wireFine() }); addRecipeAuto(new ItemStack(ModItems.ingot_aluminium, 1), new Object[] { "###", "###", "###", '#', AL.wireFine() });
addRecipeAuto(new ItemStack(ModItems.ingot_copper, 1), new Object[] { "###", "###", "###", '#', CU.wireFine() }); addRecipeAuto(new ItemStack(ModItems.ingot_copper, 1), new Object[] { "###", "###", "###", '#', CU.wireFine() });
addRecipeAuto(new ItemStack(ModItems.ingot_tungsten, 1), new Object[] { "###", "###", "###", '#', W.wireFine() }); addRecipeAuto(new ItemStack(ModItems.ingot_tungsten, 1), new Object[] { "###", "###", "###", '#', W.wireFine() });
@ -312,6 +311,10 @@ public class CraftingManager {
addRecipeAuto(DictFrame.fromOne(ModItems.arc_electrode, EnumElectrodeType.DESH), new Object[] { "C", "T", "C", 'C', DESH.ingot(), 'T', W.ingot() }); addRecipeAuto(DictFrame.fromOne(ModItems.arc_electrode, EnumElectrodeType.DESH), new Object[] { "C", "T", "C", 'C', DESH.ingot(), 'T', W.ingot() });
addRecipeAuto(DictFrame.fromOne(ModItems.arc_electrode, EnumElectrodeType.SATURNITE), new Object[] { "C", "T", "C", 'C', BIGMT.ingot(), 'T', NB.ingot() }); addRecipeAuto(DictFrame.fromOne(ModItems.arc_electrode, EnumElectrodeType.SATURNITE), new Object[] { "C", "T", "C", 'C', BIGMT.ingot(), 'T', NB.ingot() });
addRecipeAuto(new ItemStack(ModBlocks.pile_device, 1, 0), new Object[] { " A ", "CBS", 'A', AL.plate(), 'C', STEEL.plateCast(), 'B', B.ingot(), 'S', STEEL.shell() });
addRecipeAuto(new ItemStack(ModBlocks.pile_device, 1, 1), new Object[] { " M ", "ACA", " S ", 'M', ModItems.motor, 'A', AL.plate(), 'C', CU.shell(), 'S', STEEL.plateCast() });
addRecipeAuto(new ItemStack(ModBlocks.pile_device, 1, 2), new Object[] { " B ", "SBS", "SBS", 'B', B.ingot(), 'S', STEEL.plate() });
addRecipeAuto(new ItemStack(ModItems.detonator, 1), new Object[] { "C", "S", 'S', STEEL.plate(), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.BASIC), }); addRecipeAuto(new ItemStack(ModItems.detonator, 1), new Object[] { "C", "S", 'S', STEEL.plate(), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.BASIC), });
addShapelessAuto(new ItemStack(ModItems.detonator_multi, 1), new Object[] { ModItems.detonator, DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ADVANCED) }); addShapelessAuto(new ItemStack(ModItems.detonator_multi, 1), new Object[] { ModItems.detonator, DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ADVANCED) });
addShapelessAuto(new ItemStack(ModItems.detonator_laser, 1), new Object[] { ModItems.rangefinder, DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ADVANCED), RUBBER.ingot(), GOLD.wireDense() }); addShapelessAuto(new ItemStack(ModItems.detonator_laser, 1), new Object[] { ModItems.rangefinder, DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ADVANCED), RUBBER.ingot(), GOLD.wireDense() });

View File

@ -14,7 +14,6 @@ import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos; import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.redstoneoverradio.IRORValueProvider; import api.hbm.redstoneoverradio.IRORValueProvider;
import api.hbm.redstoneoverradio.IRORInteractive;
import cpw.mods.fml.common.Optional; import cpw.mods.fml.common.Optional;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View File

@ -9,20 +9,17 @@ import com.hbm.blocks.machine.MachinePWRController;
import com.hbm.blocks.machine.pile.BlockPile; import com.hbm.blocks.machine.pile.BlockPile;
import com.hbm.interfaces.NotableComments; import com.hbm.interfaces.NotableComments;
import com.hbm.items.machine.ItemPileRodMK2; import com.hbm.items.machine.ItemPileRodMK2;
import com.hbm.items.machine.ItemPileRodMK2.EnumPileRod;
import com.hbm.main.NTMSounds; import com.hbm.main.NTMSounds;
import com.hbm.packet.PacketDispatcher; import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toclient.AuxParticlePacketNT; import com.hbm.packet.toclient.AuxParticlePacketNT;
import com.hbm.packet.toclient.PlayerInformPacket;
import com.hbm.tileentity.TileEntityTickingBase; import com.hbm.tileentity.TileEntityTickingBase;
import com.hbm.util.EnumUtil; import com.hbm.util.EnumUtil;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos; import com.hbm.util.fauxpointtwelve.DirPos;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
@ -65,11 +62,16 @@ public class TileEntityPileCore extends TileEntityTickingBase {
public int left; public int left;
public int right; public int right;
public int up;
/** /**
* Segments are fuel and control channels grouped by vertical slices viewed from the front, this makes the simulation part easier. * Segments are fuel and control channels grouped by vertical slices viewed from the front, this makes the simulation part easier.
*/ */
public PileSegment[] segments = new PileSegment[0]; public PileSegment[] segments = new PileSegment[0];
public double highestHeat;
public static final int MAX_HEAT = 800;
public static boolean meltingDown = false;
@Override @Override
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt); super.readFromNBT(nbt);
@ -78,16 +80,19 @@ public class TileEntityPileCore extends TileEntityTickingBase {
depth = nbt.getInteger("depth"); depth = nbt.getInteger("depth");
left = nbt.getInteger("left"); left = nbt.getInteger("left");
right = nbt.getInteger("right"); right = nbt.getInteger("right");
up = nbt.getInteger("up");
orientation = EnumUtil.grabEnumSafely(PileOrientation.class, nbt.getInteger("orientation"));
segments = new PileSegment[width]; segments = new PileSegment[width];
int fuelCount = nbt.getByte("fc");
int ventCount = nbt.getByte("vc");
int contCount = nbt.getByte("cc");
fuelChannels.clear(); fuelChannels.clear();
ventilationChannels.clear(); ventilationChannels.clear();
controlChannels.clear(); controlChannels.clear();
int fuelCount = nbt.getByte("fc");
int ventCount = nbt.getByte("vc");
int contCount = nbt.getByte("cc");
for(int i = 0; i < fuelCount; i++) fuelChannels.add(readChannelFromNBT(nbt, "f" + i)); 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 < ventCount; i++) ventilationChannels.add(readChannelFromNBT(nbt, "v" + i));
@ -104,6 +109,9 @@ public class TileEntityPileCore extends TileEntityTickingBase {
nbt.setInteger("depth", depth); nbt.setInteger("depth", depth);
nbt.setInteger("left", left); nbt.setInteger("left", left);
nbt.setInteger("right", right); nbt.setInteger("right", right);
nbt.setInteger("up", up);
nbt.setInteger("orientation", orientation.ordinal());
int fuelCount = fuelChannels.size(); int fuelCount = fuelChannels.size();
int ventCount = ventilationChannels.size(); int ventCount = ventilationChannels.size();
@ -135,12 +143,13 @@ public class TileEntityPileCore extends TileEntityTickingBase {
return list.indexOf(chan); // more reliable when channels change and not that big of a deal because we have lists in single digit length return list.indexOf(chan); // more reliable when channels change and not that big of a deal because we have lists in single digit length
} }
public TileEntityPileCore setupSize(int h, int l, int r, int d) { public TileEntityPileCore setupSize(int up, int down, int l, int r, int d) {
this.height = h; this.height = up + 1 + down;
this.width = l + 1 + r; this.width = l + 1 + r;
this.depth = d; this.depth = d;
this.left = l; this.left = l;
this.right = r; this.right = r;
this.up = up;
this.segments = new PileSegment[width]; this.segments = new PileSegment[width];
return this; return this;
} }
@ -228,8 +237,23 @@ public class TileEntityPileCore extends TileEntityTickingBase {
this.runSimulation(); this.runSimulation();
this.handleVentilation(); this.handleVentilation();
this.handleMeltdown();
this.networkPackNT(25);
} }
} }
@Override
public void serialize(ByteBuf buf) {
super.serialize(buf);
buf.writeDouble(this.highestHeat);
}
@Override
public void deserialize(ByteBuf buf) {
super.deserialize(buf);
this.highestHeat = buf.readDouble();
}
protected void runSimulation() { protected void runSimulation() {
@ -237,7 +261,6 @@ public class TileEntityPileCore extends TileEntityTickingBase {
for(PileChannel chan : this.fuelChannels) { for(PileChannel chan : this.fuelChannels) {
if(chan.length <= 0) continue; if(chan.length <= 0) continue;
double producedNeutrons = 0; double producedNeutrons = 0;
double latestDepletion = 0D;
for(int i = 0; i < chan.rods.length; i++) { for(int i = 0; i < chan.rods.length; i++) {
ItemStack stack = chan.rods[i]; ItemStack stack = chan.rods[i];
@ -246,25 +269,10 @@ public class TileEntityPileCore extends TileEntityTickingBase {
producedNeutrons += neut; producedNeutrons += neut;
chan.heat += neut * ItemPileRodMK2.getHeatPerNeutron(stack); chan.heat += neut * ItemPileRodMK2.getHeatPerNeutron(stack);
chan.rods[i] = ItemPileRodMK2.react(stack, neut); chan.rods[i] = ItemPileRodMK2.react(stack, neut);
EnumPileRod rod = EnumUtil.grabEnumSafely(EnumPileRod.class, stack.getItemDamage());
double life = rod.life < 1 ? 1 : rod.life;
latestDepletion = ItemPileRodMK2.getDepletion(chan.rods[i]) / life;
} }
} }
chan.outgoingNeutrons = producedNeutrons; chan.outgoingNeutrons = producedNeutrons;
chan.incomingNeutrons = 0; chan.incomingNeutrons = 0;
/// DEBUG ///
int hash = BlockPos.getIdentity(xCoord, yCoord, zCoord);
for(Object o : worldObj.playerEntities) {
if(o instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) o;
int index = this.getFuelChannelNum(chan);
PacketDispatcher.wrapper.sendTo(new PlayerInformPacket("#" + index + " " + Math.round(chan.heat) + "TU " + Math.round(chan.outgoingNeutrons) + "n " + Math.round(latestDepletion * 100) + "%", hash + index), player);
}
}
/// DEBUG ///
} }
// intra-segment propagation // intra-segment propagation
@ -313,7 +321,7 @@ public class TileEntityPileCore extends TileEntityTickingBase {
for(PileChannel fuel : this.fuelChannels) { for(PileChannel fuel : this.fuelChannels) {
if(Math.abs(fuel.entry.getY() - chan.entry.getY()) <= 1) { if(Math.abs(fuel.entry.getY() - chan.entry.getY()) <= 1) {
fuel.heat *= (1D - airCap * 0.5D); // channel can hold up to 1000mB, turning into a 0.5 heat mult for connected fuel channels fuel.heat *= (1D - airCap * 0.05D); // channel can hold up to 1000mB, turning into a 0.95 heat mult for connected fuel channels
} }
} }
@ -338,6 +346,34 @@ public class TileEntityPileCore extends TileEntityTickingBase {
data.setInteger("color", 0xa0a0a0); data.setInteger("color", 0xa0a0a0);
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, x, y, z), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 150)); PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, x, y, z), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 150));
} }
for(PileChannel chan : this.fuelChannels) {
chan.heat *= 0.999;
if(chan.heat < 20) chan.heat = 20;
}
}
protected void handleMeltdown() {
this.highestHeat = 0;
for(PileChannel chan : this.fuelChannels) {
if(chan.heat > this.highestHeat) this.highestHeat = chan.heat;
}
if(this.highestHeat > this.MAX_HEAT) {
this.destroy();
double avgX = 0;
double avgZ = 0;
for(PileChannel chan : this.fuelChannels) {
avgX += chan.entry.getX() + 0.5 + chan.entry.getDir().offsetX * (chan.length - 1) / 2D;
avgZ += chan.entry.getZ() + 0.5 + chan.entry.getDir().offsetZ * (chan.length - 1) / 2D;
}
avgX /= this.fuelChannels.size();
avgZ /= this.fuelChannels.size();
meltingDown = true;
worldObj.newExplosion(null, avgX, yCoord + up, avgZ, 15F, true, true);
meltingDown= false;
}
} }
protected void recalculateSegments() { protected void recalculateSegments() {
@ -440,29 +476,29 @@ public class TileEntityPileCore extends TileEntityTickingBase {
nbt.setInteger(name + "_y", entry.getY()); nbt.setInteger(name + "_y", entry.getY());
nbt.setInteger(name + "_z", entry.getZ()); nbt.setInteger(name + "_z", entry.getZ());
nbt.setByte(name + "_d", (byte) entry.getDir().ordinal()); nbt.setByte(name + "_d", (byte) entry.getDir().ordinal());
if(type == type.FUEL) { if(type == type.FUEL) {
NBTTagList list = new NBTTagList(); NBTTagList list = new NBTTagList();
for(int i = 0; i < rods.length; i++) { for(int i = 0; i < rods.length; i++) {
if(rods[i] != null) { if(rods[i] != null) {
NBTTagCompound nbt1 = new NBTTagCompound(); NBTTagCompound nbt1 = new NBTTagCompound();
nbt1.setByte("slot", (byte)i); nbt1.setByte("slot", (byte) i);
rods[i].writeToNBT(nbt1); rods[i].writeToNBT(nbt1);
list.appendTag(nbt1); list.appendTag(nbt1);
} }
} }
nbt.setTag("items", list); nbt.setTag(name + "items", list);
nbt.setDouble("heat", heat); nbt.setDouble(name + "heat", heat);
nbt.setDouble("neutrons", incomingNeutrons); nbt.setDouble(name + "neutrons", incomingNeutrons);
} }
if(type == type.VENTILATION) { if(type == type.VENTILATION) {
nbt.setInteger("air", air); nbt.setInteger(name + "air", air);
} }
if(type == type.CONTROL) { if(type == type.CONTROL) {
nbt.setDouble("control", control); nbt.setDouble(name + "control", control);
} }
} }
@ -490,6 +526,11 @@ public class TileEntityPileCore extends TileEntityTickingBase {
int y = entry.getY(); int y = entry.getY();
int z = entry.getZ() + entry.getDir().offsetZ * depth; int z = entry.getZ() + entry.getDir().offsetZ * depth;
if(stack.hasTagCompound() && stack.stackTagCompound.hasKey(ItemPileRodMK2.KEY_NBT_DEPLETION)) {
stack.stackTagCompound.removeTag(ItemPileRodMK2.KEY_NBT_DEPLETION);
if(stack.stackTagCompound.hasNoTags()) stack.stackTagCompound = null;
}
EntityItem item = new EntityItem(worldObj, x + 0.5, y + 0.5, z + 0.5, stack); EntityItem item = new EntityItem(worldObj, x + 0.5, y + 0.5, z + 0.5, stack);
worldObj.spawnEntityInWorld(item); worldObj.spawnEntityInWorld(item);
} }
@ -502,9 +543,9 @@ public class TileEntityPileCore extends TileEntityTickingBase {
ForgeDirection dir = ForgeDirection.getOrientation(nbt.getByte(name + "_d")); ForgeDirection dir = ForgeDirection.getOrientation(nbt.getByte(name + "_d"));
PileChannel chan = new PileChannel(x, y, z, dir); PileChannel chan = new PileChannel(x, y, z, dir);
if(chan.type == chan.type.FUEL) { if(chan.type == chan.type.FUEL) {
NBTTagList list = nbt.getTagList("items", 10); NBTTagList list = nbt.getTagList(name + "items", 10);
for(int i = 0; i < list.tagCount(); i++) { for(int i = 0; i < list.tagCount(); i++) {
NBTTagCompound nbt1 = list.getCompoundTagAt(i); NBTTagCompound nbt1 = list.getCompoundTagAt(i);
byte b0 = nbt1.getByte("slot"); byte b0 = nbt1.getByte("slot");
@ -513,16 +554,16 @@ public class TileEntityPileCore extends TileEntityTickingBase {
} }
} }
chan.heat = nbt.getDouble("heat"); chan.heat = nbt.getDouble(name + "heat");
chan.incomingNeutrons = nbt.getDouble("neutrons"); chan.incomingNeutrons = nbt.getDouble(name + "neutrons");
} }
if(chan.type == chan.type.VENTILATION) { if(chan.type == chan.type.VENTILATION) {
chan.air = nbt.getInteger("air"); chan.air = nbt.getInteger(name + "air");
} }
if(chan.type == chan.type.CONTROL) { if(chan.type == chan.type.CONTROL) {
chan.control = nbt.getDouble("control"); chan.control = nbt.getDouble(name + "control");
} }
return chan; return chan;

View File

@ -3,10 +3,14 @@ package com.hbm.tileentity.machine.pile;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.machine.pile.BlockPile; import com.hbm.blocks.machine.pile.BlockPile;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.items.machine.ItemPileRodMK2;
import com.hbm.items.machine.ItemPileRodMK2.EnumPileRod;
import com.hbm.main.NTMSounds; import com.hbm.main.NTMSounds;
import com.hbm.tileentity.machine.pile.TileEntityPileCore.PileChannel; import com.hbm.tileentity.machine.pile.TileEntityPileCore.PileChannel;
import com.hbm.util.Compat; import com.hbm.util.Compat;
import com.hbm.util.EnumUtil;
import api.hbm.redstoneoverradio.IRORValueProvider;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.ISidedInventory;
@ -15,7 +19,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityPileLoader extends TileEntityPileDeviceBase implements ISidedInventory{ public class TileEntityPileLoader extends TileEntityPileDeviceBase implements ISidedInventory, IRORValueProvider {
public double syncLevel; public double syncLevel;
public double level; public double level;
@ -30,6 +34,10 @@ public class TileEntityPileLoader extends TileEntityPileDeviceBase implements IS
public ItemStack syncStack; public ItemStack syncStack;
public ItemStack stack; public ItemStack stack;
public boolean wasRedstone; public boolean wasRedstone;
public ItemStack channelStack;
public double channelDepletion;
public double channelTemp;
@Override @Override
public void updateEntity() { public void updateEntity() {
@ -38,6 +46,9 @@ public class TileEntityPileLoader extends TileEntityPileDeviceBase implements IS
ForgeDirection dir = getOrientation(); ForgeDirection dir = getOrientation();
PileChannel fuelChan = null; PileChannel fuelChan = null;
this.channelStack = null;
this.channelDepletion = 0D;
this.channelTemp = 0D;
int x = xCoord - dir.offsetX; int x = xCoord - dir.offsetX;
int y = yCoord; int y = yCoord;
@ -55,6 +66,9 @@ public class TileEntityPileLoader extends TileEntityPileDeviceBase implements IS
if(fuelChan != null) { if(fuelChan != null) {
this.chanNum = core.getFuelChannelNum(fuelChan); this.chanNum = core.getFuelChannelNum(fuelChan);
this.channelStack = fuelChan.rods[fuelChan.rods.length - 1];
this.channelDepletion = ItemPileRodMK2.getDepletionPercent(channelStack);
this.channelTemp = fuelChan.heat;
} }
} }
} }
@ -114,12 +128,23 @@ public class TileEntityPileLoader extends TileEntityPileDeviceBase implements IS
public void serialize(ByteBuf buf) { public void serialize(ByteBuf buf) {
super.serialize(buf); super.serialize(buf);
buf.writeDouble(this.level); buf.writeDouble(this.level);
if(this.stack != null) { if(this.stack != null) {
buf.writeInt(Item.getIdFromItem(this.stack.getItem())); buf.writeInt(Item.getIdFromItem(this.stack.getItem()));
buf.writeShort(this.stack.getItemDamage()); buf.writeShort(this.stack.getItemDamage());
} else { } else {
buf.writeInt(-1); buf.writeInt(-1);
} }
if(this.channelStack != null) {
buf.writeInt(Item.getIdFromItem(this.channelStack.getItem()));
buf.writeShort(this.channelStack.getItemDamage());
} else {
buf.writeInt(-1);
}
buf.writeDouble(this.channelDepletion);
buf.writeDouble(this.channelTemp);
} }
@Override @Override
@ -127,9 +152,17 @@ public class TileEntityPileLoader extends TileEntityPileDeviceBase implements IS
super.deserialize(buf); super.deserialize(buf);
double lastSync = this.syncLevel; double lastSync = this.syncLevel;
this.syncLevel = buf.readDouble(); this.syncLevel = buf.readDouble();
int itemId = buf.readInt(); int itemId = buf.readInt();
if(itemId != -1) this.syncStack = new ItemStack(Item.getItemById(itemId), 1, buf.readShort()); if(itemId != -1) this.syncStack = new ItemStack(Item.getItemById(itemId), 1, buf.readShort());
else this.syncStack = null; else this.syncStack = null;
int chanId = buf.readInt();
if(chanId != -1) this.channelStack = new ItemStack(Item.getItemById(chanId), 1, buf.readShort());
else this.channelStack = null;
this.channelDepletion = buf.readDouble();
this.channelTemp = buf.readDouble();
if(this.syncLevel != lastSync) this.turnProgress = 2; if(this.syncLevel != lastSync) this.turnProgress = 2;
} }
@ -169,4 +202,40 @@ public class TileEntityPileLoader extends TileEntityPileDeviceBase implements IS
@Override public boolean isItemValidForSlot(int slot, ItemStack stack) { return isItemLoadable(stack); } @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { return isItemLoadable(stack); }
@Override public boolean canInsertItem(int slot, ItemStack stack, int side) { return isItemLoadable(stack); } @Override public boolean canInsertItem(int slot, ItemStack stack, int side) { return isItemLoadable(stack); }
@Override public boolean canExtractItem(int slot, ItemStack stack, int side) { return false; } @Override public boolean canExtractItem(int slot, ItemStack stack, int side) { return false; }
@Override
public String[] getFunctionInfo() {
return new String[] {
PREFIX_VALUE + "meta",
PREFIX_VALUE + "depletion",
PREFIX_VALUE + "deppercent",
PREFIX_VALUE + "lifetime",
PREFIX_VALUE + "temp",
};
}
@Override
public String provideRORValue(String name) {
if(name.equals(PREFIX_VALUE + "meta")) {
return this.channelStack == null ? "-1" : this.channelStack.getItemDamage() + "";
}
if(name.equals(PREFIX_VALUE + "deppercent")) {
return "" + (int) Math.round(this.channelDepletion);
}
if(name.equals(PREFIX_VALUE + "depletion")) {
if(this.channelStack == null) return "0";
return "" + (int) Math.round(ItemPileRodMK2.getDepletionPercent(this.channelStack));
}
if(name.equals(PREFIX_VALUE + "lifetime")) {
if(this.channelStack == null) return "0";
EnumPileRod rod = EnumUtil.grabEnumSafely(EnumPileRod.class, this.channelStack.getItemDamage());
return "" + (int) Math.round(rod.life);
}
if(name.equals(PREFIX_VALUE + "meta")) {
return "" + (int) Math.round(this.channelTemp);
}
return null;
}
} }

View File

@ -242,7 +242,7 @@ public class NTMWorldGenerator implements IWorldGenerator {
spawnWeight = StructureConfig.enableRuins ? StructureConfig.ruinsJSpawnWeight : 0; spawnWeight = StructureConfig.enableRuins ? StructureConfig.ruinsJSpawnWeight : 0;
}}); }});
NBTStructure.registerStructure(0, new SpawnCondition("tower_base") {{ NBTStructure.registerStructure(0, new SpawnCondition("tower_base") {{
canSpawn = biome -> biome.heightVariation <= 0.3F && !isInvalidBiome(biome); canSpawn = biome -> biome.heightVariation <= 0.3F && !isWaterBiome(biome);
structure = new JigsawPiece("tower_base", StructureManager.tower_base, -6); structure = new JigsawPiece("tower_base", StructureManager.tower_base, -6);
spawnWeight = StructureConfig.towerBaseSpawnWeight; spawnWeight = StructureConfig.towerBaseSpawnWeight;
}}); }});

View File

@ -495,26 +495,21 @@ public class LogicBlockActions {
if(tile.phase == 1) { if(tile.phase == 1) {
world.setBlock(x, y, z, ModBlocks.skeleton_holder); world.setBlock(x, y, z, ModBlocks.skeleton_holder);
TileEntity te = world.getTileEntity(x, y, z); TileEntity te = world.getTileEntity(x, y, z);
EntityPlayer player = (EntityPlayer) world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y - 2, z + 1).expand(25, 25, 25)).get(0);
if (te instanceof BlockSkeletonHolder.TileEntitySkeletonHolder) { if(te instanceof BlockSkeletonHolder.TileEntitySkeletonHolder) {
BlockSkeletonHolder.TileEntitySkeletonHolder skeleton = (BlockSkeletonHolder.TileEntitySkeletonHolder) te; BlockSkeletonHolder.TileEntitySkeletonHolder skeleton = (BlockSkeletonHolder.TileEntitySkeletonHolder) te;
int roll = world.rand.nextInt(100); int roll = world.rand.nextInt(100);
if (roll < 44) { if(roll < 44) {
skeleton.item = new ItemStack(ModItems.ammo_standard, 3, 91); skeleton.item = new ItemStack(ModItems.ammo_standard, 3, 91);
} else if(roll < 71) {
} else if (roll < 71) { skeleton.item = new ItemStack(ModItems.ammo_standard, 1, 92);
skeleton.item = new ItemStack(ModItems.ammo_standard, 1, 92); } else if(roll < 92) {
skeleton.item = new ItemStack(ModItems.ammo_standard, 1, 73);
} else if (roll < 92) { } else if(roll < 96) {
skeleton.item = new ItemStack(ModItems.ammo_standard, 1, 73); skeleton.item = new ItemStack(ModItems.item_secret, 1, 3);
} else {
} else if (roll < 96) { skeleton.item = new ItemStack(ModItems.item_secret, 1, 4);
skeleton.item = new ItemStack(ModItems.item_secret, 1, 3);
} else {
skeleton.item = new ItemStack(ModItems.item_secret, 1, 4);
} }
} }
} }
@ -539,7 +534,7 @@ public class LogicBlockActions {
actions.put("BOMB_TRAP", BOMB_TRAP); actions.put("BOMB_TRAP", BOMB_TRAP);
actions.put("BOMB_CRANE", BOMB_CRANE); actions.put("BOMB_CRANE", BOMB_CRANE);
actions.put("DEAD_GUY_CRANE", DEAD_GUY_CRANE); actions.put("DEAD_GUY_CRANE", DEAD_GUY_CRANE);
actions.put("DEAD_GUY_TOWER_BASE", DEAD_GUY_TOWER_BASE); //actions.put("DEAD_GUY_TOWER_BASE", DEAD_GUY_TOWER_BASE);
//Mob Block Actions //Mob Block Actions
actions.put("SKELETON_GUN_TIER_1", SKELETONS_GUN_TIER_1); actions.put("SKELETON_GUN_TIER_1", SKELETONS_GUN_TIER_1);