mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
god finally i can get rid of this
Removed Analyzable implementation; terrible idea Fixed long-standing bug with proxy components, more NBT data!!!
This commit is contained in:
parent
9707c4c961
commit
9d0e02cc61
@ -2,20 +2,12 @@ package com.hbm.handler;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.tileentity.TileEntityProxyCombo;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import li.cil.oc.api.machine.Arguments;
|
||||
import li.cil.oc.api.machine.Context;
|
||||
import li.cil.oc.api.network.*;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
|
||||
|
||||
/**
|
||||
* General handler for OpenComputers compatibility.
|
||||
@ -54,11 +46,10 @@ public class CompatHandler {
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers"),
|
||||
@Optional.Interface(iface = "li.cil.oc.api.network.SidedComponent", modid = "OpenComputers"),
|
||||
@Optional.Interface(iface = "li.cil.oc.api.network.Analyzable", modid = "OpenComputers"),
|
||||
@Optional.Interface(iface = "li.cil.oc.api.network.ManagedPeripheral", modid = "OpenComputers"),
|
||||
})
|
||||
@SimpleComponent.SkipInjection // make sure OC doesn't inject this shit into the interface and crash
|
||||
public interface OCComponent extends SimpleComponent, SidedComponent, Analyzable, ManagedPeripheral {
|
||||
public interface OCComponent extends SimpleComponent, SidedComponent, ManagedPeripheral {
|
||||
|
||||
/**
|
||||
* Must be overridden in the implemented TE, or it will default to "ntm_null".
|
||||
@ -83,31 +74,6 @@ public class CompatHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to give more information when analyzing the block. Multiple entries in the array will be sent to the user in the order of the array.
|
||||
* @return Additional text to add in the form of lang entries (ex: "analyze.basic2").
|
||||
*/
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
default String[] getExtraInfo() {return new String[] {"analyze.noInfo"};}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
default Node[] onAnalyze(EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
player.addChatComponentMessage(new ChatComponentTranslation("analyze.basic1").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD)));
|
||||
player.addChatComponentMessage(new ChatComponentTranslation("analyze.basic2").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)));
|
||||
player.addChatComponentMessage(new ChatComponentTranslation("analyze.basic3").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD)));
|
||||
player.addChatComponentMessage(new ChatComponentTranslation("analyze.name", this.getComponentName()).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD)));
|
||||
String[] extraInfo = getExtraInfo();
|
||||
for (String info : extraInfo) {
|
||||
if(!info.equals(""))
|
||||
player.addChatComponentMessage(new ChatComponentTranslation(info).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)));
|
||||
}
|
||||
TileEntity te = (TileEntity) this;
|
||||
if((Array.getLength(this.methods()) == 0 && te instanceof TileEntityProxyCombo) || this.getComponentName().equals("ntm_null"))
|
||||
player.addChatComponentMessage(new ChatComponentTranslation("analyze.error").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard methods array from {@link li.cil.oc.api.network.ManagedPeripheral} extending {@link li.cil.oc.api.network.SimpleComponent}.
|
||||
* @return Array of methods to expose to the computer.
|
||||
|
||||
@ -8,6 +8,7 @@ import api.hbm.energymk2.IEnergyReceiverMK2;
|
||||
import api.hbm.fluid.IFluidConnector;
|
||||
import api.hbm.tile.IHeatSource;
|
||||
import com.hbm.inventory.material.Mats;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import li.cil.oc.api.machine.Arguments;
|
||||
import li.cil.oc.api.machine.Context;
|
||||
@ -32,7 +33,11 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy
|
||||
boolean fluid;
|
||||
boolean heat;
|
||||
public boolean moltenMetal;
|
||||
|
||||
|
||||
// due to some issues with OC deciding that it's gonna call the component name function before the worldObj is loaded
|
||||
// the component name must be cached to prevent it from shitting itself
|
||||
String componentName = OCComponent.super.getComponentName();
|
||||
|
||||
public TileEntityProxyCombo() { }
|
||||
|
||||
public TileEntityProxyCombo(boolean inventory, boolean power, boolean fluid) {
|
||||
@ -344,6 +349,9 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy
|
||||
this.fluid = nbt.getBoolean("fluid");
|
||||
this.moltenMetal = nbt.getBoolean("metal");
|
||||
this.heat = nbt.getBoolean("heat");
|
||||
if(Loader.isModLoaded("OpenComputers"))
|
||||
this.componentName = nbt.getString("ocname");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -355,6 +363,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy
|
||||
nbt.setBoolean("fluid", fluid);
|
||||
nbt.setBoolean("metal", moltenMetal);
|
||||
nbt.setBoolean("heat", heat);
|
||||
if(Loader.isModLoaded("OpenComputers"))
|
||||
nbt.setString("ocname", componentName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -452,27 +462,27 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy
|
||||
@Override // please work
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public String getComponentName() {
|
||||
if(this.getTile() instanceof OCComponent)
|
||||
return ((OCComponent) this.getTile()).getComponentName();
|
||||
if(this.worldObj == null) // OC is going too fast, grab from NBT!
|
||||
return componentName;
|
||||
if(this.getTile() instanceof OCComponent) {
|
||||
if (componentName == null || componentName.equals(OCComponent.super.getComponentName())) {
|
||||
componentName = ((OCComponent) this.getTile()).getComponentName();
|
||||
}
|
||||
return componentName;
|
||||
}
|
||||
return OCComponent.super.getComponentName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public boolean canConnectNode(ForgeDirection side) { //thank you vaer
|
||||
public boolean canConnectNode(ForgeDirection side) {
|
||||
if(this.getTile() instanceof OCComponent)
|
||||
return (this.getTile().getBlockMetadata() & 6) == 6 && ((OCComponent) this.getTile()).canConnectNode(side);
|
||||
return (this.getBlockMetadata() >= 6 && this.getBlockMetadata() <= 11)
|
||||
&& (power || fluid) &&
|
||||
((OCComponent) this.getTile()).canConnectNode(side);
|
||||
return OCComponent.super.canConnectNode(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public String[] getExtraInfo() {
|
||||
if(this.getTile() instanceof OCComponent)
|
||||
return new String[] {"analyze.dummy"};
|
||||
return OCComponent.super.getExtraInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public String[] methods() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user