Fixed controller model warning during launch + Improved memory usage of some models

This commit is contained in:
raoulvdberge
2017-04-01 15:53:39 +02:00
parent 5ef0da5988
commit 6c8b0ac057
41 changed files with 87 additions and 133 deletions

View File

@@ -12,7 +12,6 @@ import com.raoulvdberge.refinedstorage.proxy.CapabilityNetworkNodeProxy;
import com.raoulvdberge.refinedstorage.tile.TileBase;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
@@ -28,8 +27,6 @@ import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
public abstract class BlockBase extends Block {
public static final PropertyDirection DIRECTION = PropertyDirection.create("direction");
private final String name;
public BlockBase(String name) {
@@ -50,8 +47,8 @@ public abstract class BlockBase extends Block {
protected BlockStateContainer.Builder createBlockStateBuilder() {
BlockStateContainer.Builder builder = new BlockStateContainer.Builder(this);
if (getPlacementType() != null) {
builder.add(DIRECTION);
if (getDirection() != null) {
builder.add(getDirection().getProperty());
}
return builder;
@@ -63,7 +60,7 @@ public abstract class BlockBase extends Block {
}
public Item createItem() {
return new ItemBlockBase(this, getPlacementType(), false);
return new ItemBlockBase(this, getDirection(), false);
}
@Override
@@ -80,11 +77,11 @@ public abstract class BlockBase extends Block {
@Override
@SuppressWarnings("deprecation")
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
if (getPlacementType() != null) {
if (getDirection() != null) {
TileEntity tile = IntegrationMCMP.isLoaded() ? RSMCMPAddon.unwrapTile(world, pos) : world.getTileEntity(pos);
if (tile instanceof TileBase) {
return state.withProperty(DIRECTION, ((TileBase) tile).getDirection());
return state.withProperty(getDirection().getProperty(), ((TileBase) tile).getDirection());
}
}
@@ -98,10 +95,10 @@ public abstract class BlockBase extends Block {
@Override
public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis) {
if (!world.isRemote && getPlacementType() != null) {
if (!world.isRemote && getDirection() != null) {
TileBase tile = (TileBase) world.getTileEntity(pos);
tile.setDirection(getPlacementType().cycle(tile.getDirection()));
tile.setDirection(getDirection().cycle(tile.getDirection()));
RSUtils.updateBlock(world, pos);
@@ -192,7 +189,7 @@ public abstract class BlockBase extends Block {
return super.canEntityDestroy(state, world, pos, entity);
}
public PlacementType getPlacementType() {
return PlacementType.HORIZONTAL;
public Direction getDirection() {
return Direction.HORIZONTAL;
}
}

View File

@@ -60,20 +60,14 @@ public class BlockCable extends BlockNode {
@Override
protected BlockStateContainer createBlockState() {
BlockStateContainer.Builder builder = super.createBlockStateBuilder();
builder.add(NORTH)
return super.createBlockStateBuilder()
.add(NORTH)
.add(EAST)
.add(SOUTH)
.add(WEST)
.add(UP)
.add(DOWN);
if (getPlacementType() != null) {
builder.add(DIRECTION);
}
return builder.build();
.add(DOWN)
.build();
}
@Override
@@ -114,7 +108,7 @@ public class BlockCable extends BlockNode {
EnumFacing otherTileSide = direction.getOpposite();
if (otherTile != null && otherTile.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, otherTileSide)) {
if (getPlacementType() != null && ((TileNode) tile).getNode().getFacingTile() == otherTile) {
if (getDirection() != null && ((TileNode) tile).getNode().getFacingTile() == otherTile) {
return false;
}
@@ -219,8 +213,8 @@ public class BlockCable extends BlockNode {
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase entity) {
IBlockState state = super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, entity);
if (getPlacementType() != null) {
return state.withProperty(DIRECTION, getPlacementType().getFrom(facing, pos, entity));
if (getDirection() != null) {
return state.withProperty(getDirection().getProperty(), getDirection().getFrom(facing, pos, entity));
}
return state;
@@ -232,7 +226,7 @@ public class BlockCable extends BlockNode {
}
@Override
public PlacementType getPlacementType() {
public Direction getDirection() {
return null;
}

View File

@@ -38,7 +38,7 @@ public class BlockConstructor extends BlockCable {
public List<AxisAlignedBB> getNonUnionizedCollisionBoxes(IBlockState state) {
List<AxisAlignedBB> boxes = new ArrayList<>();
switch (state.getValue(DIRECTION)) {
switch (state.getValue(getDirection().getProperty())) {
case NORTH:
boxes.add(HOLDER_NORTH_AABB);
boxes.add(HEAD_NORTH_AABB);
@@ -92,7 +92,7 @@ public class BlockConstructor extends BlockCable {
}
@Override
public PlacementType getPlacementType() {
return PlacementType.ANY;
public Direction getDirection() {
return Direction.ANY;
}
}

View File

@@ -30,8 +30,8 @@ public class BlockCrafter extends BlockNode {
}
@Override
public PlacementType getPlacementType() {
return PlacementType.ANY_FACE_PLAYER;
public Direction getDirection() {
return Direction.ANY_FACE_PLAYER;
}
public boolean hasConnectivityState() {

View File

@@ -48,7 +48,7 @@ public class BlockDestructor extends BlockCable {
}
@Override
public PlacementType getPlacementType() {
return PlacementType.ANY;
public Direction getDirection() {
return Direction.ANY;
}
}

View File

@@ -87,7 +87,7 @@ public class BlockDetector extends BlockNode {
}
@Override
public PlacementType getPlacementType() {
public Direction getDirection() {
return null;
}
}

View File

@@ -64,9 +64,4 @@ public class BlockDiskManipulator extends BlockNode {
public boolean hasConnectivityState() {
return true;
}
@Override
public PlacementType getPlacementType() {
return PlacementType.HORIZONTAL;
}
}

View File

@@ -43,7 +43,7 @@ public class BlockExporter extends BlockCable {
public List<AxisAlignedBB> getNonUnionizedCollisionBoxes(IBlockState state) {
List<AxisAlignedBB> boxes = new ArrayList<>();
switch (state.getValue(DIRECTION)) {
switch (state.getValue(getDirection().getProperty())) {
case NORTH:
boxes.add(LINE_NORTH_1_AABB);
boxes.add(LINE_NORTH_2_AABB);
@@ -98,7 +98,7 @@ public class BlockExporter extends BlockCable {
}
@Override
public PlacementType getPlacementType() {
return PlacementType.ANY;
public Direction getDirection() {
return Direction.ANY;
}
}

View File

@@ -33,7 +33,7 @@ public class BlockExternalStorage extends BlockCable {
public List<AxisAlignedBB> getNonUnionizedCollisionBoxes(IBlockState state) {
List<AxisAlignedBB> boxes = new ArrayList<>();
switch (state.getValue(DIRECTION)) {
switch (state.getValue(getDirection().getProperty())) {
case NORTH:
boxes.add(BlockConstructor.HOLDER_NORTH_AABB);
boxes.add(HEAD_NORTH_AABB);
@@ -96,7 +96,7 @@ public class BlockExternalStorage extends BlockCable {
}
@Override
public PlacementType getPlacementType() {
return PlacementType.ANY;
public Direction getDirection() {
return Direction.ANY;
}
}

View File

@@ -36,7 +36,7 @@ public class BlockFluidInterface extends BlockNode {
}
@Override
public PlacementType getPlacementType() {
public Direction getDirection() {
return null;
}
}

View File

@@ -112,7 +112,7 @@ public class BlockFluidStorage extends BlockNode {
}
@Override
public PlacementType getPlacementType() {
public Direction getDirection() {
return null;
}
}

View File

@@ -69,6 +69,6 @@ public class BlockGrid extends BlockNode {
@Override
public Item createItem() {
return new ItemBlockBase(this, getPlacementType(), true);
return new ItemBlockBase(this, getDirection(), true);
}
}

View File

@@ -43,7 +43,7 @@ public class BlockImporter extends BlockCable {
public List<AxisAlignedBB> getNonUnionizedCollisionBoxes(IBlockState state) {
List<AxisAlignedBB> boxes = new ArrayList<>();
switch (state.getValue(DIRECTION)) {
switch (state.getValue(getDirection().getProperty())) {
case NORTH:
boxes.add(LINE_NORTH_1_AABB);
boxes.add(LINE_NORTH_2_AABB);
@@ -98,7 +98,7 @@ public class BlockImporter extends BlockCable {
}
@Override
public PlacementType getPlacementType() {
return PlacementType.ANY;
public Direction getDirection() {
return Direction.ANY;
}
}

View File

@@ -36,7 +36,7 @@ public class BlockInterface extends BlockNode {
}
@Override
public PlacementType getPlacementType() {
public Direction getDirection() {
return null;
}
}

View File

@@ -6,7 +6,7 @@ public class BlockMachineCasing extends BlockBase {
}
@Override
public PlacementType getPlacementType() {
public Direction getDirection() {
return null;
}
}

View File

@@ -16,7 +16,7 @@ public class BlockNetworkReceiver extends BlockNode {
}
@Override
public PlacementType getPlacementType() {
public Direction getDirection() {
return null;
}

View File

@@ -30,7 +30,7 @@ public class BlockNetworkTransmitter extends BlockNode {
}
@Override
public PlacementType getPlacementType() {
public Direction getDirection() {
return null;
}

View File

@@ -49,7 +49,7 @@ public class BlockProcessingPatternEncoder extends BlockBase {
}
@Override
public PlacementType getPlacementType() {
public Direction getDirection() {
return null;
}
}

View File

@@ -6,7 +6,7 @@ public class BlockQuartzEnrichedIron extends BlockBase {
}
@Override
public PlacementType getPlacementType() {
public Direction getDirection() {
return null;
}
}

View File

@@ -70,7 +70,7 @@ public class BlockReader extends BlockCable {
}
@Override
public PlacementType getPlacementType() {
return PlacementType.ANY_FACE_PLAYER;
public Direction getDirection() {
return Direction.ANY_FACE_PLAYER;
}
}

View File

@@ -30,7 +30,7 @@ public class BlockRelay extends BlockNode {
}
@Override
public PlacementType getPlacementType() {
public Direction getDirection() {
return null;
}

View File

@@ -61,7 +61,7 @@ public class BlockSolderer extends BlockNode {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileSolderer && ((TileSolderer) tile).isWorking()) {
EnumFacing direction = getActualState(state, world, pos).getValue(DIRECTION);
EnumFacing direction = getActualState(state, world, pos).getValue(getDirection().getProperty());
double x = 0;
double y = (double) pos.getY() + 0.6D + rand.nextDouble() / 32F;
@@ -108,9 +108,4 @@ public class BlockSolderer extends BlockNode {
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public PlacementType getPlacementType() {
return PlacementType.HORIZONTAL;
}
}

View File

@@ -112,7 +112,7 @@ public class BlockStorage extends BlockNode {
}
@Override
public PlacementType getPlacementType() {
public Direction getDirection() {
return null;
}
}

View File

@@ -85,7 +85,7 @@ public class BlockWirelessTransmitter extends BlockNode {
}
@Override
public PlacementType getPlacementType() {
public Direction getDirection() {
return null;
}

View File

@@ -91,7 +91,7 @@ public class BlockWriter extends BlockCable {
}
@Override
public PlacementType getPlacementType() {
return PlacementType.ANY_FACE_PLAYER;
public Direction getDirection() {
return Direction.ANY_FACE_PLAYER;
}
}

View File

@@ -1,27 +1,24 @@
package com.raoulvdberge.refinedstorage.block;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import scala.actors.threadpool.Arrays;
public enum PlacementType {
ANY(
EnumFacing.VALUES
),
ANY_FACE_PLAYER(
EnumFacing.VALUES
),
HORIZONTAL(
EnumFacing.NORTH,
EnumFacing.EAST,
EnumFacing.SOUTH,
EnumFacing.WEST
);
public enum Direction {
ANY(EnumFacing.VALUES),
ANY_FACE_PLAYER(EnumFacing.VALUES),
HORIZONTAL(EnumFacing.NORTH, EnumFacing.EAST, EnumFacing.SOUTH, EnumFacing.WEST);
final EnumFacing[] allowed;
private final PropertyDirection property;
PlacementType(EnumFacing... allowed) {
this.allowed = allowed;
Direction(EnumFacing... allowed) {
this.property = PropertyDirection.create("direction", Arrays.asList(allowed));
}
public PropertyDirection getProperty() {
return property;
}
public EnumFacing getFrom(EnumFacing facing, BlockPos pos, EntityLivingBase entity) {

View File

@@ -1,6 +1,6 @@
package com.raoulvdberge.refinedstorage.item;
import com.raoulvdberge.refinedstorage.block.PlacementType;
import com.raoulvdberge.refinedstorage.block.Direction;
import com.raoulvdberge.refinedstorage.tile.TileBase;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
@@ -13,14 +13,14 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class ItemBlockBase extends ItemBlock {
private PlacementType placementType;
private Direction direction;
public ItemBlockBase(Block block, PlacementType placementType, boolean subtypes) {
public ItemBlockBase(Block block, Direction direction, boolean subtypes) {
super(block);
setRegistryName(block.getRegistryName());
this.placementType = placementType;
this.direction = direction;
if (subtypes) {
setMaxDamage(0);
@@ -46,11 +46,11 @@ public class ItemBlockBase extends ItemBlock {
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
boolean result = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState);
if (result && placementType != null) {
if (result && direction != null) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileBase) {
((TileBase) tile).setDirection(placementType.getFrom(side, pos, player));
((TileBase) tile).setDirection(direction.getFrom(side, pos, player));
}
}

View File

@@ -14,7 +14,7 @@ import java.util.List;
public class ItemBlockController extends ItemBlockBase {
public ItemBlockController() {
super(RSBlocks.CONTROLLER, RSBlocks.CONTROLLER.getPlacementType(), true);
super(RSBlocks.CONTROLLER, RSBlocks.CONTROLLER.getDirection(), true);
}
@Override

View File

@@ -20,7 +20,7 @@ import java.util.List;
public class ItemBlockFluidStorage extends ItemBlockBase {
public ItemBlockFluidStorage() {
super(RSBlocks.FLUID_STORAGE, RSBlocks.FLUID_STORAGE.getPlacementType(), true);
super(RSBlocks.FLUID_STORAGE, RSBlocks.FLUID_STORAGE.getDirection(), true);
}
@Override

View File

@@ -20,7 +20,7 @@ import java.util.List;
public class ItemBlockStorage extends ItemBlockBase {
public ItemBlockStorage() {
super(RSBlocks.STORAGE, RSBlocks.STORAGE.getPlacementType(), true);
super(RSBlocks.STORAGE, RSBlocks.STORAGE.getDirection(), true);
}
@Override

View File

@@ -161,6 +161,7 @@ public class ProxyCommon {
registerBlock(RSBlocks.GRID);
registerBlock(RSBlocks.CRAFTING_MONITOR);
registerBlock(RSBlocks.STORAGE_MONITOR);
registerBlock(RSBlocks.SECURITY_MANAGER);
registerBlock(RSBlocks.CRAFTER);
registerBlock(RSBlocks.PROCESSING_PATTERN_ENCODER);
registerBlock(RSBlocks.DISK_DRIVE);
@@ -173,7 +174,6 @@ public class ProxyCommon {
registerBlock(RSBlocks.EXTERNAL_STORAGE);
registerBlock(RSBlocks.CONSTRUCTOR);
registerBlock(RSBlocks.DESTRUCTOR);
registerBlock(RSBlocks.SECURITY_MANAGER);
registerBlock(RSBlocks.READER);
registerBlock(RSBlocks.WRITER);
@@ -840,7 +840,7 @@ public class ProxyCommon {
private void registerBlock(BlockCable cable) {
GameRegistry.<Block>register(cable);
GameRegistry.register(new ItemBlockBase(cable, cable.getPlacementType(), false));
GameRegistry.register(new ItemBlockBase(cable, cable.getDirection(), false));
cableTypes.add(cable);
}

View File

@@ -3,7 +3,7 @@ package com.raoulvdberge.refinedstorage.render;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.raoulvdberge.refinedstorage.block.BlockBase;
import com.raoulvdberge.refinedstorage.RSBlocks;
import com.raoulvdberge.refinedstorage.block.BlockDiskDrive;
import com.raoulvdberge.refinedstorage.tile.TileDiskDrive;
import net.minecraft.block.state.IBlockState;
@@ -71,7 +71,7 @@ public class BakedModelDiskDrive implements IBakedModel {
private LoadingCache<CacheKey, List<BakedQuad>> cache = CacheBuilder.newBuilder().build(new CacheLoader<CacheKey, List<BakedQuad>>() {
@Override
public List<BakedQuad> load(CacheKey key) throws Exception {
EnumFacing facing = key.state.getValue(BlockBase.DIRECTION);
EnumFacing facing = key.state.getValue(RSBlocks.DISK_DRIVE.getDirection().getProperty());
List<BakedQuad> quads = models.get(facing).getQuads(key.state, key.side, 0);

View File

@@ -3,7 +3,7 @@ package com.raoulvdberge.refinedstorage.render;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.raoulvdberge.refinedstorage.block.BlockBase;
import com.raoulvdberge.refinedstorage.RSBlocks;
import com.raoulvdberge.refinedstorage.block.BlockDiskManipulator;
import com.raoulvdberge.refinedstorage.tile.TileDiskDrive;
import net.minecraft.block.state.IBlockState;
@@ -72,7 +72,7 @@ public class BakedModelDiskManipulator implements IBakedModel {
private LoadingCache<CacheKey, List<BakedQuad>> cache = CacheBuilder.newBuilder().build(new CacheLoader<CacheKey, List<BakedQuad>>() {
@Override
public List<BakedQuad> load(CacheKey key) throws Exception {
EnumFacing facing = key.state.getValue(BlockBase.DIRECTION);
EnumFacing facing = key.state.getValue(RSBlocks.DISK_MANIPULATOR.getDirection().getProperty());
List<BakedQuad> quads = (key.state.getValue(BlockDiskManipulator.CONNECTED) ? modelsConnected : modelsDisconnected).get(facing).getQuads(key.state, key.side, 0);

View File

@@ -10,6 +10,11 @@
}
},
"variants": {
"inventory": [
{
"transform": "forge:default-block"
}
],
"energy": {
"0": {
"textures": {

View File

@@ -40,12 +40,6 @@
},
"west": {
"y": 270
},
"up": {
"x": 270
},
"down": {
"x": 90
}
}
}

View File

@@ -70,12 +70,6 @@
},
"west": {
"y": 270
},
"up": {
"x": 270
},
"down": {
"x": 90
}
}
}

View File

@@ -15,8 +15,7 @@
"variants": {
"inventory": [
{
"transform": "forge:default-block",
"y": 0
"transform": "forge:default-block"
}
],
"normal": {

View File

@@ -43,12 +43,6 @@
},
"west": {
"y": 270
},
"up": {
"x": 270
},
"down": {
"x": 90
}
}
}

View File

@@ -31,12 +31,6 @@
},
"west": {
"y": 270
},
"up": {
"x": 270
},
"down": {
"x": 90
}
}
}

View File

@@ -34,12 +34,6 @@
},
"west": {
"y": 270
},
"up": {
"x": 270
},
"down": {
"x": 90
}
}
}