GUI Rendering and various fixes

This commit is contained in:
Sebastian Hartte
2020-06-07 03:29:57 +02:00
parent 97f04922b9
commit 46b1d1ffdc
72 changed files with 650 additions and 552 deletions
+49 -39
View File
@@ -19,6 +19,7 @@
package appeng.tile;
import appeng.api.implementations.tiles.ISegmentedInventory;
import appeng.api.util.ICommonTile;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
@@ -28,6 +29,9 @@ import appeng.client.render.FacingToRotation;
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;
import io.netty.buffer.Unpooled;
@@ -47,6 +51,7 @@ import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.data.ModelDataMap;
import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -293,8 +298,14 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
// TODO: Optimize Network Load
if( this.world != null )
{
AELog.blockUpdate( this.pos, this );
this.world.notifyBlockUpdate( this.pos, this.getBlockState(), this.getBlockState(), 3 );
// Let the block update
BlockState currentState = getBlockState();
BlockState newState = currentState.updatePostPlacement(Direction.EAST, currentState, world, pos, pos);
AELog.blockUpdate( this.pos, currentState, newState, this );
if (currentState != newState) {
this.world.setBlockState(pos, newState);
}
this.requestModelDataUpdate();
}
}
@@ -357,27 +368,27 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
cm.readFromNBT( compound );
}
}
// 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 ) );
// }
// }
// }
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 ) );
}
}
}
}
/**
@@ -425,21 +436,20 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
}
}
// 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 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" );
}
}
return output.isEmpty() ? null : output;
}
@@ -482,7 +492,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
this.world.markChunkDirty( this.pos, this );
if( !this.markDirtyQueued )
{
// FIXME TickHandler.INSTANCE.addCallable( null, this::markDirtyAtEndOfTick );
TickHandler.INSTANCE.addCallable( null, this::markDirtyAtEndOfTick );
this.markDirtyQueued = true;
}
}
@@ -202,7 +202,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
public boolean isFormed()
{
if( Platform.isClient() )
if( isRemote() )
{
return this.world.getBlockState( this.pos ).get( AbstractCraftingUnitBlock.FORMED );
}
@@ -357,7 +357,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
@Override
public boolean isPowered()
{
if( Platform.isClient() )
if( isRemote() )
{
return this.world.getBlockState( this.pos ).get( AbstractCraftingUnitBlock.POWERED );
}
@@ -476,16 +476,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
this.ejectHeldItems();
try
{
final TargetPoint where = new TargetPoint( this.pos.getX(), this.pos.getY(), this.pos.getZ(), 32, this.world.getDimension().getType() );
final IAEItemStack item = AEItemStack.fromItemStack( output );
NetworkHandler.instance().sendToAllAround( new PacketAssemblerAnimation( this.pos, (byte) speed, item ), where );
}
catch( final IOException e )
{
// ;P
}
final TargetPoint where = new TargetPoint( this.pos.getX(), this.pos.getY(), this.pos.getZ(), 32, this.world.getDimension().getType() );
final IAEItemStack item = AEItemStack.fromItemStack( output );
NetworkHandler.instance().sendToAllAround( new PacketAssemblerAnimation( this.pos, (byte) speed, item ), where );
this.saveChanges();
this.updateSleepiness();
@@ -96,7 +96,7 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, II
public void setSide( final Direction facing )
{
if( Platform.isClient() )
if( isRemote() )
{
return;
}
@@ -178,7 +178,7 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
@Override
public boolean isActive()
{
if( Platform.isClient() )
if( isRemote() )
{
return this.isPowered() && ( CHANNEL_FLAG == ( this.getClientFlags() & CHANNEL_FLAG ) );
}
@@ -297,7 +297,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
public boolean isPowered()
{
if( Platform.isClient() )
if( isRemote() )
{
return ( this.constructed & this.powered ) == this.powered && this.constructed != -1;
}
@@ -26,9 +26,12 @@ import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import appeng.block.storage.BlockChest;
import appeng.block.storage.DriveSlotState;
import appeng.container.implementations.ContainerMEMonitorable;
import appeng.core.Api;
import appeng.fluids.container.ContainerFluidTerminal;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.ItemStack;
@@ -37,6 +40,7 @@ import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidAttributes;
@@ -139,7 +143,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
this.setInternalPowerFlow( AccessRestriction.WRITE );
this.inputInventory.setFilter( new InputInventoryFilter() );
this.cellInventory.setFilter( new CellInventoryFilter() );
this.cellInventory.setFilter(new CellInventoryFilter());
}
public ItemStack getCell()
@@ -272,7 +276,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
@Override
public int getCellStatus( final int slot )
{
if( Platform.isClient() )
if( isRemote() )
{
return ( this.state >> ( slot * 3 ) ) & 3;
}
@@ -293,7 +297,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
@Override
public boolean isPowered()
{
if( Platform.isClient() )
if( isRemote() )
{
return ( this.state & 0x40 ) == 0x40;
}
@@ -923,7 +927,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
}
}
private class CellInventoryFilter implements IAEItemFilter
private static class CellInventoryFilter implements IAEItemFilter
{
@Override
@@ -168,7 +168,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
@Override
public boolean isPowered()
{
if( Platform.isClient() )
if( isRemote() )
{
return ( this.state & BIT_POWER_MASK ) == BIT_POWER_MASK;
}