mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
universal analysis tool, pipe debugging
This commit is contained in:
parent
60c4684158
commit
dcfa7fe811
@ -1,9 +1,12 @@
|
|||||||
package api.hbm.fluid;
|
package api.hbm.fluid;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import com.hbm.inventory.fluid.FluidType;
|
import com.hbm.inventory.fluid.FluidType;
|
||||||
|
|
||||||
@ -18,6 +21,7 @@ public class PipeNet implements IPipeNet {
|
|||||||
|
|
||||||
public static List<PipeNet> trackingInstances = null;
|
public static List<PipeNet> trackingInstances = null;
|
||||||
protected BigInteger totalTransfer = BigInteger.ZERO;
|
protected BigInteger totalTransfer = BigInteger.ZERO;
|
||||||
|
public List<String> debug = new ArrayList();
|
||||||
|
|
||||||
public PipeNet(FluidType type) {
|
public PipeNet(FluidType type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
@ -124,6 +128,15 @@ public class PipeNet implements IPipeNet {
|
|||||||
long given = (long) Math.floor(fraction * fill);
|
long given = (long) Math.floor(fraction * fill);
|
||||||
|
|
||||||
totalGiven += (given - con.transferFluid(type, pressure, given));
|
totalGiven += (given - con.transferFluid(type, pressure, given));
|
||||||
|
|
||||||
|
if(trackingInstances != null) {
|
||||||
|
for(int j = 0; j < trackingInstances.size(); j++) {
|
||||||
|
PipeNet net = trackingInstances.get(j);
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss:SSS");
|
||||||
|
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
|
log(net, sdf.format(new Date(System.currentTimeMillis())) + " Sending " + given + "mB to " + conToString(con));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(trackingInstances != null) {
|
if(trackingInstances != null) {
|
||||||
@ -162,4 +175,22 @@ public class PipeNet implements IPipeNet {
|
|||||||
public BigInteger getTotalTransfer() {
|
public BigInteger getTotalTransfer() {
|
||||||
return this.totalTransfer;
|
return this.totalTransfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void log(PipeNet net, String msg) {
|
||||||
|
net.debug.add(msg);
|
||||||
|
|
||||||
|
while(net.debug.size() > 50) {
|
||||||
|
net.debug.remove(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String conToString(IFluidConnector con) {
|
||||||
|
|
||||||
|
if(con instanceof TileEntity) {
|
||||||
|
TileEntity tile = (TileEntity) con;
|
||||||
|
return tile.getClass().getSimpleName() + " @ " + tile.xCoord + "/" + tile.yCoord + "/" + tile.zCoord;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "" + con;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10
src/main/java/com/hbm/blocks/IAnalyzable.java
Normal file
10
src/main/java/com/hbm/blocks/IAnalyzable.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package com.hbm.blocks;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public interface IAnalyzable {
|
||||||
|
|
||||||
|
public List<String> getDebugInfo(World world, int x, int y, int z);
|
||||||
|
}
|
||||||
@ -1,9 +1,15 @@
|
|||||||
package com.hbm.blocks.network;
|
package com.hbm.blocks.network;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.hbm.blocks.IAnalyzable;
|
||||||
import com.hbm.inventory.fluid.FluidType;
|
import com.hbm.inventory.fluid.FluidType;
|
||||||
import com.hbm.items.machine.IItemFluidIdentifier;
|
import com.hbm.items.machine.IItemFluidIdentifier;
|
||||||
import com.hbm.tileentity.network.TileEntityPipeBaseNT;
|
import com.hbm.tileentity.network.TileEntityPipeBaseNT;
|
||||||
|
|
||||||
|
import api.hbm.fluid.IPipeNet;
|
||||||
|
import api.hbm.fluid.PipeNet;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockContainer;
|
import net.minecraft.block.BlockContainer;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
@ -12,7 +18,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class FluidDuctBase extends BlockContainer implements IBlockFluidDuct {
|
public class FluidDuctBase extends BlockContainer implements IBlockFluidDuct, IAnalyzable {
|
||||||
|
|
||||||
public FluidDuctBase(Material mat) {
|
public FluidDuctBase(Material mat) {
|
||||||
super(mat);
|
super(mat);
|
||||||
@ -80,4 +86,35 @@ public class FluidDuctBase extends BlockContainer implements IBlockFluidDuct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getDebugInfo(World world, int x, int y, int z) {
|
||||||
|
|
||||||
|
TileEntity te = world.getTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if(te instanceof TileEntityPipeBaseNT) {
|
||||||
|
TileEntityPipeBaseNT pipe = (TileEntityPipeBaseNT) te;
|
||||||
|
FluidType type = pipe.getType();
|
||||||
|
|
||||||
|
if(type != null) {
|
||||||
|
|
||||||
|
IPipeNet net = pipe.getPipeNet(type);
|
||||||
|
|
||||||
|
if(net instanceof PipeNet) {
|
||||||
|
PipeNet pipeNet = (PipeNet) net;
|
||||||
|
|
||||||
|
List<String> debug = new ArrayList();
|
||||||
|
debug.add("=== DEBUG START ===");
|
||||||
|
debug.addAll(pipeNet.debug);
|
||||||
|
debug.add("=== DEBUG END ===");
|
||||||
|
debug.add("Links: " + pipeNet.getLinks().size());
|
||||||
|
debug.add("Subscribers: " + pipeNet.getSubscribers().size());
|
||||||
|
debug.add("Transfer: " + pipeNet.getTotalTransfer());
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1260,6 +1260,7 @@ public class ModItems {
|
|||||||
public static Item rbmk_tool;
|
public static Item rbmk_tool;
|
||||||
public static Item coltan_tool;
|
public static Item coltan_tool;
|
||||||
public static Item power_net_tool;
|
public static Item power_net_tool;
|
||||||
|
public static Item analysis_tool;
|
||||||
public static Item coupling_tool;
|
public static Item coupling_tool;
|
||||||
|
|
||||||
public static Item template_folder;
|
public static Item template_folder;
|
||||||
@ -4591,6 +4592,7 @@ public class ModItems {
|
|||||||
rbmk_tool = new ItemRBMKTool().setUnlocalizedName("rbmk_tool").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":rbmk_tool");
|
rbmk_tool = new ItemRBMKTool().setUnlocalizedName("rbmk_tool").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":rbmk_tool");
|
||||||
coltan_tool = new ItemColtanCompass().setUnlocalizedName("coltan_tool").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":coltass");
|
coltan_tool = new ItemColtanCompass().setUnlocalizedName("coltan_tool").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":coltass");
|
||||||
power_net_tool = new ItemPowerNetTool().setUnlocalizedName("power_net_tool").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":power_net_tool");
|
power_net_tool = new ItemPowerNetTool().setUnlocalizedName("power_net_tool").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":power_net_tool");
|
||||||
|
analysis_tool = new ItemAnalysisTool().setUnlocalizedName("analysis_tool").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":analysis_tool");
|
||||||
coupling_tool = new ItemCouplingTool().setUnlocalizedName("coupling_tool").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":coupling_tool");
|
coupling_tool = new ItemCouplingTool().setUnlocalizedName("coupling_tool").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":coupling_tool");
|
||||||
|
|
||||||
key = new ItemKey().setUnlocalizedName("key").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":key");
|
key = new ItemKey().setUnlocalizedName("key").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":key");
|
||||||
@ -6754,6 +6756,7 @@ public class ModItems {
|
|||||||
GameRegistry.registerItem(rbmk_tool, rbmk_tool.getUnlocalizedName());
|
GameRegistry.registerItem(rbmk_tool, rbmk_tool.getUnlocalizedName());
|
||||||
GameRegistry.registerItem(coltan_tool, coltan_tool.getUnlocalizedName());
|
GameRegistry.registerItem(coltan_tool, coltan_tool.getUnlocalizedName());
|
||||||
GameRegistry.registerItem(power_net_tool, power_net_tool.getUnlocalizedName());
|
GameRegistry.registerItem(power_net_tool, power_net_tool.getUnlocalizedName());
|
||||||
|
GameRegistry.registerItem(analysis_tool, analysis_tool.getUnlocalizedName());
|
||||||
GameRegistry.registerItem(coupling_tool, coupling_tool.getUnlocalizedName());
|
GameRegistry.registerItem(coupling_tool, coupling_tool.getUnlocalizedName());
|
||||||
GameRegistry.registerItem(dosimeter, dosimeter.getUnlocalizedName());
|
GameRegistry.registerItem(dosimeter, dosimeter.getUnlocalizedName());
|
||||||
GameRegistry.registerItem(geiger_counter, geiger_counter.getUnlocalizedName());
|
GameRegistry.registerItem(geiger_counter, geiger_counter.getUnlocalizedName());
|
||||||
|
|||||||
48
src/main/java/com/hbm/items/tool/ItemAnalysisTool.java
Normal file
48
src/main/java/com/hbm/items/tool/ItemAnalysisTool.java
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package com.hbm.items.tool;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.hbm.blocks.BlockDummyable;
|
||||||
|
import com.hbm.blocks.IAnalyzable;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ChatComponentText;
|
||||||
|
import net.minecraft.util.ChatStyle;
|
||||||
|
import net.minecraft.util.EnumChatFormatting;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class ItemAnalysisTool extends Item {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float fX, float fY, float fZ) {
|
||||||
|
|
||||||
|
Block b = world.getBlock(x, y, z);
|
||||||
|
|
||||||
|
if(b instanceof BlockDummyable) {
|
||||||
|
int[] pos = ((BlockDummyable) b).findCore(world, x, y, z);
|
||||||
|
|
||||||
|
if(pos != null) {
|
||||||
|
x = pos[0];
|
||||||
|
y = pos[1];
|
||||||
|
z = pos[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(b instanceof IAnalyzable) {
|
||||||
|
List<String> debug = ((IAnalyzable) b).getDebugInfo(world, x, y, z);
|
||||||
|
|
||||||
|
if(debug != null && !world.isRemote) {
|
||||||
|
for(String line : debug) {
|
||||||
|
player.addChatComponentMessage(new ChatComponentText(line).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
src/main/resources/assets/hbm/textures/items/analysis_tool.png
Normal file
BIN
src/main/resources/assets/hbm/textures/items/analysis_tool.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 212 B |
Loading…
x
Reference in New Issue
Block a user