More Rendering fixes
This commit is contained in:
@@ -25,6 +25,7 @@ import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.model.AEModelData;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.IStackSrc;
|
||||
import appeng.helpers.ICustomNameObject;
|
||||
@@ -521,10 +522,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
return new ModelDataMap.Builder()
|
||||
.withInitial(AEBaseTileBlock.UP, up)
|
||||
.withInitial(AEBaseTileBlock.FORWARD, forward)
|
||||
.build();
|
||||
return new AEModelData(up, forward);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package appeng.tile.crafting;
|
||||
|
||||
import appeng.client.render.model.AEModelData;
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Objects;
|
||||
|
||||
public class CraftingCubeModelData extends AEModelData {
|
||||
|
||||
// Contains information on which sides of the block are connected to other parts of a formed crafting cube
|
||||
private final EnumSet<Direction> connections;
|
||||
|
||||
public CraftingCubeModelData(Direction up, Direction forward, EnumSet<Direction> connections) {
|
||||
super(up, forward);
|
||||
this.connections = Preconditions.checkNotNull(connections);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCacheable() {
|
||||
return false; // Too many variants
|
||||
}
|
||||
|
||||
public EnumSet<Direction> getConnections() {
|
||||
return connections;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
CraftingCubeModelData that = (CraftingCubeModelData) o;
|
||||
return connections.equals(that.connections);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), connections);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package appeng.tile.crafting;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Objects;
|
||||
|
||||
public class CraftingMonitorModelData extends CraftingCubeModelData {
|
||||
|
||||
private final AEColor color;
|
||||
|
||||
public CraftingMonitorModelData(Direction up, Direction forward, EnumSet<Direction> connections, AEColor color) {
|
||||
super(up, forward, connections);
|
||||
this.color = Preconditions.checkNotNull(color);
|
||||
}
|
||||
|
||||
public AEColor getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
CraftingMonitorModelData that = (CraftingMonitorModelData) o;
|
||||
return color == that.color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), color);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,7 +22,6 @@ package appeng.tile.crafting;
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
@@ -38,8 +37,6 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -47,8 +44,6 @@ import javax.annotation.Nonnull;
|
||||
public class TileCraftingMonitorTile extends TileCraftingTile implements IColorableTile
|
||||
{
|
||||
|
||||
public static final ModelProperty<AEColor> COLOR = new ModelProperty<>();
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private Integer dspList;
|
||||
|
||||
@@ -204,11 +199,7 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
return new ModelDataMap.Builder()
|
||||
.withInitial(AEBaseTileBlock.FORWARD, getForward())
|
||||
.withInitial(AEBaseTileBlock.UP, getUp())
|
||||
.withInitial(COLOR, getColor())
|
||||
.build();
|
||||
return new CraftingMonitorModelData(getUp(), getForward(), getConnections(), getColor());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Optional;
|
||||
|
||||
import appeng.client.render.crafting.CraftingCubeState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
@@ -61,7 +60,7 @@ import net.minecraft.world.IBlockReader;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -69,8 +68,6 @@ import javax.annotation.Nonnull;
|
||||
public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IPowerChannelState
|
||||
{
|
||||
|
||||
public static final ModelProperty<CraftingCubeState> STATE = new ModelProperty<>();
|
||||
|
||||
private final CraftingCPUCalculator calc = new CraftingCPUCalculator( this );
|
||||
private CompoundNBT previousState = null;
|
||||
private boolean isCoreBlock = false;
|
||||
@@ -183,7 +180,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
{
|
||||
// Not using flag 2 here (only send to clients, prevent block update) will cause infinite loops
|
||||
// In case there is an inconsistency in the crafting clusters.
|
||||
this.world.setBlockState( this.pos, newState, 2 );
|
||||
this.world.setBlockState( this.pos, newState, Constants.BlockFlags.BLOCK_UPDATE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,12 +391,15 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
this.previousState = previousState;
|
||||
}
|
||||
|
||||
// FIXME: REMOVE AND MOVE TO IDynamicBakedModel!
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
return new CraftingCubeModelData(getUp(), getForward(), getConnections());
|
||||
}
|
||||
|
||||
protected EnumSet<Direction> getConnections() {
|
||||
if (world == null) {
|
||||
return EmptyModelData.INSTANCE;
|
||||
return EnumSet.noneOf(Direction.class);
|
||||
}
|
||||
|
||||
EnumSet<Direction> connections = EnumSet.noneOf( Direction.class );
|
||||
@@ -412,9 +412,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
}
|
||||
}
|
||||
|
||||
return new ModelDataMap.Builder()
|
||||
.withInitial(STATE, new CraftingCubeState( connections ))
|
||||
.build();
|
||||
return connections;
|
||||
}
|
||||
|
||||
private boolean isConnected( IBlockReader world, BlockPos pos, Direction side )
|
||||
@@ -423,4 +421,14 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
return world.getBlockState( adjacentPos ).getBlock() instanceof AbstractCraftingUnitBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
* When the block state changes (i.e. becoming formed or unformed), we need to update the
|
||||
* model data since it contains connections to neighboring tiles.
|
||||
*/
|
||||
@Override
|
||||
public void updateContainingBlockInfo() {
|
||||
super.updateContainingBlockInfo();
|
||||
requestModelDataUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.Map;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.block.storage.DriveSlotsState;
|
||||
import appeng.client.render.model.DriveModelData;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -76,8 +77,6 @@ import javax.annotation.Nonnull;
|
||||
public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPriorityHost
|
||||
{
|
||||
|
||||
public static final ModelProperty<DriveSlotsState> SLOTS_STATE = new ModelProperty<>();
|
||||
|
||||
private static final int BIT_POWER_MASK = 0x80000000;
|
||||
private static final int BIT_BLINK_MASK = 0x24924924;
|
||||
private static final int BIT_STATE_MASK = 0xDB6DB6DB;
|
||||
@@ -419,13 +418,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
|
||||
return new ModelDataMap.Builder()
|
||||
.withInitial(AEBaseTileBlock.UP, getUp())
|
||||
.withInitial(AEBaseTileBlock.FORWARD, getForward())
|
||||
.withInitial(SLOTS_STATE, DriveSlotsState.fromChestOrDrive( this ))
|
||||
.build();
|
||||
|
||||
return new DriveModelData(getUp(), getForward(), DriveSlotsState.fromChestOrDrive( this ));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user