More stuff ingame and showing up.

This commit is contained in:
Sebastian Hartte
2020-06-01 01:01:32 +02:00
parent 6a88728544
commit 077ff17078
864 changed files with 11515 additions and 11761 deletions
+18 -44
View File
@@ -22,17 +22,15 @@ package appeng.tile;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.EmptyHandler;
@@ -45,17 +43,21 @@ import appeng.util.inv.InvOperation;
public abstract class AEBaseInvTile extends AEBaseTile implements IAEAppEngInventory
{
public AEBaseInvTile(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@Override
public void readFromNBT( final CompoundNBT data )
public void read(final CompoundNBT data )
{
super.readFromNBT( data );
super.read( data );
final IItemHandler inv = this.getInternalInventory();
if( inv != EmptyHandler.INSTANCE )
{
final CompoundNBT opt = data.getCompoundTag( "inv" );
final CompoundNBT opt = data.getCompound( "inv" );
for( int x = 0; x < inv.getSlots(); x++ )
{
final CompoundNBT item = opt.getCompoundTag( "item" + x );
final CompoundNBT item = opt.getCompound( "item" + x );
ItemHandlerUtil.setStackInSlot( inv, x, ItemStack.read(item) );
}
}
@@ -64,9 +66,9 @@ public abstract class AEBaseInvTile extends AEBaseTile implements IAEAppEngInven
public abstract @Nonnull IItemHandler getInternalInventory();
@Override
public CompoundNBT writeToNBT( final CompoundNBT data )
public CompoundNBT write(final CompoundNBT data )
{
super.writeToNBT( data );
super.write( data );
final IItemHandler inv = this.getInternalInventory();
if( inv != EmptyHandler.INSTANCE )
{
@@ -79,9 +81,9 @@ public abstract class AEBaseInvTile extends AEBaseTile implements IAEAppEngInven
{
is.write(item);
}
opt.setTag( "item" + x, item );
opt.put( "item" + x, item );
}
data.setTag( "inv", opt );
data.put( "inv", opt );
}
return data;
}
@@ -104,51 +106,23 @@ public abstract class AEBaseInvTile extends AEBaseTile implements IAEAppEngInven
@Override
public abstract void onChangeInventory( IItemHandler inv, int slot, InvOperation mc, ItemStack removed, ItemStack added );
@Override
public ITextComponent getDisplayName()
{
if( this.hasCustomInventoryName() )
{
return new TextComponentString( this.getCustomInventoryName() );
}
return new TextComponentTranslation( this.getBlockType().getTranslationKey() );
}
protected @Nonnull IItemHandler getItemHandlerForSide( @Nonnull Direction side )
{
return this.getInternalInventory();
}
@Nonnull
@Override
public boolean hasCapability( Capability<?> capability, Direction facing )
{
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, Direction facing) {
if( capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY )
{
if( facing == null )
{
return this.getInternalInventory() != EmptyHandler.INSTANCE;
return (LazyOptional<T>) LazyOptional.of(this::getInternalInventory);
}
else
{
return this.getItemHandlerForSide( facing ) != EmptyHandler.INSTANCE;
}
}
return super.hasCapability( capability, facing );
}
@SuppressWarnings( "unchecked" )
@Override
public <T> T getCapability( Capability<T> capability, @Nullable Direction facing )
{
if( capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY )
{
if( facing == null )
{
return (T) this.getInternalInventory();
}
else
{
return (T) this.getItemHandlerForSide( facing );
return (LazyOptional<T>) LazyOptional.of(() -> getItemHandlerForSide( facing ));
}
}
return super.getCapability( capability, facing );
+50 -55
View File
@@ -28,6 +28,7 @@ import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import appeng.core.AELog;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
@@ -36,8 +37,9 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -48,12 +50,8 @@ import appeng.api.util.ICommonTile;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.api.util.IOrientable;
import appeng.core.AELog;
import appeng.core.features.IStackSrc;
import appeng.helpers.ICustomNameObject;
import appeng.helpers.IPriorityHost;
import appeng.hooks.TickHandler;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.Platform;
import appeng.util.SettingsFrom;
@@ -71,10 +69,8 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
private BlockState state;
private boolean markDirtyQueued = false;
@Override
public boolean shouldRefresh( final World world, final BlockPos pos, final BlockState oldState, final BlockState newSate )
{
return newSate.getBlock() != oldState.getBlock(); // state doesn't change tile entities in AE2.
public AEBaseTile(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
public static void registerTileItem( final Class<? extends TileEntity> c, final IStackSrc wat )
@@ -157,13 +153,13 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
}
@Override
public SPacketUpdateTileEntity getUpdatePacket()
public SUpdateTileEntityPacket getUpdatePacket()
{
return new SPacketUpdateTileEntity( this.pos, 64, this.getUpdateTag() );
return new SUpdateTileEntityPacket( this.pos, 64, this.getUpdateTag() );
}
@Override
public void onDataPacket( final NetworkManager net, final SPacketUpdateTileEntity pkt )
public void onDataPacket( final NetworkManager net, final SUpdateTileEntityPacket pkt )
{
// / pkt.actionType
if( pkt.getTileEntityType() == 64 )
@@ -359,7 +355,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
*/
public void uploadSettings( final SettingsFrom from, final CompoundNBT compound )
{
if( compound != null && this instanceof IConfigurableObject )
if( this instanceof IConfigurableObject )
{
final IConfigManager cm = ( (IConfigurableObject) this ).getConfigManager();
if( cm != null )
@@ -367,36 +363,34 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
cm.readFromNBT( compound );
}
}
if( this instanceof IPriorityHost )
{
final IPriorityHost pHost = (IPriorityHost) this;
pHost.setPriority( compound.getInt( "priority" ) );
}
if( this instanceof ISegmentedInventory )
{
final IItemHandler inv = ( (ISegmentedInventory) this ).getInventoryByName( "config" );
if( inv instanceof AppEngInternalAEInventory )
{
final AppEngInternalAEInventory target = (AppEngInternalAEInventory) inv;
final AppEngInternalAEInventory tmp = new AppEngInternalAEInventory( null, target.getSlots() );
tmp.read( compound, "config" );
for( int x = 0; x < tmp.getSlots(); x++ )
{
target.setStackInSlot( x, tmp.getStackInSlot( x ) );
}
}
}
// FIXME
// if( this instanceof IPriorityHost )
// {
// final IPriorityHost pHost = (IPriorityHost) this;
// pHost.setPriority( compound.getInt( "priority" ) );
// }
//
// if( this instanceof ISegmentedInventory )
// {
// final IItemHandler inv = ( (ISegmentedInventory) this ).getInventoryByName( "config" );
// if( inv instanceof AppEngInternalAEInventory )
// {
// final AppEngInternalAEInventory target = (AppEngInternalAEInventory) inv;
// final AppEngInternalAEInventory tmp = new AppEngInternalAEInventory( null, target.getSlots() );
// tmp.readFromNBT( compound, "config" );
// for( int x = 0; x < tmp.getSlots(); x++ )
// {
// target.setStackInSlot( x, tmp.getStackInSlot( x ) );
// }
// }
// }
}
/**
* returns the contents of the tile entity, into the world, defaults to dropping everything in the inventory.
*
* @param w world
* @param x x pos of tile entity
* @param y y pos of tile entity
* @param z z pos of tile entity
* @param pos block position
* @param drops drops of tile entity
*/
@Override
@@ -424,8 +418,8 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
if( this.hasCustomInventoryName() )
{
final CompoundNBT dsp = new CompoundNBT();
dsp.setString( "Name", this.getCustomInventoryName() );
output.setTag( "display", dsp );
dsp.putString( "Name", this.getCustomInventoryName() );
output.put( "display", dsp );
}
if( this instanceof IConfigurableObject )
@@ -437,22 +431,23 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
}
}
if( this instanceof IPriorityHost )
{
final IPriorityHost pHost = (IPriorityHost) this;
output.setInteger( "priority", pHost.getPriority() );
}
// FIXME
// if( this instanceof IPriorityHost )
// {
// final IPriorityHost pHost = (IPriorityHost) this;
// output.putInt( "priority", pHost.getPriority() );
// }
//
// if( this instanceof ISegmentedInventory )
// {
// final IItemHandler inv = ( (ISegmentedInventory) this ).getInventoryByName( "config" );
// if( inv instanceof AppEngInternalAEInventory )
// {
// ( (AppEngInternalAEInventory) inv ).writeToNBT( output, "config" );
// }
// }
if( this instanceof ISegmentedInventory )
{
final IItemHandler inv = ( (ISegmentedInventory) this ).getInventoryByName( "config" );
if( inv instanceof AppEngInternalAEInventory )
{
( (AppEngInternalAEInventory) inv ).writeToNBT( output, "config" );
}
}
return output.hasNoTags() ? null : output;
return output.isEmpty() ? null : output;
}
@Override
@@ -485,7 +480,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
this.world.markChunkDirty( this.pos, this );
if( !this.markDirtyQueued )
{
TickHandler.INSTANCE.addCallable( null, this::markDirtyAtEndOfTick );
// FIXME TickHandler.INSTANCE.addCallable( null, this::markDirtyAtEndOfTick );
this.markDirtyQueued = true;
}
}
@@ -213,9 +213,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
}
@Override
public CompoundNBT writeToNBT( final CompoundNBT data )
public CompoundNBT write(final CompoundNBT data )
{
super.writeToNBT( data );
super.write( data );
if( this.forcePlan && this.myPlan != null )
{
final ItemStack pattern = this.myPlan.getPattern();
@@ -234,9 +234,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
}
@Override
public void readFromNBT( final CompoundNBT data )
public void read(final CompoundNBT data )
{
super.readFromNBT( data );
super.read( data );
if( data.contains("myPlan") )
{
final ItemStack myPat = new ItemStack( data.getCompoundTag( "myPlan" ) );
@@ -35,16 +35,16 @@ public abstract class AENetworkInvTile extends AEBaseInvTile implements IActionH
private final AENetworkProxy gridProxy = new AENetworkProxy( this, "proxy", this.getItemFromTile( this ), true );
@Override
public void readFromNBT( final CompoundNBT data )
public void read(final CompoundNBT data )
{
super.readFromNBT( data );
super.read( data );
this.getProxy().readFromNBT( data );
}
@Override
public CompoundNBT writeToNBT( final CompoundNBT data )
public CompoundNBT write(final CompoundNBT data )
{
super.writeToNBT( data );
super.write( data );
this.getProxy().writeToNBT( data );
return data;
}
@@ -37,16 +37,16 @@ public abstract class AENetworkPowerTile extends AEBasePoweredTile implements IA
private final AENetworkProxy gridProxy = new AENetworkProxy( this, "proxy", this.getItemFromTile( this ), true );
@Override
public void readFromNBT( final CompoundNBT data )
public void read(final CompoundNBT data )
{
super.readFromNBT( data );
super.read( data );
this.getProxy().readFromNBT( data );
}
@Override
public CompoundNBT writeToNBT( final CompoundNBT data )
public CompoundNBT write(final CompoundNBT data )
{
super.writeToNBT( data );
super.write( data );
this.getProxy().writeToNBT( data );
return data;
}
@@ -85,18 +85,18 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
}
@Override
public CompoundNBT writeToNBT( final CompoundNBT data )
public CompoundNBT write(final CompoundNBT data )
{
super.writeToNBT( data );
super.write( data );
this.cm.writeToNBT( data );
data.putDouble("storedPower", this.getStoredPower());
return data;
}
@Override
public void readFromNBT( final CompoundNBT data )
public void read(final CompoundNBT data )
{
super.readFromNBT( data );
super.read( data );
this.cm.readFromNBT( data );
this.setStoredPower( data.getDouble( "storedPower" ) );
}
@@ -132,18 +132,18 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
}
@Override
public CompoundNBT writeToNBT( final CompoundNBT data )
public CompoundNBT write(final CompoundNBT data )
{
super.writeToNBT( data );
super.write( data );
this.upgrades.writeToNBT( data, "upgrades" );
this.settings.writeToNBT( data );
return data;
}
@Override
public void readFromNBT( final CompoundNBT data )
public void read(final CompoundNBT data )
{
super.readFromNBT( data );
super.read( data );
this.upgrades.readFromNBT( data, "upgrades" );
this.settings.readFromNBT( data );
}
@@ -167,18 +167,18 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, II
}
@Override
public CompoundNBT writeToNBT( final CompoundNBT data )
public CompoundNBT write(final CompoundNBT data )
{
super.writeToNBT( data );
super.write( data );
data.putBoolean("omniDirectional", this.omniDirectional);
this.duality.writeToNBT( data );
return data;
}
@Override
public void readFromNBT( final CompoundNBT data )
public void read(final CompoundNBT data )
{
super.readFromNBT( data );
super.read( data );
this.omniDirectional = data.getBoolean( "omniDirectional" );
this.duality.readFromNBT( data );
@@ -214,7 +214,7 @@ public class TilePaint extends AEBaseTile
if( this.dots == null )
{
this.world.setBlockToAir( this.pos );
this.world.removeBlock(this.pos, false);
}
}
@@ -98,9 +98,9 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
}
@Override
public CompoundNBT writeToNBT( final CompoundNBT data )
public CompoundNBT write(final CompoundNBT data )
{
super.writeToNBT( data );
super.write( data );
data.putDouble("burnTime", this.getBurnTime());
data.putDouble("maxBurnTime", this.getMaxBurnTime());
data.setInteger( "burnSpeed", this.getBurnSpeed() );
@@ -108,9 +108,9 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
}
@Override
public void readFromNBT( final CompoundNBT data )
public void read(final CompoundNBT data )
{
super.readFromNBT( data );
super.read( data );
this.setBurnTime( data.getDouble( "burnTime" ) );
this.setMaxBurnTime( data.getDouble( "maxBurnTime" ) );
this.setBurnSpeed( data.getInteger( "burnSpeed" ) );
@@ -342,7 +342,7 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
@Override
public void cleanup()
{
this.getWorld().setBlockToAir( this.pos );
this.getWorld().removeBlock(this.pos, false);
}
@Override
@@ -80,17 +80,17 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
}
@Override
public CompoundNBT writeToNBT( final CompoundNBT data )
public CompoundNBT write(final CompoundNBT data )
{
super.writeToNBT( data );
super.write( data );
data.putDouble("internalCurrentPower", this.getInternalCurrentPower());
return data;
}
@Override
public void readFromNBT( final CompoundNBT data )
public void read(final CompoundNBT data )
{
super.readFromNBT( data );
super.read( data );
this.setInternalCurrentPower( data.getDouble( "internalCurrentPower" ) );
}
@@ -277,7 +277,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
final ItemStack is = this.internalInventory.getStackInSlot( 0 );
if( !is.isEmpty() )
{
final CompoundNBT c = is.getTagCompound();
final CompoundNBT c = is.getTag();
if( c != null )
{
return c.getLong( "freq" );
@@ -65,17 +65,17 @@ public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallabl
}
@Override
public CompoundNBT writeToNBT( final CompoundNBT data )
public CompoundNBT write(final CompoundNBT data )
{
super.writeToNBT( data );
super.write( data );
data.setInteger( "lastRedstoneState", this.lastRedstoneState.ordinal() );
return data;
}
@Override
public void readFromNBT( final CompoundNBT data )
public void read(final CompoundNBT data )
{
super.readFromNBT( data );
super.read( data );
if( data.contains("lastRedstoneState") )
{
this.lastRedstoneState = YesNo.values()[data.getInteger( "lastRedstoneState" )];
@@ -431,9 +431,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
}
@Override
public void readFromNBT( final CompoundNBT data )
public void read(final CompoundNBT data )
{
super.readFromNBT( data );
super.read( data );
this.config.readFromNBT( data );
this.priority = data.getInteger( "priority" );
if( data.contains("paintedColor") )
@@ -443,9 +443,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
}
@Override
public CompoundNBT writeToNBT( final CompoundNBT data )
public CompoundNBT write(final CompoundNBT data )
{
super.writeToNBT( data );
super.write( data );
this.config.writeToNBT( data );
data.setInteger( "priority", this.priority );
data.setByte( "paintedColor", (byte) this.paintedColor.ordinal() );
@@ -172,17 +172,17 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
}
@Override
public void readFromNBT( final CompoundNBT data )
public void read(final CompoundNBT data )
{
super.readFromNBT( data );
super.read( data );
this.isCached = false;
this.priority = data.getInteger( "priority" );
}
@Override
public CompoundNBT writeToNBT( final CompoundNBT data )
public CompoundNBT write(final CompoundNBT data )
{
super.writeToNBT( data );
super.write( data );
data.setInteger( "priority", this.priority );
return data;
}
@@ -110,9 +110,9 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
}
@Override
public CompoundNBT writeToNBT( final CompoundNBT data )
public CompoundNBT write(final CompoundNBT data )
{
super.writeToNBT( data );
super.write( data );
this.manager.writeToNBT( data );
this.upgrades.writeToNBT( data, "upgrades" );
data.setInteger( "lastRedstoneState", this.lastRedstoneState.ordinal() );
@@ -120,9 +120,9 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
}
@Override
public void readFromNBT( final CompoundNBT data )
public void read(final CompoundNBT data )
{
super.readFromNBT( data );
super.read( data );
this.manager.readFromNBT( data );
this.upgrades.readFromNBT( data, "upgrades" );
if( data.contains("lastRedstoneState") )