Merge pull request #1543 from thatsIch/f-1541-td-attunements
Closes #1541: Implements Thermal Dynamics attunements
This commit is contained in:
commit
b0348fb888
3 changed files with 61 additions and 41 deletions
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* The MIT License (MIT)
|
* The MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2013 AlgorithmX2
|
* Copyright (c) 2013 - 2015 AlgorithmX2
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
@ -24,6 +24,8 @@
|
||||||
package appeng.api.features;
|
package appeng.api.features;
|
||||||
|
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import appeng.api.config.TunnelType;
|
import appeng.api.config.TunnelType;
|
||||||
|
@ -39,10 +41,10 @@ public interface IP2PTunnelRegistry
|
||||||
* Allows third parties to register items from their mod as potential
|
* Allows third parties to register items from their mod as potential
|
||||||
* attunements for AE's P2P Tunnels
|
* attunements for AE's P2P Tunnels
|
||||||
*
|
*
|
||||||
* @param trigger - the item which triggers attunement
|
* @param trigger - the item which triggers attunement. Nullable, but then ignored
|
||||||
* @param type - the type of tunnel
|
* @param type - the type of tunnel. Nullable, but then ignored
|
||||||
*/
|
*/
|
||||||
void addNewAttunement( ItemStack trigger, TunnelType type );
|
void addNewAttunement( @Nullable ItemStack trigger, @Nullable TunnelType type );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns null if no attunement can be found.
|
* returns null if no attunement can be found.
|
||||||
|
@ -51,5 +53,6 @@ public interface IP2PTunnelRegistry
|
||||||
*
|
*
|
||||||
* @return null if no attunement can be found or attunement
|
* @return null if no attunement can be found or attunement
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
TunnelType getTunnelTypeByItem( ItemStack trigger );
|
TunnelType getTunnelTypeByItem( ItemStack trigger );
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of Applied Energistics 2.
|
* This file is part of Applied Energistics 2.
|
||||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||||
*
|
*
|
||||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
@ -20,6 +20,8 @@ package appeng.core.features.registries;
|
||||||
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
|
@ -40,10 +42,11 @@ import appeng.api.util.AEColor;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
|
||||||
|
|
||||||
public class P2PTunnelRegistry implements IP2PTunnelRegistry
|
public final class P2PTunnelRegistry implements IP2PTunnelRegistry
|
||||||
{
|
{
|
||||||
|
private static final int INITIAL_CAPACITY = 40;
|
||||||
|
|
||||||
final HashMap<ItemStack, TunnelType> Tunnels = new HashMap<ItemStack, TunnelType>();
|
private final Map<ItemStack, TunnelType> tunnels = new HashMap<ItemStack, TunnelType>( INITIAL_CAPACITY );
|
||||||
|
|
||||||
public void configure()
|
public void configure()
|
||||||
{
|
{
|
||||||
|
@ -88,6 +91,7 @@ public class P2PTunnelRegistry implements IP2PTunnelRegistry
|
||||||
this.addNewAttunement( this.getModItem( "ExtraUtilities", "extractor_base", 0 ), TunnelType.ITEM );
|
this.addNewAttunement( this.getModItem( "ExtraUtilities", "extractor_base", 0 ), TunnelType.ITEM );
|
||||||
this.addNewAttunement( this.getModItem( "Mekanism", "PartTransmitter", 9 ), TunnelType.ITEM );
|
this.addNewAttunement( this.getModItem( "Mekanism", "PartTransmitter", 9 ), TunnelType.ITEM );
|
||||||
this.addNewAttunement( this.getModItem( "EnderIO", "itemItemConduit", OreDictionary.WILDCARD_VALUE ), TunnelType.ITEM );
|
this.addNewAttunement( this.getModItem( "EnderIO", "itemItemConduit", OreDictionary.WILDCARD_VALUE ), TunnelType.ITEM );
|
||||||
|
this.addNewAttunement( this.getModItem( "ThermalDynamics", "ThermalDynamics_32", 0 ), TunnelType.ITEM );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* attune based on lots of random item related stuff
|
* attune based on lots of random item related stuff
|
||||||
|
@ -101,6 +105,7 @@ public class P2PTunnelRegistry implements IP2PTunnelRegistry
|
||||||
this.addNewAttunement( this.getModItem( "ExtraUtilities", "extractor_base", 6 ), TunnelType.FLUID );
|
this.addNewAttunement( this.getModItem( "ExtraUtilities", "extractor_base", 6 ), TunnelType.FLUID );
|
||||||
this.addNewAttunement( this.getModItem( "ExtraUtilities", "drum", OreDictionary.WILDCARD_VALUE ), TunnelType.FLUID );
|
this.addNewAttunement( this.getModItem( "ExtraUtilities", "drum", OreDictionary.WILDCARD_VALUE ), TunnelType.FLUID );
|
||||||
this.addNewAttunement( this.getModItem( "EnderIO", "itemLiquidConduit", OreDictionary.WILDCARD_VALUE ), TunnelType.FLUID );
|
this.addNewAttunement( this.getModItem( "EnderIO", "itemLiquidConduit", OreDictionary.WILDCARD_VALUE ), TunnelType.FLUID );
|
||||||
|
this.addNewAttunement( this.getModItem( "ThermalDynamics", "ThermalDynamics_16", 0 ), TunnelType.FLUID );
|
||||||
|
|
||||||
for( AEColor c : AEColor.values() )
|
for( AEColor c : AEColor.values() )
|
||||||
{
|
{
|
||||||
|
@ -112,17 +117,46 @@ public class P2PTunnelRegistry implements IP2PTunnelRegistry
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addNewAttunement( ItemStack trigger, TunnelType type )
|
public void addNewAttunement( @Nullable ItemStack trigger, @Nullable TunnelType type )
|
||||||
{
|
{
|
||||||
if( type == null || trigger == null )
|
if( type == null || trigger == null )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Tunnels.put( trigger, type );
|
this.tunnels.put( trigger, type );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getModItem( String modID, String name, int meta )
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public TunnelType getTunnelTypeByItem( ItemStack trigger )
|
||||||
|
{
|
||||||
|
if( trigger != null )
|
||||||
|
{
|
||||||
|
if( FluidContainerRegistry.isContainer( trigger ) )
|
||||||
|
{
|
||||||
|
return TunnelType.FLUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
for( ItemStack is : this.tunnels.keySet() )
|
||||||
|
{
|
||||||
|
if( is.getItem() == trigger.getItem() && is.getItemDamage() == OreDictionary.WILDCARD_VALUE )
|
||||||
|
{
|
||||||
|
return this.tunnels.get( is );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( Platform.isSameItem( is, trigger ) )
|
||||||
|
{
|
||||||
|
return this.tunnels.get( is );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private ItemStack getModItem( String modID, String name, int meta )
|
||||||
{
|
{
|
||||||
ItemStack myItemStack = GameRegistry.findItemStack( modID, name, 1 );
|
ItemStack myItemStack = GameRegistry.findItemStack( modID, name, 1 );
|
||||||
|
|
||||||
|
@ -142,31 +176,4 @@ public class P2PTunnelRegistry implements IP2PTunnelRegistry
|
||||||
this.addNewAttunement( definitionStack, type );
|
this.addNewAttunement( definitionStack, type );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TunnelType getTunnelTypeByItem( ItemStack trigger )
|
|
||||||
{
|
|
||||||
if( trigger != null )
|
|
||||||
{
|
|
||||||
if( FluidContainerRegistry.isContainer( trigger ) )
|
|
||||||
{
|
|
||||||
return TunnelType.FLUID;
|
|
||||||
}
|
|
||||||
|
|
||||||
for( ItemStack is : this.Tunnels.keySet() )
|
|
||||||
{
|
|
||||||
if( is.getItem() == trigger.getItem() && is.getItemDamage() == OreDictionary.WILDCARD_VALUE )
|
|
||||||
{
|
|
||||||
return this.Tunnels.get( is );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( Platform.isSameItem( is, trigger ) )
|
|
||||||
{
|
|
||||||
return this.Tunnels.get( is );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,13 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
|
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
import appeng.api.config.TunnelType;
|
import appeng.api.config.TunnelType;
|
||||||
|
import appeng.helpers.Reflected;
|
||||||
import appeng.integration.BaseModule;
|
import appeng.integration.BaseModule;
|
||||||
|
|
||||||
|
|
||||||
public class RF extends BaseModule
|
public final class RF extends BaseModule
|
||||||
{
|
{
|
||||||
|
@Reflected
|
||||||
public static RF instance;
|
public static RF instance;
|
||||||
|
|
||||||
public RF()
|
public RF()
|
||||||
|
@ -58,14 +59,23 @@ public class RF extends BaseModule
|
||||||
this.registerRFAttunement( "ThermalExpansion", "Cell", OreDictionary.WILDCARD_VALUE );
|
this.registerRFAttunement( "ThermalExpansion", "Cell", OreDictionary.WILDCARD_VALUE );
|
||||||
this.registerRFAttunement( "ThermalExpansion", "Dynamo", OreDictionary.WILDCARD_VALUE );
|
this.registerRFAttunement( "ThermalExpansion", "Dynamo", OreDictionary.WILDCARD_VALUE );
|
||||||
|
|
||||||
|
// Fluxduct
|
||||||
|
this.registerRFAttunement( "ThermalDynamics", "ThermalDynamics_0", 0 );
|
||||||
|
|
||||||
this.registerRFAttunement( "EnderIO", "itemPowerConduit", OreDictionary.WILDCARD_VALUE );
|
this.registerRFAttunement( "EnderIO", "itemPowerConduit", OreDictionary.WILDCARD_VALUE );
|
||||||
this.registerRFAttunement( "EnderIO", "blockCapacitorBank", 0 );
|
this.registerRFAttunement( "EnderIO", "blockCapacitorBank", 0 );
|
||||||
this.registerRFAttunement( "EnderIO", "blockPowerMonitor", 0 );
|
this.registerRFAttunement( "EnderIO", "blockPowerMonitor", 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerRFAttunement( String mod, String name, int dmg )
|
private void registerRFAttunement( String mod, String name, int dmg )
|
||||||
{
|
{
|
||||||
ItemStack modItem = GameRegistry.findItemStack( mod, name, 1 );
|
assert mod != null;
|
||||||
|
assert !mod.isEmpty();
|
||||||
|
assert name != null;
|
||||||
|
assert !name.isEmpty();
|
||||||
|
assert dmg >= 0;
|
||||||
|
|
||||||
|
final ItemStack modItem = GameRegistry.findItemStack( mod, name, 1 );
|
||||||
if( modItem != null )
|
if( modItem != null )
|
||||||
{
|
{
|
||||||
modItem.setItemDamage( dmg );
|
modItem.setItemDamage( dmg );
|
||||||
|
|
Loading…
Reference in a new issue