From b0504f4141fc190dea4cf0caa80f45f25668a326 Mon Sep 17 00:00:00 2001 From: yueh Date: Wed, 5 Aug 2015 17:00:35 +0200 Subject: [PATCH] Closes #1726: Added Pressure P2P tunnel (PneumaticCraft) --- gradle.properties | 13 +- gradle/scripts/dependencies.gradle | 6 + .../java/appeng/api/config/TunnelType.java | 3 +- .../java/appeng/api/definitions/IParts.java | 2 + .../appeng/core/api/definitions/ApiParts.java | 10 +- .../java/appeng/core/features/AEFeature.java | 1 + .../appeng/core/localization/GuiText.java | 2 +- .../java/appeng/core/settings/TickRates.java | 4 +- .../appeng/integration/IntegrationType.java | 4 +- .../integration/modules/PneumaticCraft.java | 84 +++++++++ .../java/appeng/items/parts/PartType.java | 4 +- .../appeng/parts/layers/LayerPressure.java | 49 +++++ .../appeng/parts/p2p/PartP2PPressure.java | 173 ++++++++++++++++++ .../java/appeng/parts/p2p/PartP2PTunnel.java | 8 + .../appliedenergistics2/lang/en_US.lang | 1 + 15 files changed, 352 insertions(+), 12 deletions(-) create mode 100644 src/main/java/appeng/integration/modules/PneumaticCraft.java create mode 100644 src/main/java/appeng/parts/layers/LayerPressure.java create mode 100644 src/main/java/appeng/parts/p2p/PartP2PPressure.java diff --git a/gradle.properties b/gradle.properties index 75d8d8e2..13da0bba 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,8 +15,8 @@ forge_version=11.14.3.1516 ######################################################### waila_version=1.6.0_B1 jabba_version=1.2.1a -enderstorage_version=1.4.7.33 -translocator_version=1.1.1.14 +enderstorage_version=1.4.7.36 +translocator_version=1.1.2.15 ic2_version=2.2.717 enderio_version=2.3.0.375_beta #cofhlib_version=1.0.1-157 @@ -29,12 +29,13 @@ invtweaks_version=1.59 ######################################################### # Provided APIs # ######################################################### -fmp_version=1.1.1.324 -code_chicken_lib_version=1.1.2.139 -code_chicken_core_version=1.0.5.36 -nei_version=1.0.5.104 +fmp_version=1.2.0.345 +code_chicken_lib_version=1.1.3.138 +code_chicken_core_version=1.0.7.46 +nei_version=1.0.5.111 bc_version=7.0.9 opencomputers_version=1.5.18.39 +pneumaticcraft_version=1.9.15-105 ######################################################### # Self Compiled APIs # diff --git a/gradle/scripts/dependencies.gradle b/gradle/scripts/dependencies.gradle index 3b8a6265..b3835499 100644 --- a/gradle/scripts/dependencies.gradle +++ b/gradle/scripts/dependencies.gradle @@ -56,6 +56,11 @@ repositories { url = "http://maven.cil.li/" } + maven { + name = "MM repo" + url = "http://maven.k-4u.nl/" + } + ivy { name "BuildCraft" artifactPattern "http://www.mod-buildcraft.com/releases/BuildCraft/[revision]/[module]-[revision]-[classifier].[ext]" @@ -109,6 +114,7 @@ dependencies { // compile "codechicken:CodeChickenCore:${minecraft_version}-${code_chicken_core_version}:dev" // compile "codechicken:NotEnoughItems:${minecraft_version}-${nei_version}:dev" // compile "com.mod-buildcraft:buildcraft:${bc_version}:dev" +// compile "pneumaticCraft:PneumaticCraft-${minecraft_version}:${pneumaticcraft_version}:api" // provided APIs // compile "li.cil.oc:OpenComputers:MC${minecraft_version}-${opencomputers_version}:api" diff --git a/src/api/java/appeng/api/config/TunnelType.java b/src/api/java/appeng/api/config/TunnelType.java index b42d2856..77f2a616 100644 --- a/src/api/java/appeng/api/config/TunnelType.java +++ b/src/api/java/appeng/api/config/TunnelType.java @@ -34,5 +34,6 @@ public enum TunnelType ITEM, // Item Tunnel LIGHT, // Light Tunnel BUNDLED_REDSTONE, // Bundled Redstone Tunnel - COMPUTER_MESSAGE // Computer Message Tunnel + COMPUTER_MESSAGE, // Computer Message Tunnel + PRESSURE // PneumaticCraft Tunnel } diff --git a/src/api/java/appeng/api/definitions/IParts.java b/src/api/java/appeng/api/definitions/IParts.java index 08980809..5c7b4adf 100644 --- a/src/api/java/appeng/api/definitions/IParts.java +++ b/src/api/java/appeng/api/definitions/IParts.java @@ -86,6 +86,8 @@ public interface IParts //IItemDefinition p2PTunnelOpenComputers(); +// IItemDefinition p2PTunnelPneumaticCraft(); + IItemDefinition cableAnchor(); IItemDefinition monitor(); diff --git a/src/main/java/appeng/core/api/definitions/ApiParts.java b/src/main/java/appeng/core/api/definitions/ApiParts.java index 2c7c482d..9c69e539 100644 --- a/src/main/java/appeng/core/api/definitions/ApiParts.java +++ b/src/main/java/appeng/core/api/definitions/ApiParts.java @@ -60,7 +60,8 @@ public final class ApiParts implements IParts //private final IItemDefinition p2PTunnelEU; //private final IItemDefinition p2PTunnelRF; private final IItemDefinition p2PTunnelLight; - //private final IItemDefinition p2PTunnelOpenComputers; +// private final IItemDefinition p2PTunnelOpenComputers; +// private final IItemDefinition p2PTunnelPneumaticCraft; private final IItemDefinition cableAnchor; private final IItemDefinition monitor; private final IItemDefinition semiDarkMonitor; @@ -104,6 +105,7 @@ public final class ApiParts implements IParts //this.p2PTunnelRF = new DamagedItemDefinition( itemMultiPart.createPart( PartType.P2PTunnelRF ) ); this.p2PTunnelLight = new DamagedItemDefinition( "part.tunnel.light", itemMultiPart.createPart( PartType.P2PTunnelLight ) ); //this.p2PTunnelOpenComputers = new DamagedItemDefinition( itemMultiPart.createPart( PartType.P2PTunnelOpenComputers ) ); +// this.p2PTunnelPneumaticCraft = new DamagedItemDefinition( itemMultiPart.createPart( PartType.P2PTunnelPressure ) ); this.cableAnchor = new DamagedItemDefinition( "part.cable_anchor", itemMultiPart.createPart( PartType.CableAnchor ) ); this.monitor = new DamagedItemDefinition( "part.monitor", itemMultiPart.createPart( PartType.Monitor ) ); this.semiDarkMonitor = new DamagedItemDefinition( "part.monitor.semi_dark", itemMultiPart.createPart( PartType.SemiDarkMonitor ) ); @@ -284,6 +286,12 @@ public final class ApiParts implements IParts { return this.p2PTunnelOpenComputers; } + + @Override + public IItemDefinition p2PTunnelPneumaticCraft() + { + return this.p2PTunnelPneumaticCraft; + } */ @Override diff --git a/src/main/java/appeng/core/features/AEFeature.java b/src/main/java/appeng/core/features/AEFeature.java index 00811a7f..2df7006c 100644 --- a/src/main/java/appeng/core/features/AEFeature.java +++ b/src/main/java/appeng/core/features/AEFeature.java @@ -97,6 +97,7 @@ public enum AEFeature P2PTunnelLiquids( "P2PTunnels" ), P2PTunnelLight( "P2PTunnels" ), P2PTunnelOpenComputers( "P2PTunnels" ), + P2PTunnelPressure( "P2PTunnels" ), MassCannonBlockDamage( "BlockFeatures" ), TinyTNTBlockDamage( "BlockFeatures" ), diff --git a/src/main/java/appeng/core/localization/GuiText.java b/src/main/java/appeng/core/localization/GuiText.java index b686938e..48bd72b3 100644 --- a/src/main/java/appeng/core/localization/GuiText.java +++ b/src/main/java/appeng/core/localization/GuiText.java @@ -45,7 +45,7 @@ public enum GuiText CraftingTerminal, FormationPlane, Inscriber, QuartzCuttingKnife, // tunnel names - METunnel, ItemTunnel, RedstoneTunnel, EUTunnel, FluidTunnel, OCTunnel, LightTunnel, RFTunnel, + METunnel, ItemTunnel, RedstoneTunnel, EUTunnel, FluidTunnel, OCTunnel, LightTunnel, RFTunnel, PressureTunnel, StoredSize, CopyMode, CopyModeDesc, PatternTerminal, CraftingPattern, diff --git a/src/main/java/appeng/core/settings/TickRates.java b/src/main/java/appeng/core/settings/TickRates.java index 3bb3a9e5..cf19a87a 100644 --- a/src/main/java/appeng/core/settings/TickRates.java +++ b/src/main/java/appeng/core/settings/TickRates.java @@ -47,7 +47,9 @@ public enum TickRates LightTunnel( 5, 120 ), - OpenComputersTunnel( 1, 5 ); + OpenComputersTunnel( 1, 5 ), + + PressureTunnel( 1, 120 ); public int min; public int max; diff --git a/src/main/java/appeng/integration/IntegrationType.java b/src/main/java/appeng/integration/IntegrationType.java index e6d0689a..8214e616 100644 --- a/src/main/java/appeng/integration/IntegrationType.java +++ b/src/main/java/appeng/integration/IntegrationType.java @@ -63,7 +63,9 @@ public enum IntegrationType BetterStorage( IntegrationSide.BOTH, "BetterStorage", "betterstorage" ), - OpenComputers( IntegrationSide.BOTH, "OpenComputers", "OpenComputers" ); + OpenComputers( IntegrationSide.BOTH, "OpenComputers", "OpenComputers" ), + + PneumaticCraft( IntegrationSide.BOTH, "PneumaticCraft", "PneumaticCraft" ); public final IntegrationSide side; public final String dspName; diff --git a/src/main/java/appeng/integration/modules/PneumaticCraft.java b/src/main/java/appeng/integration/modules/PneumaticCraft.java new file mode 100644 index 00000000..18609ef3 --- /dev/null +++ b/src/main/java/appeng/integration/modules/PneumaticCraft.java @@ -0,0 +1,84 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules; + + +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import cpw.mods.fml.common.registry.GameRegistry; + +import appeng.api.AEApi; +import appeng.api.IAppEngApi; +import appeng.api.config.TunnelType; +import appeng.api.features.IP2PTunnelRegistry; +import appeng.api.parts.IPartHelper; +import appeng.helpers.Reflected; +import appeng.integration.BaseModule; +import appeng.integration.IntegrationRegistry; +import appeng.integration.IntegrationType; + + +public class PneumaticCraft extends BaseModule +{ + @Reflected + public static PneumaticCraft instance; + + private static final String PNEUMATIC_CRAFT_MOD_ID = "PneumaticCraft"; + + @Reflected + public PneumaticCraft() + { + this.testClassExistence( pneumaticCraft.api.block.BlockSupplier.class ); + this.testClassExistence( pneumaticCraft.api.tileentity.ISidedPneumaticMachine.class ); + this.testClassExistence( pneumaticCraft.api.tileentity.AirHandlerSupplier.class ); + this.testClassExistence( pneumaticCraft.api.tileentity.IAirHandler.class ); + } + + @Override + public void init() + { + final IAppEngApi api = AEApi.instance(); + final IPartHelper partHelper = api.partHelper(); + + if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.PneumaticCraft ) ) + { + partHelper.registerNewLayer( appeng.parts.layers.LayerPressure.class.getName(), pneumaticCraft.api.tileentity.ISidedPneumaticMachine.class.getName() ); + } + } + + @Override + public void postInit() + { + this.registerPressureAttunement( "pressureTube" ); + this.registerPressureAttunement( "advancedPressureTube" ); + } + + private void registerPressureAttunement( String itemID ) + { + final IP2PTunnelRegistry registry = AEApi.instance().registries().p2pTunnel(); + final ItemStack modItem = GameRegistry.findItemStack( PNEUMATIC_CRAFT_MOD_ID, itemID, 1 ); + + if( modItem != null ) + { + modItem.setItemDamage( OreDictionary.WILDCARD_VALUE ); + registry.addNewAttunement( modItem, TunnelType.PRESSURE ); + } + } +} diff --git a/src/main/java/appeng/items/parts/PartType.java b/src/main/java/appeng/items/parts/PartType.java index 49b18ccb..01c0e99f 100644 --- a/src/main/java/appeng/items/parts/PartType.java +++ b/src/main/java/appeng/items/parts/PartType.java @@ -154,7 +154,9 @@ public enum PartType P2PTunnelLight( 467, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelLight ), EnumSet.noneOf( IntegrationType.class ), PartP2PLight.class, GuiText.LightTunnel ), - //P2PTunnelOpenComputers( 468, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelOpenComputers ), EnumSet.of( IntegrationType.OpenComputers ), PartP2POpenComputers.class, GuiText.OCTunnel ), +// P2PTunnelOpenComputers( 468, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelOpenComputers ), EnumSet.of( IntegrationType.OpenComputers ), PartP2POpenComputers.class, GuiText.OCTunnel ), + +// P2PTunnelPressure( 469, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelPressure ), EnumSet.of( IntegrationType.PneumaticCraft ), PartP2PPressure.class, GuiText.PressureTunnel ), InterfaceTerminal( 480, EnumSet.of( AEFeature.InterfaceTerminal ), EnumSet.noneOf( IntegrationType.class ), PartInterfaceTerminal.class ); diff --git a/src/main/java/appeng/parts/layers/LayerPressure.java b/src/main/java/appeng/parts/layers/LayerPressure.java new file mode 100644 index 00000000..8ef3961b --- /dev/null +++ b/src/main/java/appeng/parts/layers/LayerPressure.java @@ -0,0 +1,49 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.parts.layers; + + +import javax.annotation.Nullable; + +import net.minecraftforge.common.util.ForgeDirection; + +import pneumaticCraft.api.tileentity.IAirHandler; +import pneumaticCraft.api.tileentity.ISidedPneumaticMachine; + +import appeng.api.parts.IPart; +import appeng.api.parts.LayerBase; + + +public class LayerPressure extends LayerBase implements ISidedPneumaticMachine +{ + + @Nullable + @Override + public IAirHandler getAirHandler( ForgeDirection side ) + { + IPart part = this.getPart( side ); + if( part instanceof ISidedPneumaticMachine ) + { + return ( (ISidedPneumaticMachine) part ).getAirHandler( side ); + } + + return null; + } + +} diff --git a/src/main/java/appeng/parts/p2p/PartP2PPressure.java b/src/main/java/appeng/parts/p2p/PartP2PPressure.java new file mode 100644 index 00000000..60be7467 --- /dev/null +++ b/src/main/java/appeng/parts/p2p/PartP2PPressure.java @@ -0,0 +1,173 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.parts.p2p; + + +//import javax.annotation.Nonnull; +//import javax.annotation.Nullable; +// +//import net.minecraft.item.ItemStack; +//import net.minecraft.nbt.NBTTagCompound; +//import net.minecraft.tileentity.TileEntity; +//import net.minecraft.util.IIcon; +//import net.minecraftforge.common.util.ForgeDirection; +// +//import pneumaticCraft.api.block.BlockSupplier; +//import pneumaticCraft.api.tileentity.AirHandlerSupplier; +//import pneumaticCraft.api.tileentity.IAirHandler; +//import pneumaticCraft.api.tileentity.ISidedPneumaticMachine; +// +//import appeng.api.networking.IGridNode; +//import appeng.api.networking.ticking.IGridTickable; +//import appeng.api.networking.ticking.TickRateModulation; +//import appeng.api.networking.ticking.TickingRequest; +//import appeng.core.settings.TickRates; +//import appeng.transformer.annotations.Integration.Interface; +//import appeng.util.Platform; +// +// +//@Interface( iface = "pneumaticCraft.api.tileentity.ISidedPneumaticMachine", iname = "PneumaticCraft" ) +//public final class PartP2PPressure extends PartP2PTunnel implements ISidedPneumaticMachine, IGridTickable +//{ +// private static final String PRESSURE_NBT_TAG = "pneumaticCraft"; +// private static final String PRESSURE_TYPE_ICON_NAME = "compressedIronBlock"; +// +// /** +// * The pressure should never exceed 30f, thus preventing the tunnel from exploding. +// */ +// private static final float MAX_PRESSURE = 30f; +// private static final int VOLUME = 1000; +// +// @Nonnull +// private final IAirHandler handler; +// private boolean isConnected = false; +// +// public PartP2PPressure( ItemStack is ) +// { +// super( is ); +// this.handler = AirHandlerSupplier.getAirHandler( MAX_PRESSURE, MAX_PRESSURE, VOLUME ); +// } +// +// @Override +// protected IIcon getTypeTexture() +// { +// return BlockSupplier.getBlock( PRESSURE_TYPE_ICON_NAME ).getIcon( 0, 0 ); +// } +// +// @Nullable +// @Override +// public IAirHandler getAirHandler( ForgeDirection side ) +// { +// if( side == this.side ) +// { +// return this.getInternalHandler(); +// } +// +// return null; +// } +// +// @Override +// public void onNeighborChanged() +// { +// super.onNeighborChanged(); +// this.getInternalHandler().onNeighborChange(); +// } +// +// @Override +// public void addToWorld() +// { +// super.addToWorld(); +// this.getInternalHandler().validateI( this.getTile() ); +// } +// +// @Override +// public void removeFromWorld() +// { +// super.removeFromWorld(); +// +// if( this.output && this.getInput() != null ) +// { +// this.getInternalHandler().removeConnection( this.getInput().getInternalHandler() ); +// this.isConnected = false; +// } +// } +// +// @Override +// public TickingRequest getTickingRequest( IGridNode node ) +// { +// return new TickingRequest( TickRates.PressureTunnel.min, TickRates.PressureTunnel.max, false, false ); +// } +// +// @Override +// public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall ) +// { +// if( this.proxy.isPowered() && this.proxy.isActive() ) +// { +// if( !this.isConnected ) +// { +// this.updateHandler(); +// } +// +// this.getInternalHandler().updateEntityI(); +// return TickRateModulation.URGENT; +// } +// +// return TickRateModulation.IDLE; +// } +// +// @Override +// public void writeToNBT( NBTTagCompound data ) +// { +// super.writeToNBT( data ); +// final NBTTagCompound pneumaticNBT = new NBTTagCompound(); +// +// this.getInternalHandler().writeToNBTI( pneumaticNBT ); +// data.setTag( PRESSURE_NBT_TAG, pneumaticNBT ); +// } +// +// @Override +// public void readFromNBT( NBTTagCompound data ) +// { +// super.readFromNBT( data ); +// this.getInternalHandler().readFromNBTI( data.getCompoundTag( PRESSURE_NBT_TAG ) ); +// } +// +// @Nonnull +// private IAirHandler getInternalHandler() +// { +// return this.handler; +// } +// +// private void updateHandler() +// { +// if( this.proxy.isPowered() && this.proxy.isActive() ) +// { +// +// if( this.output && this.getInput() != null ) +// { +// this.getInternalHandler().createConnection( this.getInput().getInternalHandler() ); +// this.isConnected = true; +// } +// +// final TileEntity te = this.getTile(); +// Platform.notifyBlocksOfNeighbors( te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord ); +// } +// } +// +//} diff --git a/src/main/java/appeng/parts/p2p/PartP2PTunnel.java b/src/main/java/appeng/parts/p2p/PartP2PTunnel.java index e09c35f3..c204251d 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PTunnel.java +++ b/src/main/java/appeng/parts/p2p/PartP2PTunnel.java @@ -347,6 +347,14 @@ public abstract class PartP2PTunnel extends PartBasicSt newType = stack; } break; + + case PRESSURE: + for( ItemStack stack : parts.p2PTunnelPneumaticCraft().maybeStack( 1 ).asSet() ) + { + newType = stack; + } + break; + */ default: diff --git a/src/main/resources/assets/appliedenergistics2/lang/en_US.lang b/src/main/resources/assets/appliedenergistics2/lang/en_US.lang index 376ed187..c80073b6 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/en_US.lang +++ b/src/main/resources/assets/appliedenergistics2/lang/en_US.lang @@ -102,6 +102,7 @@ gui.appliedenergistics2.EUTunnel=EU gui.appliedenergistics2.RFTunnel=RF gui.appliedenergistics2.LightTunnel=Light gui.appliedenergistics2.OCTunnel=OpenComputers +gui.appliedenergistics2.PressureTunnel=Pressure gui.appliedenergistics2.security.extract.name=Withdraw gui.appliedenergistics2.security.inject.name=Deposit