Closes #1726: Added Pressure P2P tunnel (PneumaticCraft)

This commit is contained in:
yueh
2015-08-05 17:00:35 +02:00
committed by thatsIch
parent 6488119318
commit b0504f4141
15 changed files with 352 additions and 12 deletions
@@ -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
@@ -97,6 +97,7 @@ public enum AEFeature
P2PTunnelLiquids( "P2PTunnels" ),
P2PTunnelLight( "P2PTunnels" ),
P2PTunnelOpenComputers( "P2PTunnels" ),
P2PTunnelPressure( "P2PTunnels" ),
MassCannonBlockDamage( "BlockFeatures" ),
TinyTNTBlockDamage( "BlockFeatures" ),
@@ -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,
@@ -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;
@@ -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;
@@ -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 <http://www.gnu.org/licenses/lgpl>.
*/
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 );
}
}
}
@@ -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 );
@@ -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 <http://www.gnu.org/licenses/lgpl>.
*/
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;
}
}
@@ -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 <http://www.gnu.org/licenses/lgpl>.
*/
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<PartP2PPressure> 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 );
// }
// }
//
//}
@@ -347,6 +347,14 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
newType = stack;
}
break;
case PRESSURE:
for( ItemStack stack : parts.p2PTunnelPneumaticCraft().maybeStack( 1 ).asSet() )
{
newType = stack;
}
break;
*/
default: