Merge remote-tracking branch 'HbmMods/master'

This commit is contained in:
Vaern 2023-08-16 15:52:16 -07:00
commit b5df3b0979
31 changed files with 544 additions and 128 deletions

View File

@ -883,9 +883,9 @@ public class ModBlocks {
public static Block pwr_neutron_source;
public static Block pwr_reflector;
public static Block pwr_casing;
public static Block pwr_port;
public static Block pwr_controller;
public static Block pwr_block;
public static Block pwr_port;
public static Block reactor_element;
public static Block reactor_control;

View File

@ -1,20 +1,29 @@
package com.hbm.blocks.machine;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
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.TileEntityPWRController;
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.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockPWR extends Block implements IBlockCT {
public class BlockPWR extends BlockContainer implements IBlockCT {
@SideOnly(Side.CLIENT) protected IIcon iconPort;
@ -26,6 +35,11 @@ public class BlockPWR extends Block implements IBlockCT {
public int getRenderType() {
return CT.renderID;
}
@Override
public Item getItemDropped(int i, Random rand, int j) {
return null;
}
@SideOnly(Side.CLIENT) public CTStitchReceiver rec;
@SideOnly(Side.CLIENT) public CTStitchReceiver recPort;
@ -49,4 +63,96 @@ public class BlockPWR extends Block implements IBlockCT {
public boolean canConnect(IBlockAccess world, int x, int y, int z, Block block) {
return block == ModBlocks.pwr_block || block == ModBlocks.pwr_controller;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityBlockPWR();
}
@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 TileEntityBlockPWR) {
TileEntityBlockPWR pwr = (TileEntityBlockPWR) tile;
world.removeTileEntity(x, y, z);
if(pwr.block != null) {
world.setBlock(x, y, z, pwr.block);
TileEntity controller = world.getTileEntity(pwr.coreX, pwr.coreY, pwr.coreZ);
if(controller instanceof TileEntityPWRController) {
((TileEntityPWRController) controller).assembled = false;
}
}
} else {
world.removeTileEntity(x, y, z);
}
super.breakBlock(world, x, y, z, block, meta);
}
public static class TileEntityBlockPWR extends TileEntity {
public Block block;
public int coreX;
public int coreY;
public int coreZ;
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
if(worldObj.getTotalWorldTime() % 20 == 0 && block != null) {
if(worldObj.getChunkProvider().chunkExists(coreX >> 4, coreZ >> 4)) {
TileEntity tile = worldObj.getTileEntity(coreX, coreY, coreZ);
if(tile instanceof TileEntityPWRController) {
TileEntityPWRController controller = (TileEntityPWRController) tile;
if(!controller.assembled) {
this.getBlockType().breakBlock(worldObj, xCoord, yCoord, zCoord, this.getBlockType(), this.getBlockMetadata());
}
} else {
this.getBlockType().breakBlock(worldObj, xCoord, yCoord, zCoord, this.getBlockType(), this.getBlockMetadata());
}
}
}
}
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
block = Block.getBlockById(nbt.getInteger("block"));
if(block != Blocks.air) {
coreX = nbt.getInteger("cX");
coreY = nbt.getInteger("cY");
coreZ = nbt.getInteger("cZ");
} else {
block = null;
}
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
if(block != null) {
nbt.setInteger("block", Block.getIdFromBlock(block));
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);
}
}
}
}

View File

@ -4,8 +4,12 @@ import java.util.HashMap;
import java.util.Map.Entry;
import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.machine.BlockPWR.TileEntityBlockPWR;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import com.hbm.tileentity.machine.TileEntityPWRController;
import com.hbm.util.fauxpointtwelve.BlockPos;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
@ -17,7 +21,9 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
@ -35,7 +41,7 @@ public class MachinePWRController extends BlockContainer {
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return null;
return new TileEntityPWRController();
}
@Override
@ -67,10 +73,15 @@ public class MachinePWRController extends BlockContainer {
if(world.isRemote) {
return true;
} else if(!player.isSneaking()) {
TileEntityPWRController controller = (TileEntityPWRController) world.getTileEntity(x, y, z);
assemble(world, x, y, z);
if(!controller.assembled) {
assemble(world, x, y, z, player);
} else {
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
}
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
return true;
} else {
return false;
@ -82,44 +93,59 @@ public class MachinePWRController extends BlockContainer {
private static boolean errored;
private static final int maxSize = 1024;
public void assemble(World world, int x, int y, int z) {
public void assemble(World world, int x, int y, int z, EntityPlayer player) {
assembly.clear();
fuelRods.clear();
assembly.put(new BlockPos(x, y, z), this);
ForgeDirection dir = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)).getOpposite();
x += dir.offsetX;
z += dir.offsetZ;
errored = false;
floodFill(world, x, y, z);
floodFill(world, x + dir.offsetX, y, z + dir.offsetZ, player);
if(fuelRods.size() == 0) errored = true;
TileEntityPWRController controller = (TileEntityPWRController) world.getTileEntity(x, y, z);
if(!errored) {
for(Entry<BlockPos, Block> entry : assembly.entrySet()) {
BlockPos pos = entry.getKey();
Block block = entry.getValue();
if(block != ModBlocks.pwr_controller) {
if(block == ModBlocks.pwr_port) {
world.setBlock(entry.getKey().getX(), entry.getKey().getY(), entry.getKey().getZ(), ModBlocks.pwr_block, 1, 3);
world.setBlock(pos.getX(), pos.getY(), pos.getZ(), ModBlocks.pwr_block, 1, 3);
} else {
world.setBlock(entry.getKey().getX(), entry.getKey().getY(), entry.getKey().getZ(), ModBlocks.pwr_block, 0, 3);
world.setBlock(pos.getX(), pos.getY(), pos.getZ(), ModBlocks.pwr_block, 0, 3);
}
TileEntityBlockPWR pwr = (TileEntityBlockPWR) world.getTileEntity(pos.getX(), pos.getY(), pos.getZ());
pwr.block = block;
pwr.coreX = x;
pwr.coreY = y;
pwr.coreZ = z;
pwr.markDirty();
}
}
controller.setup(assembly, fuelRods);
}
controller.assembled = !errored;
assembly.clear();
fuelRods.clear();
}
private void floodFill(World world, int x, int y, int z) {
private void floodFill(World world, int x, int y, int z, EntityPlayer player) {
BlockPos pos = new BlockPos(x, y, z);
if(assembly.containsKey(pos)) return;
if(assembly.size() >= maxSize) {
errored = true;
sendError(world, x, y, z, "Max size exceeded", player);
return;
}
@ -133,18 +159,32 @@ public class MachinePWRController extends BlockContainer {
if(isValidCore(block)) {
assembly.put(pos, block);
if(block == ModBlocks.pwr_fuel) fuelRods.put(pos, block);
floodFill(world, x + 1, y, z);
floodFill(world, x - 1, y, z);
floodFill(world, x, y + 1, z);
floodFill(world, x, y - 1, z);
floodFill(world, x, y, z + 1);
floodFill(world, x, y, z - 1);
floodFill(world, x + 1, y, z, player);
floodFill(world, x - 1, y, z, player);
floodFill(world, x, y + 1, z, player);
floodFill(world, x, y - 1, z, player);
floodFill(world, x, y, z + 1, player);
floodFill(world, x, y, z - 1, player);
return;
}
sendError(world, x, y, z, "Non-reactor block", player);
errored = true;
}
private void sendError(World world, int x, int y, int z, String message, EntityPlayer player) {
if(player instanceof EntityPlayerMP) {
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "marker");
data.setInteger("color", 0xff0000);
data.setInteger("expires", 5_000);
data.setDouble("dist", 128D);
if(message != null) data.setString("label", message);
PacketDispatcher.wrapper.sendTo(new AuxParticlePacketNT(data, x, y, z), (EntityPlayerMP) player);
}
}
private boolean isValidCore(Block block) {
if(block == ModBlocks.pwr_fuel || block == ModBlocks.pwr_control || block == ModBlocks.pwr_channel || block == ModBlocks.pwr_heatex || block == ModBlocks.pwr_neutron_source) return true;
return false;

View File

@ -0,0 +1,76 @@
package com.hbm.inventory.container;
import com.hbm.inventory.SlotCraftingOutput;
import com.hbm.items.machine.IItemFluidIdentifier;
import com.hbm.tileentity.machine.TileEntityPWRController;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerPWR extends Container {
TileEntityPWRController controller;
public ContainerPWR(InventoryPlayer invPlayer, TileEntityPWRController controller) {
this.controller = controller;
this.addSlotToContainer(new Slot(controller, 0, 53, 5));
this.addSlotToContainer(new SlotCraftingOutput(invPlayer.player, controller, 1, 89, 32));
this.addSlotToContainer(new Slot(controller, 2, 8, 59));
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 108 + i * 18));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 164));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2) {
ItemStack var3 = null;
Slot var4 = (Slot) this.inventorySlots.get(par2);
if(var4 != null && var4.getHasStack()) {
ItemStack var5 = var4.getStack();
var3 = var5.copy();
if(par2 <= 2) {
if(!this.mergeItemStack(var5, 3, this.inventorySlots.size(), true)) {
return null;
}
} else {
if(var3.getItem() instanceof IItemFluidIdentifier) {
if(!this.mergeItemStack(var5, 2, 3, false)) {
return null;
}
} else {
if(!this.mergeItemStack(var5, 0, 1, false)) {
return null;
}
}
}
if(var5.stackSize == 0) {
var4.putStack((ItemStack) null);
} else {
var4.onSlotChanged();
}
}
return var3;
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return controller.isUseableByPlayer(player);
}
}

View File

@ -489,8 +489,9 @@ public class Fluids {
HOTOIL.addTraits(new FT_Coolable(OIL, 1, 1, 10).setEff(CoolingType.HEATEXCHANGER, 1.0D));
HOTCRACKOIL.addTraits(new FT_Coolable(CRACKOIL, 1, 1, 10).setEff(CoolingType.HEATEXCHANGER, 1.0D));
COOLANT.addTraits(new FT_Heatable().setEff(HeatingType.HEATEXCHANGER, 1.0D).addStep(300, 1, COOLANT_HOT, 1));
COOLANT.addTraits(new FT_Heatable().setEff(HeatingType.PWR, 1.0D).addStep(300, 1, COOLANT_HOT, 1));
COOLANT_HOT.addTraits(new FT_Coolable(COOLANT, 1, 1, 300).setEff(CoolingType.HEATEXCHANGER, 1.0D));
MUG.addTraits(new FT_Heatable().setEff(HeatingType.HEATEXCHANGER, 1.0D).addStep(400, 1, MUG_HOT, 1));

View File

@ -69,7 +69,8 @@ public class FT_Heatable extends FluidTrait {
public static enum HeatingType {
BOILER("Boilable"),
HEATEXCHANGER("Heatable");
HEATEXCHANGER("Heatable"),
PWR("PWR Coolant");
public String name;

View File

@ -0,0 +1,66 @@
package com.hbm.inventory.gui;
import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerPWR;
import com.hbm.lib.RefStrings;
import com.hbm.render.util.GaugeUtil;
import com.hbm.render.util.GaugeUtil.Gauge;
import com.hbm.tileentity.machine.TileEntityPWRController;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
public class GUIPWR extends GuiInfoContainer {
protected TileEntityPWRController controller;
private final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/reactors/gui_pwr.png");
public GUIPWR(InventoryPlayer inventory, TileEntityPWRController controller) {
super(new ContainerPWR(inventory, controller));
this.controller = controller;
this.xSize = 176;
this.ySize = 188;
}
@Override
public void drawScreen(int x, int y, float interp) {
super.drawScreen(x, y, interp);
this.drawCustomInfoStat(x, y, guiLeft + 115, guiTop + 31, 18, 18, x, y, new String[] { "Core: " + String.format("%,d", controller.coreHeat) + " / " + String.format("%,d", controller.coreHeatCapacity) + " TU" });
this.drawCustomInfoStat(x, y, guiLeft + 151, guiTop + 31, 18, 18, x, y, new String[] { "Hull: " + String.format("%,d", controller.hullHeat) + " / " + String.format("%,d", controller.hullHeatCapacity) + " TU" });
int timeLeft = (controller.processTime - controller.progress) / 20;
this.drawCustomInfoStat(x, y, guiLeft + 52, guiTop + 31, 36, 18, x, y, new String[] { "Cycle: " + (timeLeft / 60) + ":" + String.format("%02d", timeLeft % 60)});
controller.tanks[0].renderTankInfo(this, x, y, guiLeft + 8, guiTop + 5, 16, 52);
controller.tanks[1].renderTankInfo(this, x, y, guiLeft + 26, guiTop + 5, 16, 52);
}
@Override
protected void drawGuiContainerForegroundLayer(int i, int j) {
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
double scale = 1.25;
String flux = String.format("%,.1f", 10000.0D);
GL11.glScaled(1 / scale, 1 / scale, 1);
this.fontRendererObj.drawString(flux, (int) (165 * scale - this.fontRendererObj.getStringWidth(flux)), (int)(64 * scale), 0x00ff00);
GL11.glScaled(scale, scale, 1);
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
if(System.currentTimeMillis() % 1000 < 500)
drawTexturedModalRect(guiLeft + 147, guiTop, 176, 14, 26, 26);
GaugeUtil.renderGauge(Gauge.ROUND_SMALL, guiLeft + 115, guiTop + 31, this.zLevel, 0.1D);
GaugeUtil.renderGauge(Gauge.ROUND_SMALL, guiLeft + 151, guiTop + 31, this.zLevel, 0.4D);
}
}

View File

@ -21,6 +21,7 @@ import com.hbm.items.machine.*;
import com.hbm.items.machine.ItemFELCrystal.EnumWavelengths;
import com.hbm.items.machine.ItemMachineUpgrade.UpgradeType;
import com.hbm.items.machine.ItemPlateFuel.FunctionEnum;
import com.hbm.items.machine.ItemPWRFuel.EnumPWRFuel;
import com.hbm.items.machine.ItemRBMKRod.EnumBurnFunc;
import com.hbm.items.machine.ItemRBMKRod.EnumDepleteFunc;
import com.hbm.items.machine.ItemRTGPelletDepleted.DepletedRTGMaterial;
@ -1103,6 +1104,10 @@ public class ModItems {
public static Item plate_fuel_sa326;
public static Item plate_fuel_ra226be;
public static Item plate_fuel_pu238be;
public static Item pwr_fuel;
public static Item pwr_fuel_hot;
public static Item pwr_fuel_depleted;
public static Item rbmk_lid;
public static Item rbmk_lid_glass;
@ -3547,6 +3552,10 @@ public class ModItems {
plate_fuel_sa326 = new ItemPlateFuel(2000000).setFunction(FunctionEnum.LINEAR, 80).setUnlocalizedName("plate_fuel_sa326").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":plate_fuel_sa326");
plate_fuel_ra226be = new ItemPlateFuel(1300000).setFunction(FunctionEnum.PASSIVE, 30).setUnlocalizedName("plate_fuel_ra226be").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":plate_fuel_ra226be");
plate_fuel_pu238be = new ItemPlateFuel(1000000).setFunction(FunctionEnum.PASSIVE, 50).setUnlocalizedName("plate_fuel_pu238be").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":plate_fuel_pu238be");
pwr_fuel = new ItemPWRFuel().setUnlocalizedName("pwr_fuel").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pwr_fuel");
pwr_fuel_hot = new ItemEnumMulti(EnumPWRFuel.class, true, false).setUnlocalizedName("pwr_fuel_hot").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pwr_fuel_hot");
pwr_fuel_depleted = new ItemEnumMulti(EnumPWRFuel.class, true, false).setUnlocalizedName("pwr_fuel_depleted").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pwr_fuel_depleted");
rbmk_lid = new ItemRBMKLid().setUnlocalizedName("rbmk_lid").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":rbmk_lid");
rbmk_lid_glass = new ItemRBMKLid().setUnlocalizedName("rbmk_lid_glass").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":rbmk_lid_glass");
@ -6640,6 +6649,11 @@ public class ModItems {
GameRegistry.registerItem(plate_fuel_ra226be, plate_fuel_ra226be.getUnlocalizedName());
GameRegistry.registerItem(plate_fuel_pu238be, plate_fuel_pu238be.getUnlocalizedName());
//PWR Parts
GameRegistry.registerItem(pwr_fuel, pwr_fuel.getUnlocalizedName());
GameRegistry.registerItem(pwr_fuel_hot, pwr_fuel_hot.getUnlocalizedName());
GameRegistry.registerItem(pwr_fuel_depleted, pwr_fuel_depleted.getUnlocalizedName());
//RBMK parts
GameRegistry.registerItem(rbmk_lid, rbmk_lid.getUnlocalizedName());
GameRegistry.registerItem(rbmk_lid_glass, rbmk_lid_glass.getUnlocalizedName());

View File

@ -0,0 +1,26 @@
package com.hbm.items.machine;
import com.hbm.items.ItemEnumMulti;
public class ItemPWRFuel extends ItemEnumMulti {
public ItemPWRFuel() {
super(EnumPWRFuel.class, true, true);
}
public static enum EnumPWRFuel {
MEU,
HEU233,
HEU235,
MEN,
HEN237,
MOX,
MEP,
HEP239,
HEP241,
MEA,
HEA242,
HES326,
HES327;
}
}

View File

@ -14,6 +14,7 @@ import com.hbm.blocks.generic.BlockLoot.TileEntityLoot;
import com.hbm.blocks.generic.BlockMotherOfAllOres.TileEntityRandomOre;
import com.hbm.blocks.generic.BlockSnowglobe.TileEntitySnowglobe;
import com.hbm.blocks.generic.PartEmitter.TileEntityPartEmitter;
import com.hbm.blocks.machine.BlockPWR.TileEntityBlockPWR;
import com.hbm.blocks.machine.MachineCapacitor.TileEntityCapacitor;
import com.hbm.blocks.machine.MachineFan.TileEntityFan;
import com.hbm.blocks.machine.PistonInserter.TileEntityPistonInserter;
@ -216,6 +217,9 @@ public class TileMappings {
put(TileEntityRandomOre.class, "tileentity_mother_of_all_ores");
put(TileEntityBedrockOre.class, "tileentity_bedrock_ore");
put(TileEntityBlockPWR.class, "tileentity_block_pwr");
put(TileEntityPWRController.class, "tileentity_pwr_controller");
putNetwork();
putBombs();

View File

@ -132,32 +132,19 @@ public class TileEntityDiFurnace extends TileEntityMachinePolluting implements I
}
public boolean canProcess() {
if(slots[0] == null || slots[1] == null) {
return false;
}
if(slots[0] == null || slots[1] == null) return false;
if(!this.hasPower()) return false;
if(!this.hasPower()) {
return false;
}
ItemStack itemStack = BlastFurnaceRecipes.getOutput(slots[0], slots[1]);
if(itemStack == null) {
return false;
}
ItemStack output = BlastFurnaceRecipes.getOutput(slots[0], slots[1]);
if(output == null) return false;
if(slots[3] == null) return true;
if(!slots[3].isItemEqual(output)) return false;
if(slots[3] == null) {
if(slots[3].stackSize + output.stackSize <= slots[3].getMaxStackSize()) {
return true;
}
if(!slots[3].isItemEqual(itemStack)) {
return false;
}
if(slots[3].stackSize < getInventoryStackLimit() && slots[3].stackSize < slots[3].getMaxStackSize()) {
return true;
} else {
return slots[3].stackSize < itemStack.getMaxStackSize();
}
return false;
}
private void processItem() {

View File

@ -0,0 +1,173 @@
package com.hbm.tileentity.machine;
import java.util.HashMap;
import java.util.Map.Entry;
import com.hbm.blocks.ModBlocks;
import com.hbm.inventory.container.ContainerPWR;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.inventory.fluid.trait.FT_Heatable;
import com.hbm.inventory.fluid.trait.FT_Heatable.HeatingType;
import com.hbm.inventory.gui.GUIPWR;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.TileEntityMachineBase;
import com.hbm.util.fauxpointtwelve.BlockPos;
import net.minecraft.block.Block;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityPWRController extends TileEntityMachineBase implements IGUIProvider {
public FluidTank[] tanks;
public int coreHeat;
public int coreHeatCapacity;
public int hullHeat;
public int hullHeatCapacity;
public int rodLevel;
public int rodTarget;
public int progress;
public int processTime;
public int rodCount;
public int connections;
public int connectionsControlled;
public int heatexCount;
public int channelCount;
public int sourceCount;
public boolean assembled;
public TileEntityPWRController() {
super(3);
this.tanks = new FluidTank[2];
this.tanks[0] = new FluidTank(Fluids.COOLANT, 128_000);
this.tanks[1] = new FluidTank(Fluids.COOLANT_HOT, 128_000);
}
public void setup(HashMap<BlockPos, Block> partMap, HashMap<BlockPos, Block> rodMap) {
rodCount = 0;
connections = 0;
connectionsControlled = 0;
heatexCount = 0;
channelCount = 0;
sourceCount = 0;
int connectionsDouble = 0;
int connectionsControlledDouble = 0;
for(Entry<BlockPos, Block> entry : partMap.entrySet()) {
Block block = entry.getValue();
if(block == ModBlocks.pwr_fuel) rodCount++;
if(block == ModBlocks.pwr_heatex) heatexCount++;
if(block == ModBlocks.pwr_channel) channelCount++;
if(block == ModBlocks.pwr_neutron_source) sourceCount++;
}
for(Entry<BlockPos, Block> entry : rodMap.entrySet()) {
BlockPos fuelPos = entry.getKey();
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
boolean controlled = false;
for(int i = 1; i < 16; i++) {
BlockPos checkPos = fuelPos.offset(dir, i);
Block atPos = partMap.get(checkPos);
if(atPos == null || atPos == ModBlocks.pwr_casing) break;
if(atPos == ModBlocks.pwr_control) controlled = true;
if(atPos == ModBlocks.pwr_fuel) {
if(controlled) {
connectionsControlledDouble++;
} else {
connectionsDouble++;
}
break;
}
if(atPos == ModBlocks.pwr_reflector) {
if(controlled) {
connectionsControlledDouble += 2;
} else {
connectionsDouble += 2;
}
break;
}
}
}
}
connections = connectionsDouble / 2;
connectionsControlled = connectionsControlledDouble / 2;
System.out.println("Finalized nuclear reactor!");
System.out.println("Rods: " + rodCount);
System.out.println("Connections: " + connections);
System.out.println("Controlled connections: " + connectionsControlled);
System.out.println("Heatex: " + heatexCount);
System.out.println("Channels: " + channelCount);
System.out.println("Sources: " + sourceCount);
}
@Override
public String getName() {
return "container.pwrController";
}
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
this.tanks[0].setType(2, slots);
setupTanks();
NBTTagCompound data = new NBTTagCompound();
tanks[0].writeToNBT(data, "t0");
tanks[1].writeToNBT(data, "t1");
}
}
protected void setupTanks() {
FT_Heatable trait = tanks[0].getTankType().getTrait(FT_Heatable.class);
if(trait == null || trait.getEfficiency(HeatingType.PWR) <= 0) {
tanks[0].setTankType(Fluids.NONE);
tanks[1].setTankType(Fluids.NONE);
}
tanks[1].setTankType(trait.getFirstStep().typeProduced);
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.assembled = nbt.getBoolean("assembled");
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setBoolean("assembled", assembled);
}
@Override
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new ContainerPWR(player.inventory, this);
}
@Override
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new GUIPWR(player.inventory, this);
}
}

View File

@ -2,8 +2,6 @@ package com.hbm.tileentity.machine.rbmk;
import api.hbm.fluid.IFluidStandardReceiver;
import com.hbm.blocks.machine.rbmk.RBMKBase;
import com.hbm.interfaces.IFluidAcceptor;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.tileentity.TileEntityLoadedBase;
@ -13,12 +11,12 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityRBMKInlet extends TileEntityLoadedBase implements IFluidAcceptor, IFluidStandardReceiver {
public class TileEntityRBMKInlet extends TileEntityLoadedBase implements IFluidStandardReceiver {
public FluidTank water;
public TileEntityRBMKInlet() {
water = new FluidTank(Fluids.WATER, 32000, 0);
water = new FluidTank(Fluids.WATER, 32000);
}
@Override
@ -63,33 +61,6 @@ public class TileEntityRBMKInlet extends TileEntityLoadedBase implements IFluidA
this.water.writeToNBT(nbt, "tank");
}
@Override
public void setFillForSync(int fill, int index) {
if(index == 0) water.setFill(fill);
}
@Override
public void setFluidFill(int fill, FluidType type) {
if(type == Fluids.WATER) water.setFill(fill);
}
@Override
public void setTypeForSync(FluidType type, int index) {
if(index == 0) water.setTankType(type);
}
@Override
public int getFluidFill(FluidType type) {
if(type == Fluids.WATER) return water.getFill();
return 0;
}
@Override
public int getMaxFluidFill(FluidType type) {
if(type == Fluids.WATER) return water.getMaxFill();
return 0;
}
@Override
public FluidTank[] getAllTanks() {
return new FluidTank[] {water};

View File

@ -1,16 +1,9 @@
package com.hbm.tileentity.machine.rbmk;
import java.util.ArrayList;
import java.util.List;
import api.hbm.fluid.IFluidStandardSender;
import com.hbm.blocks.machine.rbmk.RBMKBase;
import com.hbm.interfaces.IFluidAcceptor;
import com.hbm.interfaces.IFluidSource;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.lib.Library;
import com.hbm.tileentity.TileEntityLoadedBase;
import net.minecraft.block.Block;
@ -18,13 +11,12 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityRBMKOutlet extends TileEntityLoadedBase implements IFluidSource, IFluidStandardSender {
public class TileEntityRBMKOutlet extends TileEntityLoadedBase implements IFluidStandardSender {
public List<IFluidAcceptor> list = new ArrayList();
public FluidTank steam;
public TileEntityRBMKOutlet() {
steam = new FluidTank(Fluids.SUPERHOTSTEAM, 32000, 0);
steam = new FluidTank(Fluids.SUPERHOTSTEAM, 32000);
}
@Override
@ -53,8 +45,7 @@ public class TileEntityRBMKOutlet extends TileEntityLoadedBase implements IFluid
}
}
fillFluidInit(this.steam.getTankType());
this.sendFluidToAll(steam, this);
fillFluidInit();
}
}
@ -70,49 +61,9 @@ public class TileEntityRBMKOutlet extends TileEntityLoadedBase implements IFluid
this.steam.writeToNBT(nbt, "tank");
}
@Override
public void setFillForSync(int fill, int index) {
steam.setFill(fill);
}
@Override
public void setFluidFill(int fill, FluidType type) {
steam.setFill(fill);
}
@Override
public void setTypeForSync(FluidType type, int index) {
steam.setTankType(type);
}
@Override
public int getFluidFill(FluidType type) {
return steam.getFill();
}
@Override
public void fillFluidInit(FluidType type) {
public void fillFluidInit() {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
fillFluid(this.xCoord + dir.offsetX, this.yCoord + dir.offsetY, this.zCoord + dir.offsetZ, getTact(), type);
}
@Override
public void fillFluid(int x, int y, int z, boolean newTact, FluidType type) {
Library.transmitFluid(x, y, z, newTact, this, worldObj, type);
}
@Override
@Deprecated
public boolean getTact() { return worldObj.getTotalWorldTime() % 2 == 0; }
@Override
public List<IFluidAcceptor> getFluidList(FluidType type) {
return this.list;
}
@Override
public void clearFluidList(FluidType type) {
this.list.clear();
this.sendFluid(steam, worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
}
@Override

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 412 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 419 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B