From eb11845a2f0b2f1c06e3399951f9acdc6a6f115e Mon Sep 17 00:00:00 2001 From: Gunther De Wachter Date: Wed, 12 Jul 2017 06:04:06 +0200 Subject: [PATCH] Fixed applying the type of tunnel for P2P tunnels. This was caused by the enforced lowercase mod id's and item names since 1.11. --- .../api/features/IP2PTunnelRegistry.java | 5 +-- .../registries/P2PTunnelRegistry.java | 32 ++++++++++--------- .../java/appeng/parts/p2p/PartP2PTunnel.java | 2 +- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/api/java/appeng/api/features/IP2PTunnelRegistry.java b/src/api/java/appeng/api/features/IP2PTunnelRegistry.java index 4679422f..97ad0621 100644 --- a/src/api/java/appeng/api/features/IP2PTunnelRegistry.java +++ b/src/api/java/appeng/api/features/IP2PTunnelRegistry.java @@ -26,6 +26,7 @@ package appeng.api.features; import javax.annotation.Nullable; +import com.sun.istack.internal.NotNull; import net.minecraft.item.ItemStack; import appeng.api.config.TunnelType; @@ -44,7 +45,7 @@ public interface IP2PTunnelRegistry * @param trigger - the item which triggers attunement. Nullable, but then ignored * @param type - the type of tunnel. Nullable, but then ignored */ - void addNewAttunement( @Nullable ItemStack trigger, @Nullable TunnelType type ); + void addNewAttunement( @NotNull ItemStack trigger, @Nullable TunnelType type ); /** * returns null if no attunement can be found. @@ -53,6 +54,6 @@ public interface IP2PTunnelRegistry * * @return null if no attunement can be found or attunement */ - @Nullable + @NotNull TunnelType getTunnelTypeByItem( ItemStack trigger ); } \ No newline at end of file diff --git a/src/main/java/appeng/core/features/registries/P2PTunnelRegistry.java b/src/main/java/appeng/core/features/registries/P2PTunnelRegistry.java index 8aae8914..6eed9022 100644 --- a/src/main/java/appeng/core/features/registries/P2PTunnelRegistry.java +++ b/src/main/java/appeng/core/features/registries/P2PTunnelRegistry.java @@ -22,8 +22,10 @@ package appeng.core.features.registries; import java.util.HashMap; import java.util.Map; +import javax.annotation.Nonnull; import javax.annotation.Nullable; +import com.sun.istack.internal.NotNull; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; @@ -69,7 +71,7 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry this.addNewAttunement( new ItemStack( Blocks.REDSTONE_WIRE ), TunnelType.REDSTONE ); this.addNewAttunement( new ItemStack( Blocks.REDSTONE_BLOCK ), TunnelType.REDSTONE ); this.addNewAttunement( new ItemStack( Blocks.LEVER ), TunnelType.REDSTONE ); - this.addNewAttunement( this.getModItem( "EnderIO", "itemRedstoneConduit", OreDictionary.WILDCARD_VALUE ), TunnelType.REDSTONE ); + this.addNewAttunement( this.getModItem( "enderio", "itemredstoneconduit", OreDictionary.WILDCARD_VALUE ), TunnelType.REDSTONE ); /** * attune based on lots of random item related stuff @@ -87,10 +89,10 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry this.addNewAttunement( new ItemStack( Blocks.HOPPER ), TunnelType.ITEM ); this.addNewAttunement( new ItemStack( Blocks.CHEST ), TunnelType.ITEM ); this.addNewAttunement( new ItemStack( Blocks.TRAPPED_CHEST ), 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( "EnderIO", "itemItemConduit", OreDictionary.WILDCARD_VALUE ), TunnelType.ITEM ); - this.addNewAttunement( this.getModItem( "ThermalDynamics", "ThermalDynamics_32", 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( "enderio", "itemitemconduit", OreDictionary.WILDCARD_VALUE ), TunnelType.ITEM ); + this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 0 ), TunnelType.ITEM ); /** * attune based on lots of random item related stuff @@ -99,12 +101,12 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry this.addNewAttunement( new ItemStack( Items.LAVA_BUCKET ), TunnelType.FLUID ); this.addNewAttunement( new ItemStack( Items.MILK_BUCKET ), TunnelType.FLUID ); this.addNewAttunement( new ItemStack( Items.WATER_BUCKET ), TunnelType.FLUID ); - this.addNewAttunement( this.getModItem( "Mekanism", "MachineBlock2", 11 ), TunnelType.FLUID ); - this.addNewAttunement( this.getModItem( "Mekanism", "PartTransmitter", 4 ), 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( "EnderIO", "itemLiquidConduit", OreDictionary.WILDCARD_VALUE ), TunnelType.FLUID ); - this.addNewAttunement( this.getModItem( "ThermalDynamics", "ThermalDynamics_16", 0 ), TunnelType.FLUID ); + this.addNewAttunement( this.getModItem( "mekanism", "machineblock2", 11 ), TunnelType.FLUID ); + this.addNewAttunement( this.getModItem( "mekanism", "parttransmitter", 4 ), 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( "enderio", "itemliquidconduit", OreDictionary.WILDCARD_VALUE ), TunnelType.FLUID ); + this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_16", 0 ), TunnelType.FLUID ); for( final AEColor c : AEColor.values() ) { @@ -116,9 +118,9 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry } @Override - public void addNewAttunement( @Nullable final ItemStack trigger, @Nullable final TunnelType type ) + public void addNewAttunement( @Nonnull final ItemStack trigger, @Nullable final TunnelType type ) { - if( type == null || trigger == null ) + if( type == null || trigger.isEmpty() ) { return; } @@ -130,7 +132,7 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry @Override public TunnelType getTunnelTypeByItem( final ItemStack trigger ) { - if( trigger != null ) + if( !trigger.isEmpty() ) { // if( FluidRegistry.isContainer( trigger ) ) // { @@ -154,7 +156,7 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry return null; } - @Nullable + @NotNull private ItemStack getModItem( final String modID, final String name, final int meta ) { diff --git a/src/main/java/appeng/parts/p2p/PartP2PTunnel.java b/src/main/java/appeng/parts/p2p/PartP2PTunnel.java index fe225b45..4331c825 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PTunnel.java +++ b/src/main/java/appeng/parts/p2p/PartP2PTunnel.java @@ -160,7 +160,7 @@ public abstract class PartP2PTunnel extends PartBasicSt @Override public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos ) { - final ItemStack is = player.inventory.getCurrentItem(); + final ItemStack is = player.getHeldItem( hand ); // UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor( is.getItem() ); // AELog.info( "ID:" + id.toString() + " : " + is.getItemDamage() );