reformatted all src files (#141)
This commit is contained in:
@@ -19,32 +19,25 @@
|
||||
package appeng.integration;
|
||||
|
||||
|
||||
public interface IIntegrationModule
|
||||
{
|
||||
public interface IIntegrationModule {
|
||||
|
||||
default boolean isEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
default boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
default void preInit() throws Throwable
|
||||
{
|
||||
}
|
||||
default void preInit() throws Throwable {
|
||||
}
|
||||
|
||||
default void init() throws Throwable
|
||||
{
|
||||
}
|
||||
default void init() throws Throwable {
|
||||
}
|
||||
|
||||
default void postInit()
|
||||
{
|
||||
}
|
||||
default void postInit() {
|
||||
}
|
||||
|
||||
class Stub implements IIntegrationModule
|
||||
{
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
class Stub implements IIntegrationModule {
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,9 @@
|
||||
package appeng.integration;
|
||||
|
||||
|
||||
public class IntegrationHelper
|
||||
{
|
||||
public class IntegrationHelper {
|
||||
|
||||
public static void testClassExistence( final Object o, final Class<?> clz )
|
||||
{
|
||||
clz.isInstance( o );
|
||||
}
|
||||
public static void testClassExistence(final Object o, final Class<?> clz) {
|
||||
clz.isInstance(o);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,142 +19,116 @@
|
||||
package appeng.integration;
|
||||
|
||||
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.ModAPIManager;
|
||||
|
||||
import appeng.api.exceptions.ModNotInstalledException;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.ModAPIManager;
|
||||
|
||||
|
||||
final class IntegrationNode
|
||||
{
|
||||
final class IntegrationNode {
|
||||
|
||||
private final String displayName;
|
||||
private final String modID;
|
||||
private final IntegrationType type;
|
||||
private IntegrationStage state = IntegrationStage.PRE_INIT;
|
||||
private Throwable exception = null;
|
||||
private IIntegrationModule mod = null;
|
||||
private final String displayName;
|
||||
private final String modID;
|
||||
private final IntegrationType type;
|
||||
private IntegrationStage state = IntegrationStage.PRE_INIT;
|
||||
private Throwable exception = null;
|
||||
private IIntegrationModule mod = null;
|
||||
|
||||
IntegrationNode( final String displayName, final String modID, final IntegrationType type )
|
||||
{
|
||||
this.displayName = displayName;
|
||||
this.type = type;
|
||||
this.modID = modID;
|
||||
}
|
||||
IntegrationNode(final String displayName, final String modID, final IntegrationType type) {
|
||||
this.displayName = displayName;
|
||||
this.type = type;
|
||||
this.modID = modID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.getType().name() + ':' + this.getState().name();
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getType().name() + ':' + this.getState().name();
|
||||
}
|
||||
|
||||
boolean isActive()
|
||||
{
|
||||
if( this.getState() == IntegrationStage.PRE_INIT )
|
||||
{
|
||||
this.call( IntegrationStage.PRE_INIT );
|
||||
}
|
||||
boolean isActive() {
|
||||
if (this.getState() == IntegrationStage.PRE_INIT) {
|
||||
this.call(IntegrationStage.PRE_INIT);
|
||||
}
|
||||
|
||||
return this.getState() != IntegrationStage.FAILED;
|
||||
}
|
||||
return this.getState() != IntegrationStage.FAILED;
|
||||
}
|
||||
|
||||
void call( final IntegrationStage stage )
|
||||
{
|
||||
if( this.getState() != IntegrationStage.FAILED )
|
||||
{
|
||||
if( this.getState().ordinal() > stage.ordinal() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
void call(final IntegrationStage stage) {
|
||||
if (this.getState() != IntegrationStage.FAILED) {
|
||||
if (this.getState().ordinal() > stage.ordinal()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
switch( stage )
|
||||
{
|
||||
case PRE_INIT:
|
||||
final ModAPIManager apiManager = ModAPIManager.INSTANCE;
|
||||
boolean enabled = this.modID == null || Loader.isModLoaded( this.modID ) || apiManager.hasAPI( this.modID );
|
||||
try {
|
||||
switch (stage) {
|
||||
case PRE_INIT:
|
||||
final ModAPIManager apiManager = ModAPIManager.INSTANCE;
|
||||
boolean enabled = this.modID == null || Loader.isModLoaded(this.modID) || apiManager.hasAPI(this.modID);
|
||||
|
||||
AEConfig.instance()
|
||||
.addCustomCategoryComment( "ModIntegration",
|
||||
"Valid Values are 'AUTO', 'ON', or 'OFF' - defaults to 'AUTO' ; Suggested that you leave this alone unless your experiencing an issue, or wish to disable the integration for a reason." );
|
||||
final String mode = AEConfig.instance().get( "ModIntegration", this.displayName.replace( " ", "" ), "AUTO" ).getString();
|
||||
AEConfig.instance()
|
||||
.addCustomCategoryComment("ModIntegration",
|
||||
"Valid Values are 'AUTO', 'ON', or 'OFF' - defaults to 'AUTO' ; Suggested that you leave this alone unless your experiencing an issue, or wish to disable the integration for a reason.");
|
||||
final String mode = AEConfig.instance().get("ModIntegration", this.displayName.replace(" ", ""), "AUTO").getString();
|
||||
|
||||
if( mode.toUpperCase().equals( "ON" ) )
|
||||
{
|
||||
enabled = true;
|
||||
}
|
||||
if( mode.toUpperCase().equals( "OFF" ) )
|
||||
{
|
||||
enabled = false;
|
||||
}
|
||||
if (mode.equalsIgnoreCase("ON")) {
|
||||
enabled = true;
|
||||
}
|
||||
if (mode.equalsIgnoreCase("OFF")) {
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
if( enabled )
|
||||
{
|
||||
this.mod = this.type.createInstance();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ModNotInstalledException( this.modID );
|
||||
}
|
||||
if (enabled) {
|
||||
this.mod = this.type.createInstance();
|
||||
} else {
|
||||
throw new ModNotInstalledException(this.modID);
|
||||
}
|
||||
|
||||
this.mod.preInit();
|
||||
this.setState( IntegrationStage.INIT );
|
||||
this.mod.preInit();
|
||||
this.setState(IntegrationStage.INIT);
|
||||
|
||||
break;
|
||||
case INIT:
|
||||
this.mod.init();
|
||||
this.setState( IntegrationStage.POST_INIT );
|
||||
break;
|
||||
case INIT:
|
||||
this.mod.init();
|
||||
this.setState(IntegrationStage.POST_INIT);
|
||||
|
||||
break;
|
||||
case POST_INIT:
|
||||
this.mod.postInit();
|
||||
this.setState( IntegrationStage.READY );
|
||||
break;
|
||||
case POST_INIT:
|
||||
this.mod.postInit();
|
||||
this.setState(IntegrationStage.READY);
|
||||
|
||||
break;
|
||||
case FAILED:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
this.exception = t;
|
||||
this.setState( IntegrationStage.FAILED );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FAILED:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} catch (final Throwable t) {
|
||||
this.exception = t;
|
||||
this.setState(IntegrationStage.FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
if( stage == IntegrationStage.POST_INIT )
|
||||
{
|
||||
if( this.getState() == IntegrationStage.FAILED )
|
||||
{
|
||||
AELog.info( this.displayName + " - Integration Disabled" );
|
||||
if( !( this.exception instanceof ModNotInstalledException ) )
|
||||
{
|
||||
AELog.integration( this.exception );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AELog.info( this.displayName + " - Integration Enable" );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stage == IntegrationStage.POST_INIT) {
|
||||
if (this.getState() == IntegrationStage.FAILED) {
|
||||
AELog.info(this.displayName + " - Integration Disabled");
|
||||
if (!(this.exception instanceof ModNotInstalledException)) {
|
||||
AELog.integration(this.exception);
|
||||
}
|
||||
} else {
|
||||
AELog.info(this.displayName + " - Integration Enable");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IntegrationType getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
IntegrationType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
IntegrationStage getState()
|
||||
{
|
||||
return this.state;
|
||||
}
|
||||
IntegrationStage getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
private void setState( final IntegrationStage state )
|
||||
{
|
||||
this.state = state;
|
||||
}
|
||||
private void setState(final IntegrationStage state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,86 +19,70 @@
|
||||
package appeng.integration;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.FMLLaunchHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
public enum IntegrationRegistry
|
||||
{
|
||||
INSTANCE;
|
||||
|
||||
private final Collection<IntegrationNode> modules = new ArrayList<>();
|
||||
public enum IntegrationRegistry {
|
||||
INSTANCE;
|
||||
|
||||
public void add( final IntegrationType type )
|
||||
{
|
||||
if( type.side == IntegrationSide.CLIENT && FMLLaunchHandler.side() == Side.SERVER )
|
||||
{
|
||||
return;
|
||||
}
|
||||
private final Collection<IntegrationNode> modules = new ArrayList<>();
|
||||
|
||||
if( type.side == IntegrationSide.SERVER && FMLLaunchHandler.side() == Side.CLIENT )
|
||||
{
|
||||
return;
|
||||
}
|
||||
public void add(final IntegrationType type) {
|
||||
if (type.side == IntegrationSide.CLIENT && FMLLaunchHandler.side() == Side.SERVER) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.modules.add( new IntegrationNode( type.dspName, type.modID, type ) );
|
||||
}
|
||||
if (type.side == IntegrationSide.SERVER && FMLLaunchHandler.side() == Side.CLIENT) {
|
||||
return;
|
||||
}
|
||||
|
||||
public void preInit()
|
||||
{
|
||||
for( final IntegrationNode node : this.modules )
|
||||
{
|
||||
node.call( IntegrationStage.PRE_INIT );
|
||||
}
|
||||
}
|
||||
this.modules.add(new IntegrationNode(type.dspName, type.modID, type));
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
for( final IntegrationNode node : this.modules )
|
||||
{
|
||||
node.call( IntegrationStage.INIT );
|
||||
}
|
||||
}
|
||||
public void preInit() {
|
||||
for (final IntegrationNode node : this.modules) {
|
||||
node.call(IntegrationStage.PRE_INIT);
|
||||
}
|
||||
}
|
||||
|
||||
public void postInit()
|
||||
{
|
||||
for( final IntegrationNode node : this.modules )
|
||||
{
|
||||
node.call( IntegrationStage.POST_INIT );
|
||||
}
|
||||
}
|
||||
public void init() {
|
||||
for (final IntegrationNode node : this.modules) {
|
||||
node.call(IntegrationStage.INIT);
|
||||
}
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
final StringBuilder builder = new StringBuilder( this.modules.size() * 3 );
|
||||
public void postInit() {
|
||||
for (final IntegrationNode node : this.modules) {
|
||||
node.call(IntegrationStage.POST_INIT);
|
||||
}
|
||||
}
|
||||
|
||||
for( final IntegrationNode node : this.modules )
|
||||
{
|
||||
if( builder.length() != 0 )
|
||||
{
|
||||
builder.append( ", " );
|
||||
}
|
||||
public String getStatus() {
|
||||
final StringBuilder builder = new StringBuilder(this.modules.size() * 3);
|
||||
|
||||
final String integrationState = node.getType() + ":" + ( node.getState() == IntegrationStage.FAILED ? "OFF" : "ON" );
|
||||
builder.append( integrationState );
|
||||
}
|
||||
for (final IntegrationNode node : this.modules) {
|
||||
if (builder.length() != 0) {
|
||||
builder.append(", ");
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
final String integrationState = node.getType() + ":" + (node.getState() == IntegrationStage.FAILED ? "OFF" : "ON");
|
||||
builder.append(integrationState);
|
||||
}
|
||||
|
||||
public boolean isEnabled( final IntegrationType name )
|
||||
{
|
||||
for( final IntegrationNode node : this.modules )
|
||||
{
|
||||
if( node.getType() == name )
|
||||
{
|
||||
return node.isActive();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public boolean isEnabled(final IntegrationType name) {
|
||||
for (final IntegrationNode node : this.modules) {
|
||||
if (node.getType() == name) {
|
||||
return node.isActive();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package appeng.integration;
|
||||
|
||||
|
||||
enum IntegrationSide
|
||||
{
|
||||
CLIENT, SERVER, BOTH
|
||||
enum IntegrationSide {
|
||||
CLIENT, SERVER, BOTH
|
||||
}
|
||||
|
||||
@@ -19,14 +19,13 @@
|
||||
package appeng.integration;
|
||||
|
||||
|
||||
enum IntegrationStage
|
||||
{
|
||||
enum IntegrationStage {
|
||||
|
||||
PRE_INIT,
|
||||
INIT,
|
||||
POST_INIT,
|
||||
PRE_INIT,
|
||||
INIT,
|
||||
POST_INIT,
|
||||
|
||||
FAILED,
|
||||
READY
|
||||
FAILED,
|
||||
READY
|
||||
|
||||
}
|
||||
|
||||
@@ -27,90 +27,74 @@ import appeng.integration.modules.theoneprobe.TheOneProbeModule;
|
||||
import appeng.integration.modules.waila.WailaModule;
|
||||
|
||||
|
||||
public enum IntegrationType
|
||||
{
|
||||
IC2( IntegrationSide.BOTH, "Industrial Craft 2", "ic2" )
|
||||
{
|
||||
@Override
|
||||
public IIntegrationModule createInstance()
|
||||
{
|
||||
return Integrations.setIc2( new IC2Module() );
|
||||
}
|
||||
},
|
||||
public enum IntegrationType {
|
||||
IC2(IntegrationSide.BOTH, "Industrial Craft 2", "ic2") {
|
||||
@Override
|
||||
public IIntegrationModule createInstance() {
|
||||
return Integrations.setIc2(new IC2Module());
|
||||
}
|
||||
},
|
||||
|
||||
GTCE( IntegrationSide.BOTH, "GregTech", "gregtech" ),
|
||||
GTCE(IntegrationSide.BOTH, "GregTech", "gregtech"),
|
||||
|
||||
RC( IntegrationSide.BOTH, "Railcraft", "railcraft" ),
|
||||
RC(IntegrationSide.BOTH, "Railcraft", "railcraft"),
|
||||
|
||||
MFR( IntegrationSide.BOTH, "Mine Factory Reloaded", "minefactoryreloaded" ),
|
||||
MFR(IntegrationSide.BOTH, "Mine Factory Reloaded", "minefactoryreloaded"),
|
||||
|
||||
Waila( IntegrationSide.BOTH, "Waila", "waila" )
|
||||
{
|
||||
@Override
|
||||
public IIntegrationModule createInstance()
|
||||
{
|
||||
return new WailaModule();
|
||||
}
|
||||
},
|
||||
Waila(IntegrationSide.BOTH, "Waila", "waila") {
|
||||
@Override
|
||||
public IIntegrationModule createInstance() {
|
||||
return new WailaModule();
|
||||
}
|
||||
},
|
||||
|
||||
InvTweaks( IntegrationSide.CLIENT, "Inventory Tweaks", "inventorytweaks" )
|
||||
{
|
||||
@Override
|
||||
public IIntegrationModule createInstance()
|
||||
{
|
||||
return Integrations.setInvTweaks( new InventoryTweaksModule() );
|
||||
}
|
||||
},
|
||||
InvTweaks(IntegrationSide.CLIENT, "Inventory Tweaks", "inventorytweaks") {
|
||||
@Override
|
||||
public IIntegrationModule createInstance() {
|
||||
return Integrations.setInvTweaks(new InventoryTweaksModule());
|
||||
}
|
||||
},
|
||||
|
||||
JEI( IntegrationSide.CLIENT, "Just Enough Items", "jei" )
|
||||
{
|
||||
@Override
|
||||
public IIntegrationModule createInstance()
|
||||
{
|
||||
return Integrations.setJei( new JEIModule() );
|
||||
}
|
||||
},
|
||||
JEI(IntegrationSide.CLIENT, "Just Enough Items", "jei") {
|
||||
@Override
|
||||
public IIntegrationModule createInstance() {
|
||||
return Integrations.setJei(new JEIModule());
|
||||
}
|
||||
},
|
||||
|
||||
Mekanism( IntegrationSide.BOTH, "Mekanism", "mekanism" ),
|
||||
Mekanism(IntegrationSide.BOTH, "Mekanism", "mekanism"),
|
||||
|
||||
OpenComputers( IntegrationSide.BOTH, "OpenComputers", "opencomputers" ),
|
||||
OpenComputers(IntegrationSide.BOTH, "OpenComputers", "opencomputers"),
|
||||
|
||||
THE_ONE_PROBE( IntegrationSide.BOTH, "TheOneProbe", "theoneprobe" )
|
||||
{
|
||||
@Override
|
||||
public IIntegrationModule createInstance()
|
||||
{
|
||||
return new TheOneProbeModule();
|
||||
}
|
||||
},
|
||||
THE_ONE_PROBE(IntegrationSide.BOTH, "TheOneProbe", "theoneprobe") {
|
||||
@Override
|
||||
public IIntegrationModule createInstance() {
|
||||
return new TheOneProbeModule();
|
||||
}
|
||||
},
|
||||
|
||||
TESLA( IntegrationSide.BOTH, "Tesla", "tesla" ),
|
||||
TESLA(IntegrationSide.BOTH, "Tesla", "tesla"),
|
||||
|
||||
CRAFTTWEAKER( IntegrationSide.BOTH, "CraftTweaker", "crafttweaker" )
|
||||
{
|
||||
@Override
|
||||
public IIntegrationModule createInstance()
|
||||
{
|
||||
return new CTModule();
|
||||
}
|
||||
};
|
||||
CRAFTTWEAKER(IntegrationSide.BOTH, "CraftTweaker", "crafttweaker") {
|
||||
@Override
|
||||
public IIntegrationModule createInstance() {
|
||||
return new CTModule();
|
||||
}
|
||||
};
|
||||
|
||||
public final IntegrationSide side;
|
||||
public final String dspName;
|
||||
public final String modID;
|
||||
public final IntegrationSide side;
|
||||
public final String dspName;
|
||||
public final String modID;
|
||||
|
||||
IntegrationType( final IntegrationSide side, final String name, final String modid )
|
||||
{
|
||||
this.side = side;
|
||||
this.dspName = name;
|
||||
this.modID = modid;
|
||||
}
|
||||
IntegrationType(final IntegrationSide side, final String name, final String modid) {
|
||||
this.side = side;
|
||||
this.dspName = name;
|
||||
this.modID = modid;
|
||||
}
|
||||
|
||||
public IIntegrationModule createInstance()
|
||||
{
|
||||
return new IIntegrationModule()
|
||||
{
|
||||
};
|
||||
}
|
||||
public IIntegrationModule createInstance() {
|
||||
return new IIntegrationModule() {
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,86 +19,70 @@
|
||||
package appeng.integration;
|
||||
|
||||
|
||||
import appeng.integration.abstraction.IIC2;
|
||||
import appeng.integration.abstraction.IInvTweaks;
|
||||
import appeng.integration.abstraction.IJEI;
|
||||
import appeng.integration.abstraction.IMekanism;
|
||||
import appeng.integration.abstraction.IRC;
|
||||
import appeng.integration.abstraction.*;
|
||||
|
||||
|
||||
/**
|
||||
* Provides convenient access to various integrations with other mods.
|
||||
*/
|
||||
public final class Integrations
|
||||
{
|
||||
public final class Integrations {
|
||||
|
||||
static IIC2 ic2 = new IIC2.Stub();
|
||||
static IIC2 ic2 = new IIC2.Stub();
|
||||
|
||||
static IJEI jei = new IJEI.Stub();
|
||||
static IJEI jei = new IJEI.Stub();
|
||||
|
||||
static IRC rc = new IRC.Stub();
|
||||
static IRC rc = new IRC.Stub();
|
||||
|
||||
static IMekanism mekanism = new IMekanism.Stub();
|
||||
static IMekanism mekanism = new IMekanism.Stub();
|
||||
|
||||
static IInvTweaks invTweaks = new IInvTweaks.Stub();
|
||||
static IInvTweaks invTweaks = new IInvTweaks.Stub();
|
||||
|
||||
private Integrations()
|
||||
{
|
||||
}
|
||||
private Integrations() {
|
||||
}
|
||||
|
||||
public static IIC2 ic2()
|
||||
{
|
||||
return ic2;
|
||||
}
|
||||
public static IIC2 ic2() {
|
||||
return ic2;
|
||||
}
|
||||
|
||||
public static IJEI jei()
|
||||
{
|
||||
return jei;
|
||||
}
|
||||
public static IJEI jei() {
|
||||
return jei;
|
||||
}
|
||||
|
||||
public static IRC rc()
|
||||
{
|
||||
return rc;
|
||||
}
|
||||
public static IRC rc() {
|
||||
return rc;
|
||||
}
|
||||
|
||||
public static IMekanism mekanism()
|
||||
{
|
||||
return mekanism;
|
||||
}
|
||||
public static IMekanism mekanism() {
|
||||
return mekanism;
|
||||
}
|
||||
|
||||
public static IInvTweaks invTweaks()
|
||||
{
|
||||
return invTweaks;
|
||||
}
|
||||
public static IInvTweaks invTweaks() {
|
||||
return invTweaks;
|
||||
}
|
||||
|
||||
static IIC2 setIc2( IIC2 ic2 )
|
||||
{
|
||||
Integrations.ic2 = ic2;
|
||||
return ic2;
|
||||
}
|
||||
static IIC2 setIc2(IIC2 ic2) {
|
||||
Integrations.ic2 = ic2;
|
||||
return ic2;
|
||||
}
|
||||
|
||||
static IJEI setJei( IJEI jei )
|
||||
{
|
||||
Integrations.jei = jei;
|
||||
return jei;
|
||||
}
|
||||
static IJEI setJei(IJEI jei) {
|
||||
Integrations.jei = jei;
|
||||
return jei;
|
||||
}
|
||||
|
||||
static IRC setRc( IRC rc )
|
||||
{
|
||||
Integrations.rc = rc;
|
||||
return rc;
|
||||
}
|
||||
static IRC setRc(IRC rc) {
|
||||
Integrations.rc = rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
static IMekanism setMekanism( IMekanism mekanism )
|
||||
{
|
||||
Integrations.mekanism = mekanism;
|
||||
return mekanism;
|
||||
}
|
||||
static IMekanism setMekanism(IMekanism mekanism) {
|
||||
Integrations.mekanism = mekanism;
|
||||
return mekanism;
|
||||
}
|
||||
|
||||
static IInvTweaks setInvTweaks( IInvTweaks invTweaks )
|
||||
{
|
||||
Integrations.invTweaks = invTweaks;
|
||||
return invTweaks;
|
||||
}
|
||||
static IInvTweaks setInvTweaks(IInvTweaks invTweaks) {
|
||||
Integrations.invTweaks = invTweaks;
|
||||
return invTweaks;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,42 +19,38 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import team.chisel.ctm.api.IFacade;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
/**
|
||||
* Neat abstraction class for All the IFacade interfaces.
|
||||
*
|
||||
* @author covers1624
|
||||
*/
|
||||
@Optional.Interface( iface = "team.chisel.ctm.api.IFacade", modid = "ctm-api" )
|
||||
public interface IAEFacade extends IFacade
|
||||
{
|
||||
@Optional.Interface(iface = "team.chisel.ctm.api.IFacade", modid = "ctm-api")
|
||||
public interface IAEFacade extends IFacade {
|
||||
|
||||
IBlockState getFacadeState( IBlockAccess world, BlockPos pos, EnumFacing side );
|
||||
IBlockState getFacadeState(IBlockAccess world, BlockPos pos, EnumFacing side);
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Optional.Method( modid = "ctm-api" )
|
||||
default IBlockState getFacade( @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nullable EnumFacing side, @Nonnull BlockPos connection )
|
||||
{
|
||||
return getFacadeState( world, pos, side );
|
||||
}
|
||||
@Nonnull
|
||||
@Override
|
||||
@Optional.Method(modid = "ctm-api")
|
||||
default IBlockState getFacade(@Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nullable EnumFacing side, @Nonnull BlockPos connection) {
|
||||
return getFacadeState(world, pos, side);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Optional.Method( modid = "ctm-api" )
|
||||
default IBlockState getFacade( @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nullable EnumFacing side )
|
||||
{
|
||||
return getFacadeState( world, pos, side );
|
||||
}
|
||||
@Nonnull
|
||||
@Override
|
||||
@Optional.Method(modid = "ctm-api")
|
||||
default IBlockState getFacade(@Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nullable EnumFacing side) {
|
||||
return getFacadeState(world, pos, side);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,31 +19,26 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* Provides an abstraction for the IC2 Basic Sink so it can be stubbed out easily when the integration is disabled, or
|
||||
* if the IC2 API is not available.
|
||||
*/
|
||||
public interface IC2PowerSink
|
||||
{
|
||||
public interface IC2PowerSink {
|
||||
|
||||
default void invalidate()
|
||||
{
|
||||
}
|
||||
default void invalidate() {
|
||||
}
|
||||
|
||||
default void onChunkUnload()
|
||||
{
|
||||
}
|
||||
default void onChunkUnload() {
|
||||
}
|
||||
|
||||
default void onLoad()
|
||||
{
|
||||
}
|
||||
default void onLoad() {
|
||||
}
|
||||
|
||||
default void setValidFaces( Set<EnumFacing> faces )
|
||||
{
|
||||
}
|
||||
default void setValidFaces(Set<EnumFacing> faces) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ package appeng.integration.abstraction;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
|
||||
|
||||
public interface ICraftTweaker extends IIntegrationModule
|
||||
{
|
||||
public interface ICraftTweaker extends IIntegrationModule {
|
||||
|
||||
}
|
||||
|
||||
@@ -19,31 +19,26 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.modules.ic2.IC2PowerSinkStub;
|
||||
import appeng.tile.powersink.IExternalPowerSink;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
|
||||
public interface IIC2 extends IIntegrationModule
|
||||
{
|
||||
public interface IIC2 extends IIntegrationModule {
|
||||
|
||||
default void maceratorRecipe( ItemStack in, ItemStack out )
|
||||
{
|
||||
}
|
||||
default void maceratorRecipe(ItemStack in, ItemStack out) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an IC2 power sink for the given external sink.
|
||||
*/
|
||||
default IC2PowerSink createPowerSink( TileEntity tileEntity, IExternalPowerSink externalSink )
|
||||
{
|
||||
return IC2PowerSinkStub.INSTANCE;
|
||||
}
|
||||
/**
|
||||
* Create an IC2 power sink for the given external sink.
|
||||
*/
|
||||
default IC2PowerSink createPowerSink(TileEntity tileEntity, IExternalPowerSink externalSink) {
|
||||
return IC2PowerSinkStub.INSTANCE;
|
||||
}
|
||||
|
||||
class Stub extends IIntegrationModule.Stub implements IIC2
|
||||
{
|
||||
class Stub extends IIntegrationModule.Stub implements IIC2 {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,21 +19,17 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.integration.IIntegrationModule;
|
||||
|
||||
public interface IInvTweaks extends IIntegrationModule {
|
||||
|
||||
public interface IInvTweaks extends IIntegrationModule
|
||||
{
|
||||
default int compareItems(ItemStack i, ItemStack j) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
default int compareItems( ItemStack i, ItemStack j )
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
class Stub extends IIntegrationModule.Stub implements IInvTweaks
|
||||
{
|
||||
}
|
||||
class Stub extends IIntegrationModule.Stub implements IInvTweaks {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,19 +25,15 @@ import appeng.integration.IIntegrationModule;
|
||||
/**
|
||||
* Abstracts access to the JEI API functionality.
|
||||
*/
|
||||
public interface IJEI extends IIntegrationModule
|
||||
{
|
||||
public interface IJEI extends IIntegrationModule {
|
||||
|
||||
default String getSearchText()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
default String getSearchText() {
|
||||
return "";
|
||||
}
|
||||
|
||||
default void setSearchText( String searchText )
|
||||
{
|
||||
}
|
||||
default void setSearchText(String searchText) {
|
||||
}
|
||||
|
||||
class Stub extends IIntegrationModule.Stub implements IJEI
|
||||
{
|
||||
}
|
||||
class Stub extends IIntegrationModule.Stub implements IJEI {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,23 +19,18 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.integration.IIntegrationModule;
|
||||
|
||||
public interface IMekanism extends IIntegrationModule {
|
||||
|
||||
public interface IMekanism extends IIntegrationModule
|
||||
{
|
||||
default void addCrusherRecipe(ItemStack in, ItemStack out) {
|
||||
}
|
||||
|
||||
default void addCrusherRecipe( ItemStack in, ItemStack out )
|
||||
{
|
||||
}
|
||||
default void addEnrichmentChamberRecipe(ItemStack in, ItemStack out) {
|
||||
}
|
||||
|
||||
default void addEnrichmentChamberRecipe( ItemStack in, ItemStack out )
|
||||
{
|
||||
}
|
||||
|
||||
class Stub extends IIntegrationModule.Stub implements IMekanism
|
||||
{
|
||||
}
|
||||
class Stub extends IIntegrationModule.Stub implements IMekanism {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,20 +19,16 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.integration.IIntegrationModule;
|
||||
|
||||
public interface IRC extends IIntegrationModule {
|
||||
|
||||
public interface IRC extends IIntegrationModule
|
||||
{
|
||||
default void rockCrusher(ItemStack input, ItemStack output) {
|
||||
}
|
||||
|
||||
default void rockCrusher( ItemStack input, ItemStack output )
|
||||
{
|
||||
}
|
||||
|
||||
class Stub extends IIntegrationModule.Stub implements IRC
|
||||
{
|
||||
}
|
||||
class Stub extends IIntegrationModule.Stub implements IRC {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,8 +6,7 @@ import net.minecraftforge.fml.common.Loader;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class InventoryBogoSortModule
|
||||
{
|
||||
public class InventoryBogoSortModule {
|
||||
private static final boolean loaded = Loader.isModLoaded("bogosorter");
|
||||
|
||||
public static final Comparator<IAEItemStack> COMPARATOR = (o1, o2) -> SortHandler.ITEM_COMPARATOR.compare(o1.getDefinition(), o2.getDefinition());
|
||||
|
||||
@@ -19,114 +19,95 @@
|
||||
package appeng.integration.modules.crafttweaker;
|
||||
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.TunnelType;
|
||||
import appeng.api.features.IP2PTunnelRegistry;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.TunnelType;
|
||||
import appeng.api.features.IP2PTunnelRegistry;
|
||||
|
||||
@ZenClass("mods.appliedenergistics2.Attunement")
|
||||
public class AttunementRegistry {
|
||||
private AttunementRegistry() {
|
||||
}
|
||||
|
||||
@ZenClass( "mods.appliedenergistics2.Attunement" )
|
||||
public class AttunementRegistry
|
||||
{
|
||||
private AttunementRegistry()
|
||||
{
|
||||
}
|
||||
@ZenMethod
|
||||
public static void attuneME(IIngredient itemStack) {
|
||||
attune(itemStack, TunnelType.ME);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneME( IIngredient itemStack )
|
||||
{
|
||||
attune( itemStack, TunnelType.ME );
|
||||
}
|
||||
@ZenMethod
|
||||
public static void attuneME(String modId) {
|
||||
attune(modId, TunnelType.ME);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneME( String modId )
|
||||
{
|
||||
attune( modId, TunnelType.ME );
|
||||
}
|
||||
@ZenMethod
|
||||
public static void attuneItem(IIngredient itemStack) {
|
||||
attune(itemStack, TunnelType.ITEM);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneItem( IIngredient itemStack )
|
||||
{
|
||||
attune( itemStack, TunnelType.ITEM );
|
||||
}
|
||||
@ZenMethod
|
||||
public static void attuneItem(String modId) {
|
||||
attune(modId, TunnelType.ITEM);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneItem( String modId )
|
||||
{
|
||||
attune( modId, TunnelType.ITEM );
|
||||
}
|
||||
@ZenMethod
|
||||
public static void attuneFluid(IIngredient itemStack) {
|
||||
attune(itemStack, TunnelType.FLUID);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneFluid( IIngredient itemStack )
|
||||
{
|
||||
attune( itemStack, TunnelType.FLUID );
|
||||
}
|
||||
@ZenMethod
|
||||
public static void attuneFluid(String modId) {
|
||||
attune(modId, TunnelType.FLUID);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneFluid( String modId )
|
||||
{
|
||||
attune( modId, TunnelType.FLUID );
|
||||
}
|
||||
@ZenMethod
|
||||
public static void attuneRedstone(IIngredient itemStack) {
|
||||
attune(itemStack, TunnelType.REDSTONE);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneRedstone( IIngredient itemStack )
|
||||
{
|
||||
attune( itemStack, TunnelType.REDSTONE );
|
||||
}
|
||||
@ZenMethod
|
||||
public static void attuneRedstone(String modId) {
|
||||
attune(modId, TunnelType.REDSTONE);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneRedstone( String modId )
|
||||
{
|
||||
attune( modId, TunnelType.REDSTONE );
|
||||
}
|
||||
@ZenMethod
|
||||
public static void attuneRF(IIngredient itemStack) {
|
||||
attune(itemStack, TunnelType.FE_POWER);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneRF( IIngredient itemStack )
|
||||
{
|
||||
attune( itemStack, TunnelType.FE_POWER );
|
||||
}
|
||||
@ZenMethod
|
||||
public static void attuneRF(String modId) {
|
||||
attune(modId, TunnelType.FE_POWER);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneRF( String modId )
|
||||
{
|
||||
attune( modId, TunnelType.FE_POWER );
|
||||
}
|
||||
@ZenMethod
|
||||
public static void attuneIC2(IIngredient itemStack) {
|
||||
attune(itemStack, TunnelType.IC2_POWER);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneIC2( IIngredient itemStack )
|
||||
{
|
||||
attune( itemStack, TunnelType.IC2_POWER );
|
||||
}
|
||||
@ZenMethod
|
||||
public static void attuneIC2(String modId) {
|
||||
attune(modId, TunnelType.IC2_POWER);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneIC2( String modId )
|
||||
{
|
||||
attune( modId, TunnelType.IC2_POWER );
|
||||
}
|
||||
@ZenMethod
|
||||
public static void attuneLight(IIngredient itemStack) {
|
||||
attune(itemStack, TunnelType.LIGHT);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneLight( IIngredient itemStack )
|
||||
{
|
||||
attune( itemStack, TunnelType.LIGHT );
|
||||
}
|
||||
@ZenMethod
|
||||
public static void attuneLight(String modId) {
|
||||
attune(modId, TunnelType.LIGHT);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneLight( String modId )
|
||||
{
|
||||
attune( modId, TunnelType.LIGHT );
|
||||
}
|
||||
private static void attune(IIngredient itemStack, TunnelType type) {
|
||||
IP2PTunnelRegistry registry = AEApi.instance().registries().p2pTunnel();
|
||||
CTModule.toStacks(itemStack).ifPresent(c -> c.forEach(i -> registry.addNewAttunement(i, type)));
|
||||
}
|
||||
|
||||
private static void attune( IIngredient itemStack, TunnelType type )
|
||||
{
|
||||
IP2PTunnelRegistry registry = AEApi.instance().registries().p2pTunnel();
|
||||
CTModule.toStacks( itemStack ).ifPresent( c -> c.forEach( i -> registry.addNewAttunement( i, type ) ) );
|
||||
}
|
||||
|
||||
private static void attune( String modid, TunnelType type )
|
||||
{
|
||||
AEApi.instance().registries().p2pTunnel().addNewAttunement( modid, type );
|
||||
}
|
||||
private static void attune(String modid, TunnelType type) {
|
||||
AEApi.instance().registries().p2pTunnel().addNewAttunement(modid, type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,112 +19,83 @@
|
||||
package appeng.integration.modules.crafttweaker;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import appeng.integration.abstraction.ICraftTweaker;
|
||||
import appeng.util.Platform;
|
||||
import crafttweaker.CraftTweakerAPI;
|
||||
import crafttweaker.IAction;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import crafttweaker.CraftTweakerAPI;
|
||||
import crafttweaker.IAction;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
|
||||
import appeng.integration.abstraction.ICraftTweaker;
|
||||
import appeng.util.Platform;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
public class CTModule implements ICraftTweaker
|
||||
{
|
||||
static final List<IAction> MODIFICATIONS = new ArrayList<>();
|
||||
public class CTModule implements ICraftTweaker {
|
||||
static final List<IAction> MODIFICATIONS = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void preInit()
|
||||
{
|
||||
CraftTweakerAPI.registerClass( GrinderRecipes.class );
|
||||
CraftTweakerAPI.registerClass( InscriberRecipes.class );
|
||||
CraftTweakerAPI.registerClass( SpatialRegistry.class );
|
||||
CraftTweakerAPI.registerClass( AttunementRegistry.class );
|
||||
CraftTweakerAPI.registerClass( CannonRegistry.class );
|
||||
}
|
||||
@Override
|
||||
public void preInit() {
|
||||
CraftTweakerAPI.registerClass(GrinderRecipes.class);
|
||||
CraftTweakerAPI.registerClass(InscriberRecipes.class);
|
||||
CraftTweakerAPI.registerClass(SpatialRegistry.class);
|
||||
CraftTweakerAPI.registerClass(AttunementRegistry.class);
|
||||
CraftTweakerAPI.registerClass(CannonRegistry.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
MODIFICATIONS.forEach( CraftTweakerAPI::apply );
|
||||
}
|
||||
@Override
|
||||
public void postInit() {
|
||||
MODIFICATIONS.forEach(CraftTweakerAPI::apply);
|
||||
}
|
||||
|
||||
public static ItemStack toStack( IItemStack iStack )
|
||||
{
|
||||
if( iStack == null )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (ItemStack) iStack.getInternal();
|
||||
}
|
||||
}
|
||||
public static ItemStack toStack(IItemStack iStack) {
|
||||
if (iStack == null) {
|
||||
return ItemStack.EMPTY;
|
||||
} else {
|
||||
return (ItemStack) iStack.getInternal();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<ItemStack> toStackExpand( IItemStack iStack )
|
||||
{
|
||||
if( iStack == null )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack is = (ItemStack) iStack.getInternal();
|
||||
if( !is.isItemStackDamageable() && is.getItemDamage() == OreDictionary.WILDCARD_VALUE )
|
||||
{
|
||||
NonNullList<ItemStack> ret = NonNullList.create();
|
||||
is.getItem().getSubItems( CreativeTabs.SEARCH, ret );
|
||||
return ret.stream().map( i -> new ItemStack( i.getItem(), iStack.getAmount(), i.getItemDamage() ) ).collect( Collectors.toList() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return Collections.singletonList( is );
|
||||
}
|
||||
}
|
||||
}
|
||||
public static List<ItemStack> toStackExpand(IItemStack iStack) {
|
||||
if (iStack == null) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
ItemStack is = (ItemStack) iStack.getInternal();
|
||||
if (!is.isItemStackDamageable() && is.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
|
||||
NonNullList<ItemStack> ret = NonNullList.create();
|
||||
is.getItem().getSubItems(CreativeTabs.SEARCH, ret);
|
||||
return ret.stream().map(i -> new ItemStack(i.getItem(), iStack.getAmount(), i.getItemDamage())).collect(Collectors.toList());
|
||||
} else {
|
||||
return Collections.singletonList(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<Collection<ItemStack>> toStacks( IIngredient ingredient )
|
||||
{
|
||||
if( ingredient == null )
|
||||
{
|
||||
return Optional.empty();
|
||||
}
|
||||
Set<ItemStack> ret = new TreeSet<>( CTModule::compareItemStacks );
|
||||
ingredient.getItems().stream().map( CTModule::toStackExpand ).forEach( ret::addAll );
|
||||
if( ret.isEmpty() )
|
||||
{
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of( ret );
|
||||
}
|
||||
public static Optional<Collection<ItemStack>> toStacks(IIngredient ingredient) {
|
||||
if (ingredient == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
Set<ItemStack> ret = new TreeSet<>(CTModule::compareItemStacks);
|
||||
ingredient.getItems().stream().map(CTModule::toStackExpand).forEach(ret::addAll);
|
||||
if (ret.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of(ret);
|
||||
}
|
||||
|
||||
private static int compareItemStacks( ItemStack a, ItemStack b )
|
||||
{
|
||||
if( Platform.itemComparisons().isSameItem( a, b ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if( a == null )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if( b == null )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return System.identityHashCode( a ) - System.identityHashCode( b );
|
||||
}
|
||||
private static int compareItemStacks(ItemStack a, ItemStack b) {
|
||||
if (Platform.itemComparisons().isSameItem(a, b)) {
|
||||
return 0;
|
||||
}
|
||||
if (a == null) {
|
||||
return -1;
|
||||
}
|
||||
if (b == null) {
|
||||
return 1;
|
||||
}
|
||||
return System.identityHashCode(a) - System.identityHashCode(b);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,25 +19,21 @@
|
||||
package appeng.integration.modules.crafttweaker;
|
||||
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.IMatterCannonAmmoRegistry;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.IMatterCannonAmmoRegistry;
|
||||
|
||||
@ZenClass("mods.appliedenergistics2.Cannon")
|
||||
public class CannonRegistry {
|
||||
private CannonRegistry() {
|
||||
}
|
||||
|
||||
@ZenClass( "mods.appliedenergistics2.Cannon" )
|
||||
public class CannonRegistry
|
||||
{
|
||||
private CannonRegistry()
|
||||
{
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void registerAmmo( IIngredient itemStack, double weight )
|
||||
{
|
||||
IMatterCannonAmmoRegistry registry = AEApi.instance().registries().matterCannon();
|
||||
CTModule.toStacks( itemStack ).ifPresent( c -> c.forEach( i -> registry.registerAmmo( i, weight ) ) );
|
||||
}
|
||||
@ZenMethod
|
||||
public static void registerAmmo(IIngredient itemStack, double weight) {
|
||||
IMatterCannonAmmoRegistry registry = AEApi.instance().registries().matterCannon();
|
||||
CTModule.toStacks(itemStack).ifPresent(c -> c.forEach(i -> registry.registerAmmo(i, weight)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,109 +19,90 @@
|
||||
package appeng.integration.modules.crafttweaker;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import crafttweaker.IAction;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.IGrinderRecipe;
|
||||
import appeng.api.features.IGrinderRecipeBuilder;
|
||||
import crafttweaker.IAction;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
|
||||
@ZenClass( "mods.appliedenergistics2.Grinder" )
|
||||
public class GrinderRecipes
|
||||
{
|
||||
private GrinderRecipes()
|
||||
{
|
||||
}
|
||||
@ZenClass("mods.appliedenergistics2.Grinder")
|
||||
public class GrinderRecipes {
|
||||
private GrinderRecipes() {
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe( IItemStack output, IIngredient input, int turns, @stanhebben.zenscript.annotations.Optional IItemStack secondary1Output, @stanhebben.zenscript.annotations.Optional Float secondary1Chance, @stanhebben.zenscript.annotations.Optional IItemStack secondary2Output, @stanhebben.zenscript.annotations.Optional Float secondary2Chance )
|
||||
{
|
||||
Collection<ItemStack> inStacks = CTModule.toStacks( input ).orElse( Collections.emptySet() );
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IIngredient input, int turns, @stanhebben.zenscript.annotations.Optional IItemStack secondary1Output, @stanhebben.zenscript.annotations.Optional Float secondary1Chance, @stanhebben.zenscript.annotations.Optional IItemStack secondary2Output, @stanhebben.zenscript.annotations.Optional Float secondary2Chance) {
|
||||
Collection<ItemStack> inStacks = CTModule.toStacks(input).orElse(Collections.emptySet());
|
||||
|
||||
for( ItemStack inStack : inStacks )
|
||||
{
|
||||
IGrinderRecipeBuilder builder = AEApi.instance().registries().grinder().builder();
|
||||
builder.withInput( inStack )
|
||||
.withOutput( CTModule.toStack( output ) )
|
||||
.withTurns( turns );
|
||||
for (ItemStack inStack : inStacks) {
|
||||
IGrinderRecipeBuilder builder = AEApi.instance().registries().grinder().builder();
|
||||
builder.withInput(inStack)
|
||||
.withOutput(CTModule.toStack(output))
|
||||
.withTurns(turns);
|
||||
|
||||
final ItemStack s1 = CTModule.toStack( secondary1Output );
|
||||
if( !s1.isEmpty() )
|
||||
{
|
||||
builder.withFirstOptional( s1, secondary1Chance == null ? 1.0f : secondary1Chance );
|
||||
}
|
||||
final ItemStack s2 = CTModule.toStack( secondary2Output );
|
||||
if( !s2.isEmpty() )
|
||||
{
|
||||
builder.withSecondOptional( s2, secondary2Chance == null ? 1.0f : secondary2Chance );
|
||||
}
|
||||
CTModule.MODIFICATIONS.add( new Add( builder.build() ) );
|
||||
}
|
||||
}
|
||||
final ItemStack s1 = CTModule.toStack(secondary1Output);
|
||||
if (!s1.isEmpty()) {
|
||||
builder.withFirstOptional(s1, secondary1Chance == null ? 1.0f : secondary1Chance);
|
||||
}
|
||||
final ItemStack s2 = CTModule.toStack(secondary2Output);
|
||||
if (!s2.isEmpty()) {
|
||||
builder.withSecondOptional(s2, secondary2Chance == null ? 1.0f : secondary2Chance);
|
||||
}
|
||||
CTModule.MODIFICATIONS.add(new Add(builder.build()));
|
||||
}
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe( IIngredient input )
|
||||
{
|
||||
for( ItemStack inStack : CTModule.toStacks( input ).orElse( Collections.emptySet() ) )
|
||||
{
|
||||
CTModule.MODIFICATIONS.add( new Remove( inStack ) );
|
||||
}
|
||||
}
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient input) {
|
||||
for (ItemStack inStack : CTModule.toStacks(input).orElse(Collections.emptySet())) {
|
||||
CTModule.MODIFICATIONS.add(new Remove(inStack));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Add implements IAction
|
||||
{
|
||||
private final IGrinderRecipe entry;
|
||||
private static class Add implements IAction {
|
||||
private final IGrinderRecipe entry;
|
||||
|
||||
private Add( IGrinderRecipe entry )
|
||||
{
|
||||
this.entry = entry;
|
||||
}
|
||||
private Add(IGrinderRecipe entry) {
|
||||
this.entry = entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply()
|
||||
{
|
||||
AEApi.instance().registries().grinder().addRecipe( this.entry );
|
||||
}
|
||||
@Override
|
||||
public void apply() {
|
||||
AEApi.instance().registries().grinder().addRecipe(this.entry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe()
|
||||
{
|
||||
return "Adding Grinder Entry for " + this.entry.getInput().getDisplayName();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding Grinder Entry for " + this.entry.getInput().getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove implements IAction
|
||||
{
|
||||
private final ItemStack stack;
|
||||
private static class Remove implements IAction {
|
||||
private final ItemStack stack;
|
||||
|
||||
private Remove( ItemStack stack )
|
||||
{
|
||||
this.stack = stack;
|
||||
}
|
||||
private Remove(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply()
|
||||
{
|
||||
IGrinderRecipe recipe = AEApi.instance().registries().grinder().getRecipeForInput( this.stack );
|
||||
if( recipe != null )
|
||||
{
|
||||
AEApi.instance().registries().grinder().removeRecipe( recipe );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void apply() {
|
||||
IGrinderRecipe recipe = AEApi.instance().registries().grinder().getRecipeForInput(this.stack);
|
||||
if (recipe != null) {
|
||||
AEApi.instance().registries().grinder().removeRecipe(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe()
|
||||
{
|
||||
return "Removing Grinder Entry for " + this.stack.getDisplayName();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing Grinder Entry for " + this.stack.getDisplayName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,120 +19,101 @@
|
||||
package appeng.integration.modules.crafttweaker;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import crafttweaker.IAction;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.IInscriberRecipe;
|
||||
import appeng.api.features.IInscriberRecipeBuilder;
|
||||
import appeng.api.features.IInscriberRegistry;
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
import crafttweaker.IAction;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@ZenClass( "mods.appliedenergistics2.Inscriber" )
|
||||
public class InscriberRecipes
|
||||
{
|
||||
private InscriberRecipes()
|
||||
{
|
||||
}
|
||||
@ZenClass("mods.appliedenergistics2.Inscriber")
|
||||
public class InscriberRecipes {
|
||||
private InscriberRecipes() {
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe( IItemStack output, IIngredient input, boolean inscribe, @stanhebben.zenscript.annotations.Optional IIngredient top, @stanhebben.zenscript.annotations.Optional IIngredient bottom )
|
||||
{
|
||||
Optional<Collection<ItemStack>> inStacks = CTModule.toStacks( input );
|
||||
if( !inStacks.isPresent() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IIngredient input, boolean inscribe, @stanhebben.zenscript.annotations.Optional IIngredient top, @stanhebben.zenscript.annotations.Optional IIngredient bottom) {
|
||||
Optional<Collection<ItemStack>> inStacks = CTModule.toStacks(input);
|
||||
if (!inStacks.isPresent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Collection<ItemStack> topList = CTModule.toStacks( top ).orElse( Collections.singleton( ItemStack.EMPTY ) );
|
||||
Collection<ItemStack> bottomList = CTModule.toStacks( bottom ).orElse( Collections.singleton( ItemStack.EMPTY ) );
|
||||
Collection<ItemStack> topList = CTModule.toStacks(top).orElse(Collections.singleton(ItemStack.EMPTY));
|
||||
Collection<ItemStack> bottomList = CTModule.toStacks(bottom).orElse(Collections.singleton(ItemStack.EMPTY));
|
||||
|
||||
for( ItemStack topStack : topList )
|
||||
{
|
||||
for( ItemStack bottomStack : bottomList )
|
||||
{
|
||||
final IInscriberRecipeBuilder builder = AEApi.instance().registries().inscriber().builder();
|
||||
builder.withProcessType( inscribe ? InscriberProcessType.INSCRIBE : InscriberProcessType.PRESS )
|
||||
.withOutput( CTModule.toStack( output ) )
|
||||
.withInputs( inStacks.get() );
|
||||
for (ItemStack topStack : topList) {
|
||||
for (ItemStack bottomStack : bottomList) {
|
||||
final IInscriberRecipeBuilder builder = AEApi.instance().registries().inscriber().builder();
|
||||
builder.withProcessType(inscribe ? InscriberProcessType.INSCRIBE : InscriberProcessType.PRESS)
|
||||
.withOutput(CTModule.toStack(output))
|
||||
.withInputs(inStacks.get());
|
||||
|
||||
if( !topStack.isEmpty() )
|
||||
{
|
||||
builder.withTopOptional( topStack );
|
||||
}
|
||||
if( !bottomStack.isEmpty() )
|
||||
{
|
||||
builder.withBottomOptional( bottomStack );
|
||||
}
|
||||
CTModule.MODIFICATIONS.add( new Add( builder.build() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!topStack.isEmpty()) {
|
||||
builder.withTopOptional(topStack);
|
||||
}
|
||||
if (!bottomStack.isEmpty()) {
|
||||
builder.withBottomOptional(bottomStack);
|
||||
}
|
||||
CTModule.MODIFICATIONS.add(new Add(builder.build()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe( IItemStack output )
|
||||
{
|
||||
CTModule.MODIFICATIONS.add( new Remove( (ItemStack) output.getInternal() ) );
|
||||
}
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack output) {
|
||||
CTModule.MODIFICATIONS.add(new Remove((ItemStack) output.getInternal()));
|
||||
}
|
||||
|
||||
private static class Add implements IAction
|
||||
{
|
||||
private final IInscriberRecipe entry;
|
||||
private static class Add implements IAction {
|
||||
private final IInscriberRecipe entry;
|
||||
|
||||
private Add( IInscriberRecipe entry )
|
||||
{
|
||||
this.entry = entry;
|
||||
}
|
||||
private Add(IInscriberRecipe entry) {
|
||||
this.entry = entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply()
|
||||
{
|
||||
AEApi.instance().registries().inscriber().addRecipe( this.entry );
|
||||
}
|
||||
@Override
|
||||
public void apply() {
|
||||
AEApi.instance().registries().inscriber().addRecipe(this.entry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe()
|
||||
{
|
||||
return "Adding Inscriber Entry for " + this.entry.getOutput().getDisplayName();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding Inscriber Entry for " + this.entry.getOutput().getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove implements IAction
|
||||
{
|
||||
private final ItemStack stack;
|
||||
private static class Remove implements IAction {
|
||||
private final ItemStack stack;
|
||||
|
||||
private Remove( ItemStack stack )
|
||||
{
|
||||
this.stack = stack;
|
||||
}
|
||||
private Remove(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply()
|
||||
{
|
||||
final IInscriberRegistry inscriber = AEApi.instance().registries().inscriber();
|
||||
inscriber.getRecipes()
|
||||
.stream()
|
||||
.filter( r -> r.getOutput().isItemEqual( this.stack ) )
|
||||
.collect( Collectors.toList() )
|
||||
.forEach( inscriber::removeRecipe );
|
||||
}
|
||||
@Override
|
||||
public void apply() {
|
||||
final IInscriberRegistry inscriber = AEApi.instance().registries().inscriber();
|
||||
inscriber.getRecipes()
|
||||
.stream()
|
||||
.filter(r -> r.getOutput().isItemEqual(this.stack))
|
||||
.collect(Collectors.toList())
|
||||
.forEach(inscriber::removeRecipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe()
|
||||
{
|
||||
return "Removing Inscriber Entry for " + this.stack.getDisplayName();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing Inscriber Entry for " + this.stack.getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,43 +19,33 @@
|
||||
package appeng.integration.modules.crafttweaker;
|
||||
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.AELog;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.AELog;
|
||||
|
||||
@ZenClass("mods.appliedenergistics2.Spatial")
|
||||
public class SpatialRegistry {
|
||||
private SpatialRegistry() {
|
||||
}
|
||||
|
||||
@ZenClass( "mods.appliedenergistics2.Spatial" )
|
||||
public class SpatialRegistry
|
||||
{
|
||||
private SpatialRegistry()
|
||||
{
|
||||
}
|
||||
@ZenMethod
|
||||
public static void whitelistEntity(String entityClassName) {
|
||||
Class<? extends TileEntity> entityClass = loadClass(entityClassName);
|
||||
if (entityClass != null) {
|
||||
AEApi.instance().registries().movable().whiteListTileEntity(entityClass);
|
||||
}
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void whitelistEntity( String entityClassName )
|
||||
{
|
||||
Class<? extends TileEntity> entityClass = loadClass( entityClassName );
|
||||
if( entityClass != null )
|
||||
{
|
||||
AEApi.instance().registries().movable().whiteListTileEntity( entityClass );
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
private static Class<? extends TileEntity> loadClass( String className )
|
||||
{
|
||||
try
|
||||
{
|
||||
return (Class<? extends TileEntity>) Class.forName( className );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
AELog.warn( e, "Failed to load TileEntity class '" + className + "'" );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Class<? extends TileEntity> loadClass(String className) {
|
||||
try {
|
||||
return (Class<? extends TileEntity>) Class.forName(className);
|
||||
} catch (Exception e) {
|
||||
AELog.warn(e, "Failed to load TileEntity class '" + className + "'");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,6 @@
|
||||
package appeng.integration.modules.ic2;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import ic2.api.item.ElectricItem;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.TunnelType;
|
||||
import appeng.api.features.IP2PTunnelRegistry;
|
||||
@@ -32,60 +27,55 @@ import appeng.integration.abstraction.IC2PowerSink;
|
||||
import appeng.integration.abstraction.IIC2;
|
||||
import appeng.integration.modules.ic2.energy.PoweredItemManager;
|
||||
import appeng.tile.powersink.IExternalPowerSink;
|
||||
import ic2.api.item.ElectricItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
|
||||
public class IC2Module implements IIC2
|
||||
{
|
||||
public class IC2Module implements IIC2 {
|
||||
|
||||
private static final String[] IC2_CABLE_TYPES = { "copper", "glass", "gold", "iron", "tin", "detector", "splitter" };
|
||||
private static final String[] IC2_CABLE_TYPES = {"copper", "glass", "gold", "iron", "tin", "detector", "splitter"};
|
||||
|
||||
public IC2Module()
|
||||
{
|
||||
IntegrationHelper.testClassExistence( this, ic2.api.energy.tile.IEnergyTile.class );
|
||||
IntegrationHelper.testClassExistence( this, ic2.api.energy.tile.IEnergyAcceptor.class );
|
||||
IntegrationHelper.testClassExistence( this, ic2.api.energy.tile.IEnergyEmitter.class );
|
||||
IntegrationHelper.testClassExistence( this, ic2.api.energy.prefab.BasicSinkSource.class );
|
||||
IntegrationHelper.testClassExistence( this, ic2.api.item.IC2Items.class );
|
||||
IntegrationHelper.testClassExistence( this, ic2.api.item.IBackupElectricItemManager.class );
|
||||
IntegrationHelper.testClassExistence( this, ic2.api.recipe.Recipes.class );
|
||||
IntegrationHelper.testClassExistence( this, ic2.api.recipe.IRecipeInput.class );
|
||||
}
|
||||
public IC2Module() {
|
||||
IntegrationHelper.testClassExistence(this, ic2.api.energy.tile.IEnergyTile.class);
|
||||
IntegrationHelper.testClassExistence(this, ic2.api.energy.tile.IEnergyAcceptor.class);
|
||||
IntegrationHelper.testClassExistence(this, ic2.api.energy.tile.IEnergyEmitter.class);
|
||||
IntegrationHelper.testClassExistence(this, ic2.api.energy.prefab.BasicSinkSource.class);
|
||||
IntegrationHelper.testClassExistence(this, ic2.api.item.IC2Items.class);
|
||||
IntegrationHelper.testClassExistence(this, ic2.api.item.IBackupElectricItemManager.class);
|
||||
IntegrationHelper.testClassExistence(this, ic2.api.recipe.Recipes.class);
|
||||
IntegrationHelper.testClassExistence(this, ic2.api.recipe.IRecipeInput.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
final IP2PTunnelRegistry reg = AEApi.instance().registries().p2pTunnel();
|
||||
@Override
|
||||
public void postInit() {
|
||||
final IP2PTunnelRegistry reg = AEApi.instance().registries().p2pTunnel();
|
||||
|
||||
for( String string : IC2_CABLE_TYPES )
|
||||
{
|
||||
reg.addNewAttunement( this.getCable( string ), TunnelType.IC2_POWER );
|
||||
}
|
||||
for (String string : IC2_CABLE_TYPES) {
|
||||
reg.addNewAttunement(this.getCable(string), TunnelType.IC2_POWER);
|
||||
}
|
||||
|
||||
ElectricItem.registerBackupManager( new PoweredItemManager() );
|
||||
}
|
||||
ElectricItem.registerBackupManager(new PoweredItemManager());
|
||||
}
|
||||
|
||||
private ItemStack getItem( final String name, String variant )
|
||||
{
|
||||
return ic2.api.item.IC2Items.getItem( name, variant );
|
||||
}
|
||||
private ItemStack getItem(final String name, String variant) {
|
||||
return ic2.api.item.IC2Items.getItem(name, variant);
|
||||
}
|
||||
|
||||
private ItemStack getCable( final String type )
|
||||
{
|
||||
return this.getItem( "cable", "type:" + type );
|
||||
}
|
||||
private ItemStack getCable(final String type) {
|
||||
return this.getItem("cable", "type:" + type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an IC2 power sink for the given external sink.
|
||||
*/
|
||||
@Override
|
||||
public IC2PowerSink createPowerSink( TileEntity tileEntity, IExternalPowerSink externalSink )
|
||||
{
|
||||
return new IC2PowerSinkAdapter( tileEntity, externalSink );
|
||||
}
|
||||
/**
|
||||
* Create an IC2 power sink for the given external sink.
|
||||
*/
|
||||
@Override
|
||||
public IC2PowerSink createPowerSink(TileEntity tileEntity, IExternalPowerSink externalSink) {
|
||||
return new IC2PowerSinkAdapter(tileEntity, externalSink);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void maceratorRecipe( ItemStack in, ItemStack out )
|
||||
{
|
||||
ic2.api.recipe.Recipes.macerator.addRecipe( new IC2RecipeInput( in, in.getCount() ), null, false, out );
|
||||
}
|
||||
@Override
|
||||
public void maceratorRecipe(ItemStack in, ItemStack out) {
|
||||
ic2.api.recipe.Recipes.macerator.addRecipe(new IC2RecipeInput(in, in.getCount()), null, false, out);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,77 +19,66 @@
|
||||
package appeng.integration.modules.ic2;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import ic2.api.energy.prefab.BasicSink;
|
||||
import ic2.api.energy.tile.IEnergyEmitter;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.integration.abstraction.IC2PowerSink;
|
||||
import appeng.tile.powersink.IExternalPowerSink;
|
||||
import ic2.api.energy.prefab.BasicSink;
|
||||
import ic2.api.energy.tile.IEnergyEmitter;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* The real implementation of IC2PowerSink.
|
||||
*/
|
||||
public class IC2PowerSinkAdapter extends BasicSink implements IC2PowerSink
|
||||
{
|
||||
public class IC2PowerSinkAdapter extends BasicSink implements IC2PowerSink {
|
||||
|
||||
private final IExternalPowerSink powerSink;
|
||||
private final IExternalPowerSink powerSink;
|
||||
|
||||
private final Set<EnumFacing> validFaces = EnumSet.allOf( EnumFacing.class );
|
||||
private final Set<EnumFacing> validFaces = EnumSet.allOf(EnumFacing.class);
|
||||
|
||||
public IC2PowerSinkAdapter( TileEntity tileEntity, IExternalPowerSink powerSink )
|
||||
{
|
||||
super( tileEntity, 0, Integer.MAX_VALUE );
|
||||
this.powerSink = powerSink;
|
||||
}
|
||||
public IC2PowerSinkAdapter(TileEntity tileEntity, IExternalPowerSink powerSink) {
|
||||
super(tileEntity, 0, Integer.MAX_VALUE);
|
||||
this.powerSink = powerSink;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
super.onChunkUnload();
|
||||
}
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
super.onChunkUnload();
|
||||
}
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
{
|
||||
super.onLoad();
|
||||
}
|
||||
@Override
|
||||
public void onLoad() {
|
||||
super.onLoad();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDemandedEnergy()
|
||||
{
|
||||
return this.powerSink.getExternalPowerDemand( PowerUnits.EU, Double.MAX_VALUE );
|
||||
}
|
||||
@Override
|
||||
public double getDemandedEnergy() {
|
||||
return this.powerSink.getExternalPowerDemand(PowerUnits.EU, Double.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergy( EnumFacing directionFrom, double amount, double voltage )
|
||||
{
|
||||
return PowerUnits.EU.convertTo( PowerUnits.AE, this.powerSink.injectExternalPower( PowerUnits.EU, amount, Actionable.MODULATE ) );
|
||||
}
|
||||
@Override
|
||||
public double injectEnergy(EnumFacing directionFrom, double amount, double voltage) {
|
||||
return PowerUnits.EU.convertTo(PowerUnits.AE, this.powerSink.injectExternalPower(PowerUnits.EU, amount, Actionable.MODULATE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom( IEnergyEmitter iEnergyEmitter, EnumFacing side )
|
||||
{
|
||||
return this.validFaces.contains( side );
|
||||
}
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(IEnergyEmitter iEnergyEmitter, EnumFacing side) {
|
||||
return this.validFaces.contains(side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValidFaces( Set<EnumFacing> faces )
|
||||
{
|
||||
this.validFaces.clear();
|
||||
this.validFaces.addAll( faces );
|
||||
}
|
||||
@Override
|
||||
public void setValidFaces(Set<EnumFacing> faces) {
|
||||
this.validFaces.clear();
|
||||
this.validFaces.addAll(faces);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import appeng.integration.abstraction.IC2PowerSink;
|
||||
/**
|
||||
* Implementation of IC2PowerSink that just stubs out all methods and does nothing.
|
||||
*/
|
||||
public enum IC2PowerSinkStub implements IC2PowerSink
|
||||
{
|
||||
INSTANCE
|
||||
public enum IC2PowerSinkStub implements IC2PowerSink {
|
||||
INSTANCE
|
||||
}
|
||||
|
||||
@@ -19,14 +19,12 @@
|
||||
package appeng.integration.modules.ic2;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import ic2.api.recipe.IRecipeInput;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import ic2.api.recipe.IRecipeInput;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -34,33 +32,28 @@ import ic2.api.recipe.IRecipeInput;
|
||||
*
|
||||
* @author GuntherDW
|
||||
*/
|
||||
public class IC2RecipeInput implements IRecipeInput
|
||||
{
|
||||
@Nonnull
|
||||
private final ItemStack itemstack;
|
||||
private final int amount;
|
||||
public class IC2RecipeInput implements IRecipeInput {
|
||||
@Nonnull
|
||||
private final ItemStack itemstack;
|
||||
private final int amount;
|
||||
|
||||
public IC2RecipeInput( ItemStack in, int amount )
|
||||
{
|
||||
this.itemstack = in;
|
||||
this.amount = amount;
|
||||
}
|
||||
public IC2RecipeInput(ItemStack in, int amount) {
|
||||
this.itemstack = in;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches( ItemStack itemStack )
|
||||
{
|
||||
return this.itemstack.isItemEqual( itemStack );
|
||||
}
|
||||
@Override
|
||||
public boolean matches(ItemStack itemStack) {
|
||||
return this.itemstack.isItemEqual(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmount()
|
||||
{
|
||||
return this.amount;
|
||||
}
|
||||
@Override
|
||||
public int getAmount() {
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getInputs()
|
||||
{
|
||||
return Collections.unmodifiableList( Collections.singletonList( this.itemstack ) );
|
||||
}
|
||||
@Override
|
||||
public List<ItemStack> getInputs() {
|
||||
return Collections.unmodifiableList(Collections.singletonList(this.itemstack));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,108 +19,92 @@
|
||||
package appeng.integration.modules.ic2.energy;
|
||||
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import ic2.api.item.IBackupElectricItemManager;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import ic2.api.item.IBackupElectricItemManager;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public class PoweredItemManager implements IBackupElectricItemManager
|
||||
{
|
||||
public class PoweredItemManager implements IBackupElectricItemManager {
|
||||
|
||||
@Override
|
||||
public double charge( ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate )
|
||||
{
|
||||
final double limit = this.getTransferLimit( stack );
|
||||
final IAEItemPowerStorage poweredItem = (IAEItemPowerStorage) stack.getItem();
|
||||
final double convertedPower = PowerUnits.EU.convertTo( PowerUnits.AE, amount );
|
||||
@Override
|
||||
public double charge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate) {
|
||||
final double limit = this.getTransferLimit(stack);
|
||||
final IAEItemPowerStorage poweredItem = (IAEItemPowerStorage) stack.getItem();
|
||||
final double convertedPower = PowerUnits.EU.convertTo(PowerUnits.AE, amount);
|
||||
|
||||
double toAdd = convertedPower;
|
||||
double toAdd = convertedPower;
|
||||
|
||||
if( !ignoreTransferLimit && amount > limit )
|
||||
{
|
||||
toAdd = limit;
|
||||
}
|
||||
if (!ignoreTransferLimit && amount > limit) {
|
||||
toAdd = limit;
|
||||
}
|
||||
|
||||
final double overflow = poweredItem.injectAEPower( stack, toAdd, simulate ? Actionable.SIMULATE : Actionable.MODULATE );
|
||||
final double addedAmount = toAdd - (int) overflow;
|
||||
final double overflow = poweredItem.injectAEPower(stack, toAdd, simulate ? Actionable.SIMULATE : Actionable.MODULATE);
|
||||
final double addedAmount = toAdd - (int) overflow;
|
||||
|
||||
return PowerUnits.AE.convertTo( PowerUnits.EU, addedAmount );
|
||||
}
|
||||
return PowerUnits.AE.convertTo(PowerUnits.EU, addedAmount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double discharge( ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public double discharge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCharge( ItemStack stack )
|
||||
{
|
||||
final IAEItemPowerStorage poweredItem = (IAEItemPowerStorage) stack.getItem();
|
||||
return (int) PowerUnits.AE.convertTo( PowerUnits.EU, poweredItem.getAECurrentPower( stack ) );
|
||||
}
|
||||
@Override
|
||||
public double getCharge(ItemStack stack) {
|
||||
final IAEItemPowerStorage poweredItem = (IAEItemPowerStorage) stack.getItem();
|
||||
return (int) PowerUnits.AE.convertTo(PowerUnits.EU, poweredItem.getAECurrentPower(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxCharge( ItemStack stack )
|
||||
{
|
||||
final IAEItemPowerStorage poweredItem = (IAEItemPowerStorage) stack.getItem();
|
||||
return PowerUnits.AE.convertTo( PowerUnits.EU, poweredItem.getAEMaxPower( stack ) );
|
||||
}
|
||||
@Override
|
||||
public double getMaxCharge(ItemStack stack) {
|
||||
final IAEItemPowerStorage poweredItem = (IAEItemPowerStorage) stack.getItem();
|
||||
return PowerUnits.AE.convertTo(PowerUnits.EU, poweredItem.getAEMaxPower(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUse( ItemStack stack, double amount )
|
||||
{
|
||||
return this.getCharge( stack ) > amount;
|
||||
}
|
||||
@Override
|
||||
public boolean canUse(ItemStack stack, double amount) {
|
||||
return this.getCharge(stack) > amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean use( ItemStack stack, double amount, EntityLivingBase entity )
|
||||
{
|
||||
final IAEItemPowerStorage poweredItem = (IAEItemPowerStorage) stack.getItem();
|
||||
@Override
|
||||
public boolean use(ItemStack stack, double amount, EntityLivingBase entity) {
|
||||
final IAEItemPowerStorage poweredItem = (IAEItemPowerStorage) stack.getItem();
|
||||
|
||||
if( this.canUse( stack, amount ) )
|
||||
{
|
||||
final double toUse = PowerUnits.EU.convertTo( PowerUnits.AE, amount );
|
||||
if (this.canUse(stack, amount)) {
|
||||
final double toUse = PowerUnits.EU.convertTo(PowerUnits.AE, amount);
|
||||
|
||||
poweredItem.extractAEPower( stack, toUse, Actionable.MODULATE );
|
||||
poweredItem.extractAEPower(stack, toUse, Actionable.MODULATE);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chargeFromArmor( ItemStack stack, EntityLivingBase entity )
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
@Override
|
||||
public void chargeFromArmor(ItemStack stack, EntityLivingBase entity) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToolTip( ItemStack stack )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public String getToolTip(ItemStack stack) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTier( ItemStack stack )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public int getTier(ItemStack stack) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handles( ItemStack stack )
|
||||
{
|
||||
return !stack.isEmpty() && ( stack.getItem() instanceof IAEItemPowerStorage );
|
||||
}
|
||||
@Override
|
||||
public boolean handles(ItemStack stack) {
|
||||
return !stack.isEmpty() && (stack.getItem() instanceof IAEItemPowerStorage);
|
||||
}
|
||||
|
||||
private double getTransferLimit( ItemStack itemStack )
|
||||
{
|
||||
return Math.max( 32, this.getMaxCharge( itemStack ) / 200 );
|
||||
}
|
||||
private double getTransferLimit(ItemStack itemStack) {
|
||||
return Math.max(32, this.getMaxCharge(itemStack) / 200);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+20
-30
@@ -1,41 +1,31 @@
|
||||
|
||||
package appeng.integration.modules.inventorytweaks;
|
||||
|
||||
|
||||
import appeng.integration.abstraction.IInvTweaks;
|
||||
import invtweaks.api.InvTweaksAPI;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
|
||||
import invtweaks.api.InvTweaksAPI;
|
||||
|
||||
import appeng.integration.abstraction.IInvTweaks;
|
||||
public class InventoryTweaksModule implements IInvTweaks {
|
||||
InvTweaksAPI api = null;
|
||||
|
||||
public InventoryTweaksModule() {
|
||||
try {
|
||||
this.api = (InvTweaksAPI) Class.forName("invtweaks.forge.InvTweaksMod", true, Loader.instance().getModClassLoader())
|
||||
.getField("instance")
|
||||
.get(null);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
public class InventoryTweaksModule implements IInvTweaks
|
||||
{
|
||||
InvTweaksAPI api = null;
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return this.api != null;
|
||||
}
|
||||
|
||||
public InventoryTweaksModule()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.api = (InvTweaksAPI) Class.forName( "invtweaks.forge.InvTweaksMod", true, Loader.instance().getModClassLoader() )
|
||||
.getField( "instance" )
|
||||
.get( null );
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return this.api != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareItems( ItemStack i, ItemStack j )
|
||||
{
|
||||
return this.api.compareItems( i, j );
|
||||
}
|
||||
@Override
|
||||
public int compareItems(ItemStack i, ItemStack j) {
|
||||
return this.api.compareItems(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,132 +19,115 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IDrawableAnimated;
|
||||
import mezz.jei.api.gui.IDrawableStatic;
|
||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.api.implementations.items.IStorageComponent;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.misc.TileCondenser;
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.*;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
class CondenserCategory implements IRecipeCategory<CondenserOutputWrapper>
|
||||
{
|
||||
class CondenserCategory implements IRecipeCategory<CondenserOutputWrapper> {
|
||||
|
||||
public static final String UID = "appliedenergistics2.condenser";
|
||||
public static final String UID = "appliedenergistics2.condenser";
|
||||
|
||||
private final String localizedName;
|
||||
private final String localizedName;
|
||||
|
||||
private final IDrawable background;
|
||||
private final IDrawable background;
|
||||
|
||||
private final IDrawable iconTrash;
|
||||
private final IDrawable iconTrash;
|
||||
|
||||
private final IDrawableAnimated progress;
|
||||
private final IDrawableAnimated progress;
|
||||
|
||||
private final IDrawable iconButton;
|
||||
private final IDrawable iconButton;
|
||||
|
||||
public CondenserCategory( IGuiHelper guiHelper )
|
||||
{
|
||||
this.localizedName = I18n.format( "gui.appliedenergistics2.Condenser" );
|
||||
public CondenserCategory(IGuiHelper guiHelper) {
|
||||
this.localizedName = I18n.format("gui.appliedenergistics2.Condenser");
|
||||
|
||||
ResourceLocation location = new ResourceLocation( AppEng.MOD_ID, "textures/guis/condenser.png" );
|
||||
this.background = guiHelper.createDrawable( location, 50, 25, 94, 48 );
|
||||
ResourceLocation location = new ResourceLocation(AppEng.MOD_ID, "textures/guis/condenser.png");
|
||||
this.background = guiHelper.createDrawable(location, 50, 25, 94, 48);
|
||||
|
||||
ResourceLocation statesLocation = new ResourceLocation( AppEng.MOD_ID, "textures/guis/states.png" );
|
||||
this.iconTrash = guiHelper.createDrawable( statesLocation, 241, 81, 14, 14, 28, 0, 2, 0 );
|
||||
this.iconButton = guiHelper.createDrawable( statesLocation, 240, 240, 16, 16, 28, 0, 78, 0 );
|
||||
ResourceLocation statesLocation = new ResourceLocation(AppEng.MOD_ID, "textures/guis/states.png");
|
||||
this.iconTrash = guiHelper.createDrawable(statesLocation, 241, 81, 14, 14, 28, 0, 2, 0);
|
||||
this.iconButton = guiHelper.createDrawable(statesLocation, 240, 240, 16, 16, 28, 0, 78, 0);
|
||||
|
||||
IDrawableStatic progressDrawable = guiHelper.createDrawable( location, 178, 25, 6, 18, 0, 0, 70, 0 );
|
||||
this.progress = guiHelper.createAnimatedDrawable( progressDrawable, 40, IDrawableAnimated.StartDirection.BOTTOM, false );
|
||||
}
|
||||
IDrawableStatic progressDrawable = guiHelper.createDrawable(location, 178, 25, 6, 18, 0, 0, 70, 0);
|
||||
this.progress = guiHelper.createAnimatedDrawable(progressDrawable, 40, IDrawableAnimated.StartDirection.BOTTOM, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUid()
|
||||
{
|
||||
return CondenserCategory.UID;
|
||||
}
|
||||
@Override
|
||||
public String getUid() {
|
||||
return CondenserCategory.UID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return this.localizedName;
|
||||
}
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return this.localizedName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the mod associated with this recipe category.
|
||||
* Used for the recipe category tab's tooltip.
|
||||
*
|
||||
* @since JEI 4.5.0
|
||||
*/
|
||||
@Override
|
||||
public String getModName()
|
||||
{
|
||||
return AppEng.MOD_NAME;
|
||||
}
|
||||
/**
|
||||
* Return the name of the mod associated with this recipe category.
|
||||
* Used for the recipe category tab's tooltip.
|
||||
*
|
||||
* @since JEI 4.5.0
|
||||
*/
|
||||
@Override
|
||||
public String getModName() {
|
||||
return AppEng.MOD_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground()
|
||||
{
|
||||
return this.background;
|
||||
}
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return this.background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras( Minecraft minecraft )
|
||||
{
|
||||
this.progress.draw( minecraft );
|
||||
this.iconTrash.draw( minecraft );
|
||||
this.iconButton.draw( minecraft );
|
||||
}
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
this.progress.draw(minecraft);
|
||||
this.iconTrash.draw(minecraft);
|
||||
this.iconButton.draw(minecraft);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe( IRecipeLayout recipeLayout, CondenserOutputWrapper recipeWrapper, IIngredients ingredients )
|
||||
{
|
||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
itemStacks.init( 0, false, 54, 26 );
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, CondenserOutputWrapper recipeWrapper, IIngredients ingredients) {
|
||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
itemStacks.init(0, false, 54, 26);
|
||||
|
||||
// Get all storage cells and cycle them through a fake input slot
|
||||
itemStacks.init( 1, true, 50, 0 );
|
||||
itemStacks.set( 1, this.getViableStorageComponents( recipeWrapper ) );
|
||||
// Get all storage cells and cycle them through a fake input slot
|
||||
itemStacks.init(1, true, 50, 0);
|
||||
itemStacks.set(1, this.getViableStorageComponents(recipeWrapper));
|
||||
|
||||
// This only sets the output
|
||||
itemStacks.set( ingredients );
|
||||
}
|
||||
// This only sets the output
|
||||
itemStacks.set(ingredients);
|
||||
}
|
||||
|
||||
private List<ItemStack> getViableStorageComponents( CondenserOutputWrapper recipeWrapper )
|
||||
{
|
||||
CondenserOutput condenserOutput = recipeWrapper.getCondenserOutput();
|
||||
IMaterials materials = AEApi.instance().definitions().materials();
|
||||
List<ItemStack> viableComponents = new ArrayList<>();
|
||||
materials.cell1kPart().maybeStack( 1 ).ifPresent( itemStack -> this.addViableComponent( condenserOutput, viableComponents, itemStack ) );
|
||||
materials.cell4kPart().maybeStack( 1 ).ifPresent( itemStack -> this.addViableComponent( condenserOutput, viableComponents, itemStack ) );
|
||||
materials.cell16kPart().maybeStack( 1 ).ifPresent( itemStack -> this.addViableComponent( condenserOutput, viableComponents, itemStack ) );
|
||||
materials.cell64kPart().maybeStack( 1 ).ifPresent( itemStack -> this.addViableComponent( condenserOutput, viableComponents, itemStack ) );
|
||||
return viableComponents;
|
||||
}
|
||||
private List<ItemStack> getViableStorageComponents(CondenserOutputWrapper recipeWrapper) {
|
||||
CondenserOutput condenserOutput = recipeWrapper.getCondenserOutput();
|
||||
IMaterials materials = AEApi.instance().definitions().materials();
|
||||
List<ItemStack> viableComponents = new ArrayList<>();
|
||||
materials.cell1kPart().maybeStack(1).ifPresent(itemStack -> this.addViableComponent(condenserOutput, viableComponents, itemStack));
|
||||
materials.cell4kPart().maybeStack(1).ifPresent(itemStack -> this.addViableComponent(condenserOutput, viableComponents, itemStack));
|
||||
materials.cell16kPart().maybeStack(1).ifPresent(itemStack -> this.addViableComponent(condenserOutput, viableComponents, itemStack));
|
||||
materials.cell64kPart().maybeStack(1).ifPresent(itemStack -> this.addViableComponent(condenserOutput, viableComponents, itemStack));
|
||||
return viableComponents;
|
||||
}
|
||||
|
||||
private void addViableComponent( CondenserOutput condenserOutput, List<ItemStack> viableComponents, ItemStack itemStack )
|
||||
{
|
||||
IStorageComponent comp = (IStorageComponent) itemStack.getItem();
|
||||
int storage = comp.getBytes( itemStack ) * TileCondenser.BYTE_MULTIPLIER;
|
||||
if( storage >= condenserOutput.requiredPower )
|
||||
{
|
||||
viableComponents.add( itemStack );
|
||||
}
|
||||
}
|
||||
private void addViableComponent(CondenserOutput condenserOutput, List<ItemStack> viableComponents, ItemStack itemStack) {
|
||||
IStorageComponent comp = (IStorageComponent) itemStack.getItem();
|
||||
int storage = comp.getBytes(itemStack) * TileCondenser.BYTE_MULTIPLIER;
|
||||
if (storage >= condenserOutput.requiredPower) {
|
||||
viableComponents.add(itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,47 +19,41 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import appeng.core.AppEng;
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import mezz.jei.api.recipe.IRecipeWrapperFactory;
|
||||
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import appeng.core.AppEng;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
|
||||
class CondenserOutputHandler implements IRecipeWrapperFactory<CondenserOutput>
|
||||
{
|
||||
class CondenserOutputHandler implements IRecipeWrapperFactory<CondenserOutput> {
|
||||
|
||||
private final ItemStack matterBall;
|
||||
private final ItemStack singularity;
|
||||
private final IDrawable iconButtonMatterBall;
|
||||
private final IDrawable iconButtonSingularity;
|
||||
private final ItemStack matterBall;
|
||||
private final ItemStack singularity;
|
||||
private final IDrawable iconButtonMatterBall;
|
||||
private final IDrawable iconButtonSingularity;
|
||||
|
||||
public CondenserOutputHandler( IGuiHelper guiHelper, ItemStack matterBall, ItemStack singularity )
|
||||
{
|
||||
this.matterBall = matterBall;
|
||||
this.singularity = singularity;
|
||||
public CondenserOutputHandler(IGuiHelper guiHelper, ItemStack matterBall, ItemStack singularity) {
|
||||
this.matterBall = matterBall;
|
||||
this.singularity = singularity;
|
||||
|
||||
ResourceLocation statesLocation = new ResourceLocation( AppEng.MOD_ID, "textures/guis/states.png" );
|
||||
this.iconButtonMatterBall = guiHelper.createDrawable( statesLocation, 16, 112, 14, 14, 28, 0, 78, 0 );
|
||||
this.iconButtonSingularity = guiHelper.createDrawable( statesLocation, 32, 112, 14, 14, 28, 0, 78, 0 );
|
||||
}
|
||||
ResourceLocation statesLocation = new ResourceLocation(AppEng.MOD_ID, "textures/guis/states.png");
|
||||
this.iconButtonMatterBall = guiHelper.createDrawable(statesLocation, 16, 112, 14, 14, 28, 0, 78, 0);
|
||||
this.iconButtonSingularity = guiHelper.createDrawable(statesLocation, 32, 112, 14, 14, 28, 0, 78, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper( CondenserOutput recipe )
|
||||
{
|
||||
switch( recipe )
|
||||
{
|
||||
case MATTER_BALLS:
|
||||
return new CondenserOutputWrapper( recipe, this.matterBall, this.iconButtonMatterBall );
|
||||
case SINGULARITY:
|
||||
return new CondenserOutputWrapper( recipe, this.singularity, this.iconButtonSingularity );
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(CondenserOutput recipe) {
|
||||
switch (recipe) {
|
||||
case MATTER_BALLS:
|
||||
return new CondenserOutputWrapper(recipe, this.matterBall, this.iconButtonMatterBall);
|
||||
case SINGULARITY:
|
||||
return new CondenserOutputWrapper(recipe, this.singularity, this.iconButtonSingularity);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,82 +19,70 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import com.google.common.base.Splitter;
|
||||
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.client.config.HoverChecker;
|
||||
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
class CondenserOutputWrapper implements IRecipeWrapper
|
||||
{
|
||||
private final ItemStack outputItem;
|
||||
class CondenserOutputWrapper implements IRecipeWrapper {
|
||||
private final ItemStack outputItem;
|
||||
|
||||
private final CondenserOutput condenserOutput;
|
||||
private final CondenserOutput condenserOutput;
|
||||
|
||||
private final HoverChecker buttonHoverChecker;
|
||||
private final HoverChecker buttonHoverChecker;
|
||||
|
||||
private final IDrawable buttonIcon;
|
||||
private final IDrawable buttonIcon;
|
||||
|
||||
CondenserOutputWrapper( CondenserOutput condenserOutput, ItemStack outputItem, IDrawable buttonIcon )
|
||||
{
|
||||
this.condenserOutput = condenserOutput;
|
||||
this.outputItem = outputItem;
|
||||
this.buttonIcon = buttonIcon;
|
||||
this.buttonHoverChecker = new HoverChecker( 28, 28 + 16, 78, 78 + 16, 0 );
|
||||
}
|
||||
CondenserOutputWrapper(CondenserOutput condenserOutput, ItemStack outputItem, IDrawable buttonIcon) {
|
||||
this.condenserOutput = condenserOutput;
|
||||
this.outputItem = outputItem;
|
||||
this.buttonIcon = buttonIcon;
|
||||
this.buttonHoverChecker = new HoverChecker(28, 28 + 16, 78, 78 + 16, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getIngredients( IIngredients ingredients )
|
||||
{
|
||||
ingredients.setOutput( ItemStack.class, this.outputItem );
|
||||
}
|
||||
@Override
|
||||
public void getIngredients(IIngredients ingredients) {
|
||||
ingredients.setOutput(ItemStack.class, this.outputItem);
|
||||
}
|
||||
|
||||
public CondenserOutput getCondenserOutput()
|
||||
{
|
||||
return this.condenserOutput;
|
||||
}
|
||||
public CondenserOutput getCondenserOutput() {
|
||||
return this.condenserOutput;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> getTooltipStrings( int mouseX, int mouseY )
|
||||
{
|
||||
if( this.buttonHoverChecker.checkHover( mouseX, mouseY ) )
|
||||
{
|
||||
String key;
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> getTooltipStrings(int mouseX, int mouseY) {
|
||||
if (this.buttonHoverChecker.checkHover(mouseX, mouseY)) {
|
||||
String key;
|
||||
|
||||
switch( this.condenserOutput )
|
||||
{
|
||||
case MATTER_BALLS:
|
||||
key = "gui.tooltips.appliedenergistics2.MatterBalls";
|
||||
break;
|
||||
case SINGULARITY:
|
||||
key = "gui.tooltips.appliedenergistics2.Singularity";
|
||||
break;
|
||||
default:
|
||||
return Collections.emptyList();
|
||||
}
|
||||
switch (this.condenserOutput) {
|
||||
case MATTER_BALLS:
|
||||
key = "gui.tooltips.appliedenergistics2.MatterBalls";
|
||||
break;
|
||||
case SINGULARITY:
|
||||
key = "gui.tooltips.appliedenergistics2.Singularity";
|
||||
break;
|
||||
default:
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return Splitter.on( "\\n" ).splitToList( I18n.format( key, this.condenserOutput.requiredPower ) );
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Splitter.on("\\n").splitToList(I18n.format(key, this.condenserOutput.requiredPower));
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo( Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY )
|
||||
{
|
||||
this.buttonIcon.draw( minecraft );
|
||||
}
|
||||
@Override
|
||||
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||
this.buttonIcon.draw(minecraft);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,64 +19,58 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Acts as a fake facade recipe wrapper, created by {@link FacadeRegistryPlugin}.
|
||||
*/
|
||||
class FacadeRecipeWrapper implements IShapedCraftingRecipeWrapper
|
||||
{
|
||||
class FacadeRecipeWrapper implements IShapedCraftingRecipeWrapper {
|
||||
|
||||
private final ItemStack textureItem;
|
||||
private final ItemStack textureItem;
|
||||
|
||||
private final ItemStack cableAnchor;
|
||||
private final ItemStack cableAnchor;
|
||||
|
||||
private final ItemStack facade;
|
||||
private final ItemStack facade;
|
||||
|
||||
FacadeRecipeWrapper( ItemStack textureItem, ItemStack cableAnchor, ItemStack facade )
|
||||
{
|
||||
this.textureItem = textureItem;
|
||||
this.cableAnchor = cableAnchor;
|
||||
this.facade = facade;
|
||||
}
|
||||
FacadeRecipeWrapper(ItemStack textureItem, ItemStack cableAnchor, ItemStack facade) {
|
||||
this.textureItem = textureItem;
|
||||
this.cableAnchor = cableAnchor;
|
||||
this.facade = facade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getIngredients( IIngredients ingredients )
|
||||
{
|
||||
List<ItemStack> input = new ArrayList<>( 9 );
|
||||
@Override
|
||||
public void getIngredients(IIngredients ingredients) {
|
||||
List<ItemStack> input = new ArrayList<>(9);
|
||||
|
||||
input.add( ItemStack.EMPTY );
|
||||
input.add( this.cableAnchor );
|
||||
input.add( ItemStack.EMPTY );
|
||||
input.add(ItemStack.EMPTY);
|
||||
input.add(this.cableAnchor);
|
||||
input.add(ItemStack.EMPTY);
|
||||
|
||||
input.add( this.cableAnchor );
|
||||
input.add( this.textureItem );
|
||||
input.add( this.cableAnchor );
|
||||
input.add(this.cableAnchor);
|
||||
input.add(this.textureItem);
|
||||
input.add(this.cableAnchor);
|
||||
|
||||
input.add( ItemStack.EMPTY );
|
||||
input.add( this.cableAnchor );
|
||||
input.add( ItemStack.EMPTY );
|
||||
input.add(ItemStack.EMPTY);
|
||||
input.add(this.cableAnchor);
|
||||
input.add(ItemStack.EMPTY);
|
||||
|
||||
ingredients.setInputs( ItemStack.class, input );
|
||||
ingredients.setOutput( ItemStack.class, this.facade );
|
||||
}
|
||||
ingredients.setInputs(ItemStack.class, input);
|
||||
ingredients.setOutput(ItemStack.class, this.facade);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,101 +19,79 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.items.parts.ItemFacade;
|
||||
import mezz.jei.api.recipe.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import mezz.jei.api.recipe.IFocus;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
import mezz.jei.api.recipe.IRecipeRegistryPlugin;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
|
||||
|
||||
import appeng.items.parts.ItemFacade;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* This plugin will dynamically add facade recipes for any item that can be turned into a facade.
|
||||
*/
|
||||
class FacadeRegistryPlugin implements IRecipeRegistryPlugin
|
||||
{
|
||||
class FacadeRegistryPlugin implements IRecipeRegistryPlugin {
|
||||
|
||||
private final ItemFacade itemFacade;
|
||||
private final ItemFacade itemFacade;
|
||||
|
||||
private final ItemStack cableAnchor;
|
||||
private final ItemStack cableAnchor;
|
||||
|
||||
FacadeRegistryPlugin( ItemFacade itemFacade, ItemStack cableAnchor )
|
||||
{
|
||||
this.itemFacade = itemFacade;
|
||||
this.cableAnchor = cableAnchor;
|
||||
}
|
||||
FacadeRegistryPlugin(ItemFacade itemFacade, ItemStack cableAnchor) {
|
||||
this.itemFacade = itemFacade;
|
||||
this.cableAnchor = cableAnchor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> List<String> getRecipeCategoryUids( IFocus<V> focus )
|
||||
{
|
||||
if( focus.getMode() == IFocus.Mode.OUTPUT && focus.getValue() instanceof ItemStack )
|
||||
{
|
||||
// Looking up how a certain facade is crafted
|
||||
ItemStack itemStack = (ItemStack) focus.getValue();
|
||||
if( itemStack.getItem() instanceof ItemFacade )
|
||||
{
|
||||
return Collections.singletonList( VanillaRecipeCategoryUid.CRAFTING );
|
||||
}
|
||||
}
|
||||
else if( focus.getMode() == IFocus.Mode.INPUT && focus.getValue() instanceof ItemStack )
|
||||
{
|
||||
// Looking up if a certain block can be used to make a facade
|
||||
ItemStack itemStack = (ItemStack) focus.getValue();
|
||||
@Override
|
||||
public <V> List<String> getRecipeCategoryUids(IFocus<V> focus) {
|
||||
if (focus.getMode() == IFocus.Mode.OUTPUT && focus.getValue() instanceof ItemStack) {
|
||||
// Looking up how a certain facade is crafted
|
||||
ItemStack itemStack = (ItemStack) focus.getValue();
|
||||
if (itemStack.getItem() instanceof ItemFacade) {
|
||||
return Collections.singletonList(VanillaRecipeCategoryUid.CRAFTING);
|
||||
}
|
||||
} else if (focus.getMode() == IFocus.Mode.INPUT && focus.getValue() instanceof ItemStack) {
|
||||
// Looking up if a certain block can be used to make a facade
|
||||
ItemStack itemStack = (ItemStack) focus.getValue();
|
||||
|
||||
if( !this.itemFacade.createFacadeForItem( itemStack, true ).isEmpty() )
|
||||
{
|
||||
return Collections.singletonList( VanillaRecipeCategoryUid.CRAFTING );
|
||||
}
|
||||
}
|
||||
if (!this.itemFacade.createFacadeForItem(itemStack, true).isEmpty()) {
|
||||
return Collections.singletonList(VanillaRecipeCategoryUid.CRAFTING);
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
@Override
|
||||
public <T extends IRecipeWrapper, V> List<T> getRecipeWrappers( IRecipeCategory<T> recipeCategory, IFocus<V> focus )
|
||||
{
|
||||
if( !VanillaRecipeCategoryUid.CRAFTING.equals( recipeCategory.getUid() ) )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T extends IRecipeWrapper, V> List<T> getRecipeWrappers(IRecipeCategory<T> recipeCategory, IFocus<V> focus) {
|
||||
if (!VanillaRecipeCategoryUid.CRAFTING.equals(recipeCategory.getUid())) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
if( focus.getMode() == IFocus.Mode.OUTPUT && focus.getValue() instanceof ItemStack )
|
||||
{
|
||||
// Looking up how a certain facade is crafted
|
||||
ItemStack itemStack = (ItemStack) focus.getValue();
|
||||
if( itemStack.getItem() instanceof ItemFacade )
|
||||
{
|
||||
ItemFacade facadeItem = (ItemFacade) itemStack.getItem();
|
||||
ItemStack textureItem = facadeItem.getTextureItem( itemStack );
|
||||
return Collections.singletonList( (T) new FacadeRecipeWrapper( textureItem, this.cableAnchor, itemStack ) );
|
||||
}
|
||||
}
|
||||
else if( focus.getMode() == IFocus.Mode.INPUT && focus.getValue() instanceof ItemStack )
|
||||
{
|
||||
// Looking up if a certain block can be used to make a facade
|
||||
if (focus.getMode() == IFocus.Mode.OUTPUT && focus.getValue() instanceof ItemStack) {
|
||||
// Looking up how a certain facade is crafted
|
||||
ItemStack itemStack = (ItemStack) focus.getValue();
|
||||
if (itemStack.getItem() instanceof ItemFacade) {
|
||||
ItemFacade facadeItem = (ItemFacade) itemStack.getItem();
|
||||
ItemStack textureItem = facadeItem.getTextureItem(itemStack);
|
||||
return Collections.singletonList((T) new FacadeRecipeWrapper(textureItem, this.cableAnchor, itemStack));
|
||||
}
|
||||
} else if (focus.getMode() == IFocus.Mode.INPUT && focus.getValue() instanceof ItemStack) {
|
||||
// Looking up if a certain block can be used to make a facade
|
||||
|
||||
ItemStack itemStack = (ItemStack) focus.getValue();
|
||||
ItemStack facade = this.itemFacade.createFacadeForItem( itemStack, false );
|
||||
ItemStack itemStack = (ItemStack) focus.getValue();
|
||||
ItemStack facade = this.itemFacade.createFacadeForItem(itemStack, false);
|
||||
|
||||
if( !facade.isEmpty() )
|
||||
{
|
||||
return Collections.singletonList( (T) new FacadeRecipeWrapper( itemStack, this.cableAnchor, facade ) );
|
||||
}
|
||||
}
|
||||
if (!facade.isEmpty()) {
|
||||
return Collections.singletonList((T) new FacadeRecipeWrapper(itemStack, this.cableAnchor, facade));
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IRecipeWrapper> List<T> getRecipeWrappers( IRecipeCategory<T> recipeCategory )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@Override
|
||||
public <T extends IRecipeWrapper> List<T> getRecipeWrappers(IRecipeCategory<T> recipeCategory) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,7 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.IJeiHelpers;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
@@ -30,73 +28,64 @@ import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
|
||||
class GrinderRecipeCategory implements IRecipeCategory<GrinderRecipeWrapper>, IRecipeCategoryRegistration
|
||||
{
|
||||
class GrinderRecipeCategory implements IRecipeCategory<GrinderRecipeWrapper>, IRecipeCategoryRegistration {
|
||||
|
||||
public static final String UID = "appliedenergistics2.grinder";
|
||||
public static final String UID = "appliedenergistics2.grinder";
|
||||
|
||||
private final String localizedName;
|
||||
private final String localizedName;
|
||||
|
||||
private final IDrawable background;
|
||||
private final IDrawable background;
|
||||
|
||||
public GrinderRecipeCategory( IGuiHelper guiHelper )
|
||||
{
|
||||
this.localizedName = I18n.format( "tile.appliedenergistics2.grindstone.name" );
|
||||
public GrinderRecipeCategory(IGuiHelper guiHelper) {
|
||||
this.localizedName = I18n.format("tile.appliedenergistics2.grindstone.name");
|
||||
|
||||
ResourceLocation location = new ResourceLocation( AppEng.MOD_ID, "textures/guis/grinder.png" );
|
||||
this.background = guiHelper.createDrawable( location, 11, 16, 154, 70 );
|
||||
}
|
||||
ResourceLocation location = new ResourceLocation(AppEng.MOD_ID, "textures/guis/grinder.png");
|
||||
this.background = guiHelper.createDrawable(location, 11, 16, 154, 70);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModName()
|
||||
{
|
||||
return AppEng.MOD_NAME;
|
||||
}
|
||||
@Override
|
||||
public String getModName() {
|
||||
return AppEng.MOD_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUid()
|
||||
{
|
||||
return GrinderRecipeCategory.UID;
|
||||
}
|
||||
@Override
|
||||
public String getUid() {
|
||||
return GrinderRecipeCategory.UID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return this.localizedName;
|
||||
}
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return this.localizedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground()
|
||||
{
|
||||
return this.background;
|
||||
}
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return this.background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe( IRecipeLayout recipeLayout, GrinderRecipeWrapper recipeWrapper, IIngredients ingredients )
|
||||
{
|
||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, GrinderRecipeWrapper recipeWrapper, IIngredients ingredients) {
|
||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
itemStacks.init( 0, true, 0, 0 );
|
||||
itemStacks.init( 1, false, 100, 46 );
|
||||
itemStacks.init( 2, false, 118, 46 );
|
||||
itemStacks.init( 3, false, 136, 46 );
|
||||
itemStacks.init(0, true, 0, 0);
|
||||
itemStacks.init(1, false, 100, 46);
|
||||
itemStacks.init(2, false, 118, 46);
|
||||
itemStacks.init(3, false, 136, 46);
|
||||
|
||||
itemStacks.set( ingredients );
|
||||
}
|
||||
itemStacks.set(ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipeCategories( IRecipeCategory... recipeCategories )
|
||||
{
|
||||
@Override
|
||||
public void addRecipeCategories(IRecipeCategory... recipeCategories) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IJeiHelpers getJeiHelpers()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public IJeiHelpers getJeiHelpers() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,17 +19,14 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import appeng.api.features.IGrinderRecipe;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import mezz.jei.api.recipe.IRecipeWrapperFactory;
|
||||
|
||||
import appeng.api.features.IGrinderRecipe;
|
||||
|
||||
|
||||
class GrinderRecipeHandler implements IRecipeWrapperFactory<IGrinderRecipe>
|
||||
{
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper( IGrinderRecipe recipe )
|
||||
{
|
||||
return new GrinderRecipeWrapper( recipe );
|
||||
}
|
||||
class GrinderRecipeHandler implements IRecipeWrapperFactory<IGrinderRecipe> {
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(IGrinderRecipe recipe) {
|
||||
return new GrinderRecipeWrapper(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,71 +19,63 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.features.IGrinderRecipe;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
|
||||
import appeng.api.features.IGrinderRecipe;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
class GrinderRecipeWrapper implements IRecipeWrapper
|
||||
{
|
||||
class GrinderRecipeWrapper implements IRecipeWrapper {
|
||||
|
||||
private final IGrinderRecipe recipe;
|
||||
private final IGrinderRecipe recipe;
|
||||
|
||||
GrinderRecipeWrapper( IGrinderRecipe recipe )
|
||||
{
|
||||
this.recipe = recipe;
|
||||
}
|
||||
GrinderRecipeWrapper(IGrinderRecipe recipe) {
|
||||
this.recipe = recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getIngredients( IIngredients ingredients )
|
||||
{
|
||||
ingredients.setInput( ItemStack.class, this.recipe.getInput() );
|
||||
List<ItemStack> outputs = new ArrayList<>( 3 );
|
||||
outputs.add( this.recipe.getOutput() );
|
||||
this.recipe.getOptionalOutput().ifPresent( outputs::add );
|
||||
this.recipe.getSecondOptionalOutput().ifPresent( outputs::add );
|
||||
ingredients.setOutputs( ItemStack.class, outputs );
|
||||
}
|
||||
@Override
|
||||
public void getIngredients(IIngredients ingredients) {
|
||||
ingredients.setInput(ItemStack.class, this.recipe.getInput());
|
||||
List<ItemStack> outputs = new ArrayList<>(3);
|
||||
outputs.add(this.recipe.getOutput());
|
||||
this.recipe.getOptionalOutput().ifPresent(outputs::add);
|
||||
this.recipe.getSecondOptionalOutput().ifPresent(outputs::add);
|
||||
ingredients.setOutputs(ItemStack.class, outputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo( Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY )
|
||||
{
|
||||
@Override
|
||||
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||
|
||||
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
|
||||
int x = 118;
|
||||
int x = 118;
|
||||
|
||||
final float scale = 0.85f;
|
||||
final float invScale = 1 / scale;
|
||||
GlStateManager.scale( scale, scale, 1 );
|
||||
final float scale = 0.85f;
|
||||
final float invScale = 1 / scale;
|
||||
GlStateManager.scale(scale, scale, 1);
|
||||
|
||||
if( this.recipe.getOptionalOutput() != null )
|
||||
{
|
||||
String text = String.format( "%d%%", (int) ( this.recipe.getOptionalChance() * 100 ) );
|
||||
float width = fr.getStringWidth( text ) * scale;
|
||||
int xScaled = Math.round( ( x + ( 18 - width ) / 2 ) * invScale );
|
||||
fr.drawString( text, xScaled, (int) ( 65 * invScale ), Color.gray.getRGB() );
|
||||
x += 18;
|
||||
}
|
||||
if (this.recipe.getOptionalOutput() != null) {
|
||||
String text = String.format("%d%%", (int) (this.recipe.getOptionalChance() * 100));
|
||||
float width = fr.getStringWidth(text) * scale;
|
||||
int xScaled = Math.round((x + (18 - width) / 2) * invScale);
|
||||
fr.drawString(text, xScaled, (int) (65 * invScale), Color.gray.getRGB());
|
||||
x += 18;
|
||||
}
|
||||
|
||||
if( this.recipe.getSecondOptionalOutput() != null )
|
||||
{
|
||||
String text = String.format( "%d%%", (int) ( this.recipe.getSecondOptionalChance() * 100 ) );
|
||||
float width = fr.getStringWidth( text ) * scale;
|
||||
int xScaled = Math.round( ( x + ( 18 - width ) / 2 ) * invScale );
|
||||
fr.drawString( text, xScaled, (int) ( 65 * invScale ), Color.gray.getRGB() );
|
||||
}
|
||||
if (this.recipe.getSecondOptionalOutput() != null) {
|
||||
String text = String.format("%d%%", (int) (this.recipe.getSecondOptionalChance() * 100));
|
||||
float width = fr.getStringWidth(text) * scale;
|
||||
int xScaled = Math.round((x + (18 - width) / 2) * invScale);
|
||||
fr.drawString(text, xScaled, (int) (65 * invScale), Color.gray.getRGB());
|
||||
}
|
||||
|
||||
GlStateManager.scale( invScale, invScale, 1 );
|
||||
}
|
||||
GlStateManager.scale(invScale, invScale, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,94 +19,80 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.*;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IDrawableAnimated;
|
||||
import mezz.jei.api.gui.IDrawableStatic;
|
||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
class InscriberRecipeCategory implements IRecipeCategory<InscriberRecipeWrapper> {
|
||||
|
||||
private static final int SLOT_INPUT_TOP = 0;
|
||||
private static final int SLOT_INPUT_MIDDLE = 1;
|
||||
private static final int SLOT_INPUT_BOTTOM = 2;
|
||||
private static final int SLOT_OUTPUT = 3;
|
||||
|
||||
class InscriberRecipeCategory implements IRecipeCategory<InscriberRecipeWrapper>
|
||||
{
|
||||
static final String UID = "appliedenergistics2.inscriber";
|
||||
|
||||
private static final int SLOT_INPUT_TOP = 0;
|
||||
private static final int SLOT_INPUT_MIDDLE = 1;
|
||||
private static final int SLOT_INPUT_BOTTOM = 2;
|
||||
private static final int SLOT_OUTPUT = 3;
|
||||
private final IDrawable background;
|
||||
|
||||
static final String UID = "appliedenergistics2.inscriber";
|
||||
private final String localizedName;
|
||||
|
||||
private final IDrawable background;
|
||||
private final IDrawableAnimated progress;
|
||||
|
||||
private final String localizedName;
|
||||
public InscriberRecipeCategory(IGuiHelper guiHelper) {
|
||||
ResourceLocation location = new ResourceLocation(AppEng.MOD_ID, "textures/guis/inscriber.png");
|
||||
this.background = guiHelper.createDrawable(location, 44, 15, 97, 64);
|
||||
this.localizedName = I18n.format("tile.appliedenergistics2.inscriber.name");
|
||||
|
||||
private final IDrawableAnimated progress;
|
||||
IDrawableStatic progressDrawable = guiHelper.createDrawable(location, 135, 177, 6, 18, 24, 0, 91, 0);
|
||||
this.progress = guiHelper.createAnimatedDrawable(progressDrawable, 40, IDrawableAnimated.StartDirection.BOTTOM, false);
|
||||
}
|
||||
|
||||
public InscriberRecipeCategory( IGuiHelper guiHelper )
|
||||
{
|
||||
ResourceLocation location = new ResourceLocation( AppEng.MOD_ID, "textures/guis/inscriber.png" );
|
||||
this.background = guiHelper.createDrawable( location, 44, 15, 97, 64 );
|
||||
this.localizedName = I18n.format( "tile.appliedenergistics2.inscriber.name" );
|
||||
@Override
|
||||
public String getUid() {
|
||||
return UID;
|
||||
}
|
||||
|
||||
IDrawableStatic progressDrawable = guiHelper.createDrawable( location, 135, 177, 6, 18, 24, 0, 91, 0 );
|
||||
this.progress = guiHelper.createAnimatedDrawable( progressDrawable, 40, IDrawableAnimated.StartDirection.BOTTOM, false );
|
||||
}
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return this.localizedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUid()
|
||||
{
|
||||
return UID;
|
||||
}
|
||||
/**
|
||||
* Return the name of the mod associated with this recipe category.
|
||||
* Used for the recipe category tab's tooltip.
|
||||
*
|
||||
* @since JEI 4.5.0
|
||||
*/
|
||||
@Override
|
||||
public String getModName() {
|
||||
return AppEng.MOD_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return this.localizedName;
|
||||
}
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return this.background;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the mod associated with this recipe category.
|
||||
* Used for the recipe category tab's tooltip.
|
||||
*
|
||||
* @since JEI 4.5.0
|
||||
*/
|
||||
@Override
|
||||
public String getModName()
|
||||
{
|
||||
return AppEng.MOD_NAME;
|
||||
}
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
this.progress.draw(minecraft);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground()
|
||||
{
|
||||
return this.background;
|
||||
}
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, InscriberRecipeWrapper recipeWrapper, IIngredients ingredients) {
|
||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
@Override
|
||||
public void drawExtras( Minecraft minecraft )
|
||||
{
|
||||
this.progress.draw( minecraft );
|
||||
}
|
||||
itemStacks.init(SLOT_INPUT_TOP, true, 0, 0);
|
||||
itemStacks.init(SLOT_INPUT_MIDDLE, true, 18, 23);
|
||||
itemStacks.init(SLOT_INPUT_BOTTOM, true, 0, 46);
|
||||
itemStacks.init(SLOT_OUTPUT, false, 68, 24);
|
||||
|
||||
@Override
|
||||
public void setRecipe( IRecipeLayout recipeLayout, InscriberRecipeWrapper recipeWrapper, IIngredients ingredients )
|
||||
{
|
||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
itemStacks.init( SLOT_INPUT_TOP, true, 0, 0 );
|
||||
itemStacks.init( SLOT_INPUT_MIDDLE, true, 18, 23 );
|
||||
itemStacks.init( SLOT_INPUT_BOTTOM, true, 0, 46 );
|
||||
itemStacks.init( SLOT_OUTPUT, false, 68, 24 );
|
||||
|
||||
itemStacks.set( ingredients );
|
||||
}
|
||||
itemStacks.set(ingredients);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,18 +19,15 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import appeng.api.features.IInscriberRecipe;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import mezz.jei.api.recipe.IRecipeWrapperFactory;
|
||||
|
||||
import appeng.api.features.IInscriberRecipe;
|
||||
|
||||
|
||||
class InscriberRecipeHandler implements IRecipeWrapperFactory<IInscriberRecipe>
|
||||
{
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper( IInscriberRecipe recipe )
|
||||
{
|
||||
return new InscriberRecipeWrapper( recipe );
|
||||
}
|
||||
class InscriberRecipeHandler implements IRecipeWrapperFactory<IInscriberRecipe> {
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(IInscriberRecipe recipe) {
|
||||
return new InscriberRecipeWrapper(recipe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,37 +19,32 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import appeng.api.features.IInscriberRecipe;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
class InscriberRecipeWrapper implements IRecipeWrapper {
|
||||
|
||||
import appeng.api.features.IInscriberRecipe;
|
||||
private final IInscriberRecipe recipe;
|
||||
|
||||
public InscriberRecipeWrapper(IInscriberRecipe recipe) {
|
||||
this.recipe = recipe;
|
||||
}
|
||||
|
||||
class InscriberRecipeWrapper implements IRecipeWrapper
|
||||
{
|
||||
@Override
|
||||
public void getIngredients(IIngredients ingredients) {
|
||||
List<List<ItemStack>> inputSlots = new ArrayList<>(3);
|
||||
inputSlots.add(Collections.singletonList(this.recipe.getTopOptional().orElse(ItemStack.EMPTY)));
|
||||
inputSlots.add(this.recipe.getInputs());
|
||||
inputSlots.add(Collections.singletonList(this.recipe.getBottomOptional().orElse(ItemStack.EMPTY)));
|
||||
ingredients.setInputLists(ItemStack.class, inputSlots);
|
||||
|
||||
private final IInscriberRecipe recipe;
|
||||
|
||||
public InscriberRecipeWrapper( IInscriberRecipe recipe )
|
||||
{
|
||||
this.recipe = recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getIngredients( IIngredients ingredients )
|
||||
{
|
||||
List<List<ItemStack>> inputSlots = new ArrayList<>( 3 );
|
||||
inputSlots.add( Collections.singletonList( this.recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) );
|
||||
inputSlots.add( this.recipe.getInputs() );
|
||||
inputSlots.add( Collections.singletonList( this.recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) );
|
||||
ingredients.setInputLists( ItemStack.class, inputSlots );
|
||||
|
||||
ingredients.setOutput( ItemStack.class, this.recipe.getOutput() );
|
||||
}
|
||||
ingredients.setOutput(ItemStack.class, this.recipe.getOutput());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,57 +19,48 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.IInscriberRegistry;
|
||||
import mezz.jei.api.recipe.IFocus;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
import mezz.jei.api.recipe.IRecipeRegistryPlugin;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.IInscriberRegistry;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Exposes the inscriber registry recipes to JEI.
|
||||
*/
|
||||
class InscriberRegistryPlugin implements IRecipeRegistryPlugin
|
||||
{
|
||||
class InscriberRegistryPlugin implements IRecipeRegistryPlugin {
|
||||
|
||||
private final IInscriberRegistry inscriber = AEApi.instance().registries().inscriber();
|
||||
private final IInscriberRegistry inscriber = AEApi.instance().registries().inscriber();
|
||||
|
||||
@Override
|
||||
public <V> List<String> getRecipeCategoryUids( IFocus<V> focus )
|
||||
{
|
||||
if( !( focus.getValue() instanceof ItemStack ) )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@Override
|
||||
public <V> List<String> getRecipeCategoryUids(IFocus<V> focus) {
|
||||
if (!(focus.getValue() instanceof ItemStack)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
if( focus.getMode() == IFocus.Mode.INPUT )
|
||||
{
|
||||
ItemStack input = (ItemStack) focus.getValue();
|
||||
for( ItemStack validInput : this.inscriber.getInputs() )
|
||||
{
|
||||
if (focus.getMode() == IFocus.Mode.INPUT) {
|
||||
ItemStack input = (ItemStack) focus.getValue();
|
||||
for (ItemStack validInput : this.inscriber.getInputs()) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IRecipeWrapper, V> List<T> getRecipeWrappers( IRecipeCategory<T> recipeCategory, IFocus<V> focus )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public <T extends IRecipeWrapper, V> List<T> getRecipeWrappers(IRecipeCategory<T> recipeCategory, IFocus<V> focus) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IRecipeWrapper> List<T> getRecipeWrappers( IRecipeCategory<T> recipeCategory )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public <T extends IRecipeWrapper> List<T> getRecipeWrappers(IRecipeCategory<T> recipeCategory) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,37 +22,31 @@ package appeng.integration.modules.jei;
|
||||
import appeng.integration.abstraction.IJEI;
|
||||
|
||||
|
||||
public class JEIModule implements IJEI
|
||||
{
|
||||
public class JEIModule implements IJEI {
|
||||
|
||||
private IJEI jei = new IJEI.Stub();
|
||||
private IJEI jei = new IJEI.Stub();
|
||||
|
||||
public void setJei( IJEI jei )
|
||||
{
|
||||
this.jei = jei;
|
||||
}
|
||||
public void setJei(IJEI jei) {
|
||||
this.jei = jei;
|
||||
}
|
||||
|
||||
public IJEI getJei()
|
||||
{
|
||||
return this.jei;
|
||||
}
|
||||
public IJEI getJei() {
|
||||
return this.jei;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSearchText()
|
||||
{
|
||||
return this.jei.getSearchText();
|
||||
}
|
||||
@Override
|
||||
public String getSearchText() {
|
||||
return this.jei.getSearchText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSearchText( String searchText )
|
||||
{
|
||||
this.jei.setSearchText( searchText );
|
||||
}
|
||||
@Override
|
||||
public void setSearchText(String searchText) {
|
||||
this.jei.setSearchText(searchText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return this.jei.isEnabled();
|
||||
}
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return this.jei.isEnabled();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,25 +19,6 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import appeng.client.gui.AEGuiHandler;
|
||||
import appeng.container.implementations.ContainerExpandedProcessingPatternTerm;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import mezz.jei.api.*;
|
||||
import mezz.jei.config.Constants;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
|
||||
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
@@ -45,181 +26,174 @@ import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.api.features.IGrinderRecipe;
|
||||
import appeng.api.features.IInscriberRecipe;
|
||||
import appeng.client.gui.AEGuiHandler;
|
||||
import appeng.container.implementations.ContainerCraftingTerm;
|
||||
import appeng.container.implementations.ContainerExpandedProcessingPatternTerm;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.integration.Integrations;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import mezz.jei.api.IJeiRuntime;
|
||||
import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.ISubtypeRegistry;
|
||||
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
|
||||
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
|
||||
import mezz.jei.config.Constants;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
@mezz.jei.api.JEIPlugin
|
||||
public class JEIPlugin implements IModPlugin
|
||||
{
|
||||
public static IJeiRuntime runtime;
|
||||
public static AEGuiHandler aeGuiHandler;
|
||||
public class JEIPlugin implements IModPlugin {
|
||||
public static IJeiRuntime runtime;
|
||||
public static AEGuiHandler aeGuiHandler;
|
||||
|
||||
@Override
|
||||
public void registerItemSubtypes( ISubtypeRegistry subtypeRegistry )
|
||||
{
|
||||
final Optional<Item> maybeFacade = AEApi.instance().definitions().items().facade().maybeItem();
|
||||
maybeFacade.ifPresent( subtypeRegistry::useNbtForSubtypes );
|
||||
}
|
||||
@Override
|
||||
public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry) {
|
||||
final Optional<Item> maybeFacade = AEApi.instance().definitions().items().facade().maybeItem();
|
||||
maybeFacade.ifPresent(subtypeRegistry::useNbtForSubtypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCategories( IRecipeCategoryRegistration registry )
|
||||
{
|
||||
registry.addRecipeCategories( new GrinderRecipeCategory( registry.getJeiHelpers().getGuiHelper() ) );
|
||||
registry.addRecipeCategories( new CondenserCategory( registry.getJeiHelpers().getGuiHelper() ) );
|
||||
registry.addRecipeCategories( new InscriberRecipeCategory( registry.getJeiHelpers().getGuiHelper() ) );
|
||||
}
|
||||
@Override
|
||||
public void registerCategories(IRecipeCategoryRegistration registry) {
|
||||
registry.addRecipeCategories(new GrinderRecipeCategory(registry.getJeiHelpers().getGuiHelper()));
|
||||
registry.addRecipeCategories(new CondenserCategory(registry.getJeiHelpers().getGuiHelper()));
|
||||
registry.addRecipeCategories(new InscriberRecipeCategory(registry.getJeiHelpers().getGuiHelper()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register( IModRegistry registry )
|
||||
{
|
||||
IDefinitions definitions = AEApi.instance().definitions();
|
||||
@Override
|
||||
public void register(IModRegistry registry) {
|
||||
IDefinitions definitions = AEApi.instance().definitions();
|
||||
|
||||
this.registerFacadeRecipe( definitions, registry );
|
||||
this.registerFacadeRecipe(definitions, registry);
|
||||
|
||||
this.registerInscriberRecipes( definitions, registry );
|
||||
this.registerInscriberRecipes(definitions, registry);
|
||||
|
||||
this.registerCondenserRecipes( definitions, registry );
|
||||
this.registerCondenserRecipes(definitions, registry);
|
||||
|
||||
this.registerGrinderRecipes( definitions, registry );
|
||||
this.registerGrinderRecipes(definitions, registry);
|
||||
|
||||
this.registerDescriptions( definitions, registry );
|
||||
this.registerDescriptions(definitions, registry);
|
||||
|
||||
// Allow recipe transfer from JEI to crafting and pattern terminal
|
||||
registry.getRecipeTransferRegistry().addRecipeTransferHandler( new RecipeTransferHandler<>( ContainerCraftingTerm.class ), VanillaRecipeCategoryUid.CRAFTING );
|
||||
registry.getRecipeTransferRegistry().addRecipeTransferHandler( new RecipeTransferHandler<>( ContainerPatternTerm.class ), Constants.UNIVERSAL_RECIPE_TRANSFER_UID );
|
||||
registry.getRecipeTransferRegistry().addRecipeTransferHandler( new RecipeTransferHandler<>( ContainerExpandedProcessingPatternTerm.class ), Constants.UNIVERSAL_RECIPE_TRANSFER_UID );
|
||||
// Allow recipe transfer from JEI to crafting and pattern terminal
|
||||
registry.getRecipeTransferRegistry().addRecipeTransferHandler(new RecipeTransferHandler<>(ContainerCraftingTerm.class), VanillaRecipeCategoryUid.CRAFTING);
|
||||
registry.getRecipeTransferRegistry().addRecipeTransferHandler(new RecipeTransferHandler<>(ContainerPatternTerm.class), Constants.UNIVERSAL_RECIPE_TRANSFER_UID);
|
||||
registry.getRecipeTransferRegistry().addRecipeTransferHandler(new RecipeTransferHandler<>(ContainerExpandedProcessingPatternTerm.class), Constants.UNIVERSAL_RECIPE_TRANSFER_UID);
|
||||
|
||||
aeGuiHandler = new AEGuiHandler();
|
||||
registry.addAdvancedGuiHandlers( aeGuiHandler );
|
||||
registry.addGhostIngredientHandler( aeGuiHandler.getGuiContainerClass(), aeGuiHandler );
|
||||
}
|
||||
aeGuiHandler = new AEGuiHandler();
|
||||
registry.addAdvancedGuiHandlers(aeGuiHandler);
|
||||
registry.addGhostIngredientHandler(aeGuiHandler.getGuiContainerClass(), aeGuiHandler);
|
||||
}
|
||||
|
||||
private void registerDescriptions( IDefinitions definitions, IModRegistry registry )
|
||||
{
|
||||
IMaterials materials = definitions.materials();
|
||||
private void registerDescriptions(IDefinitions definitions, IModRegistry registry) {
|
||||
IMaterials materials = definitions.materials();
|
||||
|
||||
final String message;
|
||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.CERTUS_QUARTZ_WORLD_GEN ) )
|
||||
{
|
||||
message = GuiText.ChargedQuartz.getLocal() + "\n\n" + GuiText.ChargedQuartzFind.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
message = GuiText.ChargedQuartzFind.getLocal();
|
||||
}
|
||||
this.addDescription( registry, materials.certusQuartzCrystalCharged(), message );
|
||||
final String message;
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.CERTUS_QUARTZ_WORLD_GEN)) {
|
||||
message = GuiText.ChargedQuartz.getLocal() + "\n\n" + GuiText.ChargedQuartzFind.getLocal();
|
||||
} else {
|
||||
message = GuiText.ChargedQuartzFind.getLocal();
|
||||
}
|
||||
this.addDescription(registry, materials.certusQuartzCrystalCharged(), message);
|
||||
|
||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.METEORITE_WORLD_GEN ) )
|
||||
{
|
||||
this.addDescription( registry, materials.logicProcessorPress(), GuiText.inWorldCraftingPresses.getLocal() );
|
||||
this.addDescription( registry, materials.calcProcessorPress(), GuiText.inWorldCraftingPresses.getLocal() );
|
||||
this.addDescription( registry, materials.engProcessorPress(), GuiText.inWorldCraftingPresses.getLocal() );
|
||||
}
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.METEORITE_WORLD_GEN)) {
|
||||
this.addDescription(registry, materials.logicProcessorPress(), GuiText.inWorldCraftingPresses.getLocal());
|
||||
this.addDescription(registry, materials.calcProcessorPress(), GuiText.inWorldCraftingPresses.getLocal());
|
||||
this.addDescription(registry, materials.engProcessorPress(), GuiText.inWorldCraftingPresses.getLocal());
|
||||
}
|
||||
|
||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.IN_WORLD_FLUIX ) )
|
||||
{
|
||||
this.addDescription( registry, materials.fluixCrystal(), GuiText.inWorldFluix.getLocal() );
|
||||
}
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.IN_WORLD_FLUIX)) {
|
||||
this.addDescription(registry, materials.fluixCrystal(), GuiText.inWorldFluix.getLocal());
|
||||
}
|
||||
|
||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.IN_WORLD_SINGULARITY ) )
|
||||
{
|
||||
this.addDescription( registry, materials.qESingularity(), GuiText.inWorldSingularity.getLocal() );
|
||||
}
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.IN_WORLD_SINGULARITY)) {
|
||||
this.addDescription(registry, materials.qESingularity(), GuiText.inWorldSingularity.getLocal());
|
||||
}
|
||||
|
||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.IN_WORLD_PURIFICATION ) )
|
||||
{
|
||||
this.addDescription( registry, materials.purifiedCertusQuartzCrystal(), GuiText.inWorldPurificationCertus.getLocal() );
|
||||
this.addDescription( registry, materials.purifiedNetherQuartzCrystal(), GuiText.inWorldPurificationNether.getLocal() );
|
||||
this.addDescription( registry, materials.purifiedFluixCrystal(), GuiText.inWorldPurificationFluix.getLocal() );
|
||||
}
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.IN_WORLD_PURIFICATION)) {
|
||||
this.addDescription(registry, materials.purifiedCertusQuartzCrystal(), GuiText.inWorldPurificationCertus.getLocal());
|
||||
this.addDescription(registry, materials.purifiedNetherQuartzCrystal(), GuiText.inWorldPurificationNether.getLocal());
|
||||
this.addDescription(registry, materials.purifiedFluixCrystal(), GuiText.inWorldPurificationFluix.getLocal());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void addDescription( IModRegistry registry, IItemDefinition itemDefinition, String message )
|
||||
{
|
||||
itemDefinition.maybeStack( 1 ).ifPresent( itemStack -> registry.addIngredientInfo( itemStack, ItemStack.class, message ) );
|
||||
}
|
||||
private void addDescription(IModRegistry registry, IItemDefinition itemDefinition, String message) {
|
||||
itemDefinition.maybeStack(1).ifPresent(itemStack -> registry.addIngredientInfo(itemStack, ItemStack.class, message));
|
||||
}
|
||||
|
||||
private void registerGrinderRecipes( IDefinitions definitions, IModRegistry registry )
|
||||
{
|
||||
private void registerGrinderRecipes(IDefinitions definitions, IModRegistry registry) {
|
||||
|
||||
ItemStack grindstone = definitions.blocks().grindstone().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
ItemStack grindstone = definitions.blocks().grindstone().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
|
||||
if( grindstone.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (grindstone.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
registry.handleRecipes( IGrinderRecipe.class, new GrinderRecipeHandler(), GrinderRecipeCategory.UID );
|
||||
registry.addRecipes( Lists.newArrayList( AEApi.instance().registries().grinder().getRecipes() ), GrinderRecipeCategory.UID );
|
||||
registry.addRecipeCatalyst( grindstone, GrinderRecipeCategory.UID );
|
||||
}
|
||||
registry.handleRecipes(IGrinderRecipe.class, new GrinderRecipeHandler(), GrinderRecipeCategory.UID);
|
||||
registry.addRecipes(Lists.newArrayList(AEApi.instance().registries().grinder().getRecipes()), GrinderRecipeCategory.UID);
|
||||
registry.addRecipeCatalyst(grindstone, GrinderRecipeCategory.UID);
|
||||
}
|
||||
|
||||
private void registerCondenserRecipes( IDefinitions definitions, IModRegistry registry )
|
||||
{
|
||||
private void registerCondenserRecipes(IDefinitions definitions, IModRegistry registry) {
|
||||
|
||||
ItemStack condenser = definitions.blocks().condenser().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
if( condenser.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
ItemStack condenser = definitions.blocks().condenser().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
if (condenser.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack matterBall = definitions.materials().matterBall().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
if( !matterBall.isEmpty() )
|
||||
{
|
||||
registry.addRecipes( ImmutableList.of( CondenserOutput.MATTER_BALLS ), CondenserCategory.UID );
|
||||
}
|
||||
ItemStack matterBall = definitions.materials().matterBall().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
if (!matterBall.isEmpty()) {
|
||||
registry.addRecipes(ImmutableList.of(CondenserOutput.MATTER_BALLS), CondenserCategory.UID);
|
||||
}
|
||||
|
||||
ItemStack singularity = definitions.materials().singularity().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
if( !singularity.isEmpty() )
|
||||
{
|
||||
registry.addRecipes( ImmutableList.of( CondenserOutput.SINGULARITY ), CondenserCategory.UID );
|
||||
}
|
||||
ItemStack singularity = definitions.materials().singularity().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
if (!singularity.isEmpty()) {
|
||||
registry.addRecipes(ImmutableList.of(CondenserOutput.SINGULARITY), CondenserCategory.UID);
|
||||
}
|
||||
|
||||
if( !matterBall.isEmpty() || !singularity.isEmpty() )
|
||||
{
|
||||
registry.addRecipeCatalyst( condenser, CondenserCategory.UID );
|
||||
registry.handleRecipes( CondenserOutput.class, new CondenserOutputHandler( registry.getJeiHelpers().getGuiHelper(), matterBall, singularity ),
|
||||
CondenserCategory.UID );
|
||||
}
|
||||
}
|
||||
if (!matterBall.isEmpty() || !singularity.isEmpty()) {
|
||||
registry.addRecipeCatalyst(condenser, CondenserCategory.UID);
|
||||
registry.handleRecipes(CondenserOutput.class, new CondenserOutputHandler(registry.getJeiHelpers().getGuiHelper(), matterBall, singularity),
|
||||
CondenserCategory.UID);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerInscriberRecipes( IDefinitions definitions, IModRegistry registry )
|
||||
{
|
||||
registry.handleRecipes( IInscriberRecipe.class, new InscriberRecipeHandler(), InscriberRecipeCategory.UID );
|
||||
private void registerInscriberRecipes(IDefinitions definitions, IModRegistry registry) {
|
||||
registry.handleRecipes(IInscriberRecipe.class, new InscriberRecipeHandler(), InscriberRecipeCategory.UID);
|
||||
|
||||
// Register the inscriber as the crafting item for the inscription category
|
||||
definitions.blocks().inscriber().maybeStack( 1 ).ifPresent( inscriber ->
|
||||
{
|
||||
registry.addRecipeCatalyst( inscriber, InscriberRecipeCategory.UID );
|
||||
} );
|
||||
// Register the inscriber as the crafting item for the inscription category
|
||||
definitions.blocks().inscriber().maybeStack(1).ifPresent(inscriber ->
|
||||
{
|
||||
registry.addRecipeCatalyst(inscriber, InscriberRecipeCategory.UID);
|
||||
});
|
||||
|
||||
List<IInscriberRecipe> inscriberRecipes = new ArrayList<>( AEApi.instance().registries().inscriber().getRecipes() );
|
||||
registry.addRecipes( inscriberRecipes, InscriberRecipeCategory.UID );
|
||||
}
|
||||
List<IInscriberRecipe> inscriberRecipes = new ArrayList<>(AEApi.instance().registries().inscriber().getRecipes());
|
||||
registry.addRecipes(inscriberRecipes, InscriberRecipeCategory.UID);
|
||||
}
|
||||
|
||||
// Handle the generic crafting recipe for patterns in JEI
|
||||
private void registerFacadeRecipe( IDefinitions definitions, IModRegistry registry )
|
||||
{
|
||||
Optional<Item> itemFacade = definitions.items().facade().maybeItem();
|
||||
Optional<ItemStack> cableAnchor = definitions.parts().cableAnchor().maybeStack( 1 );
|
||||
if( itemFacade.isPresent() && cableAnchor.isPresent() && AEConfig.instance().isFeatureEnabled( AEFeature.ENABLE_FACADE_CRAFTING ) )
|
||||
{
|
||||
registry.addRecipeRegistryPlugin( new FacadeRegistryPlugin( (ItemFacade) itemFacade.get(), cableAnchor.get() ) );
|
||||
}
|
||||
}
|
||||
// Handle the generic crafting recipe for patterns in JEI
|
||||
private void registerFacadeRecipe(IDefinitions definitions, IModRegistry registry) {
|
||||
Optional<Item> itemFacade = definitions.items().facade().maybeItem();
|
||||
Optional<ItemStack> cableAnchor = definitions.parts().cableAnchor().maybeStack(1);
|
||||
if (itemFacade.isPresent() && cableAnchor.isPresent() && AEConfig.instance().isFeatureEnabled(AEFeature.ENABLE_FACADE_CRAFTING)) {
|
||||
registry.addRecipeRegistryPlugin(new FacadeRegistryPlugin((ItemFacade) itemFacade.get(), cableAnchor.get()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRuntimeAvailable( IJeiRuntime jeiRuntime )
|
||||
{
|
||||
JEIModule jeiModule = (JEIModule) Integrations.jei();
|
||||
jeiModule.setJei( new JeiRuntimeAdapter( jeiRuntime ) );
|
||||
runtime = jeiRuntime;
|
||||
}
|
||||
@Override
|
||||
public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {
|
||||
JEIModule jeiModule = (JEIModule) Integrations.jei();
|
||||
jeiModule.setJei(new JeiRuntimeAdapter(jeiRuntime));
|
||||
runtime = jeiRuntime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,38 +19,31 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import appeng.integration.abstraction.IJEI;
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import mezz.jei.api.IJeiRuntime;
|
||||
|
||||
import appeng.integration.abstraction.IJEI;
|
||||
|
||||
class JeiRuntimeAdapter implements IJEI {
|
||||
|
||||
class JeiRuntimeAdapter implements IJEI
|
||||
{
|
||||
private final IJeiRuntime runtime;
|
||||
|
||||
private final IJeiRuntime runtime;
|
||||
JeiRuntimeAdapter(IJeiRuntime jeiRuntime) {
|
||||
this.runtime = jeiRuntime;
|
||||
}
|
||||
|
||||
JeiRuntimeAdapter( IJeiRuntime jeiRuntime )
|
||||
{
|
||||
this.runtime = jeiRuntime;
|
||||
}
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String getSearchText() {
|
||||
return Strings.nullToEmpty(this.runtime.getIngredientFilter().getFilterText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSearchText()
|
||||
{
|
||||
return Strings.nullToEmpty( this.runtime.getIngredientFilter().getFilterText() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSearchText( String searchText )
|
||||
{
|
||||
this.runtime.getIngredientFilter().setFilterText( Strings.nullToEmpty( searchText ) );
|
||||
}
|
||||
@Override
|
||||
public void setSearchText(String searchText) {
|
||||
this.runtime.getIngredientFilter().setFilterText(Strings.nullToEmpty(searchText));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,19 +19,20 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketJEIRecipe;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.util.Platform;
|
||||
import mezz.jei.api.gui.IGuiIngredient;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
|
||||
import mezz.jei.transfer.RecipeTransferErrorInternal;
|
||||
import mezz.jei.transfer.RecipeTransferErrorTooltip;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
@@ -39,157 +40,121 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import mezz.jei.api.gui.IGuiIngredient;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
|
||||
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketJEIRecipe;
|
||||
import appeng.util.Platform;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandler<T>
|
||||
{
|
||||
class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandler<T> {
|
||||
|
||||
private final Class<T> containerClass;
|
||||
private final Class<T> containerClass;
|
||||
|
||||
RecipeTransferHandler( Class<T> containerClass )
|
||||
{
|
||||
this.containerClass = containerClass;
|
||||
}
|
||||
RecipeTransferHandler(Class<T> containerClass) {
|
||||
this.containerClass = containerClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<T> getContainerClass()
|
||||
{
|
||||
return this.containerClass;
|
||||
}
|
||||
@Override
|
||||
public Class<T> getContainerClass() {
|
||||
return this.containerClass;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IRecipeTransferError transferRecipe( T container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer, boolean doTransfer )
|
||||
{
|
||||
final String recipeType = recipeLayout.getRecipeCategory().getUid();
|
||||
@Nullable
|
||||
@Override
|
||||
public IRecipeTransferError transferRecipe(T container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer, boolean doTransfer) {
|
||||
final String recipeType = recipeLayout.getRecipeCategory().getUid();
|
||||
|
||||
if (recipeType.equals( VanillaRecipeCategoryUid.INFORMATION) || recipeType.equals(VanillaRecipeCategoryUid.FUEL))
|
||||
{
|
||||
return RecipeTransferErrorInternal.INSTANCE;
|
||||
}
|
||||
if (recipeType.equals(VanillaRecipeCategoryUid.INFORMATION) || recipeType.equals(VanillaRecipeCategoryUid.FUEL)) {
|
||||
return RecipeTransferErrorInternal.INSTANCE;
|
||||
}
|
||||
|
||||
if( !doTransfer )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (!doTransfer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if( container instanceof ContainerPatternTerm )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( !( (ContainerPatternTerm) container ).isCraftingMode() )
|
||||
{
|
||||
if( recipeType.equals( VanillaRecipeCategoryUid.CRAFTING ) )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.CraftMode", "1" ) );
|
||||
}
|
||||
}
|
||||
else if( !recipeType.equals( VanillaRecipeCategoryUid.CRAFTING ) )
|
||||
{
|
||||
if (container instanceof ContainerPatternTerm) {
|
||||
try {
|
||||
if (!((ContainerPatternTerm) container).isCraftingMode()) {
|
||||
if (recipeType.equals(VanillaRecipeCategoryUid.CRAFTING)) {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.CraftMode", "1"));
|
||||
}
|
||||
} else if (!recipeType.equals(VanillaRecipeCategoryUid.CRAFTING)) {
|
||||
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.CraftMode", "0" ) );
|
||||
}
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.CraftMode", "0"));
|
||||
}
|
||||
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Map<Integer, ? extends IGuiIngredient<ItemStack>> ingredients = recipeLayout.getItemStacks().getGuiIngredients();
|
||||
Map<Integer, ? extends IGuiIngredient<ItemStack>> ingredients = recipeLayout.getItemStacks().getGuiIngredients();
|
||||
|
||||
final NBTTagCompound recipe = new NBTTagCompound();
|
||||
final NBTTagList outputs = new NBTTagList();
|
||||
final NBTTagCompound recipe = new NBTTagCompound();
|
||||
final NBTTagList outputs = new NBTTagList();
|
||||
|
||||
|
||||
int slotIndex = 0;
|
||||
for( Map.Entry<Integer, ? extends IGuiIngredient<ItemStack>> ingredientEntry : ingredients.entrySet() )
|
||||
{
|
||||
IGuiIngredient<ItemStack> ingredient = ingredientEntry.getValue();
|
||||
if( !ingredient.isInput() )
|
||||
{
|
||||
ItemStack output = ingredient.getDisplayedIngredient();
|
||||
if( output != null )
|
||||
{
|
||||
final NBTTagCompound tag = new NBTTagCompound();
|
||||
output.writeToNBT( tag );
|
||||
outputs.appendTag( tag );
|
||||
}
|
||||
continue;
|
||||
}
|
||||
int slotIndex = 0;
|
||||
for (Map.Entry<Integer, ? extends IGuiIngredient<ItemStack>> ingredientEntry : ingredients.entrySet()) {
|
||||
IGuiIngredient<ItemStack> ingredient = ingredientEntry.getValue();
|
||||
if (!ingredient.isInput()) {
|
||||
ItemStack output = ingredient.getDisplayedIngredient();
|
||||
if (output != null) {
|
||||
final NBTTagCompound tag = new NBTTagCompound();
|
||||
output.writeToNBT(tag);
|
||||
outputs.appendTag(tag);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
for( final Slot slot : container.inventorySlots )
|
||||
{
|
||||
if( slot instanceof SlotCraftingMatrix || slot instanceof SlotFakeCraftingMatrix )
|
||||
{
|
||||
if( slot.getSlotIndex() == slotIndex )
|
||||
{
|
||||
final NBTTagList tags = new NBTTagList();
|
||||
final List<ItemStack> list = new ArrayList<>();
|
||||
final ItemStack displayed = ingredient.getDisplayedIngredient();
|
||||
for (final Slot slot : container.inventorySlots) {
|
||||
if (slot instanceof SlotCraftingMatrix || slot instanceof SlotFakeCraftingMatrix) {
|
||||
if (slot.getSlotIndex() == slotIndex) {
|
||||
final NBTTagList tags = new NBTTagList();
|
||||
final List<ItemStack> list = new ArrayList<>();
|
||||
final ItemStack displayed = ingredient.getDisplayedIngredient();
|
||||
|
||||
// prefer currently displayed item
|
||||
if( displayed != null && !displayed.isEmpty() )
|
||||
{
|
||||
list.add( displayed );
|
||||
}
|
||||
// prefer currently displayed item
|
||||
if (displayed != null && !displayed.isEmpty()) {
|
||||
list.add(displayed);
|
||||
}
|
||||
|
||||
// prefer pure crystals.
|
||||
for ( ItemStack stack : ingredient.getAllIngredients() )
|
||||
{
|
||||
if( stack == null )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if( Platform.isRecipePrioritized( stack ) )
|
||||
{
|
||||
list.add( 0, stack );
|
||||
}
|
||||
else
|
||||
{
|
||||
list.add( stack );
|
||||
}
|
||||
}
|
||||
// prefer pure crystals.
|
||||
for (ItemStack stack : ingredient.getAllIngredients()) {
|
||||
if (stack == null) {
|
||||
continue;
|
||||
}
|
||||
if (Platform.isRecipePrioritized(stack)) {
|
||||
list.add(0, stack);
|
||||
} else {
|
||||
list.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
for ( final ItemStack is : list )
|
||||
{
|
||||
final NBTTagCompound tag = new NBTTagCompound();
|
||||
is.writeToNBT( tag );
|
||||
tags.appendTag( tag );
|
||||
}
|
||||
for (final ItemStack is : list) {
|
||||
final NBTTagCompound tag = new NBTTagCompound();
|
||||
is.writeToNBT(tag);
|
||||
tags.appendTag(tag);
|
||||
}
|
||||
|
||||
recipe.setTag( "#" + slot.getSlotIndex(), tags );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
recipe.setTag("#" + slot.getSlotIndex(), tags);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
slotIndex++;
|
||||
}
|
||||
slotIndex++;
|
||||
}
|
||||
|
||||
recipe.setTag( "outputs", outputs );
|
||||
recipe.setTag("outputs", outputs);
|
||||
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketJEIRecipe( recipe ) );
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
try {
|
||||
NetworkHandler.instance().sendToServer(new PacketJEIRecipe(recipe));
|
||||
} catch (IOException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,68 +19,54 @@
|
||||
package appeng.integration.modules.theoneprobe;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.integration.modules.theoneprobe.part.*;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.IProbeInfoProvider;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.IProbeInfoProvider;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.integration.modules.theoneprobe.part.ChannelInfoProvider;
|
||||
import appeng.integration.modules.theoneprobe.part.IPartProbInfoProvider;
|
||||
import appeng.integration.modules.theoneprobe.part.P2PStateInfoProvider;
|
||||
import appeng.integration.modules.theoneprobe.part.PartAccessor;
|
||||
import appeng.integration.modules.theoneprobe.part.PowerStateInfoProvider;
|
||||
import appeng.integration.modules.theoneprobe.part.StorageMonitorInfoProvider;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public final class PartInfoProvider implements IProbeInfoProvider
|
||||
{
|
||||
private final List<IPartProbInfoProvider> providers;
|
||||
public final class PartInfoProvider implements IProbeInfoProvider {
|
||||
private final List<IPartProbInfoProvider> providers;
|
||||
|
||||
private final PartAccessor accessor = new PartAccessor();
|
||||
private final PartAccessor accessor = new PartAccessor();
|
||||
|
||||
public PartInfoProvider()
|
||||
{
|
||||
final IPartProbInfoProvider channel = new ChannelInfoProvider();
|
||||
final IPartProbInfoProvider power = new PowerStateInfoProvider();
|
||||
final IPartProbInfoProvider storageMonitor = new StorageMonitorInfoProvider();
|
||||
final IPartProbInfoProvider p2p = new P2PStateInfoProvider();
|
||||
public PartInfoProvider() {
|
||||
final IPartProbInfoProvider channel = new ChannelInfoProvider();
|
||||
final IPartProbInfoProvider power = new PowerStateInfoProvider();
|
||||
final IPartProbInfoProvider storageMonitor = new StorageMonitorInfoProvider();
|
||||
final IPartProbInfoProvider p2p = new P2PStateInfoProvider();
|
||||
|
||||
this.providers = Lists.newArrayList( channel, power, p2p, storageMonitor );
|
||||
}
|
||||
this.providers = Lists.newArrayList(channel, power, p2p, storageMonitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID()
|
||||
{
|
||||
return AppEng.MOD_ID + ":PartInfoProvider";
|
||||
}
|
||||
@Override
|
||||
public String getID() {
|
||||
return AppEng.MOD_ID + ":PartInfoProvider";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
final TileEntity te = world.getTileEntity( data.getPos() );
|
||||
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, data );
|
||||
@Override
|
||||
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
|
||||
final TileEntity te = world.getTileEntity(data.getPos());
|
||||
final Optional<IPart> maybePart = this.accessor.getMaybePart(te, data);
|
||||
|
||||
if( maybePart.isPresent() )
|
||||
{
|
||||
final IPart part = maybePart.get();
|
||||
if (maybePart.isPresent()) {
|
||||
final IPart part = maybePart.get();
|
||||
|
||||
for( final IPartProbInfoProvider provider : this.providers )
|
||||
{
|
||||
provider.addProbeInfo( part, mode, probeInfo, player, world, blockState, data );
|
||||
}
|
||||
}
|
||||
for (final IPartProbInfoProvider provider : this.providers) {
|
||||
provider.addProbeInfo(part, mode, probeInfo, player, world, blockState, data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,33 +19,28 @@
|
||||
package appeng.integration.modules.theoneprobe;
|
||||
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms;
|
||||
|
||||
import mcjty.theoneprobe.api.ITheOneProbe;
|
||||
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.modules.theoneprobe.config.AEConfigProvider;
|
||||
import mcjty.theoneprobe.api.ITheOneProbe;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
|
||||
public class TheOneProbeModule implements IIntegrationModule, Function<ITheOneProbe, Void>
|
||||
{
|
||||
@Override
|
||||
public void preInit() throws Throwable
|
||||
{
|
||||
FMLInterModComms.sendFunctionMessage( "theoneprobe", "getTheOneProbe", this.getClass().getName() );
|
||||
}
|
||||
public class TheOneProbeModule implements IIntegrationModule, Function<ITheOneProbe, Void> {
|
||||
@Override
|
||||
public void preInit() throws Throwable {
|
||||
FMLInterModComms.sendFunctionMessage("theoneprobe", "getTheOneProbe", this.getClass().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void apply( ITheOneProbe input )
|
||||
{
|
||||
input.registerProbeConfigProvider( new AEConfigProvider() );
|
||||
@Override
|
||||
public Void apply(ITheOneProbe input) {
|
||||
input.registerProbeConfigProvider(new AEConfigProvider());
|
||||
|
||||
input.registerProvider( new TileInfoProvider() );
|
||||
input.registerProvider(new TileInfoProvider());
|
||||
|
||||
input.registerProvider( new PartInfoProvider() );
|
||||
input.registerProvider(new PartInfoProvider());
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,51 +19,47 @@
|
||||
package appeng.integration.modules.theoneprobe;
|
||||
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum TheOneProbeText
|
||||
{
|
||||
CRAFTING,
|
||||
|
||||
DEVICE_ONLINE,
|
||||
DEVICE_OFFLINE,
|
||||
DEVICE_MISSING_CHANNEL,
|
||||
public enum TheOneProbeText {
|
||||
CRAFTING,
|
||||
|
||||
P2P_UNLINKED,
|
||||
P2P_INPUT_ONE_OUTPUT,
|
||||
P2P_INPUT_MANY_OUTPUTS,
|
||||
P2P_OUTPUT_ONE_INPUT,
|
||||
P2P_OUTPUT_MANY_INPUTS,
|
||||
P2P_OUTPUT,
|
||||
P2P_FREQUENCY,
|
||||
DEVICE_ONLINE,
|
||||
DEVICE_OFFLINE,
|
||||
DEVICE_MISSING_CHANNEL,
|
||||
|
||||
LOCKED,
|
||||
UNLOCKED,
|
||||
SHOWING,
|
||||
P2P_UNLINKED,
|
||||
P2P_INPUT_ONE_OUTPUT,
|
||||
P2P_INPUT_MANY_OUTPUTS,
|
||||
P2P_OUTPUT_ONE_INPUT,
|
||||
P2P_OUTPUT_MANY_INPUTS,
|
||||
P2P_OUTPUT,
|
||||
P2P_FREQUENCY,
|
||||
|
||||
CONTAINS,
|
||||
CHANNELS,
|
||||
LOCKED,
|
||||
UNLOCKED,
|
||||
SHOWING,
|
||||
|
||||
STORED_ENERGY;
|
||||
CONTAINS,
|
||||
CHANNELS,
|
||||
|
||||
private final String root;
|
||||
STORED_ENERGY;
|
||||
|
||||
TheOneProbeText()
|
||||
{
|
||||
this.root = "theoneprobe.appliedenergistics2";
|
||||
}
|
||||
private final String root;
|
||||
|
||||
public String getLocal()
|
||||
{
|
||||
return I18n.translateToLocal( this.getUnlocalized() );
|
||||
}
|
||||
TheOneProbeText() {
|
||||
this.root = "theoneprobe.appliedenergistics2";
|
||||
}
|
||||
|
||||
public String getUnlocalized()
|
||||
{
|
||||
return this.root + '.' + this.name().toLowerCase( Locale.ENGLISH );
|
||||
}
|
||||
public String getLocal() {
|
||||
return I18n.translateToLocal(this.getUnlocalized());
|
||||
}
|
||||
|
||||
public String getUnlocalized() {
|
||||
return this.root + '.' + this.name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,62 +19,49 @@
|
||||
package appeng.integration.modules.theoneprobe;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import appeng.integration.modules.theoneprobe.tile.*;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.IProbeInfoProvider;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.IProbeInfoProvider;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import appeng.integration.modules.theoneprobe.tile.ChargerInfoProvider;
|
||||
import appeng.integration.modules.theoneprobe.tile.CraftingMonitorInfoProvider;
|
||||
import appeng.integration.modules.theoneprobe.tile.ITileProbInfoProvider;
|
||||
import appeng.integration.modules.theoneprobe.tile.PowerStateInfoProvider;
|
||||
import appeng.integration.modules.theoneprobe.tile.PowerStorageInfoProvider;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public final class TileInfoProvider implements IProbeInfoProvider
|
||||
{
|
||||
private final List<ITileProbInfoProvider> providers;
|
||||
public final class TileInfoProvider implements IProbeInfoProvider {
|
||||
private final List<ITileProbInfoProvider> providers;
|
||||
|
||||
public TileInfoProvider()
|
||||
{
|
||||
final ITileProbInfoProvider charger = new ChargerInfoProvider();
|
||||
final ITileProbInfoProvider energyCell = new CraftingMonitorInfoProvider();
|
||||
final ITileProbInfoProvider craftingBlock = new PowerStateInfoProvider();
|
||||
final ITileProbInfoProvider craftingMonitor = new PowerStorageInfoProvider();
|
||||
public TileInfoProvider() {
|
||||
final ITileProbInfoProvider charger = new ChargerInfoProvider();
|
||||
final ITileProbInfoProvider energyCell = new CraftingMonitorInfoProvider();
|
||||
final ITileProbInfoProvider craftingBlock = new PowerStateInfoProvider();
|
||||
final ITileProbInfoProvider craftingMonitor = new PowerStorageInfoProvider();
|
||||
|
||||
this.providers = Lists.newArrayList( charger, energyCell, craftingBlock, craftingMonitor );
|
||||
}
|
||||
this.providers = Lists.newArrayList(charger, energyCell, craftingBlock, craftingMonitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID()
|
||||
{
|
||||
return AppEng.MOD_ID + ":TileInfoProvider";
|
||||
}
|
||||
@Override
|
||||
public String getID() {
|
||||
return AppEng.MOD_ID + ":TileInfoProvider";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
final TileEntity tile = world.getTileEntity( data.getPos() );
|
||||
@Override
|
||||
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
|
||||
final TileEntity tile = world.getTileEntity(data.getPos());
|
||||
|
||||
if( tile instanceof AEBaseTile )
|
||||
{
|
||||
final AEBaseTile aeBaseTile = (AEBaseTile) tile;
|
||||
if (tile instanceof AEBaseTile) {
|
||||
final AEBaseTile aeBaseTile = (AEBaseTile) tile;
|
||||
|
||||
for( final ITileProbInfoProvider provider : this.providers )
|
||||
{
|
||||
provider.addProbeInfo( aeBaseTile, mode, probeInfo, player, world, blockState, data );
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final ITileProbInfoProvider provider : this.providers) {
|
||||
provider.addProbeInfo(aeBaseTile, mode, probeInfo, player, world, blockState, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,35 +19,29 @@
|
||||
package appeng.integration.modules.theoneprobe.config;
|
||||
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
import mcjty.theoneprobe.api.IProbeConfig;
|
||||
import mcjty.theoneprobe.api.IProbeConfigProvider;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeHitEntityData;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeConfig;
|
||||
import mcjty.theoneprobe.api.IProbeConfigProvider;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeHitEntityData;
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
public class AEConfigProvider implements IProbeConfigProvider {
|
||||
|
||||
@Override
|
||||
public void getProbeConfig(IProbeConfig config, EntityPlayer player, World world, Entity entity, IProbeHitEntityData data) {
|
||||
// Still no AE entities.
|
||||
}
|
||||
|
||||
public class AEConfigProvider implements IProbeConfigProvider
|
||||
{
|
||||
|
||||
@Override
|
||||
public void getProbeConfig( IProbeConfig config, EntityPlayer player, World world, Entity entity, IProbeHitEntityData data )
|
||||
{
|
||||
// Still no AE entities.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getProbeConfig( IProbeConfig config, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( world.getTileEntity( data.getPos() ) instanceof AEBaseTile )
|
||||
{
|
||||
config.setRFMode( 0 );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void getProbeConfig(IProbeConfig config, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
|
||||
if (world.getTileEntity(data.getPos()) instanceof AEBaseTile) {
|
||||
config.setRFMode(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+27
-36
@@ -19,54 +19,45 @@
|
||||
package appeng.integration.modules.theoneprobe.part;
|
||||
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.parts.networking.PartCableSmart;
|
||||
import appeng.parts.networking.PartDenseCableSmart;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.parts.networking.PartCableSmart;
|
||||
import appeng.parts.networking.PartDenseCableSmart;
|
||||
public class ChannelInfoProvider implements IPartProbInfoProvider {
|
||||
|
||||
@Override
|
||||
public void addProbeInfo(IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
|
||||
if (!AEConfig.instance().isFeatureEnabled(AEFeature.CHANNELS)) {
|
||||
return;
|
||||
}
|
||||
if (part instanceof PartDenseCableSmart || part instanceof PartCableSmart) {
|
||||
final int usedChannels;
|
||||
final int maxChannels = (part instanceof PartDenseCableSmart) ? 32 : 8;
|
||||
|
||||
public class ChannelInfoProvider implements IPartProbInfoProvider
|
||||
{
|
||||
if (part.getGridNode().isActive()) {
|
||||
final NBTTagCompound tmp = new NBTTagCompound();
|
||||
part.writeToNBT(tmp);
|
||||
usedChannels = tmp.getByte("usedChannels");
|
||||
} else {
|
||||
usedChannels = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( !AEConfig.instance().isFeatureEnabled( AEFeature.CHANNELS ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if( part instanceof PartDenseCableSmart || part instanceof PartCableSmart )
|
||||
{
|
||||
final int usedChannels;
|
||||
final int maxChannels = ( part instanceof PartDenseCableSmart ) ? 32 : 8;
|
||||
final String formattedChannelString = String.format(TheOneProbeText.CHANNELS.getLocal(), usedChannels, maxChannels);
|
||||
|
||||
if( part.getGridNode().isActive() )
|
||||
{
|
||||
final NBTTagCompound tmp = new NBTTagCompound();
|
||||
part.writeToNBT( tmp );
|
||||
usedChannels = tmp.getByte( "usedChannels" );
|
||||
}
|
||||
else
|
||||
{
|
||||
usedChannels = 0;
|
||||
}
|
||||
probeInfo.text(formattedChannelString);
|
||||
}
|
||||
|
||||
final String formattedChannelString = String.format( TheOneProbeText.CHANNELS.getLocal(), usedChannels, maxChannels );
|
||||
|
||||
probeInfo.text( formattedChannelString );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
-13
@@ -19,27 +19,23 @@
|
||||
package appeng.integration.modules.theoneprobe.part;
|
||||
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.IProbeInfoProvider;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
/**
|
||||
* Similar to {@link IProbeInfoProvider}, but already providing the {@link IPart} being looked at.
|
||||
*
|
||||
*/
|
||||
public interface IPartProbInfoProvider
|
||||
{
|
||||
public interface IPartProbInfoProvider {
|
||||
|
||||
/**
|
||||
* @see IProbeInfoProvider#addProbeInfo(ProbeMode, IProbeInfo, EntityPlayer, World, IBlockState, IProbeHitData)
|
||||
*/
|
||||
void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data );
|
||||
/**
|
||||
* @see IProbeInfoProvider#addProbeInfo(ProbeMode, IProbeInfo, EntityPlayer, World, IBlockState, IProbeHitData)
|
||||
*/
|
||||
void addProbeInfo(IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data);
|
||||
}
|
||||
|
||||
+78
-107
@@ -19,131 +19,102 @@
|
||||
package appeng.integration.modules.theoneprobe.part;
|
||||
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.p2p.PartP2PTunnel;
|
||||
import appeng.util.Platform;
|
||||
import com.google.common.collect.Iterators;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
public class P2PStateInfoProvider implements IPartProbInfoProvider
|
||||
{
|
||||
public class P2PStateInfoProvider implements IPartProbInfoProvider {
|
||||
|
||||
private static final int STATE_UNLINKED = 0;
|
||||
private static final int STATE_OUTPUT = 1;
|
||||
private static final int STATE_INPUT = 2;
|
||||
private static final int STATE_UNLINKED = 0;
|
||||
private static final int STATE_OUTPUT = 1;
|
||||
private static final int STATE_INPUT = 2;
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( part instanceof PartP2PTunnel )
|
||||
{
|
||||
final PartP2PTunnel tunnel = (PartP2PTunnel) part;
|
||||
@Override
|
||||
public void addProbeInfo(IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
|
||||
if (part instanceof PartP2PTunnel) {
|
||||
final PartP2PTunnel tunnel = (PartP2PTunnel) part;
|
||||
|
||||
if( !tunnel.isPowered() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!tunnel.isPowered()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The default state
|
||||
int state = STATE_UNLINKED;
|
||||
int outputCount = getOutputCount( tunnel );
|
||||
int inputCount = getInputCount( tunnel );
|
||||
// The default state
|
||||
int state = STATE_UNLINKED;
|
||||
int outputCount = getOutputCount(tunnel);
|
||||
int inputCount = getInputCount(tunnel);
|
||||
|
||||
if( !tunnel.isOutput() )
|
||||
{
|
||||
if( outputCount > 0 )
|
||||
{
|
||||
// Only set it to INPUT if we know there are any outputs
|
||||
state = STATE_INPUT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( inputCount > 0 )
|
||||
{
|
||||
state = STATE_OUTPUT;
|
||||
}
|
||||
}
|
||||
if (!tunnel.isOutput()) {
|
||||
if (outputCount > 0) {
|
||||
// Only set it to INPUT if we know there are any outputs
|
||||
state = STATE_INPUT;
|
||||
}
|
||||
} else {
|
||||
if (inputCount > 0) {
|
||||
state = STATE_OUTPUT;
|
||||
}
|
||||
}
|
||||
|
||||
switch( state )
|
||||
{
|
||||
case STATE_UNLINKED:
|
||||
probeInfo.text( TheOneProbeText.P2P_UNLINKED.getLocal() );
|
||||
break;
|
||||
case STATE_OUTPUT:
|
||||
probeInfo.text( getInputText( inputCount ) );
|
||||
break;
|
||||
case STATE_INPUT:
|
||||
probeInfo.text( getOutputText( outputCount ) );
|
||||
break;
|
||||
}
|
||||
switch (state) {
|
||||
case STATE_UNLINKED:
|
||||
probeInfo.text(TheOneProbeText.P2P_UNLINKED.getLocal());
|
||||
break;
|
||||
case STATE_OUTPUT:
|
||||
probeInfo.text(getInputText(inputCount));
|
||||
break;
|
||||
case STATE_INPUT:
|
||||
probeInfo.text(getOutputText(outputCount));
|
||||
break;
|
||||
}
|
||||
|
||||
final short freq = tunnel.getFrequency();
|
||||
final String freqTooltip = Platform.p2p().toHexString( freq );
|
||||
final short freq = tunnel.getFrequency();
|
||||
final String freqTooltip = Platform.p2p().toHexString(freq);
|
||||
|
||||
probeInfo.text( freqTooltip );
|
||||
}
|
||||
}
|
||||
probeInfo.text(freqTooltip);
|
||||
}
|
||||
}
|
||||
|
||||
private static int getOutputCount( PartP2PTunnel tunnel )
|
||||
{
|
||||
try
|
||||
{
|
||||
return Iterators.size( tunnel.getOutputs().iterator() );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// Well... unknown size it is!
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
private static int getOutputCount(PartP2PTunnel tunnel) {
|
||||
try {
|
||||
return Iterators.size(tunnel.getOutputs().iterator());
|
||||
} catch (GridAccessException e) {
|
||||
// Well... unknown size it is!
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static int getInputCount( PartP2PTunnel tunnel )
|
||||
{
|
||||
try
|
||||
{
|
||||
return Iterators.size( tunnel.getInputs().iterator() );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// Well... unknown size it is!
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
private static int getInputCount(PartP2PTunnel tunnel) {
|
||||
try {
|
||||
return Iterators.size(tunnel.getInputs().iterator());
|
||||
} catch (GridAccessException e) {
|
||||
// Well... unknown size it is!
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getOutputText( int outputs )
|
||||
{
|
||||
if( outputs <= 1 )
|
||||
{
|
||||
return TheOneProbeText.P2P_INPUT_ONE_OUTPUT.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.format( TheOneProbeText.P2P_INPUT_MANY_OUTPUTS.getLocal(), outputs );
|
||||
}
|
||||
}
|
||||
private static String getOutputText(int outputs) {
|
||||
if (outputs <= 1) {
|
||||
return TheOneProbeText.P2P_INPUT_ONE_OUTPUT.getLocal();
|
||||
} else {
|
||||
return String.format(TheOneProbeText.P2P_INPUT_MANY_OUTPUTS.getLocal(), outputs);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getInputText( int inputs )
|
||||
{
|
||||
if( inputs <= 1 )
|
||||
{
|
||||
return TheOneProbeText.P2P_OUTPUT_ONE_INPUT.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.format( TheOneProbeText.P2P_OUTPUT_MANY_INPUTS.getLocal(), inputs );
|
||||
}
|
||||
}
|
||||
private static String getInputText(int inputs) {
|
||||
if (inputs <= 1) {
|
||||
return TheOneProbeText.P2P_OUTPUT_ONE_INPUT.getLocal();
|
||||
} else {
|
||||
return String.format(TheOneProbeText.P2P_OUTPUT_MANY_INPUTS.getLocal(), inputs);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,37 +19,31 @@
|
||||
package appeng.integration.modules.theoneprobe.part;
|
||||
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public final class PartAccessor
|
||||
{
|
||||
public final class PartAccessor {
|
||||
|
||||
public Optional<IPart> getMaybePart( final TileEntity te, final IProbeHitData data )
|
||||
{
|
||||
if( te instanceof IPartHost )
|
||||
{
|
||||
BlockPos pos = data.getPos();
|
||||
final Vec3d position = data.getHitVec().addVector( -pos.getX(), -pos.getY(), -pos.getZ() );
|
||||
final IPartHost host = (IPartHost) te;
|
||||
final SelectedPart sp = host.selectPart( position );
|
||||
public Optional<IPart> getMaybePart(final TileEntity te, final IProbeHitData data) {
|
||||
if (te instanceof IPartHost) {
|
||||
BlockPos pos = data.getPos();
|
||||
final Vec3d position = data.getHitVec().addVector(-pos.getX(), -pos.getY(), -pos.getZ());
|
||||
final IPartHost host = (IPartHost) te;
|
||||
final SelectedPart sp = host.selectPart(position);
|
||||
|
||||
if( sp.part != null )
|
||||
{
|
||||
return Optional.of( sp.part );
|
||||
}
|
||||
}
|
||||
if (sp.part != null) {
|
||||
return Optional.of(sp.part);
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
+26
-37
@@ -19,53 +19,42 @@
|
||||
package appeng.integration.modules.theoneprobe.part;
|
||||
|
||||
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
public class PowerStateInfoProvider implements IPartProbInfoProvider {
|
||||
|
||||
@Override
|
||||
public void addProbeInfo(IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
|
||||
if (part instanceof IPowerChannelState) {
|
||||
final IPowerChannelState state = (IPowerChannelState) part;
|
||||
final String tooltip = this.getToolTip(state.isActive(), state.isPowered());
|
||||
|
||||
public class PowerStateInfoProvider implements IPartProbInfoProvider
|
||||
{
|
||||
probeInfo.text(tooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( part instanceof IPowerChannelState )
|
||||
{
|
||||
final IPowerChannelState state = (IPowerChannelState) part;
|
||||
final String tooltip = this.getToolTip( state.isActive(), state.isPowered() );
|
||||
}
|
||||
|
||||
probeInfo.text( tooltip );
|
||||
}
|
||||
private String getToolTip(final boolean isActive, final boolean isPowered) {
|
||||
final String result;
|
||||
|
||||
}
|
||||
if (isActive && isPowered) {
|
||||
result = TheOneProbeText.DEVICE_ONLINE.getLocal();
|
||||
} else if (isPowered) {
|
||||
result = TheOneProbeText.DEVICE_MISSING_CHANNEL.getLocal();
|
||||
} else {
|
||||
result = TheOneProbeText.DEVICE_OFFLINE.getLocal();
|
||||
}
|
||||
|
||||
private String getToolTip( final boolean isActive, final boolean isPowered )
|
||||
{
|
||||
final String result;
|
||||
|
||||
if( isActive && isPowered )
|
||||
{
|
||||
result = TheOneProbeText.DEVICE_ONLINE.getLocal();
|
||||
}
|
||||
else if( isPowered )
|
||||
{
|
||||
result = TheOneProbeText.DEVICE_MISSING_CHANNEL.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = TheOneProbeText.DEVICE_OFFLINE.getLocal();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+24
-32
@@ -19,49 +19,41 @@
|
||||
package appeng.integration.modules.theoneprobe.part;
|
||||
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.implementations.parts.IPartStorageMonitor;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
public class StorageMonitorInfoProvider implements IPartProbInfoProvider
|
||||
{
|
||||
public class StorageMonitorInfoProvider implements IPartProbInfoProvider {
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( part instanceof IPartStorageMonitor )
|
||||
{
|
||||
final IPartStorageMonitor monitor = (IPartStorageMonitor) part;
|
||||
@Override
|
||||
public void addProbeInfo(IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
|
||||
if (part instanceof IPartStorageMonitor) {
|
||||
final IPartStorageMonitor monitor = (IPartStorageMonitor) part;
|
||||
|
||||
final IAEStack<?> displayed = monitor.getDisplayed();
|
||||
final boolean isLocked = monitor.isLocked();
|
||||
final IAEStack<?> displayed = monitor.getDisplayed();
|
||||
final boolean isLocked = monitor.isLocked();
|
||||
|
||||
// TODO: generalize
|
||||
if( displayed instanceof IAEItemStack )
|
||||
{
|
||||
final IAEItemStack ais = (IAEItemStack) displayed;
|
||||
probeInfo.text( TheOneProbeText.SHOWING.getLocal() + ": " + ais.asItemStackRepresentation().getDisplayName() );
|
||||
}
|
||||
else if( displayed instanceof IAEFluidStack )
|
||||
{
|
||||
final IAEFluidStack ais = (IAEFluidStack) displayed;
|
||||
probeInfo.text( TheOneProbeText.SHOWING.getLocal() + ": " + ais.getFluid().getLocalizedName( ais.getFluidStack() ) );
|
||||
}
|
||||
// TODO: generalize
|
||||
if (displayed instanceof IAEItemStack) {
|
||||
final IAEItemStack ais = (IAEItemStack) displayed;
|
||||
probeInfo.text(TheOneProbeText.SHOWING.getLocal() + ": " + ais.asItemStackRepresentation().getDisplayName());
|
||||
} else if (displayed instanceof IAEFluidStack) {
|
||||
final IAEFluidStack ais = (IAEFluidStack) displayed;
|
||||
probeInfo.text(TheOneProbeText.SHOWING.getLocal() + ": " + ais.getFluid().getLocalizedName(ais.getFluidStack()));
|
||||
}
|
||||
|
||||
probeInfo.text( isLocked ? TheOneProbeText.LOCKED.getLocal() : TheOneProbeText.UNLOCKED.getLocal() );
|
||||
}
|
||||
}
|
||||
probeInfo.text(isLocked ? TheOneProbeText.LOCKED.getLocal() : TheOneProbeText.UNLOCKED.getLocal());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+22
-28
@@ -19,43 +19,37 @@
|
||||
package appeng.integration.modules.theoneprobe.tile;
|
||||
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.misc.TileCharger;
|
||||
import mcjty.theoneprobe.api.ElementAlignment;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import mcjty.theoneprobe.api.ElementAlignment;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.misc.TileCharger;
|
||||
public class ChargerInfoProvider implements ITileProbInfoProvider {
|
||||
|
||||
@Override
|
||||
public void addProbeInfo(AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
|
||||
if (tile instanceof TileCharger) {
|
||||
final TileCharger charger = (TileCharger) tile;
|
||||
final IItemHandler chargerInventory = charger.getInternalInventory();
|
||||
final ItemStack chargingItem = chargerInventory.getStackInSlot(0);
|
||||
|
||||
public class ChargerInfoProvider implements ITileProbInfoProvider
|
||||
{
|
||||
if (!chargingItem.isEmpty()) {
|
||||
final String currentInventory = chargingItem.getDisplayName();
|
||||
final IProbeInfo centerAlignedHorizontalLayout = probeInfo
|
||||
.horizontal(probeInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER));
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( tile instanceof TileCharger )
|
||||
{
|
||||
final TileCharger charger = (TileCharger) tile;
|
||||
final IItemHandler chargerInventory = charger.getInternalInventory();
|
||||
final ItemStack chargingItem = chargerInventory.getStackInSlot( 0 );
|
||||
|
||||
if( !chargingItem.isEmpty() )
|
||||
{
|
||||
final String currentInventory = chargingItem.getDisplayName();
|
||||
final IProbeInfo centerAlignedHorizontalLayout = probeInfo
|
||||
.horizontal( probeInfo.defaultLayoutStyle().alignment( ElementAlignment.ALIGN_CENTER ) );
|
||||
|
||||
centerAlignedHorizontalLayout.item( chargingItem );
|
||||
centerAlignedHorizontalLayout.text( currentInventory );
|
||||
}
|
||||
}
|
||||
}
|
||||
centerAlignedHorizontalLayout.item(chargingItem);
|
||||
centerAlignedHorizontalLayout.text(currentInventory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+26
-32
@@ -19,47 +19,41 @@
|
||||
package appeng.integration.modules.theoneprobe.tile;
|
||||
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.crafting.TileCraftingMonitorTile;
|
||||
import mcjty.theoneprobe.api.ElementAlignment;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.ElementAlignment;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.crafting.TileCraftingMonitorTile;
|
||||
public class CraftingMonitorInfoProvider implements ITileProbInfoProvider {
|
||||
|
||||
@Override
|
||||
public void addProbeInfo(AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
|
||||
if (tile instanceof TileCraftingMonitorTile) {
|
||||
final TileCraftingMonitorTile monitor = (TileCraftingMonitorTile) tile;
|
||||
final IAEItemStack displayStack = monitor.getJobProgress();
|
||||
|
||||
public class CraftingMonitorInfoProvider implements ITileProbInfoProvider
|
||||
{
|
||||
if (displayStack != null) {
|
||||
// TODO: check if OK
|
||||
final ItemStack itemStack = displayStack.asItemStackRepresentation();
|
||||
final String itemName = itemStack.getDisplayName();
|
||||
final String formattedCrafting = String.format(TheOneProbeText.CRAFTING.getLocal(), itemName);
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( tile instanceof TileCraftingMonitorTile )
|
||||
{
|
||||
final TileCraftingMonitorTile monitor = (TileCraftingMonitorTile) tile;
|
||||
final IAEItemStack displayStack = monitor.getJobProgress();
|
||||
final IProbeInfo centerAlignedHorizontalLayout = probeInfo
|
||||
.horizontal(probeInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER));
|
||||
|
||||
if( displayStack != null )
|
||||
{
|
||||
// TODO: check if OK
|
||||
final ItemStack itemStack = displayStack.asItemStackRepresentation();
|
||||
final String itemName = itemStack.getDisplayName();
|
||||
final String formattedCrafting = String.format( TheOneProbeText.CRAFTING.getLocal(), itemName );
|
||||
|
||||
final IProbeInfo centerAlignedHorizontalLayout = probeInfo
|
||||
.horizontal( probeInfo.defaultLayoutStyle().alignment( ElementAlignment.ALIGN_CENTER ) );
|
||||
|
||||
centerAlignedHorizontalLayout.item( itemStack );
|
||||
centerAlignedHorizontalLayout.text( formattedCrafting );
|
||||
}
|
||||
}
|
||||
}
|
||||
centerAlignedHorizontalLayout.item(itemStack);
|
||||
centerAlignedHorizontalLayout.text(formattedCrafting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
-13
@@ -19,27 +19,23 @@
|
||||
package appeng.integration.modules.theoneprobe.tile;
|
||||
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.IProbeInfoProvider;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
/**
|
||||
* Similar to {@link IProbeInfoProvider}, but already providing the {@link AEBaseTile} being looked at.
|
||||
*
|
||||
*/
|
||||
public interface ITileProbInfoProvider
|
||||
{
|
||||
public interface ITileProbInfoProvider {
|
||||
|
||||
/**
|
||||
* @see IProbeInfoProvider#addProbeInfo(ProbeMode, IProbeInfo, EntityPlayer, World, IBlockState, IProbeHitData)
|
||||
*/
|
||||
void addProbeInfo( AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data );
|
||||
/**
|
||||
* @see IProbeInfoProvider#addProbeInfo(ProbeMode, IProbeInfo, EntityPlayer, World, IBlockState, IProbeHitData)
|
||||
*/
|
||||
void addProbeInfo(AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data);
|
||||
}
|
||||
|
||||
+22
-32
@@ -19,46 +19,36 @@
|
||||
package appeng.integration.modules.theoneprobe.tile;
|
||||
|
||||
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.tile.AEBaseTile;
|
||||
public class PowerStateInfoProvider implements ITileProbInfoProvider {
|
||||
|
||||
@Override
|
||||
public void addProbeInfo(AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
|
||||
if (tile instanceof IPowerChannelState) {
|
||||
final IPowerChannelState state = (IPowerChannelState) tile;
|
||||
|
||||
public class PowerStateInfoProvider implements ITileProbInfoProvider
|
||||
{
|
||||
final boolean isActive = state.isActive();
|
||||
final boolean isPowered = state.isPowered();
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( tile instanceof IPowerChannelState )
|
||||
{
|
||||
final IPowerChannelState state = (IPowerChannelState) tile;
|
||||
if (isActive && isPowered) {
|
||||
probeInfo.text(TheOneProbeText.DEVICE_ONLINE.getLocal());
|
||||
} else if (isPowered) {
|
||||
probeInfo.text(TheOneProbeText.DEVICE_MISSING_CHANNEL.getLocal());
|
||||
} else {
|
||||
probeInfo.text(TheOneProbeText.DEVICE_OFFLINE.getLocal());
|
||||
}
|
||||
}
|
||||
|
||||
final boolean isActive = state.isActive();
|
||||
final boolean isPowered = state.isPowered();
|
||||
|
||||
if( isActive && isPowered )
|
||||
{
|
||||
probeInfo.text( TheOneProbeText.DEVICE_ONLINE.getLocal() );
|
||||
}
|
||||
else if( isPowered )
|
||||
{
|
||||
probeInfo.text( TheOneProbeText.DEVICE_MISSING_CHANNEL.getLocal() );
|
||||
}
|
||||
else
|
||||
{
|
||||
probeInfo.text( TheOneProbeText.DEVICE_OFFLINE.getLocal() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+24
-31
@@ -19,48 +19,41 @@
|
||||
package appeng.integration.modules.theoneprobe.tile;
|
||||
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.networking.energy.IAEPowerStorage;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
public class PowerStorageInfoProvider implements ITileProbInfoProvider
|
||||
{
|
||||
public class PowerStorageInfoProvider implements ITileProbInfoProvider {
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( tile instanceof IAEPowerStorage )
|
||||
{
|
||||
final IAEPowerStorage storage = (IAEPowerStorage) tile;
|
||||
final double maxPower = storage.getAEMaxPower();
|
||||
@Override
|
||||
public void addProbeInfo(AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
|
||||
if (tile instanceof IAEPowerStorage) {
|
||||
final IAEPowerStorage storage = (IAEPowerStorage) tile;
|
||||
final double maxPower = storage.getAEMaxPower();
|
||||
|
||||
if( maxPower > 0 )
|
||||
{
|
||||
final long internalCurrentPower = (long) ( storage.getAECurrentPower() * 100 );
|
||||
if (maxPower > 0) {
|
||||
final long internalCurrentPower = (long) (storage.getAECurrentPower() * 100);
|
||||
|
||||
if( internalCurrentPower >= 0 )
|
||||
{
|
||||
final long internalMaxPower = (long) ( 100 * maxPower );
|
||||
if (internalCurrentPower >= 0) {
|
||||
final long internalMaxPower = (long) (100 * maxPower);
|
||||
|
||||
final String formatCurrentPower = Platform.formatPowerLong( internalCurrentPower, false );
|
||||
final String formatMaxPower = Platform.formatPowerLong( internalMaxPower, false );
|
||||
final String formattedString = String.format( TheOneProbeText.STORED_ENERGY.getLocal(), formatCurrentPower, formatMaxPower );
|
||||
final String formatCurrentPower = Platform.formatPowerLong(internalCurrentPower, false);
|
||||
final String formatMaxPower = Platform.formatPowerLong(internalMaxPower, false);
|
||||
final String formattedString = String.format(TheOneProbeText.STORED_ENERGY.getLocal(), formatCurrentPower, formatMaxPower);
|
||||
|
||||
probeInfo.text( formattedString );
|
||||
}
|
||||
}
|
||||
}
|
||||
probeInfo.text(formattedString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
package appeng.integration.modules.waila;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -28,9 +29,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -40,35 +39,29 @@ import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public abstract class BaseWailaDataProvider implements IWailaDataProvider
|
||||
{
|
||||
@Override
|
||||
public ItemStack getWailaStack( final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
public abstract class BaseWailaDataProvider implements IWailaDataProvider {
|
||||
@Override
|
||||
public ItemStack getWailaStack(final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
return currentToolTip;
|
||||
}
|
||||
@Override
|
||||
public List<String> getWailaHead(final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
return currentToolTip;
|
||||
}
|
||||
@Override
|
||||
public List<String> getWailaBody(final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
return currentToolTip;
|
||||
}
|
||||
@Override
|
||||
public List<String> getWailaTail(final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData( EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos )
|
||||
{
|
||||
return tag;
|
||||
}
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,12 @@
|
||||
package appeng.integration.modules.waila;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.integration.modules.waila.part.*;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -32,19 +33,8 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.integration.modules.waila.part.ChannelWailaDataProvider;
|
||||
import appeng.integration.modules.waila.part.IPartWailaDataProvider;
|
||||
import appeng.integration.modules.waila.part.P2PStateWailaDataProvider;
|
||||
import appeng.integration.modules.waila.part.PartAccessor;
|
||||
import appeng.integration.modules.waila.part.PartStackWailaDataProvider;
|
||||
import appeng.integration.modules.waila.part.PowerStateWailaDataProvider;
|
||||
import appeng.integration.modules.waila.part.StorageMonitorWailaDataProvider;
|
||||
import appeng.integration.modules.waila.part.Tracer;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
/**
|
||||
@@ -54,144 +44,126 @@ import appeng.integration.modules.waila.part.Tracer;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class PartWailaDataProvider implements IWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* Contains all providers
|
||||
*/
|
||||
private final List<IPartWailaDataProvider> providers;
|
||||
public final class PartWailaDataProvider implements IWailaDataProvider {
|
||||
/**
|
||||
* Contains all providers
|
||||
*/
|
||||
private final List<IPartWailaDataProvider> providers;
|
||||
|
||||
/**
|
||||
* Can access parts through view-hits
|
||||
*/
|
||||
private final PartAccessor accessor = new PartAccessor();
|
||||
/**
|
||||
* Can access parts through view-hits
|
||||
*/
|
||||
private final PartAccessor accessor = new PartAccessor();
|
||||
|
||||
/**
|
||||
* Traces views hit on blocks
|
||||
*/
|
||||
private final Tracer tracer = new Tracer();
|
||||
/**
|
||||
* Traces views hit on blocks
|
||||
*/
|
||||
private final Tracer tracer = new Tracer();
|
||||
|
||||
/**
|
||||
* Initializes the provider list with all wanted providers
|
||||
*/
|
||||
public PartWailaDataProvider()
|
||||
{
|
||||
final IPartWailaDataProvider channel = new ChannelWailaDataProvider();
|
||||
final IPartWailaDataProvider storageMonitor = new StorageMonitorWailaDataProvider();
|
||||
final IPartWailaDataProvider powerState = new PowerStateWailaDataProvider();
|
||||
final IPartWailaDataProvider p2pState = new P2PStateWailaDataProvider();
|
||||
final IPartWailaDataProvider partStack = new PartStackWailaDataProvider();
|
||||
/**
|
||||
* Initializes the provider list with all wanted providers
|
||||
*/
|
||||
public PartWailaDataProvider() {
|
||||
final IPartWailaDataProvider channel = new ChannelWailaDataProvider();
|
||||
final IPartWailaDataProvider storageMonitor = new StorageMonitorWailaDataProvider();
|
||||
final IPartWailaDataProvider powerState = new PowerStateWailaDataProvider();
|
||||
final IPartWailaDataProvider p2pState = new P2PStateWailaDataProvider();
|
||||
final IPartWailaDataProvider partStack = new PartStackWailaDataProvider();
|
||||
|
||||
this.providers = Lists.newArrayList( channel, storageMonitor, powerState, partStack, p2pState );
|
||||
}
|
||||
this.providers = Lists.newArrayList(channel, storageMonitor, powerState, partStack, p2pState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack( final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
final RayTraceResult mop = accessor.getMOP();
|
||||
@Override
|
||||
public ItemStack getWailaStack(final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
final RayTraceResult mop = accessor.getMOP();
|
||||
|
||||
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, mop );
|
||||
final Optional<IPart> maybePart = this.accessor.getMaybePart(te, mop);
|
||||
|
||||
if( maybePart.isPresent() )
|
||||
{
|
||||
final IPart part = maybePart.get();
|
||||
if (maybePart.isPresent()) {
|
||||
final IPart part = maybePart.get();
|
||||
|
||||
ItemStack wailaStack = ItemStack.EMPTY;
|
||||
ItemStack wailaStack = ItemStack.EMPTY;
|
||||
|
||||
for( final IPartWailaDataProvider provider : this.providers )
|
||||
{
|
||||
wailaStack = provider.getWailaStack( part, config, wailaStack );
|
||||
}
|
||||
return wailaStack;
|
||||
}
|
||||
for (final IPartWailaDataProvider provider : this.providers) {
|
||||
wailaStack = provider.getWailaStack(part, config, wailaStack);
|
||||
}
|
||||
return wailaStack;
|
||||
}
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
final RayTraceResult mop = accessor.getMOP();
|
||||
@Override
|
||||
public List<String> getWailaHead(final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
final RayTraceResult mop = accessor.getMOP();
|
||||
|
||||
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, mop );
|
||||
final Optional<IPart> maybePart = this.accessor.getMaybePart(te, mop);
|
||||
|
||||
if( maybePart.isPresent() )
|
||||
{
|
||||
final IPart part = maybePart.get();
|
||||
if (maybePart.isPresent()) {
|
||||
final IPart part = maybePart.get();
|
||||
|
||||
for( final IPartWailaDataProvider provider : this.providers )
|
||||
{
|
||||
provider.getWailaHead( part, currentToolTip, accessor, config );
|
||||
}
|
||||
}
|
||||
for (final IPartWailaDataProvider provider : this.providers) {
|
||||
provider.getWailaHead(part, currentToolTip, accessor, config);
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
final RayTraceResult mop = accessor.getMOP();
|
||||
@Override
|
||||
public List<String> getWailaBody(final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
final RayTraceResult mop = accessor.getMOP();
|
||||
|
||||
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, mop );
|
||||
final Optional<IPart> maybePart = this.accessor.getMaybePart(te, mop);
|
||||
|
||||
if( maybePart.isPresent() )
|
||||
{
|
||||
final IPart part = maybePart.get();
|
||||
if (maybePart.isPresent()) {
|
||||
final IPart part = maybePart.get();
|
||||
|
||||
for( final IPartWailaDataProvider provider : this.providers )
|
||||
{
|
||||
provider.getWailaBody( part, currentToolTip, accessor, config );
|
||||
}
|
||||
}
|
||||
for (final IPartWailaDataProvider provider : this.providers) {
|
||||
provider.getWailaBody(part, currentToolTip, accessor, config);
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
final RayTraceResult mop = accessor.getMOP();
|
||||
@Override
|
||||
public List<String> getWailaTail(final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
final RayTraceResult mop = accessor.getMOP();
|
||||
|
||||
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, mop );
|
||||
final Optional<IPart> maybePart = this.accessor.getMaybePart(te, mop);
|
||||
|
||||
if( maybePart.isPresent() )
|
||||
{
|
||||
final IPart part = maybePart.get();
|
||||
if (maybePart.isPresent()) {
|
||||
final IPart part = maybePart.get();
|
||||
|
||||
for( final IPartWailaDataProvider provider : this.providers )
|
||||
{
|
||||
provider.getWailaTail( part, currentToolTip, accessor, config );
|
||||
}
|
||||
}
|
||||
for (final IPartWailaDataProvider provider : this.providers) {
|
||||
provider.getWailaTail(part, currentToolTip, accessor, config);
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData( final EntityPlayerMP player, final TileEntity te, final NBTTagCompound tag, final World world, BlockPos pos )
|
||||
{
|
||||
final RayTraceResult mop = this.tracer.retraceBlock( world, player, pos );
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(final EntityPlayerMP player, final TileEntity te, final NBTTagCompound tag, final World world, BlockPos pos) {
|
||||
final RayTraceResult mop = this.tracer.retraceBlock(world, player, pos);
|
||||
|
||||
if( mop != null )
|
||||
{
|
||||
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, mop );
|
||||
if (mop != null) {
|
||||
final Optional<IPart> maybePart = this.accessor.getMaybePart(te, mop);
|
||||
|
||||
if( maybePart.isPresent() )
|
||||
{
|
||||
final IPart part = maybePart.get();
|
||||
if (maybePart.isPresent()) {
|
||||
final IPart part = maybePart.get();
|
||||
|
||||
for( final IPartWailaDataProvider provider : this.providers )
|
||||
{
|
||||
provider.getNBTData( player, part, te, tag, world, pos );
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final IPartWailaDataProvider provider : this.providers) {
|
||||
provider.getNBTData(player, part, te, tag, world, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,14 @@
|
||||
package appeng.integration.modules.waila;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.integration.modules.waila.tile.ChargerWailaDataProvider;
|
||||
import appeng.integration.modules.waila.tile.CraftingMonitorWailaDataProvider;
|
||||
import appeng.integration.modules.waila.tile.PowerStateWailaDataProvider;
|
||||
import appeng.integration.modules.waila.tile.PowerStorageWailaDataProvider;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -30,14 +34,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
import appeng.integration.modules.waila.tile.ChargerWailaDataProvider;
|
||||
import appeng.integration.modules.waila.tile.CraftingMonitorWailaDataProvider;
|
||||
import appeng.integration.modules.waila.tile.PowerStateWailaDataProvider;
|
||||
import appeng.integration.modules.waila.tile.PowerStorageWailaDataProvider;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -47,73 +44,62 @@ import appeng.integration.modules.waila.tile.PowerStorageWailaDataProvider;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class TileWailaDataProvider implements IWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* Contains all providers
|
||||
*/
|
||||
private final List<IWailaDataProvider> providers;
|
||||
public final class TileWailaDataProvider implements IWailaDataProvider {
|
||||
/**
|
||||
* Contains all providers
|
||||
*/
|
||||
private final List<IWailaDataProvider> providers;
|
||||
|
||||
/**
|
||||
* Initializes the provider list with all wanted providers
|
||||
*/
|
||||
public TileWailaDataProvider()
|
||||
{
|
||||
final IWailaDataProvider charger = new ChargerWailaDataProvider();
|
||||
final IWailaDataProvider energyCell = new PowerStorageWailaDataProvider();
|
||||
final IWailaDataProvider craftingBlock = new PowerStateWailaDataProvider();
|
||||
final IWailaDataProvider craftingMonitor = new CraftingMonitorWailaDataProvider();
|
||||
/**
|
||||
* Initializes the provider list with all wanted providers
|
||||
*/
|
||||
public TileWailaDataProvider() {
|
||||
final IWailaDataProvider charger = new ChargerWailaDataProvider();
|
||||
final IWailaDataProvider energyCell = new PowerStorageWailaDataProvider();
|
||||
final IWailaDataProvider craftingBlock = new PowerStateWailaDataProvider();
|
||||
final IWailaDataProvider craftingMonitor = new CraftingMonitorWailaDataProvider();
|
||||
|
||||
this.providers = Lists.newArrayList( charger, energyCell, craftingBlock, craftingMonitor );
|
||||
}
|
||||
this.providers = Lists.newArrayList(charger, energyCell, craftingBlock, craftingMonitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack( final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getWailaStack(final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
for( final IWailaDataProvider provider : this.providers )
|
||||
{
|
||||
provider.getWailaHead( itemStack, currentToolTip, accessor, config );
|
||||
}
|
||||
@Override
|
||||
public List<String> getWailaHead(final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
for (final IWailaDataProvider provider : this.providers) {
|
||||
provider.getWailaHead(itemStack, currentToolTip, accessor, config);
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
for( final IWailaDataProvider provider : this.providers )
|
||||
{
|
||||
provider.getWailaBody( itemStack, currentToolTip, accessor, config );
|
||||
}
|
||||
@Override
|
||||
public List<String> getWailaBody(final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
for (final IWailaDataProvider provider : this.providers) {
|
||||
provider.getWailaBody(itemStack, currentToolTip, accessor, config);
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
for( final IWailaDataProvider provider : this.providers )
|
||||
{
|
||||
provider.getWailaTail( itemStack, currentToolTip, accessor, config );
|
||||
}
|
||||
@Override
|
||||
public List<String> getWailaTail(final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
for (final IWailaDataProvider provider : this.providers) {
|
||||
provider.getWailaTail(itemStack, currentToolTip, accessor, config);
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData( EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos )
|
||||
{
|
||||
for( final IWailaDataProvider provider : this.providers )
|
||||
{
|
||||
provider.getNBTData( player, te, tag, world, pos );
|
||||
}
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
|
||||
for (final IWailaDataProvider provider : this.providers) {
|
||||
provider.getNBTData(player, te, tag, world, pos);
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,46 +19,40 @@
|
||||
package appeng.integration.modules.waila;
|
||||
|
||||
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.IWailaRegistrar;
|
||||
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.IntegrationHelper;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.IWailaRegistrar;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms;
|
||||
|
||||
|
||||
public class WailaModule implements IIntegrationModule
|
||||
{
|
||||
public class WailaModule implements IIntegrationModule {
|
||||
|
||||
public WailaModule()
|
||||
{
|
||||
IntegrationHelper.testClassExistence( this, mcp.mobius.waila.api.IWailaDataProvider.class );
|
||||
IntegrationHelper.testClassExistence( this, mcp.mobius.waila.api.IWailaRegistrar.class );
|
||||
IntegrationHelper.testClassExistence( this, mcp.mobius.waila.api.IWailaConfigHandler.class );
|
||||
IntegrationHelper.testClassExistence( this, mcp.mobius.waila.api.IWailaDataAccessor.class );
|
||||
IntegrationHelper.testClassExistence( this, mcp.mobius.waila.api.ITaggedList.class );
|
||||
}
|
||||
public WailaModule() {
|
||||
IntegrationHelper.testClassExistence(this, mcp.mobius.waila.api.IWailaDataProvider.class);
|
||||
IntegrationHelper.testClassExistence(this, mcp.mobius.waila.api.IWailaRegistrar.class);
|
||||
IntegrationHelper.testClassExistence(this, mcp.mobius.waila.api.IWailaConfigHandler.class);
|
||||
IntegrationHelper.testClassExistence(this, mcp.mobius.waila.api.IWailaDataAccessor.class);
|
||||
IntegrationHelper.testClassExistence(this, mcp.mobius.waila.api.ITaggedList.class);
|
||||
}
|
||||
|
||||
public static void register( final IWailaRegistrar registrar )
|
||||
{
|
||||
final IWailaDataProvider partHost = new PartWailaDataProvider();
|
||||
public static void register(final IWailaRegistrar registrar) {
|
||||
final IWailaDataProvider partHost = new PartWailaDataProvider();
|
||||
|
||||
registrar.registerStackProvider( partHost, AEBaseTile.class );
|
||||
registrar.registerBodyProvider( partHost, AEBaseTile.class );
|
||||
registrar.registerNBTProvider( partHost, AEBaseTile.class );
|
||||
registrar.registerStackProvider(partHost, AEBaseTile.class);
|
||||
registrar.registerBodyProvider(partHost, AEBaseTile.class);
|
||||
registrar.registerNBTProvider(partHost, AEBaseTile.class);
|
||||
|
||||
final IWailaDataProvider tile = new TileWailaDataProvider();
|
||||
final IWailaDataProvider tile = new TileWailaDataProvider();
|
||||
|
||||
registrar.registerBodyProvider( tile, AEBaseTile.class );
|
||||
registrar.registerNBTProvider( tile, AEBaseTile.class );
|
||||
}
|
||||
registrar.registerBodyProvider(tile, AEBaseTile.class);
|
||||
registrar.registerNBTProvider(tile, AEBaseTile.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws Throwable
|
||||
{
|
||||
FMLInterModComms.sendMessage( "waila", "register", this.getClass().getName() + ".register" );
|
||||
}
|
||||
@Override
|
||||
public void init() throws Throwable {
|
||||
FMLInterModComms.sendMessage("waila", "register", this.getClass().getName() + ".register");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+25
-33
@@ -19,8 +19,9 @@
|
||||
package appeng.integration.modules.waila.part;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -28,10 +29,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -41,35 +39,29 @@ import appeng.api.parts.IPart;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public abstract class BasePartWailaDataProvider implements IPartWailaDataProvider
|
||||
{
|
||||
@Override
|
||||
public ItemStack getWailaStack( final IPart part, final IWailaConfigHandler config, final ItemStack partStack )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
public abstract class BasePartWailaDataProvider implements IPartWailaDataProvider {
|
||||
@Override
|
||||
public ItemStack getWailaStack(final IPart part, final IWailaConfigHandler config, final ItemStack partStack) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
return currentToolTip;
|
||||
}
|
||||
@Override
|
||||
public List<String> getWailaHead(final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
return currentToolTip;
|
||||
}
|
||||
@Override
|
||||
public List<String> getWailaBody(final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
return currentToolTip;
|
||||
}
|
||||
@Override
|
||||
public List<String> getWailaTail(final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData( EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos )
|
||||
{
|
||||
return tag;
|
||||
}
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
+97
-113
@@ -19,25 +19,23 @@
|
||||
package appeng.integration.modules.waila.part;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.parts.networking.PartCableSmart;
|
||||
import appeng.parts.networking.PartDenseCableSmart;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ByteMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ByteOpenHashMap;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ByteMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ByteOpenHashMap;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.parts.networking.PartCableSmart;
|
||||
import appeng.parts.networking.PartDenseCableSmart;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -47,120 +45,106 @@ import appeng.parts.networking.PartDenseCableSmart;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class ChannelWailaDataProvider extends BasePartWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* Channel key used for the transferred {@link net.minecraft.nbt.NBTTagCompound}
|
||||
*/
|
||||
private static final String ID_USED_CHANNELS = "usedChannels";
|
||||
public final class ChannelWailaDataProvider extends BasePartWailaDataProvider {
|
||||
/**
|
||||
* Channel key used for the transferred {@link net.minecraft.nbt.NBTTagCompound}
|
||||
*/
|
||||
private static final String ID_USED_CHANNELS = "usedChannels";
|
||||
|
||||
/**
|
||||
* Used cache for channels if the channel was not transmitted through the server.
|
||||
* <p/>
|
||||
* This is useful, when a player just started to look at a tile and thus just requested the new information from the
|
||||
* server.
|
||||
* <p/>
|
||||
* The cache will be updated from the server.
|
||||
*/
|
||||
private final Object2ByteMap<IPart> cache = new Object2ByteOpenHashMap<>();
|
||||
/**
|
||||
* Used cache for channels if the channel was not transmitted through the server.
|
||||
* <p/>
|
||||
* This is useful, when a player just started to look at a tile and thus just requested the new information from the
|
||||
* server.
|
||||
* <p/>
|
||||
* The cache will be updated from the server.
|
||||
*/
|
||||
private final Object2ByteMap<IPart> cache = new Object2ByteOpenHashMap<>();
|
||||
|
||||
/**
|
||||
* Adds the used and max channel to the tool tip
|
||||
*
|
||||
* @param part being looked at part
|
||||
* @param currentToolTip current tool tip
|
||||
* @param accessor wrapper for various world information
|
||||
* @param config config to react to various settings
|
||||
* @return modified tool tip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
if( !AEConfig.instance().isFeatureEnabled( AEFeature.CHANNELS ) )
|
||||
{
|
||||
return currentToolTip;
|
||||
}
|
||||
if( part instanceof PartCableSmart || part instanceof PartDenseCableSmart )
|
||||
{
|
||||
final NBTTagCompound tag = accessor.getNBTData();
|
||||
/**
|
||||
* Adds the used and max channel to the tool tip
|
||||
*
|
||||
* @param part being looked at part
|
||||
* @param currentToolTip current tool tip
|
||||
* @param accessor wrapper for various world information
|
||||
* @param config config to react to various settings
|
||||
* @return modified tool tip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody(final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
if (!AEConfig.instance().isFeatureEnabled(AEFeature.CHANNELS)) {
|
||||
return currentToolTip;
|
||||
}
|
||||
if (part instanceof PartCableSmart || part instanceof PartDenseCableSmart) {
|
||||
final NBTTagCompound tag = accessor.getNBTData();
|
||||
|
||||
final byte usedChannels = this.getUsedChannels( part, tag, this.cache );
|
||||
final byte usedChannels = this.getUsedChannels(part, tag, this.cache);
|
||||
|
||||
if( usedChannels >= 0 )
|
||||
{
|
||||
final byte maxChannels = (byte) ( ( part instanceof PartDenseCableSmart ) ? 32 : 8 );
|
||||
if (usedChannels >= 0) {
|
||||
final byte maxChannels = (byte) ((part instanceof PartDenseCableSmart) ? 32 : 8);
|
||||
|
||||
final String formattedToolTip = String.format( WailaText.Channels.getLocal(), usedChannels, maxChannels );
|
||||
currentToolTip.add( formattedToolTip );
|
||||
}
|
||||
}
|
||||
final String formattedToolTip = String.format(WailaText.Channels.getLocal(), usedChannels, maxChannels);
|
||||
currentToolTip.add(formattedToolTip);
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the source of the channel.
|
||||
* <p/>
|
||||
* If the client received information of the channels on the server, they are used, else if the cache contains a
|
||||
* previous stored value, this will be used. Default value is 0.
|
||||
*
|
||||
* @param part part to be looked at
|
||||
* @param tag tag maybe containing the channel information
|
||||
* @param cache cache with previous knowledge
|
||||
* @return used channels on the cable
|
||||
*/
|
||||
private byte getUsedChannels( final IPart part, final NBTTagCompound tag, final Object2ByteMap<IPart> cache )
|
||||
{
|
||||
final byte usedChannels;
|
||||
/**
|
||||
* Determines the source of the channel.
|
||||
* <p/>
|
||||
* If the client received information of the channels on the server, they are used, else if the cache contains a
|
||||
* previous stored value, this will be used. Default value is 0.
|
||||
*
|
||||
* @param part part to be looked at
|
||||
* @param tag tag maybe containing the channel information
|
||||
* @param cache cache with previous knowledge
|
||||
* @return used channels on the cable
|
||||
*/
|
||||
private byte getUsedChannels(final IPart part, final NBTTagCompound tag, final Object2ByteMap<IPart> cache) {
|
||||
final byte usedChannels;
|
||||
|
||||
if( tag.hasKey( ID_USED_CHANNELS ) )
|
||||
{
|
||||
usedChannels = tag.getByte( ID_USED_CHANNELS );
|
||||
this.cache.put( part, usedChannels );
|
||||
}
|
||||
else if( this.cache.containsKey( part ) )
|
||||
{
|
||||
usedChannels = this.cache.get( part );
|
||||
}
|
||||
else
|
||||
{
|
||||
usedChannels = -1;
|
||||
}
|
||||
if (tag.hasKey(ID_USED_CHANNELS)) {
|
||||
usedChannels = tag.getByte(ID_USED_CHANNELS);
|
||||
this.cache.put(part, usedChannels);
|
||||
} else if (this.cache.containsKey(part)) {
|
||||
usedChannels = this.cache.get(part);
|
||||
} else {
|
||||
usedChannels = -1;
|
||||
}
|
||||
|
||||
return usedChannels;
|
||||
}
|
||||
return usedChannels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on server to transfer information from server to client.
|
||||
* <p/>
|
||||
* If the part is a cable, it writes the channel information in the {@code #tag} using the {@code ID_USED_CHANNELS}
|
||||
* key.
|
||||
*
|
||||
* @param player player looking at the part
|
||||
* @param part part being looked at
|
||||
* @param te host of the part
|
||||
* @param tag transferred tag which is send to the client
|
||||
* @param world world of the part
|
||||
* @param pos pos of the part
|
||||
* @return tag send to the client
|
||||
*/
|
||||
@Override
|
||||
public NBTTagCompound getNBTData( EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos )
|
||||
{
|
||||
if( part instanceof PartCableSmart || part instanceof PartDenseCableSmart )
|
||||
{
|
||||
final NBTTagCompound tempTag = new NBTTagCompound();
|
||||
/**
|
||||
* Called on server to transfer information from server to client.
|
||||
* <p/>
|
||||
* If the part is a cable, it writes the channel information in the {@code #tag} using the {@code ID_USED_CHANNELS}
|
||||
* key.
|
||||
*
|
||||
* @param player player looking at the part
|
||||
* @param part part being looked at
|
||||
* @param te host of the part
|
||||
* @param tag transferred tag which is send to the client
|
||||
* @param world world of the part
|
||||
* @param pos pos of the part
|
||||
* @return tag send to the client
|
||||
*/
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
|
||||
if (part instanceof PartCableSmart || part instanceof PartDenseCableSmart) {
|
||||
final NBTTagCompound tempTag = new NBTTagCompound();
|
||||
|
||||
part.writeToNBT( tempTag );
|
||||
part.writeToNBT(tempTag);
|
||||
|
||||
if( tempTag.hasKey( ID_USED_CHANNELS ) )
|
||||
{
|
||||
final byte usedChannels = tempTag.getByte( ID_USED_CHANNELS );
|
||||
if (tempTag.hasKey(ID_USED_CHANNELS)) {
|
||||
final byte usedChannels = tempTag.getByte(ID_USED_CHANNELS);
|
||||
|
||||
tag.setByte( ID_USED_CHANNELS, usedChannels );
|
||||
}
|
||||
}
|
||||
tag.setByte(ID_USED_CHANNELS, usedChannels);
|
||||
}
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
package appeng.integration.modules.waila.part;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -28,10 +29,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -42,15 +40,14 @@ import appeng.api.parts.IPart;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public interface IPartWailaDataProvider
|
||||
{
|
||||
ItemStack getWailaStack( IPart part, IWailaConfigHandler config, ItemStack partStack );
|
||||
public interface IPartWailaDataProvider {
|
||||
ItemStack getWailaStack(IPart part, IWailaConfigHandler config, ItemStack partStack);
|
||||
|
||||
List<String> getWailaHead( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config );
|
||||
List<String> getWailaHead(IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config);
|
||||
|
||||
List<String> getWailaBody( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config );
|
||||
List<String> getWailaBody(IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config);
|
||||
|
||||
List<String> getWailaTail( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config );
|
||||
List<String> getWailaTail(IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config);
|
||||
|
||||
NBTTagCompound getNBTData( EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos );
|
||||
NBTTagCompound getNBTData(EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos);
|
||||
}
|
||||
|
||||
+112
-147
@@ -19,11 +19,14 @@
|
||||
package appeng.integration.modules.waila.part;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.p2p.PartP2PTunnel;
|
||||
import appeng.util.Platform;
|
||||
import com.google.common.collect.Iterators;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -31,170 +34,132 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.p2p.PartP2PTunnel;
|
||||
import appeng.util.Platform;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Provides information about a P2P tunnel to WAILA.
|
||||
*/
|
||||
public final class P2PStateWailaDataProvider extends BasePartWailaDataProvider
|
||||
{
|
||||
public final class P2PStateWailaDataProvider extends BasePartWailaDataProvider {
|
||||
|
||||
private static final int STATE_UNLINKED = 0;
|
||||
private static final int STATE_OUTPUT = 1;
|
||||
private static final int STATE_INPUT = 2;
|
||||
public static final String TAG_P2P_STATE = "p2p_state";
|
||||
public static final String TAG_P2P_FREQUENCY = "p2p_frequency";
|
||||
private static final int STATE_UNLINKED = 0;
|
||||
private static final int STATE_OUTPUT = 1;
|
||||
private static final int STATE_INPUT = 2;
|
||||
public static final String TAG_P2P_STATE = "p2p_state";
|
||||
public static final String TAG_P2P_FREQUENCY = "p2p_frequency";
|
||||
|
||||
/**
|
||||
* Adds state to the tooltip
|
||||
*
|
||||
* @param part part with state
|
||||
* @param currentToolTip to be added to tooltip
|
||||
* @param accessor wrapper for various information
|
||||
* @param config config settings
|
||||
*
|
||||
* @return modified tooltip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
if( part instanceof PartP2PTunnel )
|
||||
{
|
||||
NBTTagCompound nbtData = accessor.getNBTData();
|
||||
if( nbtData.hasKey( TAG_P2P_STATE ) )
|
||||
{
|
||||
int[] stateArr = nbtData.getIntArray( TAG_P2P_STATE );
|
||||
if( stateArr.length == 2 )
|
||||
{
|
||||
int state = stateArr[0];
|
||||
int outputs = stateArr[1];
|
||||
/**
|
||||
* Adds state to the tooltip
|
||||
*
|
||||
* @param part part with state
|
||||
* @param currentToolTip to be added to tooltip
|
||||
* @param accessor wrapper for various information
|
||||
* @param config config settings
|
||||
* @return modified tooltip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody(final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
if (part instanceof PartP2PTunnel) {
|
||||
NBTTagCompound nbtData = accessor.getNBTData();
|
||||
if (nbtData.hasKey(TAG_P2P_STATE)) {
|
||||
int[] stateArr = nbtData.getIntArray(TAG_P2P_STATE);
|
||||
if (stateArr.length == 2) {
|
||||
int state = stateArr[0];
|
||||
int outputs = stateArr[1];
|
||||
|
||||
switch( state )
|
||||
{
|
||||
case STATE_UNLINKED:
|
||||
currentToolTip.add( WailaText.P2PUnlinked.getLocal() );
|
||||
break;
|
||||
case STATE_OUTPUT:
|
||||
currentToolTip.add( WailaText.P2POutput.getLocal() );
|
||||
break;
|
||||
case STATE_INPUT:
|
||||
currentToolTip.add( getOutputText( outputs ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (state) {
|
||||
case STATE_UNLINKED:
|
||||
currentToolTip.add(WailaText.P2PUnlinked.getLocal());
|
||||
break;
|
||||
case STATE_OUTPUT:
|
||||
currentToolTip.add(WailaText.P2POutput.getLocal());
|
||||
break;
|
||||
case STATE_INPUT:
|
||||
currentToolTip.add(getOutputText(outputs));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final short freq = nbtData.getShort( TAG_P2P_FREQUENCY );
|
||||
final String freqTooltip = Platform.p2p().toHexString( freq );
|
||||
currentToolTip.add( I18n.translateToLocalFormatted( "gui.tooltips.appliedenergistics2.P2PFrequency", freqTooltip ) );
|
||||
}
|
||||
}
|
||||
final short freq = nbtData.getShort(TAG_P2P_FREQUENCY);
|
||||
final String freqTooltip = Platform.p2p().toHexString(freq);
|
||||
currentToolTip.add(I18n.translateToLocalFormatted("gui.tooltips.appliedenergistics2.P2PFrequency", freqTooltip));
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData( EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos )
|
||||
{
|
||||
if( part instanceof PartP2PTunnel )
|
||||
{
|
||||
final PartP2PTunnel tunnel = (PartP2PTunnel) part;
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
|
||||
if (part instanceof PartP2PTunnel) {
|
||||
final PartP2PTunnel tunnel = (PartP2PTunnel) part;
|
||||
|
||||
if( !tunnel.isPowered() )
|
||||
{
|
||||
return tag;
|
||||
}
|
||||
if (!tunnel.isPowered()) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
// Frquency
|
||||
final short frequency = tunnel.getFrequency();
|
||||
tag.setShort( TAG_P2P_FREQUENCY, frequency );
|
||||
// Frquency
|
||||
final short frequency = tunnel.getFrequency();
|
||||
tag.setShort(TAG_P2P_FREQUENCY, frequency);
|
||||
|
||||
// The default state
|
||||
int state = STATE_UNLINKED;
|
||||
int outputCount = getOutputCount( tunnel );
|
||||
int inputCount = getInputCount( tunnel );
|
||||
// The default state
|
||||
int state = STATE_UNLINKED;
|
||||
int outputCount = getOutputCount(tunnel);
|
||||
int inputCount = getInputCount(tunnel);
|
||||
|
||||
if( !tunnel.isOutput() )
|
||||
{
|
||||
if( outputCount > 0 )
|
||||
{
|
||||
// Only set it to INPUT if we know there are any outputs
|
||||
state = STATE_INPUT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( inputCount > 0 )
|
||||
{
|
||||
state = STATE_OUTPUT;
|
||||
}
|
||||
}
|
||||
if (!tunnel.isOutput()) {
|
||||
if (outputCount > 0) {
|
||||
// Only set it to INPUT if we know there are any outputs
|
||||
state = STATE_INPUT;
|
||||
}
|
||||
} else {
|
||||
if (inputCount > 0) {
|
||||
state = STATE_OUTPUT;
|
||||
}
|
||||
}
|
||||
|
||||
tag.setIntArray( TAG_P2P_STATE, new int[] {
|
||||
state,
|
||||
outputCount
|
||||
} );
|
||||
tag.setIntArray(TAG_P2P_STATE, new int[]{
|
||||
state,
|
||||
outputCount
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
private static int getOutputCount( PartP2PTunnel tunnel )
|
||||
{
|
||||
try
|
||||
{
|
||||
return Iterators.size( tunnel.getOutputs().iterator() );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// Well... unknown size it is!
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
private static int getOutputCount(PartP2PTunnel tunnel) {
|
||||
try {
|
||||
return Iterators.size(tunnel.getOutputs().iterator());
|
||||
} catch (GridAccessException e) {
|
||||
// Well... unknown size it is!
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static int getInputCount( PartP2PTunnel tunnel )
|
||||
{
|
||||
try
|
||||
{
|
||||
return Iterators.size( tunnel.getInputs().iterator() );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// Well... unknown size it is!
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
private static int getInputCount(PartP2PTunnel tunnel) {
|
||||
try {
|
||||
return Iterators.size(tunnel.getInputs().iterator());
|
||||
} catch (GridAccessException e) {
|
||||
// Well... unknown size it is!
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getOutputText( int outputs )
|
||||
{
|
||||
if( outputs <= 1 )
|
||||
{
|
||||
return WailaText.P2P_INPUT_ONE_OUTPUT.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.format( WailaText.P2P_INPUT_MANY_OUTPUTS.getLocal(), outputs );
|
||||
}
|
||||
}
|
||||
private static String getOutputText(int outputs) {
|
||||
if (outputs <= 1) {
|
||||
return WailaText.P2P_INPUT_ONE_OUTPUT.getLocal();
|
||||
} else {
|
||||
return String.format(WailaText.P2P_INPUT_MANY_OUTPUTS.getLocal(), outputs);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getInputText( int inputs )
|
||||
{
|
||||
if( inputs <= 1 )
|
||||
{
|
||||
return WailaText.P2P_OUTPUT_ONE_INPUT.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.format( WailaText.P2P_OUTPUT_MANY_INPUTS.getLocal(), inputs );
|
||||
}
|
||||
}
|
||||
private static String getInputText(int inputs) {
|
||||
if (inputs <= 1) {
|
||||
return WailaText.P2P_OUTPUT_ONE_INPUT.getLocal();
|
||||
} else {
|
||||
return String.format(WailaText.P2P_OUTPUT_MANY_INPUTS.getLocal(), inputs);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,16 +19,15 @@
|
||||
package appeng.integration.modules.waila.part;
|
||||
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
/**
|
||||
@@ -38,34 +37,29 @@ import appeng.api.parts.SelectedPart;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class PartAccessor
|
||||
{
|
||||
/**
|
||||
* Hits a {@link IPartHost} with {@link BlockPos}.
|
||||
* <p/>
|
||||
* You can derive the looked at {@link IPart} by doing that. If a facade is being looked at, it is
|
||||
* defined as being absent.
|
||||
*
|
||||
* @param te being looked at {@link TileEntity}
|
||||
* @param mop type of ray-trace
|
||||
*
|
||||
* @return maybe the looked at {@link IPart}
|
||||
*/
|
||||
public Optional<IPart> getMaybePart( final TileEntity te, final RayTraceResult mop )
|
||||
{
|
||||
if( te instanceof IPartHost )
|
||||
{
|
||||
BlockPos pos = mop.getBlockPos();
|
||||
final Vec3d position = mop.hitVec.addVector( -pos.getX(), -pos.getY(), -pos.getZ() );
|
||||
final IPartHost host = (IPartHost) te;
|
||||
final SelectedPart sp = host.selectPart( position );
|
||||
public final class PartAccessor {
|
||||
/**
|
||||
* Hits a {@link IPartHost} with {@link BlockPos}.
|
||||
* <p/>
|
||||
* You can derive the looked at {@link IPart} by doing that. If a facade is being looked at, it is
|
||||
* defined as being absent.
|
||||
*
|
||||
* @param te being looked at {@link TileEntity}
|
||||
* @param mop type of ray-trace
|
||||
* @return maybe the looked at {@link IPart}
|
||||
*/
|
||||
public Optional<IPart> getMaybePart(final TileEntity te, final RayTraceResult mop) {
|
||||
if (te instanceof IPartHost) {
|
||||
BlockPos pos = mop.getBlockPos();
|
||||
final Vec3d position = mop.hitVec.addVector(-pos.getX(), -pos.getY(), -pos.getZ());
|
||||
final IPartHost host = (IPartHost) te;
|
||||
final SelectedPart sp = host.selectPart(position);
|
||||
|
||||
if( sp.part != null )
|
||||
{
|
||||
return Optional.of( sp.part );
|
||||
}
|
||||
}
|
||||
if (sp.part != null) {
|
||||
return Optional.of(sp.part);
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
+8
-12
@@ -19,12 +19,10 @@
|
||||
package appeng.integration.modules.waila.part;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.PartItemStack;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
/**
|
||||
@@ -34,14 +32,12 @@ import appeng.api.parts.PartItemStack;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public class PartStackWailaDataProvider extends BasePartWailaDataProvider
|
||||
{
|
||||
public class PartStackWailaDataProvider extends BasePartWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack( final IPart part, final IWailaConfigHandler config, ItemStack partStack )
|
||||
{
|
||||
partStack = part.getItemStack( PartItemStack.PICK );
|
||||
return partStack;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getWailaStack(final IPart part, final IWailaConfigHandler config, ItemStack partStack) {
|
||||
partStack = part.getItemStack(PartItemStack.PICK);
|
||||
return partStack;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+40
-52
@@ -19,14 +19,13 @@
|
||||
package appeng.integration.modules.waila.part;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.core.localization.WailaText;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -36,56 +35,45 @@ import appeng.core.localization.WailaText;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class PowerStateWailaDataProvider extends BasePartWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* Adds state to the tooltip
|
||||
*
|
||||
* @param part part with state
|
||||
* @param currentToolTip to be added to tooltip
|
||||
* @param accessor wrapper for various information
|
||||
* @param config config settings
|
||||
*
|
||||
* @return modified tooltip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
if( part instanceof IPowerChannelState )
|
||||
{
|
||||
final IPowerChannelState state = (IPowerChannelState) part;
|
||||
public final class PowerStateWailaDataProvider extends BasePartWailaDataProvider {
|
||||
/**
|
||||
* Adds state to the tooltip
|
||||
*
|
||||
* @param part part with state
|
||||
* @param currentToolTip to be added to tooltip
|
||||
* @param accessor wrapper for various information
|
||||
* @param config config settings
|
||||
* @return modified tooltip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody(final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
if (part instanceof IPowerChannelState) {
|
||||
final IPowerChannelState state = (IPowerChannelState) part;
|
||||
|
||||
currentToolTip.add( this.getToolTip( state.isActive(), state.isPowered() ) );
|
||||
}
|
||||
currentToolTip.add(this.getToolTip(state.isActive(), state.isPowered()));
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the corresponding tool tip for different values of {@code #isActive} and {@code #isPowered}
|
||||
*
|
||||
* @param isActive if part is active
|
||||
* @param isPowered if part is powered
|
||||
*
|
||||
* @return tooltip of the state
|
||||
*/
|
||||
private String getToolTip( final boolean isActive, final boolean isPowered )
|
||||
{
|
||||
final String result;
|
||||
/**
|
||||
* Gets the corresponding tool tip for different values of {@code #isActive} and {@code #isPowered}
|
||||
*
|
||||
* @param isActive if part is active
|
||||
* @param isPowered if part is powered
|
||||
* @return tooltip of the state
|
||||
*/
|
||||
private String getToolTip(final boolean isActive, final boolean isPowered) {
|
||||
final String result;
|
||||
|
||||
if( isActive && isPowered )
|
||||
{
|
||||
result = WailaText.DeviceOnline.getLocal();
|
||||
}
|
||||
else if( isPowered )
|
||||
{
|
||||
result = WailaText.DeviceMissingChannel.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = WailaText.DeviceOffline.getLocal();
|
||||
}
|
||||
if (isActive && isPowered) {
|
||||
result = WailaText.DeviceOnline.getLocal();
|
||||
} else if (isPowered) {
|
||||
result = WailaText.DeviceMissingChannel.getLocal();
|
||||
} else {
|
||||
result = WailaText.DeviceOffline.getLocal();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
+33
-41
@@ -19,17 +19,16 @@
|
||||
package appeng.integration.modules.waila.part;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.implementations.parts.IPartStorageMonitor;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.core.localization.WailaText;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -39,44 +38,37 @@ import appeng.core.localization.WailaText;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class StorageMonitorWailaDataProvider extends BasePartWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* Displays the stack if present and if the monitor is locked.
|
||||
* Can handle fluids and items.
|
||||
*
|
||||
* @param part maybe storage monitor
|
||||
* @param currentToolTip to be written to tooltip
|
||||
* @param accessor information wrapper
|
||||
* @param config config option
|
||||
*
|
||||
* @return modified tooltip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
if( part instanceof IPartStorageMonitor )
|
||||
{
|
||||
final IPartStorageMonitor monitor = (IPartStorageMonitor) part;
|
||||
public final class StorageMonitorWailaDataProvider extends BasePartWailaDataProvider {
|
||||
/**
|
||||
* Displays the stack if present and if the monitor is locked.
|
||||
* Can handle fluids and items.
|
||||
*
|
||||
* @param part maybe storage monitor
|
||||
* @param currentToolTip to be written to tooltip
|
||||
* @param accessor information wrapper
|
||||
* @param config config option
|
||||
* @return modified tooltip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody(final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
if (part instanceof IPartStorageMonitor) {
|
||||
final IPartStorageMonitor monitor = (IPartStorageMonitor) part;
|
||||
|
||||
final IAEStack<?> displayed = monitor.getDisplayed();
|
||||
final boolean isLocked = monitor.isLocked();
|
||||
final IAEStack<?> displayed = monitor.getDisplayed();
|
||||
final boolean isLocked = monitor.isLocked();
|
||||
|
||||
// TODO: generalize
|
||||
if( displayed instanceof IAEItemStack )
|
||||
{
|
||||
final IAEItemStack ais = (IAEItemStack) displayed;
|
||||
currentToolTip.add( WailaText.Showing.getLocal() + ": " + ais.asItemStackRepresentation().getDisplayName() );
|
||||
}
|
||||
else if( displayed instanceof IAEFluidStack )
|
||||
{
|
||||
final IAEFluidStack ais = (IAEFluidStack) displayed;
|
||||
currentToolTip.add( WailaText.Showing.getLocal() + ": " + ais.getFluid().getLocalizedName( ais.getFluidStack() ) );
|
||||
}
|
||||
// TODO: generalize
|
||||
if (displayed instanceof IAEItemStack) {
|
||||
final IAEItemStack ais = (IAEItemStack) displayed;
|
||||
currentToolTip.add(WailaText.Showing.getLocal() + ": " + ais.asItemStackRepresentation().getDisplayName());
|
||||
} else if (displayed instanceof IAEFluidStack) {
|
||||
final IAEFluidStack ais = (IAEFluidStack) displayed;
|
||||
currentToolTip.add(WailaText.Showing.getLocal() + ": " + ais.getFluid().getLocalizedName(ais.getFluidStack()));
|
||||
}
|
||||
|
||||
currentToolTip.add( ( isLocked ) ? WailaText.Locked.getLocal() : WailaText.Unlocked.getLocal() );
|
||||
}
|
||||
currentToolTip.add((isLocked) ? WailaText.Locked.getLocal() : WailaText.Unlocked.getLocal());
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,66 +35,55 @@ import net.minecraft.world.World;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class Tracer
|
||||
{
|
||||
/**
|
||||
* Trace view of players to blocks.
|
||||
* Ignore all which are out of reach.
|
||||
*
|
||||
* @param world word of block
|
||||
* @param player player viewing block
|
||||
* @param pos pos of block
|
||||
*
|
||||
* @return trace movement. Can be null
|
||||
*/
|
||||
public RayTraceResult retraceBlock( final World world, final EntityPlayerMP player, BlockPos pos )
|
||||
{
|
||||
IBlockState blockState = world.getBlockState( pos );
|
||||
public final class Tracer {
|
||||
/**
|
||||
* Trace view of players to blocks.
|
||||
* Ignore all which are out of reach.
|
||||
*
|
||||
* @param world word of block
|
||||
* @param player player viewing block
|
||||
* @param pos pos of block
|
||||
* @return trace movement. Can be null
|
||||
*/
|
||||
public RayTraceResult retraceBlock(final World world, final EntityPlayerMP player, BlockPos pos) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
|
||||
final Vec3d headVec = this.getCorrectedHeadVec( player );
|
||||
final Vec3d lookVec = player.getLook( 1.0F );
|
||||
final double reach = this.getBlockReachDistance_server( player );
|
||||
final Vec3d endVec = headVec.addVector( lookVec.x * reach, lookVec.y * reach, lookVec.z * reach );
|
||||
final Vec3d headVec = this.getCorrectedHeadVec(player);
|
||||
final Vec3d lookVec = player.getLook(1.0F);
|
||||
final double reach = this.getBlockReachDistance_server(player);
|
||||
final Vec3d endVec = headVec.addVector(lookVec.x * reach, lookVec.y * reach, lookVec.z * reach);
|
||||
|
||||
return blockState.collisionRayTrace( world, pos, headVec, endVec );
|
||||
}
|
||||
return blockState.collisionRayTrace(world, pos, headVec, endVec);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the view point of a player
|
||||
*
|
||||
* @param player player with head
|
||||
*
|
||||
* @return view point of player
|
||||
*/
|
||||
private Vec3d getCorrectedHeadVec( final EntityPlayer player )
|
||||
{
|
||||
double x = player.posX;
|
||||
double y = player.posY;
|
||||
double z = player.posZ;
|
||||
/**
|
||||
* Gets the view point of a player
|
||||
*
|
||||
* @param player player with head
|
||||
* @return view point of player
|
||||
*/
|
||||
private Vec3d getCorrectedHeadVec(final EntityPlayer player) {
|
||||
double x = player.posX;
|
||||
double y = player.posY;
|
||||
double z = player.posZ;
|
||||
|
||||
if( player.world.isRemote )
|
||||
{
|
||||
// compatibility with eye height changing mods
|
||||
y += player.getEyeHeight() - player.getDefaultEyeHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
y += player.getEyeHeight();
|
||||
if( player instanceof EntityPlayerMP && player.isSneaking() )
|
||||
{
|
||||
y -= 0.08;
|
||||
}
|
||||
}
|
||||
return new Vec3d( x, y, z );
|
||||
}
|
||||
if (player.world.isRemote) {
|
||||
// compatibility with eye height changing mods
|
||||
y += player.getEyeHeight() - player.getDefaultEyeHeight();
|
||||
} else {
|
||||
y += player.getEyeHeight();
|
||||
if (player instanceof EntityPlayerMP && player.isSneaking()) {
|
||||
y -= 0.08;
|
||||
}
|
||||
}
|
||||
return new Vec3d(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player multi-player player
|
||||
*
|
||||
* @return block reach distance of player
|
||||
*/
|
||||
private double getBlockReachDistance_server( final EntityPlayerMP player )
|
||||
{
|
||||
return player.interactionManager.getBlockReachDistance();
|
||||
}
|
||||
/**
|
||||
* @param player multi-player player
|
||||
* @return block reach distance of player
|
||||
*/
|
||||
private double getBlockReachDistance_server(final EntityPlayerMP player) {
|
||||
return player.interactionManager.getBlockReachDistance();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,11 @@
|
||||
package appeng.integration.modules.waila.tile;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.integration.modules.waila.BaseWailaDataProvider;
|
||||
import appeng.tile.misc.TileCharger;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -30,12 +31,8 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.integration.modules.waila.BaseWailaDataProvider;
|
||||
import appeng.tile.misc.TileCharger;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -45,40 +42,35 @@ import appeng.tile.misc.TileCharger;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class ChargerWailaDataProvider extends BaseWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* Displays the holding item and its tooltip
|
||||
*
|
||||
* @param itemStack stack of charger
|
||||
* @param currentToolTip unmodified tooltip
|
||||
* @param accessor wrapper information
|
||||
* @param config config option
|
||||
*
|
||||
* @return modified tooltip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody( @Nonnull final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
if( te instanceof TileCharger )
|
||||
{
|
||||
final TileCharger charger = (TileCharger) te;
|
||||
final IItemHandler chargerInventory = charger.getInternalInventory();
|
||||
final ItemStack chargingItem = chargerInventory.getStackInSlot( 0 );
|
||||
public final class ChargerWailaDataProvider extends BaseWailaDataProvider {
|
||||
/**
|
||||
* Displays the holding item and its tooltip
|
||||
*
|
||||
* @param itemStack stack of charger
|
||||
* @param currentToolTip unmodified tooltip
|
||||
* @param accessor wrapper information
|
||||
* @param config config option
|
||||
* @return modified tooltip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody(@Nonnull final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
if (te instanceof TileCharger) {
|
||||
final TileCharger charger = (TileCharger) te;
|
||||
final IItemHandler chargerInventory = charger.getInternalInventory();
|
||||
final ItemStack chargingItem = chargerInventory.getStackInSlot(0);
|
||||
|
||||
if( !chargingItem.isEmpty() )
|
||||
{
|
||||
final String currentInventory = chargingItem.getDisplayName();
|
||||
final EntityPlayer player = accessor.getPlayer();
|
||||
if (!chargingItem.isEmpty()) {
|
||||
final String currentInventory = chargingItem.getDisplayName();
|
||||
final EntityPlayer player = accessor.getPlayer();
|
||||
|
||||
currentToolTip.add( WailaText.Contains + ": " + currentInventory );
|
||||
ITooltipFlag.TooltipFlags tooltipFlag = Minecraft
|
||||
.getMinecraft().gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL;
|
||||
chargingItem.getItem().addInformation( chargingItem, player.world, currentToolTip, tooltipFlag );
|
||||
}
|
||||
}
|
||||
currentToolTip.add(WailaText.Contains + ": " + currentInventory);
|
||||
ITooltipFlag.TooltipFlags tooltipFlag = Minecraft
|
||||
.getMinecraft().gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL;
|
||||
chargingItem.getItem().addInformation(chargingItem, player.world, currentToolTip, tooltipFlag);
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
}
|
||||
|
||||
+29
-36
@@ -19,18 +19,16 @@
|
||||
package appeng.integration.modules.waila.tile;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.integration.modules.waila.BaseWailaDataProvider;
|
||||
import appeng.tile.crafting.TileCraftingMonitorTile;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -40,35 +38,30 @@ import appeng.tile.crafting.TileCraftingMonitorTile;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class CraftingMonitorWailaDataProvider extends BaseWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* Displays the item currently crafted by the CPU cluster
|
||||
*
|
||||
* @param itemStack stack of crafting monitor
|
||||
* @param currentToolTip unmodified tooltip
|
||||
* @param accessor information wrapper
|
||||
* @param config config option
|
||||
*
|
||||
* @return modified tooltip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
if( te instanceof TileCraftingMonitorTile )
|
||||
{
|
||||
final TileCraftingMonitorTile monitor = (TileCraftingMonitorTile) te;
|
||||
final IAEItemStack displayStack = monitor.getJobProgress();
|
||||
public final class CraftingMonitorWailaDataProvider extends BaseWailaDataProvider {
|
||||
/**
|
||||
* Displays the item currently crafted by the CPU cluster
|
||||
*
|
||||
* @param itemStack stack of crafting monitor
|
||||
* @param currentToolTip unmodified tooltip
|
||||
* @param accessor information wrapper
|
||||
* @param config config option
|
||||
* @return modified tooltip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody(final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
if (te instanceof TileCraftingMonitorTile) {
|
||||
final TileCraftingMonitorTile monitor = (TileCraftingMonitorTile) te;
|
||||
final IAEItemStack displayStack = monitor.getJobProgress();
|
||||
|
||||
if( displayStack != null )
|
||||
{
|
||||
final String currentCrafting = displayStack.asItemStackRepresentation().getDisplayName();
|
||||
if (displayStack != null) {
|
||||
final String currentCrafting = displayStack.asItemStackRepresentation().getDisplayName();
|
||||
|
||||
currentToolTip.add( WailaText.Crafting.getLocal() + ": " + currentCrafting );
|
||||
}
|
||||
}
|
||||
currentToolTip.add(WailaText.Crafting.getLocal() + ": " + currentCrafting);
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
}
|
||||
|
||||
+33
-44
@@ -19,17 +19,15 @@
|
||||
package appeng.integration.modules.waila.tile;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.integration.modules.waila.BaseWailaDataProvider;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -39,44 +37,35 @@ import appeng.integration.modules.waila.BaseWailaDataProvider;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class PowerStateWailaDataProvider extends BaseWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* Adds state to the tooltip
|
||||
*
|
||||
* @param itemStack stack of power state
|
||||
* @param currentToolTip to be added to tooltip
|
||||
* @param accessor wrapper for various information
|
||||
* @param config config settings
|
||||
*
|
||||
* @return modified tooltip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
public final class PowerStateWailaDataProvider extends BaseWailaDataProvider {
|
||||
/**
|
||||
* Adds state to the tooltip
|
||||
*
|
||||
* @param itemStack stack of power state
|
||||
* @param currentToolTip to be added to tooltip
|
||||
* @param accessor wrapper for various information
|
||||
* @param config config settings
|
||||
* @return modified tooltip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody(final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
|
||||
if( te instanceof IPowerChannelState )
|
||||
{
|
||||
final IPowerChannelState state = (IPowerChannelState) te;
|
||||
if (te instanceof IPowerChannelState) {
|
||||
final IPowerChannelState state = (IPowerChannelState) te;
|
||||
|
||||
final boolean isActive = state.isActive();
|
||||
final boolean isPowered = state.isPowered();
|
||||
final boolean isActive = state.isActive();
|
||||
final boolean isPowered = state.isPowered();
|
||||
|
||||
if( isActive && isPowered )
|
||||
{
|
||||
currentToolTip.add( WailaText.DeviceOnline.getLocal() );
|
||||
}
|
||||
else if( isPowered )
|
||||
{
|
||||
currentToolTip.add( WailaText.DeviceMissingChannel.getLocal() );
|
||||
}
|
||||
else
|
||||
{
|
||||
currentToolTip.add( WailaText.DeviceOffline.getLocal() );
|
||||
}
|
||||
}
|
||||
if (isActive && isPowered) {
|
||||
currentToolTip.add(WailaText.DeviceOnline.getLocal());
|
||||
} else if (isPowered) {
|
||||
currentToolTip.add(WailaText.DeviceMissingChannel.getLocal());
|
||||
} else {
|
||||
currentToolTip.add(WailaText.DeviceOffline.getLocal());
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
}
|
||||
+101
-120
@@ -19,8 +19,15 @@
|
||||
package appeng.integration.modules.waila.tile;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.networking.energy.IAEPowerStorage;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.integration.modules.waila.BaseWailaDataProvider;
|
||||
import appeng.util.Platform;
|
||||
import it.unimi.dsi.fastutil.objects.Object2LongMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
|
||||
import mcp.mobius.waila.api.ITaggedList;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -28,16 +35,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2LongMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
|
||||
import mcp.mobius.waila.api.ITaggedList;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.networking.energy.IAEPowerStorage;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.integration.modules.waila.BaseWailaDataProvider;
|
||||
import appeng.util.Platform;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -47,128 +45,111 @@ import appeng.util.Platform;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class PowerStorageWailaDataProvider extends BaseWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* Power key used for the transferred {@link net.minecraft.nbt.NBTTagCompound}
|
||||
*/
|
||||
private static final String ID_CURRENT_POWER = "currentPower";
|
||||
public final class PowerStorageWailaDataProvider extends BaseWailaDataProvider {
|
||||
/**
|
||||
* Power key used for the transferred {@link net.minecraft.nbt.NBTTagCompound}
|
||||
*/
|
||||
private static final String ID_CURRENT_POWER = "currentPower";
|
||||
|
||||
/**
|
||||
* Used cache for power if the power was not transmitted through the server.
|
||||
* <p/>
|
||||
* This is useful, when a player just started to look at a tile and thus just requested the new information from the
|
||||
* server.
|
||||
* <p/>
|
||||
* The cache will be updated from the server.
|
||||
*/
|
||||
private final Object2LongMap<TileEntity> cache = new Object2LongOpenHashMap<>();
|
||||
/**
|
||||
* Used cache for power if the power was not transmitted through the server.
|
||||
* <p/>
|
||||
* This is useful, when a player just started to look at a tile and thus just requested the new information from the
|
||||
* server.
|
||||
* <p/>
|
||||
* The cache will be updated from the server.
|
||||
*/
|
||||
private final Object2LongMap<TileEntity> cache = new Object2LongOpenHashMap<>();
|
||||
|
||||
/**
|
||||
* Adds the current and max power to the tool tip
|
||||
* Will ignore if the tile has an energy buffer ( > 0 )
|
||||
*
|
||||
* @param itemStack stack of power storage
|
||||
* @param currentToolTip current tool tip
|
||||
* @param accessor wrapper for various world information
|
||||
* @param config config to react to various settings
|
||||
*
|
||||
* @return modified tool tip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
// Removes RF tooltip on WAILA 1.5.9+
|
||||
( (ITaggedList<String, String>) currentToolTip ).removeEntries( "RFEnergyStorage" );
|
||||
/**
|
||||
* Adds the current and max power to the tool tip
|
||||
* Will ignore if the tile has an energy buffer ( > 0 )
|
||||
*
|
||||
* @param itemStack stack of power storage
|
||||
* @param currentToolTip current tool tip
|
||||
* @param accessor wrapper for various world information
|
||||
* @param config config to react to various settings
|
||||
* @return modified tool tip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody(final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
// Removes RF tooltip on WAILA 1.5.9+
|
||||
((ITaggedList<String, String>) currentToolTip).removeEntries("RFEnergyStorage");
|
||||
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
if( te instanceof IAEPowerStorage )
|
||||
{
|
||||
final IAEPowerStorage storage = (IAEPowerStorage) te;
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
if (te instanceof IAEPowerStorage) {
|
||||
final IAEPowerStorage storage = (IAEPowerStorage) te;
|
||||
|
||||
final double maxPower = storage.getAEMaxPower();
|
||||
if( maxPower > 0 )
|
||||
{
|
||||
final NBTTagCompound tag = accessor.getNBTData();
|
||||
final double maxPower = storage.getAEMaxPower();
|
||||
if (maxPower > 0) {
|
||||
final NBTTagCompound tag = accessor.getNBTData();
|
||||
|
||||
final long internalCurrentPower = this.getInternalCurrentPower( tag, te );
|
||||
final long internalCurrentPower = this.getInternalCurrentPower(tag, te);
|
||||
|
||||
if( internalCurrentPower >= 0 )
|
||||
{
|
||||
final long internalMaxPower = (long) ( 100 * maxPower );
|
||||
if (internalCurrentPower >= 0) {
|
||||
final long internalMaxPower = (long) (100 * maxPower);
|
||||
|
||||
final String formatCurrentPower = Platform.formatPowerLong( internalCurrentPower, false );
|
||||
final String formatMaxPower = Platform.formatPowerLong( internalMaxPower, false );
|
||||
final String formatCurrentPower = Platform.formatPowerLong(internalCurrentPower, false);
|
||||
final String formatMaxPower = Platform.formatPowerLong(internalMaxPower, false);
|
||||
|
||||
currentToolTip.add( WailaText.Contains.getLocal() + ": " + formatCurrentPower + " / " + formatMaxPower );
|
||||
}
|
||||
}
|
||||
}
|
||||
currentToolTip.add(WailaText.Contains.getLocal() + ": " + formatCurrentPower + " / " + formatMaxPower);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on server to transfer information from server to client.
|
||||
* <p/>
|
||||
* If the {@link net.minecraft.tileentity.TileEntity} is a {@link appeng.api.networking.energy.IAEPowerStorage}, it
|
||||
* writes the power information to the {@code #tag} using the {@code #ID_CURRENT_POWER} key.
|
||||
*
|
||||
* @param player player looking at the power storage
|
||||
* @param te power storage
|
||||
* @param tag transferred tag which is send to the client
|
||||
* @param world world of the power storage
|
||||
* @param pos pos of the power storage
|
||||
*
|
||||
* @return tag send to the client
|
||||
*/
|
||||
@Override
|
||||
public NBTTagCompound getNBTData( EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos )
|
||||
{
|
||||
if( te instanceof IAEPowerStorage )
|
||||
{
|
||||
final IAEPowerStorage storage = (IAEPowerStorage) te;
|
||||
/**
|
||||
* Called on server to transfer information from server to client.
|
||||
* <p/>
|
||||
* If the {@link net.minecraft.tileentity.TileEntity} is a {@link appeng.api.networking.energy.IAEPowerStorage}, it
|
||||
* writes the power information to the {@code #tag} using the {@code #ID_CURRENT_POWER} key.
|
||||
*
|
||||
* @param player player looking at the power storage
|
||||
* @param te power storage
|
||||
* @param tag transferred tag which is send to the client
|
||||
* @param world world of the power storage
|
||||
* @param pos pos of the power storage
|
||||
* @return tag send to the client
|
||||
*/
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
|
||||
if (te instanceof IAEPowerStorage) {
|
||||
final IAEPowerStorage storage = (IAEPowerStorage) te;
|
||||
|
||||
if( storage.getAEMaxPower() > 0 )
|
||||
{
|
||||
final long internalCurrentPower = (long) ( 100 * storage.getAECurrentPower() );
|
||||
if (storage.getAEMaxPower() > 0) {
|
||||
final long internalCurrentPower = (long) (100 * storage.getAECurrentPower());
|
||||
|
||||
tag.setLong( ID_CURRENT_POWER, internalCurrentPower );
|
||||
}
|
||||
}
|
||||
tag.setLong(ID_CURRENT_POWER, internalCurrentPower);
|
||||
}
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the current power.
|
||||
* <p/>
|
||||
* If the client received power information on the server, they are used, else if the cache contains a previous
|
||||
* stored value, this will be used. Default value is 0.
|
||||
*
|
||||
* @param te te to be looked at
|
||||
* @param tag tag maybe containing the channel information
|
||||
*
|
||||
* @return used channels on the cable
|
||||
*/
|
||||
private long getInternalCurrentPower( final NBTTagCompound tag, final TileEntity te )
|
||||
{
|
||||
final long internalCurrentPower;
|
||||
/**
|
||||
* Determines the current power.
|
||||
* <p/>
|
||||
* If the client received power information on the server, they are used, else if the cache contains a previous
|
||||
* stored value, this will be used. Default value is 0.
|
||||
*
|
||||
* @param te te to be looked at
|
||||
* @param tag tag maybe containing the channel information
|
||||
* @return used channels on the cable
|
||||
*/
|
||||
private long getInternalCurrentPower(final NBTTagCompound tag, final TileEntity te) {
|
||||
final long internalCurrentPower;
|
||||
|
||||
if( tag.hasKey( ID_CURRENT_POWER ) )
|
||||
{
|
||||
internalCurrentPower = tag.getLong( ID_CURRENT_POWER );
|
||||
this.cache.put( te, internalCurrentPower );
|
||||
}
|
||||
else if( this.cache.containsKey( te ) )
|
||||
{
|
||||
internalCurrentPower = this.cache.get( te );
|
||||
}
|
||||
else
|
||||
{
|
||||
internalCurrentPower = -1;
|
||||
}
|
||||
if (tag.hasKey(ID_CURRENT_POWER)) {
|
||||
internalCurrentPower = tag.getLong(ID_CURRENT_POWER);
|
||||
this.cache.put(te, internalCurrentPower);
|
||||
} else if (this.cache.containsKey(te)) {
|
||||
internalCurrentPower = this.cache.get(te);
|
||||
} else {
|
||||
internalCurrentPower = -1;
|
||||
}
|
||||
|
||||
return internalCurrentPower;
|
||||
}
|
||||
return internalCurrentPower;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user