1.15 port
This commit is contained in:
@@ -28,7 +28,7 @@ import java.util.List;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -77,7 +77,7 @@ public class PartP2PFluids extends PartP2PTunnel<PartP2PFluids> implements IFlui
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
|
||||
public void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor )
|
||||
{
|
||||
this.cachedTank = null;
|
||||
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
/*
|
||||
* 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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import ic2.api.energy.prefab.BasicSinkSource;
|
||||
import ic2.api.energy.tile.IEnergyAcceptor;
|
||||
import ic2.api.energy.tile.IEnergyEmitter;
|
||||
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.cache.helpers.TunnelCollection;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power>
|
||||
{
|
||||
|
||||
private static final String TAG_BUFFERED_ENERGY_1 = "bufferedEnergy1";
|
||||
private static final String TAG_BUFFERED_ENERGY_2 = "bufferedEnergy2";
|
||||
private static final String TAG_BUFFERED_VOLTAGE_1 = "outputPacket1";
|
||||
private static final String TAG_BUFFERED_VOLTAGE_2 = "outputPacket2";
|
||||
|
||||
private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_ic2" );
|
||||
|
||||
// Buffer the energy + voltage for two IC2 ENET packets
|
||||
private double bufferedEnergy1;
|
||||
private double bufferedVoltage1;
|
||||
private double bufferedEnergy2;
|
||||
private double bufferedVoltage2;
|
||||
|
||||
private BasicSinkSource sinkSource;
|
||||
|
||||
public PartP2PIC2Power( ItemStack is )
|
||||
{
|
||||
super( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound tag )
|
||||
{
|
||||
super.readFromNBT( tag );
|
||||
this.bufferedEnergy1 = tag.getDouble( TAG_BUFFERED_ENERGY_1 );
|
||||
this.bufferedEnergy2 = tag.getDouble( TAG_BUFFERED_ENERGY_2 );
|
||||
this.bufferedVoltage1 = tag.getDouble( TAG_BUFFERED_VOLTAGE_1 );
|
||||
this.bufferedVoltage2 = tag.getDouble( TAG_BUFFERED_VOLTAGE_2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound tag )
|
||||
{
|
||||
super.writeToNBT( tag );
|
||||
tag.setDouble( TAG_BUFFERED_ENERGY_1, this.bufferedEnergy1 );
|
||||
tag.setDouble( TAG_BUFFERED_ENERGY_2, this.bufferedEnergy2 );
|
||||
tag.setDouble( TAG_BUFFERED_VOLTAGE_1, this.bufferedVoltage1 );
|
||||
tag.setDouble( TAG_BUFFERED_VOLTAGE_2, this.bufferedVoltage2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTunnelConfigChange()
|
||||
{
|
||||
this.updateSinkSource();
|
||||
this.getHost().partChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTunnelNetworkChange()
|
||||
{
|
||||
this.updateSinkSource();
|
||||
this.getHost().notifyNeighbors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFromWorld()
|
||||
{
|
||||
super.removeFromWorld();
|
||||
this.invalidateSinkSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToWorld()
|
||||
{
|
||||
super.addToWorld();
|
||||
this.updateSinkSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartModel getStaticModels()
|
||||
{
|
||||
return MODELS.getModel( this.isPowered(), this.isActive() );
|
||||
}
|
||||
|
||||
@PartModels
|
||||
public static List<IPartModel> getModels()
|
||||
{
|
||||
return MODELS.getModels();
|
||||
}
|
||||
|
||||
private void updateSinkSource()
|
||||
{
|
||||
if( this.sinkSource == null )
|
||||
{
|
||||
this.sinkSource = new SinkSource( this.getHost().getTile().getWorld(), this.getHost().getLocation().getPos(), 2048, 4, 4 );
|
||||
}
|
||||
|
||||
this.sinkSource.update();
|
||||
}
|
||||
|
||||
private void invalidateSinkSource()
|
||||
{
|
||||
if( this.sinkSource != null )
|
||||
{
|
||||
this.sinkSource.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private class SinkSource extends BasicSinkSource
|
||||
{
|
||||
|
||||
SinkSource( World world, BlockPos pos, int i, int j, int k )
|
||||
{
|
||||
super( world, pos, i, j, k );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean emitsEnergyTo( IEnergyAcceptor receiver, EnumFacing side )
|
||||
{
|
||||
return PartP2PIC2Power.this.isOutput() && side == PartP2PIC2Power.this.getSide().getFacing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom( IEnergyEmitter emitter, EnumFacing side )
|
||||
{
|
||||
return !PartP2PIC2Power.this.isOutput() && side == PartP2PIC2Power.this.getSide().getFacing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDemandedEnergy()
|
||||
{
|
||||
if( PartP2PIC2Power.this.isOutput() )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
for( PartP2PIC2Power t : PartP2PIC2Power.this.getOutputs() )
|
||||
{
|
||||
if( t.bufferedEnergy1 <= 0.0001 || t.bufferedEnergy2 <= 0.0001 )
|
||||
{
|
||||
return 2048;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergy( EnumFacing directionFrom, double amount, double voltage )
|
||||
{
|
||||
TunnelCollection<PartP2PIC2Power> outs;
|
||||
try
|
||||
{
|
||||
outs = PartP2PIC2Power.this.getOutputs();
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
|
||||
if( outs.isEmpty() )
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
|
||||
List<PartP2PIC2Power> options = new ArrayList<>();
|
||||
for( PartP2PIC2Power o : outs )
|
||||
{
|
||||
if( o.bufferedEnergy1 <= 0.01 )
|
||||
{
|
||||
options.add( o );
|
||||
}
|
||||
}
|
||||
|
||||
if( options.isEmpty() )
|
||||
{
|
||||
for( PartP2PIC2Power o : outs )
|
||||
{
|
||||
if( o.bufferedEnergy2 <= 0.01 )
|
||||
{
|
||||
options.add( o );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( options.isEmpty() )
|
||||
{
|
||||
for( PartP2PIC2Power o : outs )
|
||||
{
|
||||
options.add( o );
|
||||
}
|
||||
}
|
||||
|
||||
if( options.isEmpty() )
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
|
||||
PartP2PIC2Power x = Platform.pickRandom( options );
|
||||
|
||||
if( x != null && x.bufferedEnergy1 <= 0.001 )
|
||||
{
|
||||
PartP2PIC2Power.this.queueTunnelDrain( PowerUnits.EU, amount );
|
||||
x.bufferedEnergy1 = amount;
|
||||
x.bufferedVoltage1 = voltage;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( x != null && x.bufferedEnergy2 <= 0.001 )
|
||||
{
|
||||
PartP2PIC2Power.this.queueTunnelDrain( PowerUnits.EU, amount );
|
||||
x.bufferedEnergy2 = amount;
|
||||
x.bufferedVoltage2 = voltage;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getOfferedEnergy()
|
||||
{
|
||||
if( PartP2PIC2Power.this.isOutput() )
|
||||
{
|
||||
return PartP2PIC2Power.this.bufferedEnergy1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawEnergy( double amount )
|
||||
{
|
||||
PartP2PIC2Power.this.bufferedEnergy1 -= amount;
|
||||
if( PartP2PIC2Power.this.bufferedEnergy1 < 0.001 )
|
||||
{
|
||||
PartP2PIC2Power.this.bufferedEnergy1 = PartP2PIC2Power.this.bufferedEnergy2;
|
||||
PartP2PIC2Power.this.bufferedEnergy2 = 0;
|
||||
|
||||
PartP2PIC2Power.this.bufferedVoltage1 = PartP2PIC2Power.this.bufferedVoltage2;
|
||||
PartP2PIC2Power.this.bufferedVoltage2 = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,9 +24,9 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -71,7 +71,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IItemHa
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
|
||||
public void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor )
|
||||
{
|
||||
this.cachedInv = null;
|
||||
final PartP2PItems input = this.getInput();
|
||||
@@ -129,7 +129,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IItemHa
|
||||
this.partVisited = true;
|
||||
if( this.getProxy().isActive() )
|
||||
{
|
||||
final EnumFacing facing = this.getSide().getFacing();
|
||||
final Direction facing = this.getSide().getFacing();
|
||||
final TileEntity te = this.getTile().getWorld().getTileEntity( this.getTile().getPos().offset( facing ) );
|
||||
|
||||
if( te != null && te.hasCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite() ) )
|
||||
|
||||
@@ -25,10 +25,10 @@ import java.util.List;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.networking.IGridNode;
|
||||
@@ -108,7 +108,7 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
|
||||
final TileEntity te = this.getTile();
|
||||
final World w = te.getWorld();
|
||||
|
||||
final int newLevel = w.getLightFromNeighbors( te.getPos().offset( this.getSide().getFacing() ) );
|
||||
final int newLevel = w.getLight( te.getPos().offset( this.getSide().getFacing() ) );
|
||||
|
||||
if( this.lastValue != newLevel && this.getProxy().isActive() )
|
||||
{
|
||||
@@ -130,7 +130,7 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
|
||||
public void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor )
|
||||
{
|
||||
if( this.isOutput() && pos.offset( this.getSide().getFacing() ).equals( neighbor ) )
|
||||
{
|
||||
@@ -165,24 +165,24 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
|
||||
if( this.opacity < 0 )
|
||||
{
|
||||
final TileEntity te = this.getTile();
|
||||
this.opacity = 255 - te.getWorld().getBlockLightOpacity( te.getPos().offset( this.getSide().getFacing() ) );
|
||||
this.opacity = 255 - te.getWorld().getLight( te.getPos().offset( this.getSide().getFacing() ) );
|
||||
}
|
||||
|
||||
return (int) ( emit * ( this.opacity / 255.0f ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound tag )
|
||||
public void readFromNBT( final CompoundNBT tag )
|
||||
{
|
||||
super.readFromNBT( tag );
|
||||
this.lastValue = tag.getInteger( "lastValue" );
|
||||
this.lastValue = tag.getInt( "lastValue" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( final NBTTagCompound tag )
|
||||
public void writeToNBT( final CompoundNBT tag )
|
||||
{
|
||||
super.writeToNBT( tag );
|
||||
tag.setInteger( "lastValue", this.lastValue );
|
||||
tag.putInt( "lastValue", this.lastValue );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,194 +0,0 @@
|
||||
/*
|
||||
* 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.Nullable;
|
||||
//
|
||||
// import net.minecraft.item.ItemStack;
|
||||
// import net.minecraft.nbt.NBTTagCompound;
|
||||
// import net.minecraft.util.IIcon;
|
||||
// import net.minecraftforge.common.util.ForgeDirection;
|
||||
//
|
||||
// import cpw.mods.fml.relauncher.Side;
|
||||
// import cpw.mods.fml.relauncher.SideOnly;
|
||||
//
|
||||
// import li.cil.oc.api.API;
|
||||
// import li.cil.oc.api.Items;
|
||||
// import li.cil.oc.api.Network;
|
||||
// import li.cil.oc.api.network.Environment;
|
||||
// import li.cil.oc.api.network.Message;
|
||||
// import li.cil.oc.api.network.Node;
|
||||
// import li.cil.oc.api.network.SidedEnvironment;
|
||||
// import li.cil.oc.api.network.Visibility;
|
||||
//
|
||||
// import appeng.api.networking.events.MENetworkBootingStatusChange;
|
||||
// import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
// import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
// import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
// import appeng.integration.IntegrationRegistry;
|
||||
// import appeng.integration.IntegrationType;
|
||||
// import appeng.coremod.annotations.Integration.Interface;
|
||||
// import appeng.coremod.annotations.Integration.InterfaceList;
|
||||
//
|
||||
//
|
||||
// @InterfaceList( value = { @Interface( iface = "li.cil.oc.api.network.Environment", iname =
|
||||
// IntegrationType.OpenComputers ), @Interface( iface = "li.cil.oc.api.network.SidedEnvironment", iname =
|
||||
// IntegrationType.OpenComputers ) } )
|
||||
// public final class PartP2POpenComputers extends PartP2PTunnel<PartP2POpenComputers> implements Environment,
|
||||
// SidedEnvironment
|
||||
// {
|
||||
// @Nullable
|
||||
// private final Node node;
|
||||
//
|
||||
// public PartP2POpenComputers( final ItemStack is )
|
||||
// {
|
||||
// super( is );
|
||||
//
|
||||
// if( !IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.OpenComputers ) )
|
||||
// {
|
||||
// throw new RuntimeException( "OpenComputers is not installed!" );
|
||||
// }
|
||||
//
|
||||
// // Avoid NPE when called in pre-init phase (part population).
|
||||
// if( API.network != null )
|
||||
// {
|
||||
// this.node = Network.newNode( this, Visibility.None ).create();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// this.node = null; // to satisfy final
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @MENetworkEventSubscribe
|
||||
// public void changeStateA( final MENetworkBootingStatusChange bs )
|
||||
// {
|
||||
// this.updateConnections();
|
||||
// }
|
||||
//
|
||||
// @MENetworkEventSubscribe
|
||||
// public void changeStateB( final MENetworkChannelsChanged bs )
|
||||
// {
|
||||
// this.updateConnections();
|
||||
// }
|
||||
//
|
||||
// @MENetworkEventSubscribe
|
||||
// public void changeStateC( final MENetworkPowerStatusChange bs )
|
||||
// {
|
||||
// this.updateConnections();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @SideOnly( Side.CLIENT )
|
||||
// public IIcon getTypeTexture()
|
||||
// {
|
||||
// return Items.get( "adapter" ).block().getBlockTextureFromSide( 2 );
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void removeFromWorld()
|
||||
// {
|
||||
// super.removeFromWorld();
|
||||
// if( this.node != null )
|
||||
// {
|
||||
// this.node.remove();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onTunnelNetworkChange()
|
||||
// {
|
||||
// this.updateConnections();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void readFromNBT( final NBTTagCompound data )
|
||||
// {
|
||||
// super.readFromNBT( data );
|
||||
// if( this.node != null )
|
||||
// {
|
||||
// this.node.load( data );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void writeToNBT( final NBTTagCompound data )
|
||||
// {
|
||||
// super.writeToNBT( data );
|
||||
// if( this.node != null )
|
||||
// {
|
||||
// this.node.save( data );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void updateConnections()
|
||||
// {
|
||||
// if( this.getProxy().isPowered() && this.getProxy().isActive() )
|
||||
// {
|
||||
// // Make sure we're connected to existing OC nodes in the world.
|
||||
// Network.joinOrCreateNetwork( this.getTile() );
|
||||
//
|
||||
// if( this.isOutput() && this.getInput() != null && this.node != null )
|
||||
// {
|
||||
// Network.joinOrCreateNetwork( this.getInput().getTile() );
|
||||
// this.node.connect( this.getInput().node() );
|
||||
// }
|
||||
// }
|
||||
// else if( this.node != null )
|
||||
// {
|
||||
// this.node.remove();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Nullable
|
||||
// @Override
|
||||
// public Node node()
|
||||
// {
|
||||
// return this.node;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onConnect( final Node node )
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onDisconnect( final Node node )
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onMessage( final Message message )
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// @Nullable
|
||||
// @Override
|
||||
// public Node sidedNode( final ForgeDirection side )
|
||||
// {
|
||||
// return side == this.getSide() ? this.node : null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean canConnect( final ForgeDirection side )
|
||||
// {
|
||||
// return side == this.getSide();
|
||||
// }
|
||||
// }
|
||||
@@ -22,13 +22,13 @@ package appeng.parts.p2p;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRedstoneWire;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.RedstoneWireBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.networking.events.MENetworkBootingStatusChange;
|
||||
@@ -105,7 +105,7 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
|
||||
Platform.notifyBlocksOfNeighbors( world, this.getTile().getPos() );
|
||||
|
||||
// and this cause sometimes it can go thought walls.
|
||||
for( final EnumFacing face : EnumFacing.VALUES )
|
||||
for( final Direction face : Direction.values() )
|
||||
{
|
||||
Platform.notifyBlocksOfNeighbors( world, this.getTile().getPos().offset( face ) );
|
||||
}
|
||||
@@ -124,17 +124,17 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound tag )
|
||||
public void readFromNBT( final CompoundNBT tag )
|
||||
{
|
||||
super.readFromNBT( tag );
|
||||
this.power = tag.getInteger( "power" );
|
||||
this.power = tag.getInt( "power" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( final NBTTagCompound tag )
|
||||
public void writeToNBT( final CompoundNBT tag )
|
||||
{
|
||||
super.writeToNBT( tag );
|
||||
tag.setInteger( "power", this.power );
|
||||
tag.putInt( "power", this.power );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -149,20 +149,20 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
|
||||
public void onNeighborChanged( IBlockReader w, BlockPos pos, BlockPos neighbor )
|
||||
{
|
||||
if( !this.isOutput() )
|
||||
{
|
||||
final BlockPos target = this.getTile().getPos().offset( this.getSide().getFacing() );
|
||||
|
||||
final IBlockState state = this.getTile().getWorld().getBlockState( target );
|
||||
final BlockState state = this.getTile().getWorld().getBlockState( target );
|
||||
final Block b = state.getBlock();
|
||||
if( b != null && !this.isOutput() )
|
||||
{
|
||||
EnumFacing srcSide = this.getSide().getFacing();
|
||||
if( b instanceof BlockRedstoneWire )
|
||||
Direction srcSide = this.getSide().getFacing();
|
||||
if( b instanceof RedstoneWireBlock )
|
||||
{
|
||||
srcSide = EnumFacing.UP;
|
||||
srcSide = Direction.UP;
|
||||
}
|
||||
|
||||
this.power = b.getWeakPower( state, this.getTile().getWorld(), target, srcSide );
|
||||
|
||||
@@ -26,10 +26,10 @@ import java.util.Optional;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -134,7 +134,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
public void readFromNBT( final CompoundNBT data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.setOutput( data.getBoolean( "output" ) );
|
||||
@@ -142,11 +142,11 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( final NBTTagCompound data )
|
||||
public void writeToNBT( final CompoundNBT data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setBoolean( "output", this.isOutput() );
|
||||
data.setShort( "freq", this.getFrequency() );
|
||||
data.putBoolean( "output", this.isOutput() );
|
||||
data.putShort( "freq", this.getFrequency() );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -178,14 +178,14 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
|
||||
public boolean onPartActivate( final PlayerEntity player, final Hand hand, final Vec3d pos )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( hand == EnumHand.OFF_HAND )
|
||||
if( hand == Hand.OFF_HAND )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -199,9 +199,9 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
if( !is.isEmpty() && is.getItem() instanceof IMemoryCard )
|
||||
{
|
||||
final IMemoryCard mc = (IMemoryCard) is.getItem();
|
||||
final NBTTagCompound data = mc.getData( is );
|
||||
final CompoundNBT data = mc.getData( is );
|
||||
|
||||
final ItemStack newType = new ItemStack( data );
|
||||
final ItemStack newType = ItemStack.read( data );
|
||||
final short freq = data.getShort( "freq" );
|
||||
|
||||
if( !newType.isEmpty() )
|
||||
@@ -325,7 +325,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartShiftActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
|
||||
public boolean onPartShiftActivate( final PlayerEntity player, final Hand hand, final Vec3d pos )
|
||||
{
|
||||
final ItemStack is = player.inventory.getCurrentItem();
|
||||
if( !is.isEmpty() && is.getItem() instanceof IMemoryCard )
|
||||
@@ -336,7 +336,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
}
|
||||
|
||||
final IMemoryCard mc = (IMemoryCard) is.getItem();
|
||||
final NBTTagCompound data = mc.getData( is );
|
||||
final CompoundNBT data = mc.getData( is );
|
||||
final short storedFrequency = data.getShort( "freq" );
|
||||
|
||||
short newFreq = this.getFrequency();
|
||||
@@ -362,10 +362,10 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
this.onTunnelConfigChange();
|
||||
|
||||
final ItemStack p2pItem = this.getItemStack( PartItemStack.WRENCH );
|
||||
final String type = p2pItem.getUnlocalizedName();
|
||||
final String type = p2pItem.getTranslationKey();
|
||||
|
||||
p2pItem.writeToNBT( data );
|
||||
data.setShort( "freq", this.getFrequency() );
|
||||
p2pItem.write( data );
|
||||
data.putShort( "freq", this.getFrequency() );
|
||||
|
||||
final AEColor[] colors = Platform.p2p().toColors( this.getFrequency() );
|
||||
final int[] colorCode = new int[] {
|
||||
@@ -373,7 +373,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
colors[2].ordinal(), colors[2].ordinal(), colors[3].ordinal(), colors[3].ordinal(),
|
||||
};
|
||||
|
||||
data.setIntArray( "colorCode", colorCode );
|
||||
data.putIntArray( "colorCode", colorCode );
|
||||
|
||||
mc.setMemoryCardContents( is, type + ".name", data );
|
||||
if( needsNewFrequency )
|
||||
|
||||
@@ -24,11 +24,11 @@ import java.util.EnumSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.Hand;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.exceptions.FailedConnectionException;
|
||||
@@ -73,14 +73,14 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound extra )
|
||||
public void readFromNBT( final CompoundNBT extra )
|
||||
{
|
||||
super.readFromNBT( extra );
|
||||
this.outerProxy.readFromNBT( extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( final NBTTagCompound extra )
|
||||
public void writeToNBT( final CompoundNBT extra )
|
||||
{
|
||||
super.writeToNBT( extra );
|
||||
this.outerProxy.writeToNBT( extra );
|
||||
@@ -137,7 +137,7 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlacement( final EntityPlayer player, final EnumHand hand, final ItemStack held, final AEPartLocation side )
|
||||
public void onPlacement( final PlayerEntity player, final Hand hand, final ItemStack held, final AEPartLocation side )
|
||||
{
|
||||
super.onPlacement( player, hand, held, side );
|
||||
this.outerProxy.setOwner( player );
|
||||
|
||||
Reference in New Issue
Block a user