Retexture AE2 machines (#338)
This commit is contained in:
@@ -26,12 +26,15 @@ import appeng.tile.spatial.TileSpatialIOPort;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -39,8 +42,11 @@ import javax.annotation.Nullable;
|
||||
|
||||
public class BlockSpatialIOPort extends AEBaseTileBlock {
|
||||
|
||||
public static final PropertyBool POWERED = PropertyBool.create("powered");
|
||||
|
||||
public BlockSpatialIOPort() {
|
||||
super(Material.IRON);
|
||||
setDefaultState(getDefaultState().withProperty(POWERED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,6 +57,19 @@ public class BlockSpatialIOPort extends AEBaseTileBlock {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
|
||||
TileSpatialIOPort te = this.getTileEntity(worldIn, pos);
|
||||
boolean powered = te != null && te.isActive();
|
||||
return super.getActualState(state, worldIn, pos)
|
||||
.withProperty(POWERED, powered);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IProperty[] getAEStates() {
|
||||
return new IProperty[]{POWERED};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
|
||||
if (p.isSneaking()) {
|
||||
|
||||
@@ -26,12 +26,15 @@ import appeng.tile.storage.TileIOPort;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -39,8 +42,25 @@ import javax.annotation.Nullable;
|
||||
|
||||
public class BlockIOPort extends AEBaseTileBlock {
|
||||
|
||||
public static final PropertyBool POWERED = PropertyBool.create("powered");
|
||||
|
||||
public BlockIOPort() {
|
||||
super(Material.IRON);
|
||||
setDefaultState(getDefaultState().withProperty(POWERED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
|
||||
TileIOPort te = this.getTileEntity(worldIn, pos);
|
||||
boolean powred = te != null && te.isActive();
|
||||
|
||||
return super.getActualState(state, worldIn, pos)
|
||||
.withProperty(POWERED, powred);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IProperty[] getAEStates() {
|
||||
return new IProperty[]{POWERED};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,12 +28,15 @@ import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.events.MENetworkEvent;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.events.MENetworkSpatialEvent;
|
||||
import appeng.api.networking.spatial.ISpatialCache;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.cache.SpatialPylonCache;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
@@ -42,6 +45,7 @@ import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.WrapperFilteredItemHandler;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -49,6 +53,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallable<Void> {
|
||||
@@ -57,10 +62,17 @@ public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallabl
|
||||
private final IItemHandler invExt = new WrapperFilteredItemHandler(this.inv, new SpatialIOFilter());
|
||||
private YesNo lastRedstoneState = YesNo.UNDECIDED;
|
||||
|
||||
private boolean isActive = false;
|
||||
|
||||
public TileSpatialIOPort() {
|
||||
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void onPower(final MENetworkPowerStatusChange ch) {
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(final NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
@@ -76,6 +88,32 @@ public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallabl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean readFromStream(ByteBuf data) throws IOException {
|
||||
boolean c = super.readFromStream(data);
|
||||
|
||||
final boolean oldIsActive = this.isActive;
|
||||
this.isActive = data.readBoolean();
|
||||
return oldIsActive != this.isActive || c;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeToStream(ByteBuf data) throws IOException {
|
||||
super.writeToStream(data);
|
||||
data.writeBoolean(this.isActive());
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
if (Platform.isServer()) {
|
||||
try {
|
||||
return this.getProxy().getEnergy().isNetworkPowered();
|
||||
} catch (final GridAccessException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return this.isActive;
|
||||
}
|
||||
|
||||
public boolean getRedstoneState() {
|
||||
if (this.lastRedstoneState == YesNo.UNDECIDED) {
|
||||
this.updateRedstoneState();
|
||||
|
||||
@@ -25,6 +25,8 @@ import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
@@ -55,6 +57,7 @@ import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.WrapperChainedItemHandler;
|
||||
import appeng.util.inv.WrapperFilteredItemHandler;
|
||||
import appeng.util.inv.filter.AEItemFilters;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -63,6 +66,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -87,6 +91,8 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
private ItemStack currentCell;
|
||||
private Map<IStorageChannel<?>, IMEInventory<?>> cachedInventories;
|
||||
|
||||
private boolean isActive = false;
|
||||
|
||||
public TileIOPort() {
|
||||
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
|
||||
this.manager = new ConfigManager(this);
|
||||
@@ -100,6 +106,11 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
this.upgrades = new BlockUpgradeInventory(ioPortBlock, this, NUMBER_OF_UPGRADE_SLOTS);
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void onPower(final MENetworkPowerStatusChange ch) {
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(final NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
@@ -119,6 +130,32 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean readFromStream(ByteBuf data) throws IOException {
|
||||
boolean c = super.readFromStream(data);
|
||||
|
||||
final boolean oldIsActive = this.isActive;
|
||||
this.isActive = data.readBoolean();
|
||||
return oldIsActive != this.isActive || c;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeToStream(ByteBuf data) throws IOException {
|
||||
super.writeToStream(data);
|
||||
data.writeBoolean(this.isActive());
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
if (Platform.isServer()) {
|
||||
try {
|
||||
return this.getProxy().getEnergy().isNetworkPowered();
|
||||
} catch (GridAccessException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return this.isActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(final AEPartLocation dir) {
|
||||
return AECableType.SMART;
|
||||
|
||||
Reference in New Issue
Block a user