finished cable debugger, disabled bidirectional re-eval

This commit is contained in:
Boblet 2022-04-04 13:03:24 +02:00
parent 7cb0bec184
commit ce7e6d07b2
10 changed files with 68 additions and 35 deletions

View File

@ -5,7 +5,6 @@ import java.util.HashMap;
import java.util.List;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
import net.minecraftforge.common.util.ForgeDirection;
/**
@ -84,7 +83,7 @@ public interface IEnergyConductor extends IEnergyConnector {
}
//bidirectional re-eval, experimental and technically optional, only useful as a fallback
} else {
} /*else {
//no neighbor net and no self net
if(this.getPowerNet() == null) {
@ -94,7 +93,9 @@ public interface IEnergyConductor extends IEnergyConnector {
} else {
neighbor.setPowerNet(this.getPowerNet().joinLink(neighbor));
}
}
}*/
//extensive debugging has shown that bidirectional re-eval ic complete shit
}
}
}
@ -141,9 +142,19 @@ public interface IEnergyConductor extends IEnergyConnector {
return this.getPowerNet().transferPower(power);
}
public default Vec3 getDebugParticlePos() {
TileEntity te = (TileEntity) this;
Vec3 vec = Vec3.createVectorHelper(te.xCoord + 0.5, te.yCoord + 1.5, te.zCoord + 0.5);
return vec;
/**
* Returns whether the conductor has mutliblock proxies which need to be taken into consideration for re-eval.
* @return
*/
public default boolean hasProxies() {
return false;
}
/**
* Returns the identities (position-based) of proxies which resolve into the conductor's own identity.
* @return
*/
public default List<Integer> getProxies() {
return new ArrayList();
}
}

View File

@ -1,14 +1,12 @@
package api.hbm.energy;
import java.util.ArrayList;
import java.util.List;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@ -98,19 +96,9 @@ public interface IEnergyConnector extends ILoadedTile {
public static final boolean particleDebug = false;
/**
* Returns whether the conductor has mutliblock proxies which need to be taken into consideration for re-eval.
* @return
*/
public default boolean hasProxies() {
return false;
}
/**
* Returns the identities (position-based) of proxies which resolve into the conductor's own identity.
* @return
*/
public default List<Integer> getProxies() {
return new ArrayList();
public default Vec3 getDebugParticlePos() {
TileEntity te = (TileEntity) this;
Vec3 vec = Vec3.createVectorHelper(te.xCoord + 0.5, te.yCoord + 1, te.zCoord + 0.5);
return vec;
}
}

View File

@ -164,6 +164,8 @@ public class PowerNet implements IPowerNet {
@Override
public void reevaluate() {
//this.destroy();//
HashMap<Integer, IEnergyConductor> copy = new HashMap(links);
HashMap<Integer, Integer> proxyCopy = new HashMap(proxies);

View File

@ -137,6 +137,7 @@ public class ToolRecipes {
CraftingManager.addRecipeAuto(new ItemStack(ModItems.mirror_tool), new Object[] { " A ", " IA", "I ", 'A', AL.ingot(), 'I', IRON.ingot() });
CraftingManager.addRecipeAuto(new ItemStack(ModItems.rbmk_tool), new Object[] { " A ", " IA", "I ", 'A', PB.ingot(), 'I', IRON.ingot() });
CraftingManager.addRecipeAuto(new ItemStack(ModItems.power_net_tool), new Object[] { "WRW", " I ", " B ", 'W', ModItems.wire_red_copper, 'R', REDSTONE.dust(), 'I', IRON.ingot(), 'B', ModItems.battery_su });
CraftingManager.addRecipeAuto(new ItemStack(ModItems.kit_toolbox_empty), new Object[] { "CCC", "CIC", 'C', CU.plate(), 'I', IRON.ingot() });

View File

@ -1,11 +1,14 @@
package com.hbm.items.tool;
import java.util.List;
import com.hbm.blocks.BlockDummyable;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import com.hbm.util.ChatBuilder;
import api.hbm.energy.IEnergyConductor;
import api.hbm.energy.IEnergyConnector;
import api.hbm.energy.IPowerNet;
import api.hbm.energy.PowerNet;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
@ -59,23 +62,49 @@ public class ItemPowerNetTool extends Item {
PowerNet network = (PowerNet) net;
String id = Integer.toHexString(net.hashCode());
player.addChatComponentMessage(ChatBuilder.start("Start of diagnostic for network" + id).color(EnumChatFormatting.GOLD).flush());
player.addChatComponentMessage(ChatBuilder.start("Start of diagnostic for network " + id).color(EnumChatFormatting.GOLD).flush());
player.addChatComponentMessage(ChatBuilder.start("Links: " + network.getLinks().size()).color(EnumChatFormatting.YELLOW).flush());
player.addChatComponentMessage(ChatBuilder.start("Proxies: " + network.getProxies().size()).color(EnumChatFormatting.YELLOW).flush());
player.addChatComponentMessage(ChatBuilder.start("Subscribers: " + network.getSubscribers().size()).color(EnumChatFormatting.YELLOW).flush());
player.addChatComponentMessage(ChatBuilder.start("End of diagnostic for network" + id).color(EnumChatFormatting.GOLD).flush());
player.addChatComponentMessage(ChatBuilder.start("End of diagnostic for network " + id).color(EnumChatFormatting.GOLD).flush());
for(IEnergyConductor link : network.getLinks()) {
Vec3 pos = link.getDebugParticlePos();
boolean errored = link.getPowerNet() != net;
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "text");
data.setInteger("color", 0xffff00);
data.setString("type", "debug");
data.setInteger("color", errored ? 0xff0000 : 0xffff00);
data.setFloat("scale", 0.5F);
data.setString("text", id);
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, pos.xCoord, pos.yCoord, pos.zCoord), new TargetPoint(world.provider.dimensionId, pos.xCoord, pos.yCoord, pos.zCoord, 20));
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, pos.xCoord, pos.yCoord, pos.zCoord), new TargetPoint(world.provider.dimensionId, pos.xCoord, pos.yCoord, pos.zCoord, radius));
}
for(IEnergyConnector subscriber : network.getSubscribers()) {
Vec3 pos = subscriber.getDebugParticlePos();
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "debug");
data.setInteger("color", 0x0000ff);
data.setFloat("scale", 1.5F);
data.setString("text", id);
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, pos.xCoord, pos.yCoord, pos.zCoord), new TargetPoint(world.provider.dimensionId, pos.xCoord, pos.yCoord, pos.zCoord, radius));
}
return true;
}
private static final int radius = 20;
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) {
list.add(EnumChatFormatting.RED + "Right-click cable to analyze the power net.");
list.add(EnumChatFormatting.RED + "Links (cables, poles, etc.) are YELLOW");
list.add(EnumChatFormatting.RED + "Subscribers (any receiver) are BLUE");
list.add(EnumChatFormatting.RED + "Links with mismatching netowrk info (BUGGED!) are RED");
list.add(EnumChatFormatting.RED + "Displays stats such as link and subscriber count");
list.add(EnumChatFormatting.RED + "Proxies are connection points for multiblock links (e.g. 4 for substations)");
list.add(EnumChatFormatting.RED + "Particles only spawn in a " + radius + " block radius!");
}
}

View File

@ -62,7 +62,6 @@ import com.hbm.util.EntityDamageUtil;
import com.hbm.world.WorldProviderNTM;
import com.hbm.world.generator.TimedGenerator;
import api.hbm.energy.IEnergyConductor;
import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@ -1171,7 +1170,7 @@ public class ModEventHandler {
/// PU RADIATION END ///
if(player instanceof EntityPlayerMP) {
/*if(player instanceof EntityPlayerMP) {
int x = (int) Math.floor(player.posX);
int y = (int) Math.floor(player.posY - 0.01);
@ -1180,7 +1179,7 @@ public class ModEventHandler {
if(player.worldObj.getTileEntity(x, y, z) instanceof IEnergyConductor) {
PacketDispatcher.wrapper.sendTo(new PlayerInformPacket(((IEnergyConductor) player.worldObj.getTileEntity(x, y, z)).getPowerNet() + ""), (EntityPlayerMP) player);
}
}
}*/
/// NEW ITEM SYS START ///
HazardSystem.updatePlayerInventory(player);

View File

@ -17,11 +17,12 @@ public class ParticleText extends EntityFX {
public ParticleText(World world, double x, double y, double z, int color, String text) {
super(world, x, y, z);
this.particleMaxAge = 30;
this.particleMaxAge = 100;
this.color = color;
this.text = text;
this.motionY = 0.1D;
this.motionY = 0.01D;
this.noClip = true;
}
public int getFXLayer() {
@ -51,7 +52,7 @@ public class ParticleText extends EntityFX {
GL11.glRotatef(this.rotationPitch, 1.0F, 0.0F, 0.0F);
GL11.glScalef(-1.0F, -1.0F, 1.0F);
GL11.glScaled(particleScale, particleScale, particleScale);
GL11.glScaled(particleScale * 0.01, particleScale * 0.01, particleScale * 0.01);
font.drawStringWithShadow(text, -(int) (font.getStringWidth(text) * 0.5F), -(int) (font.FONT_HEIGHT * 0.5F), color);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

View File

@ -2262,6 +2262,7 @@ item.powder_xe135.name=Xenon-135-Staub
item.powder_xe135_tiny.name=Kleiner Haufen Xenon-135-Staub
item.powder_yellowcake.name=Yellowcake
item.powder_zirconium.name=Zirkoniumstaub
item.power_net_tool.name=Stromnetz-Analysewerkzeug
item.primer_357.name=.357 Magnum-Zündhütchen (x24)
item.primer_44.name=.44 Magnum-Zündhütchen (x24)
item.primer_50.name=Großkaliber-Zündhütchen (x12)

View File

@ -2570,6 +2570,7 @@ item.powder_xe135.name=Xenon-135 Powder
item.powder_xe135_tiny.name=Tiny Pile of Xenon-135 Powder
item.powder_yellowcake.name=Yellowcake
item.powder_zirconium.name=Zirconium Powder
item.power_net_tool.name=Cable Network Analysis Tool
item.primer_357.name=.357 Magnum Primer (x24)
item.primer_44.name=.44 Magnum Primer (x24)
item.primer_50.name=Large Caliber Primer (x12)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 321 B

After

Width:  |  Height:  |  Size: 368 B