Introduce new cube builder, rename "hollow cover" to "hollow wide cover".

This commit is contained in:
raoulvdberge
2018-07-08 17:30:44 +02:00
parent e915c5fbda
commit a1b6b704d9
40 changed files with 1016 additions and 573 deletions

View File

@@ -22,5 +22,5 @@ public final class RSItems {
public static final ItemSecurityCard SECURITY_CARD = new ItemSecurityCard();
public static final ItemCuttingTool CUTTING_TOOL = new ItemCuttingTool();
public static final ItemCover COVER = new ItemCover();
public static final ItemHollowCover HOLLOW_COVER = new ItemHollowCover();
public static final ItemHollowWideCover HOLLOW_WIDE_COVER = new ItemHollowWideCover();
}

View File

@@ -44,7 +44,7 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
private int type = IType.ITEMS;
private CoverManager coverManager = new CoverManager(this, CoverManager.CoverPlacementMode.HOLLOW_ON_FACE);
private CoverManager coverManager = new CoverManager(this, CoverManager.CoverPlacementMode.HOLLOW_WIDE_ON_FACE);
private int filterSlot;

View File

@@ -56,7 +56,7 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
private AccessType accessType = AccessType.INSERT_EXTRACT;
private int networkTicks;
private CoverManager coverManager = new CoverManager(this, CoverManager.CoverPlacementMode.HOLLOW_ON_FACE);
private CoverManager coverManager = new CoverManager(this, CoverManager.CoverPlacementMode.HOLLOW_WIDE_ON_FACE);
private List<IStorageExternal<ItemStack>> itemStorages = new CopyOnWriteArrayList<>();
private List<IStorageExternal<FluidStack>> fluidStorages = new CopyOnWriteArrayList<>();

View File

@@ -49,7 +49,7 @@ public class NetworkNodeImporter extends NetworkNode implements IComparable, IFi
private int mode = IFilterable.BLACKLIST;
private int type = IType.ITEMS;
private CoverManager coverManager = new CoverManager(this, CoverManager.CoverPlacementMode.HOLLOW_ON_FACE);
private CoverManager coverManager = new CoverManager(this, CoverManager.CoverPlacementMode.HOLLOW_WIDE_ON_FACE);
private int currentSlot;

View File

@@ -4,18 +4,18 @@ import net.minecraft.item.ItemStack;
public class Cover {
private ItemStack stack;
private boolean hollow;
private CoverType type;
public Cover(ItemStack stack, boolean hollow) {
public Cover(ItemStack stack, CoverType type) {
this.stack = stack;
this.hollow = hollow;
this.type = type;
}
public ItemStack getStack() {
return stack;
}
public boolean isHollow() {
return hollow;
public CoverType getType() {
return type;
}
}

View File

@@ -1,6 +1,5 @@
package com.raoulvdberge.refinedstorage.apiimpl.network.node.cover;
import com.raoulvdberge.refinedstorage.RSItems;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.ICoverable;
@@ -28,12 +27,12 @@ public class CoverManager {
public enum CoverPlacementMode {
ALLOW_ALL,
NONE_ON_FACE,
HOLLOW_ON_FACE
HOLLOW_WIDE_ON_FACE
}
private static final String NBT_DIRECTION = "Direction";
private static final String NBT_ITEM = "Item";
private static final String NBT_HOLLOW = "Hollow";
private static final String NBT_TYPE = "Type";
private Map<EnumFacing, Cover> covers = new HashMap<>();
private NetworkNode node;
@@ -46,7 +45,7 @@ public class CoverManager {
public boolean canConduct(EnumFacing direction) {
Cover cover = getCover(direction);
if (cover != null && !cover.isHollow()) {
if (cover != null && !cover.getType().isHollow()) {
return false;
}
@@ -54,7 +53,7 @@ public class CoverManager {
if (neighbor instanceof ICoverable) {
cover = ((ICoverable) neighbor).getCoverManager().getCover(direction.getOpposite());
if (cover != null && !cover.isHollow()) {
if (cover != null && !cover.getType().isHollow()) {
return false;
}
}
@@ -79,8 +78,8 @@ public class CoverManager {
break;
case NONE_ON_FACE:
return false;
case HOLLOW_ON_FACE:
if (!cover.isHollow()) {
case HOLLOW_WIDE_ON_FACE:
if (cover.getType() != CoverType.HOLLOW_WIDE) {
return false;
}
break;
@@ -108,10 +107,10 @@ public class CoverManager {
if (tag.hasKey(NBT_DIRECTION) && tag.hasKey(NBT_ITEM)) {
EnumFacing direction = EnumFacing.getFront(tag.getInteger(NBT_DIRECTION));
ItemStack item = new ItemStack(tag.getCompoundTag(NBT_ITEM));
boolean hollow = tag.hasKey(NBT_HOLLOW) && tag.getBoolean(NBT_HOLLOW);
int type = tag.hasKey(NBT_TYPE) ? tag.getInteger(NBT_TYPE) : 0;
if (isValidCover(item)) {
covers.put(direction, new Cover(item, hollow));
covers.put(direction, new Cover(item, CoverType.values()[type]));
}
}
}
@@ -125,7 +124,7 @@ public class CoverManager {
tag.setInteger(NBT_DIRECTION, entry.getKey().ordinal());
tag.setTag(NBT_ITEM, entry.getValue().getStack().serializeNBT());
tag.setBoolean(NBT_HOLLOW, entry.getValue().isHollow());
tag.setInteger(NBT_TYPE, entry.getValue().getType().ordinal());
list.appendTag(tag);
}
@@ -139,7 +138,7 @@ public class CoverManager {
int i = 0;
for (Map.Entry<EnumFacing, Cover> entry : covers.entrySet()) {
ItemStack cover = new ItemStack(entry.getValue().isHollow() ? RSItems.HOLLOW_COVER : RSItems.COVER);
ItemStack cover = entry.getValue().getType().createStack();
ItemCover.setItem(cover, entry.getValue().getStack());

View File

@@ -0,0 +1,18 @@
package com.raoulvdberge.refinedstorage.apiimpl.network.node.cover;
import com.raoulvdberge.refinedstorage.RSItems;
import net.minecraft.item.ItemStack;
public enum CoverType {
NORMAL,
HOLLOW,
HOLLOW_WIDE;
public boolean isHollow() {
return this == HOLLOW || this == HOLLOW_WIDE;
}
public ItemStack createStack() {
return new ItemStack(this == NORMAL ? RSItems.COVER : RSItems.HOLLOW_WIDE_COVER);
}
}

View File

@@ -5,6 +5,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.network.node.ICoverable;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.Cover;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager;
import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy;
import com.raoulvdberge.refinedstorage.render.constants.ConstantsCable;
import com.raoulvdberge.refinedstorage.tile.TileBase;
import com.raoulvdberge.refinedstorage.tile.TileCable;
import com.raoulvdberge.refinedstorage.tile.TileNode;
@@ -38,21 +39,6 @@ public class BlockCable extends BlockNode {
public static final PropertyObject<Cover> COVER_UP = new PropertyObject<>("cover_up", Cover.class);
public static final PropertyObject<Cover> COVER_DOWN = new PropertyObject<>("cover_down", Cover.class);
public static final AxisAlignedBB HOLDER_NORTH_AABB = RenderUtils.getBounds(7, 7, 2, 9, 9, 6);
public static final AxisAlignedBB HOLDER_EAST_AABB = RenderUtils.getBounds(10, 7, 7, 14, 9, 9);
public static final AxisAlignedBB HOLDER_SOUTH_AABB = RenderUtils.getBounds(7, 7, 10, 9, 9, 14);
public static final AxisAlignedBB HOLDER_WEST_AABB = RenderUtils.getBounds(2, 7, 7, 6, 9, 9);
public static final AxisAlignedBB HOLDER_UP_AABB = RenderUtils.getBounds(7, 10, 7, 9, 14, 9);
public static final AxisAlignedBB HOLDER_DOWN_AABB = RenderUtils.getBounds(7, 2, 7, 9, 6, 9);
public static final AxisAlignedBB CORE_AABB = RenderUtils.getBounds(6, 6, 6, 10, 10, 10);
private static final AxisAlignedBB NORTH_AABB = RenderUtils.getBounds(6, 6, 0, 10, 10, 6);
private static final AxisAlignedBB EAST_AABB = RenderUtils.getBounds(10, 6, 6, 16, 10, 10);
private static final AxisAlignedBB SOUTH_AABB = RenderUtils.getBounds(6, 6, 10, 10, 10, 16);
private static final AxisAlignedBB WEST_AABB = RenderUtils.getBounds(0, 6, 6, 6, 10, 10);
private static final AxisAlignedBB UP_AABB = RenderUtils.getBounds(6, 10, 6, 10, 16, 10);
private static final AxisAlignedBB DOWN_AABB = RenderUtils.getBounds(6, 0, 6, 10, 6, 10);
protected static final PropertyBool NORTH = PropertyBool.create("north");
protected static final PropertyBool EAST = PropertyBool.create("east");
protected static final PropertyBool SOUTH = PropertyBool.create("south");
@@ -139,7 +125,7 @@ public class BlockCable extends BlockNode {
if (node instanceof ICoverable) {
Cover cover = ((ICoverable) node).getCoverManager().getCover(direction);
if (cover != null && !cover.isHollow()) {
if (cover != null && !cover.getType().isHollow()) {
return false;
}
}
@@ -149,7 +135,7 @@ public class BlockCable extends BlockNode {
if (otherTile instanceof TileNode && ((TileNode) otherTile).getNode() instanceof ICoverable) {
Cover cover = ((ICoverable) ((TileNode) otherTile).getNode()).getCoverManager().getCover(direction.getOpposite());
if (cover != null && !cover.isHollow()) {
if (cover != null && !cover.getType().isHollow()) {
return false;
}
}
@@ -170,13 +156,13 @@ public class BlockCable extends BlockNode {
protected boolean hitCablePart(IBlockState state, World world, BlockPos pos, float hitX, float hitY, float hitZ) {
state = getActualState(state, world, pos);
if ((RenderUtils.isInBounds(CORE_AABB, hitX, hitY, hitZ)) ||
(state.getValue(NORTH) && RenderUtils.isInBounds(NORTH_AABB, hitX, hitY, hitZ)) ||
(state.getValue(EAST) && RenderUtils.isInBounds(EAST_AABB, hitX, hitY, hitZ)) ||
(state.getValue(SOUTH) && RenderUtils.isInBounds(SOUTH_AABB, hitX, hitY, hitZ)) ||
(state.getValue(WEST) && RenderUtils.isInBounds(WEST_AABB, hitX, hitY, hitZ)) ||
(state.getValue(UP) && RenderUtils.isInBounds(UP_AABB, hitX, hitY, hitZ)) ||
(state.getValue(DOWN) && RenderUtils.isInBounds(DOWN_AABB, hitX, hitY, hitZ))) {
if ((RenderUtils.isInBounds(ConstantsCable.CORE_AABB, hitX, hitY, hitZ)) ||
(state.getValue(NORTH) && RenderUtils.isInBounds(ConstantsCable.NORTH_AABB, hitX, hitY, hitZ)) ||
(state.getValue(EAST) && RenderUtils.isInBounds(ConstantsCable.EAST_AABB, hitX, hitY, hitZ)) ||
(state.getValue(SOUTH) && RenderUtils.isInBounds(ConstantsCable.SOUTH_AABB, hitX, hitY, hitZ)) ||
(state.getValue(WEST) && RenderUtils.isInBounds(ConstantsCable.WEST_AABB, hitX, hitY, hitZ)) ||
(state.getValue(UP) && RenderUtils.isInBounds(ConstantsCable.UP_AABB, hitX, hitY, hitZ)) ||
(state.getValue(DOWN) && RenderUtils.isInBounds(ConstantsCable.DOWN_AABB, hitX, hitY, hitZ))) {
return true;
}
@@ -194,30 +180,30 @@ public class BlockCable extends BlockNode {
public List<AxisAlignedBB> getCombinedCollisionBoxes(IBlockState state) {
List<AxisAlignedBB> boxes = new ArrayList<>();
boxes.add(CORE_AABB);
boxes.add(ConstantsCable.CORE_AABB);
if (state.getValue(NORTH)) {
boxes.add(NORTH_AABB);
boxes.add(ConstantsCable.NORTH_AABB);
}
if (state.getValue(EAST)) {
boxes.add(EAST_AABB);
boxes.add(ConstantsCable.EAST_AABB);
}
if (state.getValue(SOUTH)) {
boxes.add(SOUTH_AABB);
boxes.add(ConstantsCable.SOUTH_AABB);
}
if (state.getValue(WEST)) {
boxes.add(WEST_AABB);
boxes.add(ConstantsCable.WEST_AABB);
}
if (state.getValue(UP)) {
boxes.add(UP_AABB);
boxes.add(ConstantsCable.UP_AABB);
}
if (state.getValue(DOWN)) {
boxes.add(DOWN_AABB);
boxes.add(ConstantsCable.DOWN_AABB);
}
return boxes;
@@ -246,8 +232,8 @@ public class BlockCable extends BlockNode {
coverEast != null ? 14 : 16, coverUp != null ? 14 : 16, 2
));
if (!coverNorth.isHollow()) {
boxes.add(HOLDER_NORTH_AABB);
if (!coverNorth.getType().isHollow()) {
boxes.add(ConstantsCable.HOLDER_NORTH_AABB);
}
}
@@ -257,8 +243,8 @@ public class BlockCable extends BlockNode {
16, coverUp != null ? 14 : 16, 16
));
if (!coverEast.isHollow()) {
boxes.add(HOLDER_EAST_AABB);
if (!coverEast.getType().isHollow()) {
boxes.add(ConstantsCable.HOLDER_EAST_AABB);
}
}
@@ -268,8 +254,8 @@ public class BlockCable extends BlockNode {
coverWest != null ? 2 : 0, coverUp != null ? 14 : 16, 14
));
if (!coverSouth.isHollow()) {
boxes.add(HOLDER_SOUTH_AABB);
if (!coverSouth.getType().isHollow()) {
boxes.add(ConstantsCable.HOLDER_SOUTH_AABB);
}
}
@@ -279,8 +265,8 @@ public class BlockCable extends BlockNode {
2, coverUp != null ? 14 : 16, 16
));
if (!coverWest.isHollow()) {
boxes.add(HOLDER_WEST_AABB);
if (!coverWest.getType().isHollow()) {
boxes.add(ConstantsCable.HOLDER_WEST_AABB);
}
}
@@ -290,8 +276,8 @@ public class BlockCable extends BlockNode {
16, 16, 16
));
if (!coverUp.isHollow()) {
boxes.add(HOLDER_UP_AABB);
if (!coverUp.getType().isHollow()) {
boxes.add(ConstantsCable.HOLDER_UP_AABB);
}
}
@@ -301,8 +287,8 @@ public class BlockCable extends BlockNode {
16, 2, 16
));
if (!coverDown.isHollow()) {
boxes.add(HOLDER_DOWN_AABB);
if (!coverDown.getType().isHollow()) {
boxes.add(ConstantsCable.HOLDER_DOWN_AABB);
}
}
}

View File

@@ -1,8 +1,9 @@
package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.RSGui;
import com.raoulvdberge.refinedstorage.render.constants.ConstantsCable;
import com.raoulvdberge.refinedstorage.render.constants.ConstantsConstructor;
import com.raoulvdberge.refinedstorage.tile.TileConstructor;
import com.raoulvdberge.refinedstorage.util.RenderUtils;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
@@ -16,13 +17,6 @@ import javax.annotation.Nullable;
import java.util.List;
public class BlockConstructor extends BlockCable {
private static final AxisAlignedBB HEAD_NORTH_AABB = RenderUtils.getBounds(2, 2, 0, 14, 14, 2);
private static final AxisAlignedBB HEAD_EAST_AABB = RenderUtils.getBounds(14, 2, 2, 16, 14, 14);
private static final AxisAlignedBB HEAD_SOUTH_AABB = RenderUtils.getBounds(2, 2, 14, 14, 14, 16);
private static final AxisAlignedBB HEAD_WEST_AABB = RenderUtils.getBounds(0, 2, 2, 2, 14, 14);
private static final AxisAlignedBB HEAD_DOWN_AABB = RenderUtils.getBounds(2, 0, 2, 14, 2, 14);
private static final AxisAlignedBB HEAD_UP_AABB = RenderUtils.getBounds(2, 14, 2, 14, 16, 14);
public BlockConstructor() {
super("constructor");
}
@@ -33,28 +27,28 @@ public class BlockConstructor extends BlockCable {
switch (state.getValue(getDirection().getProperty())) {
case NORTH:
boxes.add(HOLDER_NORTH_AABB);
boxes.add(HEAD_NORTH_AABB);
boxes.add(ConstantsCable.HOLDER_NORTH_AABB);
boxes.add(ConstantsConstructor.HEAD_NORTH_AABB);
break;
case EAST:
boxes.add(HOLDER_EAST_AABB);
boxes.add(HEAD_EAST_AABB);
boxes.add(ConstantsCable.HOLDER_EAST_AABB);
boxes.add(ConstantsConstructor.HEAD_EAST_AABB);
break;
case SOUTH:
boxes.add(HOLDER_SOUTH_AABB);
boxes.add(HEAD_SOUTH_AABB);
boxes.add(ConstantsCable.HOLDER_SOUTH_AABB);
boxes.add(ConstantsConstructor.HEAD_SOUTH_AABB);
break;
case WEST:
boxes.add(HOLDER_WEST_AABB);
boxes.add(HEAD_WEST_AABB);
boxes.add(ConstantsCable.HOLDER_WEST_AABB);
boxes.add(ConstantsConstructor.HEAD_WEST_AABB);
break;
case UP:
boxes.add(HOLDER_UP_AABB);
boxes.add(HEAD_UP_AABB);
boxes.add(ConstantsCable.HOLDER_UP_AABB);
boxes.add(ConstantsConstructor.HEAD_UP_AABB);
break;
case DOWN:
boxes.add(HOLDER_DOWN_AABB);
boxes.add(HEAD_DOWN_AABB);
boxes.add(ConstantsCable.HOLDER_DOWN_AABB);
boxes.add(ConstantsConstructor.HEAD_DOWN_AABB);
break;
}

View File

@@ -1,6 +1,7 @@
package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.RSGui;
import com.raoulvdberge.refinedstorage.render.constants.ConstantsDetector;
import com.raoulvdberge.refinedstorage.tile.TileDetector;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockFaceShape;
@@ -19,8 +20,6 @@ import net.minecraft.world.World;
import javax.annotation.Nullable;
public class BlockDetector extends BlockNode {
private static final AxisAlignedBB AABB_DETECTOR = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 5D / 16D, 1.0D);
private static final PropertyBool POWERED = PropertyBool.create("powered");
public BlockDetector() {
@@ -43,7 +42,7 @@ public class BlockDetector extends BlockNode {
@Override
@SuppressWarnings("deprecation")
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
return AABB_DETECTOR;
return ConstantsDetector.DETECTOR_AABB;
}
@Override

View File

@@ -1,8 +1,8 @@
package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.RSGui;
import com.raoulvdberge.refinedstorage.render.constants.ConstantsExporter;
import com.raoulvdberge.refinedstorage.tile.TileExporter;
import com.raoulvdberge.refinedstorage.util.RenderUtils;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
@@ -16,25 +16,6 @@ import javax.annotation.Nullable;
import java.util.List;
public class BlockExporter extends BlockCable {
private static final AxisAlignedBB LINE_NORTH_1_AABB = RenderUtils.getBounds(6, 6, 0, 10, 10, 2);
private static final AxisAlignedBB LINE_NORTH_2_AABB = RenderUtils.getBounds(5, 5, 2, 11, 11, 4);
private static final AxisAlignedBB LINE_NORTH_3_AABB = RenderUtils.getBounds(3, 3, 4, 13, 13, 6);
private static final AxisAlignedBB LINE_EAST_1_AABB = RenderUtils.getBounds(14, 6, 6, 16, 10, 10);
private static final AxisAlignedBB LINE_EAST_2_AABB = RenderUtils.getBounds(12, 5, 5, 14, 11, 11);
private static final AxisAlignedBB LINE_EAST_3_AABB = RenderUtils.getBounds(10, 3, 3, 12, 13, 13);
private static final AxisAlignedBB LINE_SOUTH_1_AABB = RenderUtils.getBounds(6, 6, 14, 10, 10, 16);
private static final AxisAlignedBB LINE_SOUTH_2_AABB = RenderUtils.getBounds(5, 5, 12, 11, 11, 14);
private static final AxisAlignedBB LINE_SOUTH_3_AABB = RenderUtils.getBounds(3, 3, 10, 13, 13, 12);
private static final AxisAlignedBB LINE_WEST_1_AABB = RenderUtils.getBounds(0, 6, 6, 2, 10, 10);
private static final AxisAlignedBB LINE_WEST_2_AABB = RenderUtils.getBounds(2, 5, 5, 4, 11, 11);
private static final AxisAlignedBB LINE_WEST_3_AABB = RenderUtils.getBounds(4, 3, 3, 6, 13, 13);
private static final AxisAlignedBB LINE_UP_1_AABB = RenderUtils.getBounds(6, 14, 6, 10, 16, 10);
private static final AxisAlignedBB LINE_UP_2_AABB = RenderUtils.getBounds(5, 12, 5, 11, 14, 11);
private static final AxisAlignedBB LINE_UP_3_AABB = RenderUtils.getBounds(3, 10, 3, 13, 12, 13);
private static final AxisAlignedBB LINE_DOWN_1_AABB = RenderUtils.getBounds(6, 0, 6, 10, 2, 10);
private static final AxisAlignedBB LINE_DOWN_2_AABB = RenderUtils.getBounds(5, 2, 5, 11, 4, 11);
private static final AxisAlignedBB LINE_DOWN_3_AABB = RenderUtils.getBounds(3, 4, 3, 13, 6, 13);
public BlockExporter() {
super("exporter");
}
@@ -45,34 +26,34 @@ public class BlockExporter extends BlockCable {
switch (state.getValue(getDirection().getProperty())) {
case NORTH:
boxes.add(LINE_NORTH_1_AABB);
boxes.add(LINE_NORTH_2_AABB);
boxes.add(LINE_NORTH_3_AABB);
boxes.add(ConstantsExporter.LINE_NORTH_1_AABB);
boxes.add(ConstantsExporter.LINE_NORTH_2_AABB);
boxes.add(ConstantsExporter.LINE_NORTH_3_AABB);
break;
case EAST:
boxes.add(LINE_EAST_1_AABB);
boxes.add(LINE_EAST_2_AABB);
boxes.add(LINE_EAST_3_AABB);
boxes.add(ConstantsExporter.LINE_EAST_1_AABB);
boxes.add(ConstantsExporter.LINE_EAST_2_AABB);
boxes.add(ConstantsExporter.LINE_EAST_3_AABB);
break;
case SOUTH:
boxes.add(LINE_SOUTH_1_AABB);
boxes.add(LINE_SOUTH_2_AABB);
boxes.add(LINE_SOUTH_3_AABB);
boxes.add(ConstantsExporter.LINE_SOUTH_1_AABB);
boxes.add(ConstantsExporter.LINE_SOUTH_2_AABB);
boxes.add(ConstantsExporter.LINE_SOUTH_3_AABB);
break;
case WEST:
boxes.add(LINE_WEST_1_AABB);
boxes.add(LINE_WEST_2_AABB);
boxes.add(LINE_WEST_3_AABB);
boxes.add(ConstantsExporter.LINE_WEST_1_AABB);
boxes.add(ConstantsExporter.LINE_WEST_2_AABB);
boxes.add(ConstantsExporter.LINE_WEST_3_AABB);
break;
case UP:
boxes.add(LINE_UP_1_AABB);
boxes.add(LINE_UP_2_AABB);
boxes.add(LINE_UP_3_AABB);
boxes.add(ConstantsExporter.LINE_UP_1_AABB);
boxes.add(ConstantsExporter.LINE_UP_2_AABB);
boxes.add(ConstantsExporter.LINE_UP_3_AABB);
break;
case DOWN:
boxes.add(LINE_DOWN_1_AABB);
boxes.add(LINE_DOWN_2_AABB);
boxes.add(LINE_DOWN_3_AABB);
boxes.add(ConstantsExporter.LINE_DOWN_1_AABB);
boxes.add(ConstantsExporter.LINE_DOWN_2_AABB);
boxes.add(ConstantsExporter.LINE_DOWN_3_AABB);
break;
}

View File

@@ -2,8 +2,9 @@ package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.RSGui;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeExternalStorage;
import com.raoulvdberge.refinedstorage.render.constants.ConstantsCable;
import com.raoulvdberge.refinedstorage.render.constants.ConstantsExternalStorage;
import com.raoulvdberge.refinedstorage.tile.TileExternalStorage;
import com.raoulvdberge.refinedstorage.util.RenderUtils;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
@@ -18,13 +19,6 @@ import javax.annotation.Nullable;
import java.util.List;
public class BlockExternalStorage extends BlockCable {
private static final AxisAlignedBB HEAD_NORTH_AABB = RenderUtils.getBounds(3, 3, 0, 13, 13, 2);
private static final AxisAlignedBB HEAD_EAST_AABB = RenderUtils.getBounds(14, 3, 3, 16, 13, 13);
private static final AxisAlignedBB HEAD_SOUTH_AABB = RenderUtils.getBounds(3, 3, 14, 13, 13, 16);
private static final AxisAlignedBB HEAD_WEST_AABB = RenderUtils.getBounds(0, 3, 3, 2, 13, 13);
private static final AxisAlignedBB HEAD_UP_AABB = RenderUtils.getBounds(3, 14, 3, 13, 16, 13);
private static final AxisAlignedBB HEAD_DOWN_AABB = RenderUtils.getBounds(3, 0, 3, 13, 2, 13);
public BlockExternalStorage() {
super("external_storage");
}
@@ -35,28 +29,28 @@ public class BlockExternalStorage extends BlockCable {
switch (state.getValue(getDirection().getProperty())) {
case NORTH:
boxes.add(HOLDER_NORTH_AABB);
boxes.add(HEAD_NORTH_AABB);
boxes.add(ConstantsCable.HOLDER_NORTH_AABB);
boxes.add(ConstantsExternalStorage.HEAD_NORTH_AABB);
break;
case EAST:
boxes.add(HOLDER_EAST_AABB);
boxes.add(HEAD_EAST_AABB);
boxes.add(ConstantsCable.HOLDER_EAST_AABB);
boxes.add(ConstantsExternalStorage.HEAD_EAST_AABB);
break;
case SOUTH:
boxes.add(HOLDER_SOUTH_AABB);
boxes.add(HEAD_SOUTH_AABB);
boxes.add(ConstantsCable.HOLDER_SOUTH_AABB);
boxes.add(ConstantsExternalStorage.HEAD_SOUTH_AABB);
break;
case WEST:
boxes.add(HOLDER_WEST_AABB);
boxes.add(HEAD_WEST_AABB);
boxes.add(ConstantsCable.HOLDER_WEST_AABB);
boxes.add(ConstantsExternalStorage.HEAD_WEST_AABB);
break;
case UP:
boxes.add(HOLDER_UP_AABB);
boxes.add(HEAD_UP_AABB);
boxes.add(ConstantsCable.HOLDER_UP_AABB);
boxes.add(ConstantsExternalStorage.HEAD_UP_AABB);
break;
case DOWN:
boxes.add(HOLDER_DOWN_AABB);
boxes.add(HEAD_DOWN_AABB);
boxes.add(ConstantsCable.HOLDER_DOWN_AABB);
boxes.add(ConstantsExternalStorage.HEAD_DOWN_AABB);
break;
}

View File

@@ -1,8 +1,8 @@
package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.RSGui;
import com.raoulvdberge.refinedstorage.render.constants.ConstantsImporter;
import com.raoulvdberge.refinedstorage.tile.TileImporter;
import com.raoulvdberge.refinedstorage.util.RenderUtils;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
@@ -16,25 +16,6 @@ import javax.annotation.Nullable;
import java.util.List;
public class BlockImporter extends BlockCable {
private static final AxisAlignedBB LINE_NORTH_1_AABB = RenderUtils.getBounds(6, 6, 4, 10, 10, 6);
private static final AxisAlignedBB LINE_NORTH_2_AABB = RenderUtils.getBounds(5, 5, 2, 11, 11, 4);
private static final AxisAlignedBB LINE_NORTH_3_AABB = RenderUtils.getBounds(3, 3, 0, 13, 13, 2);
private static final AxisAlignedBB LINE_EAST_1_AABB = RenderUtils.getBounds(10, 6, 6, 12, 10, 10);
private static final AxisAlignedBB LINE_EAST_2_AABB = RenderUtils.getBounds(12, 5, 5, 14, 11, 11);
private static final AxisAlignedBB LINE_EAST_3_AABB = RenderUtils.getBounds(14, 3, 3, 16, 13, 13);
private static final AxisAlignedBB LINE_SOUTH_1_AABB = RenderUtils.getBounds(6, 6, 10, 10, 10, 12);
private static final AxisAlignedBB LINE_SOUTH_2_AABB = RenderUtils.getBounds(5, 5, 12, 11, 11, 14);
private static final AxisAlignedBB LINE_SOUTH_3_AABB = RenderUtils.getBounds(3, 3, 14, 13, 13, 16);
private static final AxisAlignedBB LINE_WEST_1_AABB = RenderUtils.getBounds(4, 6, 6, 6, 10, 10);
private static final AxisAlignedBB LINE_WEST_2_AABB = RenderUtils.getBounds(2, 5, 5, 4, 11, 11);
private static final AxisAlignedBB LINE_WEST_3_AABB = RenderUtils.getBounds(0, 3, 3, 2, 13, 13);
private static final AxisAlignedBB LINE_UP_1_AABB = RenderUtils.getBounds(6, 10, 6, 10, 12, 10);
private static final AxisAlignedBB LINE_UP_2_AABB = RenderUtils.getBounds(5, 12, 5, 11, 14, 11);
private static final AxisAlignedBB LINE_UP_3_AABB = RenderUtils.getBounds(3, 14, 3, 13, 16, 13);
private static final AxisAlignedBB LINE_DOWN_1_AABB = RenderUtils.getBounds(6, 4, 6, 10, 6, 10);
private static final AxisAlignedBB LINE_DOWN_2_AABB = RenderUtils.getBounds(5, 2, 5, 11, 4, 11);
private static final AxisAlignedBB LINE_DOWN_3_AABB = RenderUtils.getBounds(3, 0, 3, 13, 2, 13);
public BlockImporter() {
super("importer");
}
@@ -45,34 +26,34 @@ public class BlockImporter extends BlockCable {
switch (state.getValue(getDirection().getProperty())) {
case NORTH:
boxes.add(LINE_NORTH_1_AABB);
boxes.add(LINE_NORTH_2_AABB);
boxes.add(LINE_NORTH_3_AABB);
boxes.add(ConstantsImporter.LINE_NORTH_1_AABB);
boxes.add(ConstantsImporter.LINE_NORTH_2_AABB);
boxes.add(ConstantsImporter.LINE_NORTH_3_AABB);
break;
case EAST:
boxes.add(LINE_EAST_1_AABB);
boxes.add(LINE_EAST_2_AABB);
boxes.add(LINE_EAST_3_AABB);
boxes.add(ConstantsImporter.LINE_EAST_1_AABB);
boxes.add(ConstantsImporter.LINE_EAST_2_AABB);
boxes.add(ConstantsImporter.LINE_EAST_3_AABB);
break;
case SOUTH:
boxes.add(LINE_SOUTH_1_AABB);
boxes.add(LINE_SOUTH_2_AABB);
boxes.add(LINE_SOUTH_3_AABB);
boxes.add(ConstantsImporter.LINE_SOUTH_1_AABB);
boxes.add(ConstantsImporter.LINE_SOUTH_2_AABB);
boxes.add(ConstantsImporter.LINE_SOUTH_3_AABB);
break;
case WEST:
boxes.add(LINE_WEST_1_AABB);
boxes.add(LINE_WEST_2_AABB);
boxes.add(LINE_WEST_3_AABB);
boxes.add(ConstantsImporter.LINE_WEST_1_AABB);
boxes.add(ConstantsImporter.LINE_WEST_2_AABB);
boxes.add(ConstantsImporter.LINE_WEST_3_AABB);
break;
case UP:
boxes.add(LINE_UP_1_AABB);
boxes.add(LINE_UP_2_AABB);
boxes.add(LINE_UP_3_AABB);
boxes.add(ConstantsImporter.LINE_UP_1_AABB);
boxes.add(ConstantsImporter.LINE_UP_2_AABB);
boxes.add(ConstantsImporter.LINE_UP_3_AABB);
break;
case DOWN:
boxes.add(LINE_DOWN_1_AABB);
boxes.add(LINE_DOWN_2_AABB);
boxes.add(LINE_DOWN_3_AABB);
boxes.add(ConstantsImporter.LINE_DOWN_1_AABB);
boxes.add(ConstantsImporter.LINE_DOWN_2_AABB);
boxes.add(ConstantsImporter.LINE_DOWN_3_AABB);
break;
}

View File

@@ -3,6 +3,7 @@ package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.RSGui;
import com.raoulvdberge.refinedstorage.item.ItemBlockPortableGrid;
import com.raoulvdberge.refinedstorage.render.constants.ConstantsPortableGrid;
import com.raoulvdberge.refinedstorage.tile.grid.portable.TilePortableGrid;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyEnum;
@@ -25,8 +26,6 @@ import net.minecraft.world.World;
import javax.annotation.Nullable;
public class BlockPortableGrid extends BlockBase {
private static final AxisAlignedBB PORTABLE_GRID_AABB = new AxisAlignedBB(0, 0, 0, 1, 13.2F / 16F, 1);
public static final PropertyEnum TYPE = PropertyEnum.create("type", PortableGridType.class);
public static final PropertyEnum DISK_STATE = PropertyEnum.create("disk_state", PortableGridDiskState.class);
public static final PropertyBool CONNECTED = PropertyBool.create("connected");
@@ -59,7 +58,7 @@ public class BlockPortableGrid extends BlockBase {
@Override
@SuppressWarnings("deprecation")
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) {
return PORTABLE_GRID_AABB;
return ConstantsPortableGrid.PORTABLE_GRID_AABB;
}
@Override

View File

@@ -1,6 +1,7 @@
package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.RSGui;
import com.raoulvdberge.refinedstorage.render.constants.ConstantsWirelessTransmitter;
import com.raoulvdberge.refinedstorage.tile.TileWirelessTransmitter;
import net.minecraft.block.Block;
import net.minecraft.block.state.BlockFaceShape;
@@ -23,9 +24,6 @@ import javax.annotation.Nullable;
import java.util.List;
public class BlockWirelessTransmitter extends BlockNode {
// From BlockTorch
private static final AxisAlignedBB WIRELESS_TRANSMITTER_AABB = new AxisAlignedBB(0.4000000059604645D, 0.0D, 0.4000000059604645D, 0.6000000238418579D, 0.6000000238418579D, 0.6000000238418579D);
public BlockWirelessTransmitter() {
super("wireless_transmitter");
}
@@ -57,7 +55,7 @@ public class BlockWirelessTransmitter extends BlockNode {
@Override
@SuppressWarnings("deprecation")
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) {
return WIRELESS_TRANSMITTER_AABB;
return ConstantsWirelessTransmitter.WIRELESS_TRANSMITTER_AABB;
}
@Override

View File

@@ -20,7 +20,7 @@ public class RSJEIPlugin implements IModPlugin {
registry.addAdvancedGuiHandlers(new AdvancedGuiHandlerGrid());
registry.addRecipeRegistryPlugin(new RecipeRegistryPluginCover());
registry.addRecipeRegistryPlugin(new RecipeRegistryPluginHollowCover());
registry.addRecipeRegistryPlugin(new RecipeRegistryPluginHollowWideCover());
}
@Override

View File

@@ -9,7 +9,7 @@ import net.minecraft.item.ItemStack;
import java.util.Collections;
import java.util.List;
public class RecipeRegistryPluginHollowCover implements IRecipeRegistryPlugin {
public class RecipeRegistryPluginHollowWideCover implements IRecipeRegistryPlugin {
@Override
public <V> List<String> getRecipeCategoryUids(IFocus<V> focus) {
if (focus.getValue() instanceof ItemStack) {
@@ -20,7 +20,7 @@ public class RecipeRegistryPluginHollowCover implements IRecipeRegistryPlugin {
return Collections.singletonList(VanillaRecipeCategoryUid.CRAFTING);
}
} else if (focus.getMode() == IFocus.Mode.OUTPUT) {
if (stack.getItem() == RSItems.HOLLOW_COVER) {
if (stack.getItem() == RSItems.HOLLOW_WIDE_COVER) {
return Collections.singletonList(VanillaRecipeCategoryUid.CRAFTING);
}
}
@@ -36,19 +36,19 @@ public class RecipeRegistryPluginHollowCover implements IRecipeRegistryPlugin {
if (focus.getMode() == IFocus.Mode.INPUT) {
if (stack.getItem() == RSItems.COVER && CoverManager.isValidCover(ItemCover.getItem(stack))) {
ItemStack hollowCover = new ItemStack(RSItems.HOLLOW_COVER);
ItemStack hollowWideCover = new ItemStack(RSItems.HOLLOW_WIDE_COVER);
ItemCover.setItem(hollowCover, ItemCover.getItem(stack));
ItemCover.setItem(hollowWideCover, ItemCover.getItem(stack));
return Collections.singletonList((T) new RecipeWrapperHollowCover(stack, hollowCover));
return Collections.singletonList((T) new RecipeWrapperHollowWideCover(stack, hollowWideCover));
}
} else if (focus.getMode() == IFocus.Mode.OUTPUT) {
if (stack.getItem() == RSItems.HOLLOW_COVER) {
if (stack.getItem() == RSItems.HOLLOW_WIDE_COVER) {
ItemStack cover = new ItemStack(RSItems.COVER);
ItemCover.setItem(cover, ItemCover.getItem(stack));
return Collections.singletonList((T) new RecipeWrapperHollowCover(cover, stack));
return Collections.singletonList((T) new RecipeWrapperHollowWideCover(cover, stack));
}
}
}

View File

@@ -8,13 +8,13 @@ import net.minecraftforge.items.ItemHandlerHelper;
import java.util.ArrayList;
import java.util.List;
public class RecipeWrapperHollowCover implements IShapedCraftingRecipeWrapper {
public class RecipeWrapperHollowWideCover implements IShapedCraftingRecipeWrapper {
private ItemStack cover;
private ItemStack hollowCover;
private ItemStack hollowWideCover;
public RecipeWrapperHollowCover(ItemStack cover, ItemStack hollowCover) {
public RecipeWrapperHollowWideCover(ItemStack cover, ItemStack hollowWideCover) {
this.cover = ItemHandlerHelper.copyStackWithSize(cover, 1);
this.hollowCover = ItemHandlerHelper.copyStackWithSize(hollowCover, 8);
this.hollowWideCover = ItemHandlerHelper.copyStackWithSize(hollowWideCover, 8);
}
@Override
@@ -26,7 +26,7 @@ public class RecipeWrapperHollowCover implements IShapedCraftingRecipeWrapper {
}
ingredients.setInputs(ItemStack.class, inputs);
ingredients.setOutput(ItemStack.class, hollowCover);
ingredients.setOutput(ItemStack.class, hollowWideCover);
}
@Override

View File

@@ -6,6 +6,7 @@ import com.raoulvdberge.refinedstorage.api.network.security.Permission;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.ICoverable;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.Cover;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverType;
import com.raoulvdberge.refinedstorage.tile.TileNode;
import com.raoulvdberge.refinedstorage.util.WorldUtils;
import net.minecraft.block.Block;
@@ -143,6 +144,6 @@ public class ItemCover extends ItemBase {
}
protected Cover createCover(ItemStack stack) {
return new Cover(stack, false);
return new Cover(stack, CoverType.NORMAL);
}
}

View File

@@ -1,15 +0,0 @@
package com.raoulvdberge.refinedstorage.item;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.Cover;
import net.minecraft.item.ItemStack;
public class ItemHollowCover extends ItemCover {
public ItemHollowCover() {
super("hollow_cover");
}
@Override
protected Cover createCover(ItemStack stack) {
return new Cover(stack, true);
}
}

View File

@@ -0,0 +1,16 @@
package com.raoulvdberge.refinedstorage.item;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.Cover;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverType;
import net.minecraft.item.ItemStack;
public class ItemHollowWideCover extends ItemCover {
public ItemHollowWideCover() {
super("hollow_wide_cover");
}
@Override
protected Cover createCover(ItemStack stack) {
return new Cover(stack, CoverType.HOLLOW_WIDE);
}
}

View File

@@ -231,7 +231,7 @@ public class ProxyClient extends ProxyCommon {
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.QUARTZ_ENRICHED_IRON), 0, new ModelResourceLocation("refinedstorage:quartz_enriched_iron_block", "inventory"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.STORAGE_MONITOR), 0, new ModelResourceLocation("refinedstorage:storage_monitor", "connected=false,direction=north"));
ModelLoader.setCustomModelResourceLocation(RSItems.COVER, 0, new ModelResourceLocation("refinedstorage:cover", "inventory"));
ModelLoader.setCustomModelResourceLocation(RSItems.HOLLOW_COVER, 0, new ModelResourceLocation("refinedstorage:hollow_cover", "inventory"));
ModelLoader.setCustomModelResourceLocation(RSItems.HOLLOW_WIDE_COVER, 0, new ModelResourceLocation("refinedstorage:hollow_wide_cover", "inventory"));
ModelLoaderRegistry.registerLoader(new CustomModelLoaderDefault(new ResourceLocation(RS.ID, "disk_drive"), ModelDiskDrive::new));
ModelLoaderRegistry.registerLoader(new CustomModelLoaderDefault(new ResourceLocation(RS.ID, "disk_manipulator"), ModelDiskManipulator::new));

View File

@@ -43,7 +43,7 @@ import com.raoulvdberge.refinedstorage.integration.oc.IntegrationOC;
import com.raoulvdberge.refinedstorage.item.ItemProcessor;
import com.raoulvdberge.refinedstorage.network.*;
import com.raoulvdberge.refinedstorage.recipe.RecipeCover;
import com.raoulvdberge.refinedstorage.recipe.RecipeHollowCover;
import com.raoulvdberge.refinedstorage.recipe.RecipeHollowWideCover;
import com.raoulvdberge.refinedstorage.tile.*;
import com.raoulvdberge.refinedstorage.tile.craftingmonitor.TileCraftingMonitor;
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
@@ -264,7 +264,7 @@ public class ProxyCommon {
registerItem(RSItems.NETWORK_CARD);
registerItem(RSItems.SECURITY_CARD);
registerItem(RSItems.COVER);
registerItem(RSItems.HOLLOW_COVER);
registerItem(RSItems.HOLLOW_WIDE_COVER);
IntegrationInventorySorter.register();
}
@@ -312,7 +312,7 @@ public class ProxyCommon {
@SubscribeEvent
public void registerRecipes(RegistryEvent.Register<IRecipe> e) {
e.getRegistry().register(new RecipeCover().setRegistryName(new ResourceLocation(RS.ID, "cover")));
e.getRegistry().register(new RecipeHollowCover().setRegistryName(new ResourceLocation(RS.ID, "hollow_cover")));
e.getRegistry().register(new RecipeHollowWideCover().setRegistryName(new ResourceLocation(RS.ID, "hollow_wide_cover")));
}
@SubscribeEvent

View File

@@ -3,7 +3,7 @@ package com.raoulvdberge.refinedstorage.recipe;
import com.raoulvdberge.refinedstorage.RSItems;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager;
import com.raoulvdberge.refinedstorage.item.ItemCover;
import com.raoulvdberge.refinedstorage.item.ItemHollowCover;
import com.raoulvdberge.refinedstorage.item.ItemHollowWideCover;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
@@ -12,7 +12,7 @@ import net.minecraftforge.registries.IForgeRegistryEntry;
import javax.annotation.Nullable;
public class RecipeHollowCover extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
public class RecipeHollowWideCover extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
private boolean isValid(ItemStack slot, @Nullable ItemStack previousValidSlot) {
ItemStack currentCover = ItemCover.getItem(slot);
@@ -54,9 +54,9 @@ public class RecipeHollowCover extends IForgeRegistryEntry.Impl<IRecipe> impleme
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
ItemStack stack = new ItemStack(RSItems.HOLLOW_COVER, 8);
ItemStack stack = new ItemStack(RSItems.HOLLOW_WIDE_COVER, 8);
ItemHollowCover.setItem(stack, ItemCover.getItem(inv.getStackInSlot(0)));
ItemHollowWideCover.setItem(stack, ItemCover.getItem(inv.getStackInSlot(0)));
return stack;
}

View File

@@ -1,74 +1,100 @@
package com.raoulvdberge.refinedstorage.render;
import net.minecraft.client.renderer.block.model.*;
import com.raoulvdberge.refinedstorage.util.RenderUtils;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.renderer.vertex.VertexFormatElement;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
import org.lwjgl.util.vector.Vector3f;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
public class CubeBuilder {
private class CubeFace {
private TextureAtlasSprite sprite;
public enum UvRotation {
CLOCKWISE_0,
CLOCKWISE_90,
CLOCKWISE_180,
CLOCKWISE_270
}
private static class Uv {
private float xFrom;
private float xTo;
private float yFrom;
private float yTo;
}
CubeFace(TextureAtlasSprite sprite, float xFrom, float xTo, float yFrom, float yTo) {
public static class Face {
private EnumFacing face;
private TextureAtlasSprite sprite;
private int light;
private UvRotation uvRotation = UvRotation.CLOCKWISE_0;
public Face(EnumFacing face, TextureAtlasSprite sprite) {
this.face = face;
this.sprite = sprite;
this.xFrom = xFrom;
this.xTo = xTo;
this.yFrom = yFrom;
this.yTo = yTo;
}
}
private static final FaceBakery BAKERY = new FaceBakery();
public Face(EnumFacing face, TextureAtlasSprite sprite, UvRotation uvRotation) {
this(face, sprite);
this.uvRotation = uvRotation;
}
public Face(EnumFacing face, TextureAtlasSprite sprite, UvRotation uvRotation, int light) {
this(face, sprite, uvRotation);
this.light = light;
}
}
private Vector3f from;
private Vector3f to;
private Map<EnumFacing, CubeFace> faces = new HashMap<>();
private ModelRotation rotation = ModelRotation.X0_Y0;
private boolean uvLocked = true;
private VertexFormat format = DefaultVertexFormats.ITEM;
private Map<EnumFacing, Face> faces = new HashMap<>();
private int color = 0xFFFFFFFF;
public CubeBuilder from(float x, float y, float z) {
this.from = new Vector3f(x, y, z);
this.from = new Vector3f(x / 16, y / 16, z / 16);
return this;
}
public CubeBuilder to(float x, float y, float z) {
this.to = new Vector3f(x, y, z);
this.to = new Vector3f(x / 16, y / 16, z / 16);
return this;
}
public CubeBuilder face(EnumFacing face, float xFrom, float xTo, float yFrom, float yTo, TextureAtlasSprite sprite) {
faces.put(face, new CubeFace(
sprite,
xFrom,
xTo,
yFrom,
yTo
));
public CubeBuilder color(int color) {
this.color = color;
return this;
}
public CubeBuilder allFaces(float xFrom, float xTo, float yFrom, float yTo, TextureAtlasSprite sprite) {
public CubeBuilder lightmap() {
this.format = RenderUtils.getFormatWithLightMap(format);
return this;
}
public CubeBuilder addFaces(Function<EnumFacing, Face> faceSupplier) {
for (EnumFacing facing : EnumFacing.VALUES) {
face(facing, xFrom, xTo, yFrom, yTo, sprite);
addFace(faceSupplier.apply(facing));
}
return this;
}
public CubeBuilder rotate(ModelRotation rotation) {
this.rotation = rotation;
public CubeBuilder addFace(Face face) {
faces.put(face.face, face);
return this;
}
@@ -76,36 +102,251 @@ public class CubeBuilder {
public List<BakedQuad> bake() {
List<BakedQuad> quads = new ArrayList<>();
for (Map.Entry<EnumFacing, CubeFace> entry : faces.entrySet()) {
EnumFacing face = entry.getKey();
CubeFace faceData = entry.getValue();
BlockFaceUV uv = new BlockFaceUV(new float[]{
faceData.xFrom, faceData.yFrom, faceData.xTo, faceData.yTo
}, 0);
BlockPartFace part = new BlockPartFace(face, -1, null, uv);
quads.add(BAKERY.makeBakedQuad(
from,
to,
part,
faceData.sprite,
face,
rotation,
null,
uvLocked,
true
));
for (Map.Entry<EnumFacing, Face> entry : faces.entrySet()) {
quads.add(bakeFace(entry.getKey(), entry.getValue()));
}
return quads;
}
public CubeBuilder setUvLocked(boolean uvLocked) {
this.uvLocked = uvLocked;
private BakedQuad bakeFace(EnumFacing facing, Face cubeFace) {
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
return this;
builder.setTexture(cubeFace.sprite);
builder.setQuadOrientation(facing);
builder.setQuadTint(-1);
builder.setApplyDiffuseLighting(true);
Uv uv = getDefaultUv(facing, cubeFace.sprite, from.x, from.y, from.z, to.x, to.y, to.z);
switch (facing) {
case DOWN:
addVertexTopRight(builder, cubeFace, to.x, from.y, from.z, uv);
addVertexBottomRight(builder, cubeFace, to.x, from.y, to.z, uv);
addVertexBottomLeft(builder, cubeFace, from.x, from.y, to.z, uv);
addVertexTopLeft(builder, cubeFace, from.x, from.y, from.z, uv);
break;
case UP:
addVertexTopLeft(builder, cubeFace, from.x, to.y, from.z, uv);
addVertexBottomLeft(builder, cubeFace, from.x, to.y, to.z, uv);
addVertexBottomRight(builder, cubeFace, to.x, to.y, to.z, uv);
addVertexTopRight(builder, cubeFace, to.x, to.y, from.z, uv);
break;
case NORTH:
addVertexBottomRight(builder, cubeFace, to.x, to.y, from.z, uv);
addVertexTopRight(builder, cubeFace, to.x, from.y, from.z, uv);
addVertexTopLeft(builder, cubeFace, from.x, from.y, from.z, uv);
addVertexBottomLeft(builder, cubeFace, from.x, to.y, from.z, uv);
break;
case SOUTH:
addVertexBottomLeft(builder, cubeFace, from.x, to.y, to.z, uv);
addVertexTopLeft(builder, cubeFace, from.x, from.y, to.z, uv);
addVertexTopRight(builder, cubeFace, to.x, from.y, to.z, uv);
addVertexBottomRight(builder, cubeFace, to.x, to.y, to.z, uv);
break;
case WEST:
addVertexTopLeft(builder, cubeFace, from.x, from.y, from.z, uv);
addVertexTopRight(builder, cubeFace, from.x, from.y, to.z, uv);
addVertexBottomRight(builder, cubeFace, from.x, to.y, to.z, uv);
addVertexBottomLeft(builder, cubeFace, from.x, to.y, from.z, uv);
break;
case EAST:
addVertexBottomRight(builder, cubeFace, to.x, to.y, from.z, uv);
addVertexBottomLeft(builder, cubeFace, to.x, to.y, to.z, uv);
addVertexTopLeft(builder, cubeFace, to.x, from.y, to.z, uv);
addVertexTopRight(builder, cubeFace, to.x, from.y, from.z, uv);
break;
}
return builder.build();
}
private Uv getDefaultUv(EnumFacing face, TextureAtlasSprite texture, float fromX, float fromY, float fromZ, float toX, float toY, float toZ) {
Uv uv = new Uv();
switch (face) {
case DOWN:
uv.xFrom = texture.getInterpolatedU(fromX * 16);
uv.yFrom = texture.getInterpolatedV(16 - fromZ * 16);
uv.xTo = texture.getInterpolatedU(toX * 16);
uv.yTo = texture.getInterpolatedV(16 - toZ * 16);
break;
case UP:
uv.xFrom = texture.getInterpolatedU(fromX * 16);
uv.yFrom = texture.getInterpolatedV(fromZ * 16);
uv.xTo = texture.getInterpolatedU(toX * 16);
uv.yTo = texture.getInterpolatedV(toZ * 16);
break;
case NORTH:
uv.xFrom = texture.getInterpolatedU(16 - fromX * 16);
uv.yFrom = texture.getInterpolatedV(16 - fromY * 16);
uv.xTo = texture.getInterpolatedU(16 - toX * 16);
uv.yTo = texture.getInterpolatedV(16 - toY * 16);
break;
case SOUTH:
uv.xFrom = texture.getInterpolatedU(fromX * 16);
uv.yFrom = texture.getInterpolatedV(16 - fromY * 16);
uv.xTo = texture.getInterpolatedU(toX * 16);
uv.yTo = texture.getInterpolatedV(16 - toY * 16);
break;
case WEST:
uv.xFrom = texture.getInterpolatedU(fromZ * 16);
uv.yFrom = texture.getInterpolatedV(16 - fromY * 16);
uv.xTo = texture.getInterpolatedU(toZ * 16);
uv.yTo = texture.getInterpolatedV(16 - toY * 16);
break;
case EAST:
uv.xFrom = texture.getInterpolatedU(16 - toZ * 16);
uv.yFrom = texture.getInterpolatedV(16 - fromY * 16);
uv.xTo = texture.getInterpolatedU(16 - fromZ * 16);
uv.yTo = texture.getInterpolatedV(16 - toY * 16);
break;
}
return uv;
}
private void addVertexTopLeft(UnpackedBakedQuad.Builder builder, Face face, float x, float y, float z, Uv uv) {
float u;
float v;
switch (face.uvRotation) {
default:
case CLOCKWISE_0:
u = uv.xFrom;
v = uv.yFrom;
break;
case CLOCKWISE_90:
u = uv.xFrom;
v = uv.yTo;
break;
case CLOCKWISE_180:
u = uv.xTo;
v = uv.yTo;
break;
case CLOCKWISE_270:
u = uv.xTo;
v = uv.yFrom;
break;
}
addVertex(builder, face, x, y, z, u, v);
}
private void addVertexTopRight(UnpackedBakedQuad.Builder builder, Face face, float x, float y, float z, Uv uv) {
float u;
float v;
switch (face.uvRotation) {
default:
case CLOCKWISE_0:
u = uv.xTo;
v = uv.yFrom;
break;
case CLOCKWISE_90:
u = uv.xFrom;
v = uv.yFrom;
break;
case CLOCKWISE_180:
u = uv.xFrom;
v = uv.yTo;
break;
case CLOCKWISE_270:
u = uv.xTo;
v = uv.yTo;
break;
}
addVertex(builder, face, x, y, z, u, v);
}
private void addVertexBottomRight(UnpackedBakedQuad.Builder builder, Face face, float x, float y, float z, Uv uv) {
float u;
float v;
switch (face.uvRotation) {
default:
case CLOCKWISE_0:
u = uv.xTo;
v = uv.yTo;
break;
case CLOCKWISE_90:
u = uv.xTo;
v = uv.yFrom;
break;
case CLOCKWISE_180:
u = uv.xFrom;
v = uv.yFrom;
break;
case CLOCKWISE_270:
u = uv.xFrom;
v = uv.yTo;
break;
}
addVertex(builder, face, x, y, z, u, v);
}
private void addVertexBottomLeft(UnpackedBakedQuad.Builder builder, Face face, float x, float y, float z, Uv uv) {
float u;
float v;
switch (face.uvRotation) {
default:
case CLOCKWISE_0:
u = uv.xFrom;
v = uv.yTo;
break;
case CLOCKWISE_90:
u = uv.xTo;
v = uv.yTo;
break;
case CLOCKWISE_180:
u = uv.xTo;
v = uv.yFrom;
break;
case CLOCKWISE_270:
u = uv.xFrom;
v = uv.yFrom;
break;
}
addVertex(builder, face, x, y, z, u, v);
}
private void addVertex(UnpackedBakedQuad.Builder builder, Face face, float x, float y, float z, float u, float v) {
VertexFormat format = builder.getVertexFormat();
for (int i = 0; i < format.getElementCount(); i++) {
VertexFormatElement e = format.getElement(i);
switch (e.getUsage()) {
case POSITION:
builder.put(i, x, y, z);
break;
case NORMAL:
builder.put(i, face.face.getFrontOffsetX(), face.face.getFrontOffsetY(), face.face.getFrontOffsetZ());
break;
case COLOR:
float r = (color >> 16 & 0xFF) / 255f;
float g = (color >> 8 & 0xFF) / 255f;
float b = (color & 0xFF) / 255f;
float a = (color >> 24 & 0xFF) / 255f;
builder.put(i, r, g, b, a);
break;
case UV:
if (e.getIndex() == 0) {
builder.put(i, u, v);
} else {
builder.put(i, (float) (face.light * 0x20) / 0xFFFF, (float) (face.light * 0x20) / 0xFFFF);
}
break;
default:
builder.put(i);
break;
}
}
}
}

View File

@@ -0,0 +1,98 @@
package com.raoulvdberge.refinedstorage.render.constants;
import com.raoulvdberge.refinedstorage.util.RenderUtils;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.util.vector.Vector3f;
public final class ConstantsCable {
public static final AxisAlignedBB CORE_AABB = RenderUtils.getBounds(6, 6, 6, 10, 10, 10);
public static final AxisAlignedBB NORTH_AABB = RenderUtils.getBounds(6, 6, 0, 10, 10, 6);
public static final AxisAlignedBB EAST_AABB = RenderUtils.getBounds(10, 6, 6, 16, 10, 10);
public static final AxisAlignedBB SOUTH_AABB = RenderUtils.getBounds(6, 6, 10, 10, 10, 16);
public static final AxisAlignedBB WEST_AABB = RenderUtils.getBounds(0, 6, 6, 6, 10, 10);
public static final AxisAlignedBB UP_AABB = RenderUtils.getBounds(6, 10, 6, 10, 16, 10);
public static final AxisAlignedBB DOWN_AABB = RenderUtils.getBounds(6, 0, 6, 10, 6, 10);
public static final AxisAlignedBB HOLDER_NORTH_AABB = RenderUtils.getBounds(7, 7, 2, 9, 9, 6);
public static final AxisAlignedBB HOLDER_EAST_AABB = RenderUtils.getBounds(10, 7, 7, 14, 9, 9);
public static final AxisAlignedBB HOLDER_SOUTH_AABB = RenderUtils.getBounds(7, 7, 10, 9, 9, 14);
public static final AxisAlignedBB HOLDER_WEST_AABB = RenderUtils.getBounds(2, 7, 7, 6, 9, 9);
public static final AxisAlignedBB HOLDER_UP_AABB = RenderUtils.getBounds(7, 10, 7, 9, 14, 9);
public static final AxisAlignedBB HOLDER_DOWN_AABB = RenderUtils.getBounds(7, 2, 7, 9, 6, 9);
public static Pair<Vector3f, Vector3f> getCoverBounds(EnumFacing side) {
switch (side) {
case DOWN:
return Pair.of(
new Vector3f(0, 0, 0),
new Vector3f(16, 2, 16)
);
case UP:
return Pair.of(
new Vector3f(0, 14, 0),
new Vector3f(16, 16, 16)
);
case NORTH:
return Pair.of(
new Vector3f(0, 0, 0),
new Vector3f(16, 16, 2)
);
case SOUTH:
return Pair.of(
new Vector3f(16, 0, 16),
new Vector3f(0, 16, 14)
);
case WEST:
return Pair.of(
new Vector3f(0, 0, 0),
new Vector3f(2, 16, 16)
);
case EAST:
return Pair.of(
new Vector3f(14, 0, 0),
new Vector3f(16, 16, 16)
);
default:
return null;
}
}
public static Pair<Vector3f, Vector3f> getHolderBounds(EnumFacing side) {
switch (side) {
case DOWN:
return Pair.of(
new Vector3f(7, 2, 7),
new Vector3f(9, 6, 9)
);
case UP:
return Pair.of(
new Vector3f(7, 10, 7),
new Vector3f(9, 14, 9)
);
case NORTH:
return Pair.of(
new Vector3f(7, 7, 2),
new Vector3f(9, 9, 6)
);
case SOUTH:
return Pair.of(
new Vector3f(7, 7, 10),
new Vector3f(9, 9, 14)
);
case WEST:
return Pair.of(
new Vector3f(2, 7, 7),
new Vector3f(6, 9, 9)
);
case EAST:
return Pair.of(
new Vector3f(10, 7, 7),
new Vector3f(14, 9, 9)
);
default:
return null;
}
}
}

View File

@@ -0,0 +1,13 @@
package com.raoulvdberge.refinedstorage.render.constants;
import com.raoulvdberge.refinedstorage.util.RenderUtils;
import net.minecraft.util.math.AxisAlignedBB;
public final class ConstantsConstructor {
public static final AxisAlignedBB HEAD_NORTH_AABB = RenderUtils.getBounds(2, 2, 0, 14, 14, 2);
public static final AxisAlignedBB HEAD_EAST_AABB = RenderUtils.getBounds(14, 2, 2, 16, 14, 14);
public static final AxisAlignedBB HEAD_SOUTH_AABB = RenderUtils.getBounds(2, 2, 14, 14, 14, 16);
public static final AxisAlignedBB HEAD_WEST_AABB = RenderUtils.getBounds(0, 2, 2, 2, 14, 14);
public static final AxisAlignedBB HEAD_DOWN_AABB = RenderUtils.getBounds(2, 0, 2, 14, 2, 14);
public static final AxisAlignedBB HEAD_UP_AABB = RenderUtils.getBounds(2, 14, 2, 14, 16, 14);
}

View File

@@ -0,0 +1,7 @@
package com.raoulvdberge.refinedstorage.render.constants;
import net.minecraft.util.math.AxisAlignedBB;
public final class ConstantsDetector {
public static final AxisAlignedBB DETECTOR_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 5D / 16D, 1.0D);
}

View File

@@ -0,0 +1,25 @@
package com.raoulvdberge.refinedstorage.render.constants;
import com.raoulvdberge.refinedstorage.util.RenderUtils;
import net.minecraft.util.math.AxisAlignedBB;
public final class ConstantsExporter {
public static final AxisAlignedBB LINE_NORTH_1_AABB = RenderUtils.getBounds(6, 6, 0, 10, 10, 2);
public static final AxisAlignedBB LINE_NORTH_2_AABB = RenderUtils.getBounds(5, 5, 2, 11, 11, 4);
public static final AxisAlignedBB LINE_NORTH_3_AABB = RenderUtils.getBounds(3, 3, 4, 13, 13, 6);
public static final AxisAlignedBB LINE_EAST_1_AABB = RenderUtils.getBounds(14, 6, 6, 16, 10, 10);
public static final AxisAlignedBB LINE_EAST_2_AABB = RenderUtils.getBounds(12, 5, 5, 14, 11, 11);
public static final AxisAlignedBB LINE_EAST_3_AABB = RenderUtils.getBounds(10, 3, 3, 12, 13, 13);
public static final AxisAlignedBB LINE_SOUTH_1_AABB = RenderUtils.getBounds(6, 6, 14, 10, 10, 16);
public static final AxisAlignedBB LINE_SOUTH_2_AABB = RenderUtils.getBounds(5, 5, 12, 11, 11, 14);
public static final AxisAlignedBB LINE_SOUTH_3_AABB = RenderUtils.getBounds(3, 3, 10, 13, 13, 12);
public static final AxisAlignedBB LINE_WEST_1_AABB = RenderUtils.getBounds(0, 6, 6, 2, 10, 10);
public static final AxisAlignedBB LINE_WEST_2_AABB = RenderUtils.getBounds(2, 5, 5, 4, 11, 11);
public static final AxisAlignedBB LINE_WEST_3_AABB = RenderUtils.getBounds(4, 3, 3, 6, 13, 13);
public static final AxisAlignedBB LINE_UP_1_AABB = RenderUtils.getBounds(6, 14, 6, 10, 16, 10);
public static final AxisAlignedBB LINE_UP_2_AABB = RenderUtils.getBounds(5, 12, 5, 11, 14, 11);
public static final AxisAlignedBB LINE_UP_3_AABB = RenderUtils.getBounds(3, 10, 3, 13, 12, 13);
public static final AxisAlignedBB LINE_DOWN_1_AABB = RenderUtils.getBounds(6, 0, 6, 10, 2, 10);
public static final AxisAlignedBB LINE_DOWN_2_AABB = RenderUtils.getBounds(5, 2, 5, 11, 4, 11);
public static final AxisAlignedBB LINE_DOWN_3_AABB = RenderUtils.getBounds(3, 4, 3, 13, 6, 13);
}

View File

@@ -0,0 +1,13 @@
package com.raoulvdberge.refinedstorage.render.constants;
import com.raoulvdberge.refinedstorage.util.RenderUtils;
import net.minecraft.util.math.AxisAlignedBB;
public final class ConstantsExternalStorage {
public static final AxisAlignedBB HEAD_NORTH_AABB = RenderUtils.getBounds(3, 3, 0, 13, 13, 2);
public static final AxisAlignedBB HEAD_EAST_AABB = RenderUtils.getBounds(14, 3, 3, 16, 13, 13);
public static final AxisAlignedBB HEAD_SOUTH_AABB = RenderUtils.getBounds(3, 3, 14, 13, 13, 16);
public static final AxisAlignedBB HEAD_WEST_AABB = RenderUtils.getBounds(0, 3, 3, 2, 13, 13);
public static final AxisAlignedBB HEAD_UP_AABB = RenderUtils.getBounds(3, 14, 3, 13, 16, 13);
public static final AxisAlignedBB HEAD_DOWN_AABB = RenderUtils.getBounds(3, 0, 3, 13, 2, 13);
}

View File

@@ -0,0 +1,25 @@
package com.raoulvdberge.refinedstorage.render.constants;
import com.raoulvdberge.refinedstorage.util.RenderUtils;
import net.minecraft.util.math.AxisAlignedBB;
public final class ConstantsImporter {
public static final AxisAlignedBB LINE_NORTH_1_AABB = RenderUtils.getBounds(6, 6, 4, 10, 10, 6);
public static final AxisAlignedBB LINE_NORTH_2_AABB = RenderUtils.getBounds(5, 5, 2, 11, 11, 4);
public static final AxisAlignedBB LINE_NORTH_3_AABB = RenderUtils.getBounds(3, 3, 0, 13, 13, 2);
public static final AxisAlignedBB LINE_EAST_1_AABB = RenderUtils.getBounds(10, 6, 6, 12, 10, 10);
public static final AxisAlignedBB LINE_EAST_2_AABB = RenderUtils.getBounds(12, 5, 5, 14, 11, 11);
public static final AxisAlignedBB LINE_EAST_3_AABB = RenderUtils.getBounds(14, 3, 3, 16, 13, 13);
public static final AxisAlignedBB LINE_SOUTH_1_AABB = RenderUtils.getBounds(6, 6, 10, 10, 10, 12);
public static final AxisAlignedBB LINE_SOUTH_2_AABB = RenderUtils.getBounds(5, 5, 12, 11, 11, 14);
public static final AxisAlignedBB LINE_SOUTH_3_AABB = RenderUtils.getBounds(3, 3, 14, 13, 13, 16);
public static final AxisAlignedBB LINE_WEST_1_AABB = RenderUtils.getBounds(4, 6, 6, 6, 10, 10);
public static final AxisAlignedBB LINE_WEST_2_AABB = RenderUtils.getBounds(2, 5, 5, 4, 11, 11);
public static final AxisAlignedBB LINE_WEST_3_AABB = RenderUtils.getBounds(0, 3, 3, 2, 13, 13);
public static final AxisAlignedBB LINE_UP_1_AABB = RenderUtils.getBounds(6, 10, 6, 10, 12, 10);
public static final AxisAlignedBB LINE_UP_2_AABB = RenderUtils.getBounds(5, 12, 5, 11, 14, 11);
public static final AxisAlignedBB LINE_UP_3_AABB = RenderUtils.getBounds(3, 14, 3, 13, 16, 13);
public static final AxisAlignedBB LINE_DOWN_1_AABB = RenderUtils.getBounds(6, 4, 6, 10, 6, 10);
public static final AxisAlignedBB LINE_DOWN_2_AABB = RenderUtils.getBounds(5, 2, 5, 11, 4, 11);
public static final AxisAlignedBB LINE_DOWN_3_AABB = RenderUtils.getBounds(3, 0, 3, 13, 2, 13);
}

View File

@@ -0,0 +1,7 @@
package com.raoulvdberge.refinedstorage.render.constants;
import net.minecraft.util.math.AxisAlignedBB;
public final class ConstantsPortableGrid {
public static final AxisAlignedBB PORTABLE_GRID_AABB = new AxisAlignedBB(0, 0, 0, 1, 13.2F / 16F, 1);
}

View File

@@ -0,0 +1,8 @@
package com.raoulvdberge.refinedstorage.render.constants;
import net.minecraft.util.math.AxisAlignedBB;
public final class ConstantsWirelessTransmitter {
// From BlockTorch
public static final AxisAlignedBB WIRELESS_TRANSMITTER_AABB = new AxisAlignedBB(0.4000000059604645D, 0.0D, 0.4000000059604645D, 0.6000000238418579D, 0.6000000238418579D, 0.6000000238418579D);
}

View File

@@ -1,5 +1,6 @@
package com.raoulvdberge.refinedstorage.render.model;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverType;
import com.raoulvdberge.refinedstorage.render.model.baked.BakedModelCover;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
@@ -11,14 +12,14 @@ import net.minecraftforge.common.model.IModelState;
import java.util.function.Function;
public class ModelCover implements IModel {
private boolean hollow;
private CoverType coverType;
public ModelCover(boolean hollow) {
this.hollow = hollow;
public ModelCover(CoverType coverType) {
this.coverType = coverType;
}
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
return new BakedModelCover(null, hollow);
return new BakedModelCover(null, coverType);
}
}

View File

@@ -5,16 +5,19 @@ import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.Cover;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager;
import com.raoulvdberge.refinedstorage.block.BlockCable;
import com.raoulvdberge.refinedstorage.render.CubeBuilder;
import com.raoulvdberge.refinedstorage.render.constants.ConstantsCable;
import com.raoulvdberge.refinedstorage.util.RenderUtils;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.*;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.property.IExtendedBlockState;
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.util.vector.Vector3f;
import javax.annotation.Nullable;
import javax.vecmath.Matrix4f;
@@ -43,343 +46,300 @@ public class BakedModelCableCover implements IBakedModel {
boolean hasEast = s.getValue(BlockCable.COVER_EAST) != null;
boolean hasWest = s.getValue(BlockCable.COVER_WEST) != null;
addCoverOrHollow(quads, s.getValue(BlockCable.COVER_NORTH), EnumFacing.NORTH, side, rand, hasUp, hasDown, hasEast, hasWest, true);
addCoverOrHollow(quads, s.getValue(BlockCable.COVER_SOUTH), EnumFacing.SOUTH, side, rand, hasUp, hasDown, hasEast, hasWest, true);
addCoverOrHollow(quads, s.getValue(BlockCable.COVER_EAST), EnumFacing.EAST, side, rand, hasUp, hasDown, hasEast, hasWest, true);
addCoverOrHollow(quads, s.getValue(BlockCable.COVER_WEST), EnumFacing.WEST, side, rand, hasUp, hasDown, hasEast, hasWest, true);
addCoverOrHollow(quads, s.getValue(BlockCable.COVER_DOWN), EnumFacing.DOWN, side, rand, hasUp, hasDown, hasEast, hasWest, true);
addCoverOrHollow(quads, s.getValue(BlockCable.COVER_UP), EnumFacing.UP, side, rand, hasUp, hasDown, hasEast, hasWest, true);
addCover(quads, s.getValue(BlockCable.COVER_NORTH), EnumFacing.NORTH, side, rand, hasUp, hasDown, hasEast, hasWest, true);
addCover(quads, s.getValue(BlockCable.COVER_SOUTH), EnumFacing.SOUTH, side, rand, hasUp, hasDown, hasEast, hasWest, true);
addCover(quads, s.getValue(BlockCable.COVER_EAST), EnumFacing.EAST, side, rand, hasUp, hasDown, hasEast, hasWest, true);
addCover(quads, s.getValue(BlockCable.COVER_WEST), EnumFacing.WEST, side, rand, hasUp, hasDown, hasEast, hasWest, true);
addCover(quads, s.getValue(BlockCable.COVER_DOWN), EnumFacing.DOWN, side, rand, hasUp, hasDown, hasEast, hasWest, true);
addCover(quads, s.getValue(BlockCable.COVER_UP), EnumFacing.UP, side, rand, hasUp, hasDown, hasEast, hasWest, true);
}
return quads;
}
protected static void addCoverOrHollow(List<BakedQuad> quads, @Nullable Cover cover, EnumFacing coverSide, EnumFacing side, long rand, boolean hasUp, boolean hasDown, boolean hasEast, boolean hasWest, boolean handle) {
protected static void addCover(List<BakedQuad> quads, @Nullable Cover cover, EnumFacing coverSide, EnumFacing side, long rand, boolean hasUp, boolean hasDown, boolean hasEast, boolean hasWest, boolean handle) {
if (cover == null) {
return;
}
if (cover.isHollow()) {
addHollowCover(quads, cover, coverSide, side, rand, hasUp, hasDown, hasEast, hasWest);
} else {
addCover(quads, cover, coverSide, side, rand, hasUp, hasDown, hasEast, hasWest, handle);
}
}
private static void addCover(List<BakedQuad> quads, Cover cover, EnumFacing coverSide, EnumFacing side, long rand, boolean hasUp, boolean hasDown, boolean hasEast, boolean hasWest, boolean handle) {
IBlockState coverState = CoverManager.getBlockState(cover.getStack());
if (coverState == null) {
return;
}
IBakedModel coverModel = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(coverState);
TextureAtlasSprite sprite = RenderUtils.getSprite(Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(coverState), coverState, side, rand);
TextureAtlasSprite sprite = getSprite(coverModel, coverState, side, rand);
switch (cover.getType()) {
case NORMAL:
addNormalCover(quads, sprite, coverSide, hasUp, hasDown, hasEast, hasWest, handle);
break;
case HOLLOW:
break;
case HOLLOW_WIDE:
addHollowWideCover(quads, sprite, coverSide, hasUp, hasDown, hasEast, hasWest);
break;
}
}
ModelRotation rotation = ModelRotation.X0_Y0;
int xStart = 0;
int xEnd = 16;
int xTexStart = 0;
int xTexEnd = 16;
int xTexBackStart = 0;
int xTexBackEnd = 16;
int yStart = 0;
int yEnd = 16;
int yTexStart = 0;
int yTexEnd = 16;
private static void addNormalCover(List<BakedQuad> quads, TextureAtlasSprite sprite, EnumFacing coverSide, boolean hasUp, boolean hasDown, boolean hasEast, boolean hasWest, boolean handle) {
Pair<Vector3f, Vector3f> bounds = ConstantsCable.getCoverBounds(coverSide);
if (coverSide == EnumFacing.NORTH) {
if (hasWest) {
xStart = 2;
xTexEnd = 14;
xTexBackStart = 2;
bounds.getLeft().setX(2);
}
if (hasEast) {
xEnd = 14;
xTexStart = 2;
xTexBackEnd = 14;
bounds.getRight().setX(14);
}
} else if (coverSide == EnumFacing.SOUTH) {
rotation = ModelRotation.X0_Y180;
if (hasWest) {
xEnd = 14;
xTexStart = 2;
xTexBackEnd = 14;
bounds.getRight().setX(2);
}
if (hasEast) {
xStart = 2;
xTexEnd = 14;
xTexBackStart = 2;
bounds.getLeft().setX(14);
}
} else if (coverSide == EnumFacing.EAST) {
rotation = ModelRotation.X0_Y90;
} else if (coverSide == EnumFacing.WEST) {
rotation = ModelRotation.X0_Y270;
} else if (coverSide == EnumFacing.DOWN) {
rotation = ModelRotation.X90_Y0;
} else if (coverSide == EnumFacing.UP) {
rotation = ModelRotation.X270_Y0;
}
if (coverSide.getAxis() != EnumFacing.Axis.Y) {
if (hasDown) {
yStart = 2;
yTexEnd = 14;
bounds.getLeft().setY(2);
}
if (hasUp) {
yEnd = 14;
yTexStart = 2;
bounds.getRight().setY(14);
}
}
quads.addAll(new CubeBuilder()
.from(xStart, yStart, 0)
.to(xEnd, yEnd, 2)
.face(EnumFacing.NORTH, xTexStart, xTexEnd, yTexStart, yTexEnd, sprite)
.face(EnumFacing.SOUTH, xTexBackStart, xTexBackEnd, yTexStart, yTexEnd, sprite)
.face(EnumFacing.UP, 0, 16, 0, 2, sprite)
.face(EnumFacing.DOWN, 0, 16, 14, 16, sprite)
.face(EnumFacing.EAST, 14, 16, yTexStart, yTexEnd, sprite)
.face(EnumFacing.WEST, 0, 2, yTexStart, yTexEnd, sprite)
.rotate(rotation)
.from(bounds.getLeft().getX(), bounds.getLeft().getY(), bounds.getLeft().getZ())
.to(bounds.getRight().getX(), bounds.getRight().getY(), bounds.getRight().getZ())
.addFaces(face -> new CubeBuilder.Face(face, sprite))
.bake()
);
if (handle) {
addHandle(quads, rotation);
}
}
private static void addHollowCover(List<BakedQuad> quads, Cover cover, EnumFacing coverSide, EnumFacing side, long rand, boolean hasUp, boolean hasDown, boolean hasEast, boolean hasWest) {
IBlockState coverState = CoverManager.getBlockState(cover.getStack());
if (coverState == null) {
return;
}
IBakedModel coverModel = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(coverState);
TextureAtlasSprite sprite = getSprite(coverModel, coverState, side, rand);
ModelRotation rotation = ModelRotation.X0_Y0;
int xLeftStart = 13;
int xLeftEnd = 16;
int xLeftTexStart = 0;
int xLeftTexEnd = 3;
int xLeftTexBackStart = 13;
int xLeftTexBackEnd = 16;
int xRightStart = 0;
int xRightEnd = 3;
int xRightTexStart = 13;
int xRightTexEnd = 16;
int xRightTexBackStart = 0;
int xRightTexBackEnd = 3;
int yStart = 0;
int yEnd = 16;
int yTexStart = 0;
int yTexEnd = 16;
if (coverSide == EnumFacing.NORTH) {
if (hasEast) {
xLeftEnd = 14;
xLeftTexStart = 2;
xLeftTexBackEnd = 14;
}
if (hasWest) {
xRightStart = 2;
xRightTexEnd = 14;
xRightTexBackStart = 2;
}
} else if (coverSide == EnumFacing.SOUTH) {
rotation = ModelRotation.X0_Y180;
if (hasWest) {
xLeftEnd = 14;
xLeftTexStart = 2;
xLeftTexBackEnd = 14;
}
if (hasEast) {
xRightStart = 2;
xRightTexEnd = 14;
xRightTexBackStart = 2;
}
} else if (coverSide == EnumFacing.EAST) {
rotation = ModelRotation.X0_Y90;
} else if (coverSide == EnumFacing.WEST) {
rotation = ModelRotation.X0_Y270;
} else if (coverSide == EnumFacing.DOWN) {
rotation = ModelRotation.X90_Y0;
} else if (coverSide == EnumFacing.UP) {
rotation = ModelRotation.X270_Y0;
}
if (coverSide.getAxis() != EnumFacing.Axis.Y) {
if (hasDown) {
yStart = 2;
yTexEnd = 14;
}
if (hasUp) {
yEnd = 14;
yTexStart = 2;
}
}
quads.addAll(new CubeBuilder()
.from(xLeftStart, yStart, 0)
.to(xLeftEnd, yEnd, 2)
.face(EnumFacing.NORTH, xLeftTexStart, xLeftTexEnd, yTexStart, yTexEnd, sprite)
.face(EnumFacing.SOUTH, xLeftTexBackStart, xLeftTexBackEnd, yTexStart, yTexEnd, sprite)
.face(EnumFacing.UP, 13, 16, 0, 2, sprite)
.face(EnumFacing.DOWN, 13, 16, 14, 16, sprite)
.face(EnumFacing.EAST, 14, 16, yTexStart, yTexEnd, sprite)
.face(EnumFacing.WEST, 0, 2, yTexStart, yTexEnd, sprite)
.rotate(rotation)
.bake()
);
quads.addAll(new CubeBuilder()
.from(xRightStart, yStart, 0)
.to(xRightEnd, yEnd, 2)
.face(EnumFacing.NORTH, xRightTexStart, xRightTexEnd, yTexStart, yTexEnd, sprite)
.face(EnumFacing.SOUTH, xRightTexBackStart, xRightTexBackEnd, yTexStart, yTexEnd, sprite)
.face(EnumFacing.UP, 0, 3, 0, 2, sprite)
.face(EnumFacing.DOWN, 0, 3, 14, 16, sprite)
.face(EnumFacing.EAST, 14, 16, yTexStart, yTexEnd, sprite)
.face(EnumFacing.WEST, 0, 2, yTexStart, yTexEnd, sprite)
.rotate(rotation)
.bake()
);
quads.addAll(new CubeBuilder()
.from(3, yStart, 0)
.to(13, 3, 2)
.face(EnumFacing.NORTH, 3, 13, 13, yTexEnd, sprite)
.face(EnumFacing.SOUTH, 3, 13, 13, yTexEnd, sprite)
.face(EnumFacing.UP, 3, 13, 0, 2, sprite)
.face(EnumFacing.DOWN, 3, 13, 14, 16, sprite)
.rotate(rotation)
.bake()
);
quads.addAll(new CubeBuilder()
.from(3, 13, 0)
.to(13, yEnd, 2)
.face(EnumFacing.NORTH, 3, 13, yTexStart, 3, sprite)
.face(EnumFacing.SOUTH, 3, 13, yTexStart, 3, sprite)
.face(EnumFacing.UP, 3, 13, 0, 2, sprite)
.face(EnumFacing.DOWN, 3, 13, 14, 16, sprite)
.rotate(rotation)
.bake()
);
}
private static void addHandle(List<BakedQuad> quads, ModelRotation rotation) {
if (GREY_SPRITE == null) {
GREY_SPRITE = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(RS.ID + ":blocks/generic_grey");
}
bounds = ConstantsCable.getHolderBounds(coverSide);
quads.addAll(new CubeBuilder()
.from(7, 7, 2)
.to(9, 9, 6)
.from(bounds.getLeft().getX(), bounds.getLeft().getY(), bounds.getLeft().getZ())
.to(bounds.getRight().getX(), bounds.getRight().getY(), bounds.getRight().getZ())
.face(EnumFacing.NORTH, 0, 0, 4, 4, GREY_SPRITE)
.face(EnumFacing.EAST, 0, 0, 2, 4, GREY_SPRITE)
.face(EnumFacing.SOUTH, 0, 0, 4, 4, GREY_SPRITE)
.face(EnumFacing.WEST, 0, 0, 2, 4, GREY_SPRITE)
.face(EnumFacing.UP, 0, 0, 4, 2, GREY_SPRITE)
.face(EnumFacing.DOWN, 0, 0, 4, 2, GREY_SPRITE)
.rotate(rotation)
.setUvLocked(false)
.addFaces(face -> new CubeBuilder.Face(face, GREY_SPRITE))
.bake()
);
}
private static TextureAtlasSprite getSprite(IBakedModel coverModel, IBlockState coverState, EnumFacing facing, long rand) {
TextureAtlasSprite sprite = null;
BlockRenderLayer originalLayer = MinecraftForgeClient.getRenderLayer();
try {
for (BlockRenderLayer layer : BlockRenderLayer.values()) {
ForgeHooksClient.setRenderLayer(layer);
for (BakedQuad bakedQuad : coverModel.getQuads(coverState, facing, rand)) {
return bakedQuad.getSprite();
}
for (BakedQuad bakedQuad : coverModel.getQuads(coverState, null, rand)) {
if (sprite == null) {
sprite = bakedQuad.getSprite();
private static void addHollowWideCover(List<BakedQuad> quads, TextureAtlasSprite sprite, EnumFacing coverSide, boolean hasUp, boolean hasDown, boolean hasEast, boolean hasWest) {
Pair<Vector3f, Vector3f> bounds = ConstantsCable.getCoverBounds(coverSide);
if (coverSide.getAxis() != EnumFacing.Axis.Y) {
if (hasDown) {
bounds.getLeft().setY(2);
}
if (bakedQuad.getFace() == facing) {
return bakedQuad.getSprite();
}
}
}
} catch (Exception e) {
// NO OP
} finally {
ForgeHooksClient.setRenderLayer(originalLayer);
}
if (sprite == null) {
try {
sprite = coverModel.getParticleTexture();
} catch (Exception e) {
// NO OP
if (hasUp) {
bounds.getRight().setY(14);
}
}
if (sprite == null) {
sprite = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
// Right
if (coverSide == EnumFacing.NORTH) {
if (hasWest) {
bounds.getLeft().setX(2);
} else {
bounds.getLeft().setX(0);
}
return sprite;
bounds.getRight().setX(3);
} else if (coverSide == EnumFacing.SOUTH) {
if (hasEast) {
bounds.getLeft().setX(14);
} else {
bounds.getLeft().setX(16);
}
bounds.getRight().setX(13);
} else if (coverSide == EnumFacing.EAST) {
bounds.getLeft().setZ(0);
bounds.getRight().setZ(3);
} else if (coverSide == EnumFacing.WEST) {
bounds.getLeft().setZ(13);
bounds.getRight().setZ(16);
} else if (coverSide == EnumFacing.DOWN || coverSide == EnumFacing.UP) {
bounds.getLeft().setZ(13);
bounds.getRight().setZ(16);
}
quads.addAll(new CubeBuilder()
.from(bounds.getLeft().getX(), bounds.getLeft().getY(), bounds.getLeft().getZ())
.to(bounds.getRight().getX(), bounds.getRight().getY(), bounds.getRight().getZ())
.addFaces(face -> new CubeBuilder.Face(face, sprite))
.bake()
);
// Left
if (coverSide == EnumFacing.NORTH) {
if (hasEast) {
bounds.getRight().setX(14);
} else {
bounds.getRight().setX(16);
}
bounds.getLeft().setX(13);
} else if (coverSide == EnumFacing.SOUTH) {
if (hasWest) {
bounds.getRight().setX(2);
} else {
bounds.getRight().setX(0);
}
bounds.getLeft().setX(3);
} else if (coverSide == EnumFacing.EAST) {
bounds.getRight().setZ(16);
bounds.getLeft().setZ(13);
} else if (coverSide == EnumFacing.WEST) {
bounds.getLeft().setZ(0);
bounds.getRight().setZ(3);
} else if (coverSide == EnumFacing.DOWN || coverSide == EnumFacing.UP) {
bounds.getLeft().setZ(0);
bounds.getRight().setZ(3);
}
quads.addAll(new CubeBuilder()
.from(bounds.getLeft().getX(), bounds.getLeft().getY(), bounds.getLeft().getZ())
.to(bounds.getRight().getX(), bounds.getRight().getY(), bounds.getRight().getZ())
.addFaces(face -> new CubeBuilder.Face(face, sprite))
.bake()
);
// Bottom
if (coverSide == EnumFacing.NORTH) {
bounds.getLeft().setX(3);
bounds.getRight().setX(13);
if (hasDown) {
bounds.getLeft().setY(2);
} else {
bounds.getLeft().y = 0;
}
bounds.getRight().y = 3;
} else if (coverSide == EnumFacing.SOUTH) {
bounds.getRight().setX(3);
bounds.getLeft().setX(13);
if (hasDown) {
bounds.getLeft().setY(2);
} else {
bounds.getLeft().y = 0;
}
bounds.getRight().y = 3;
} else if (coverSide == EnumFacing.EAST) {
bounds.getLeft().setZ(3);
bounds.getRight().setZ(13);
if (hasDown) {
bounds.getLeft().setY(2);
} else {
bounds.getLeft().y = 0;
}
bounds.getRight().y = 3;
} else if (coverSide == EnumFacing.WEST) {
bounds.getLeft().setZ(3);
bounds.getRight().setZ(13);
if (hasDown) {
bounds.getLeft().setY(2);
} else {
bounds.getLeft().y = 0;
}
bounds.getRight().y = 3;
} else if (coverSide == EnumFacing.DOWN || coverSide == EnumFacing.UP) {
bounds.getLeft().setZ(3);
bounds.getRight().setZ(13);
bounds.getLeft().setX(0);
bounds.getRight().setX(3);
}
quads.addAll(new CubeBuilder()
.from(bounds.getLeft().getX(), bounds.getLeft().getY(), bounds.getLeft().getZ())
.to(bounds.getRight().getX(), bounds.getRight().getY(), bounds.getRight().getZ())
.addFaces(face -> new CubeBuilder.Face(face, sprite))
.bake()
);
// Up
if (coverSide == EnumFacing.NORTH) {
bounds.getLeft().setX(3);
bounds.getRight().setX(13);
if (hasUp) {
bounds.getRight().setY(14);
} else {
bounds.getRight().y = 16;
}
bounds.getLeft().y = 13;
} else if (coverSide == EnumFacing.SOUTH) {
bounds.getRight().setX(3);
bounds.getLeft().setX(13);
if (hasUp) {
bounds.getRight().setY(14);
} else {
bounds.getRight().y = 16;
}
bounds.getLeft().y = 13;
} else if (coverSide == EnumFacing.EAST) {
bounds.getLeft().setZ(3);
bounds.getRight().setZ(13);
if (hasUp) {
bounds.getRight().setY(14);
} else {
bounds.getRight().y = 16;
}
bounds.getLeft().y = 13;
} else if (coverSide == EnumFacing.WEST) {
bounds.getLeft().setZ(3);
bounds.getRight().setZ(13);
if (hasUp) {
bounds.getRight().setY(14);
} else {
bounds.getRight().y = 16;
}
bounds.getLeft().y = 13;
} else if (coverSide == EnumFacing.DOWN || coverSide == EnumFacing.UP) {
bounds.getLeft().setZ(3);
bounds.getRight().setZ(13);
bounds.getLeft().setX(13);
bounds.getRight().setX(16);
}
quads.addAll(new CubeBuilder()
.from(bounds.getLeft().getX(), bounds.getLeft().getY(), bounds.getLeft().getZ())
.to(bounds.getRight().getX(), bounds.getRight().getY(), bounds.getRight().getZ())
.addFaces(face -> new CubeBuilder.Face(face, sprite))
.bake()
);
}
@Override

View File

@@ -4,6 +4,7 @@ import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.Cover;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverType;
import com.raoulvdberge.refinedstorage.item.ItemCover;
import com.raoulvdberge.refinedstorage.util.RenderUtils;
import net.minecraft.block.state.IBlockState;
@@ -31,13 +32,13 @@ public class BakedModelCover extends BakedModelCableCover {
private IBlockState state;
private ItemStack stack;
private EnumFacing side;
private boolean hollow;
private CoverType type;
CacheKey(IBlockState state, ItemStack stack, EnumFacing side, boolean hollow) {
CacheKey(IBlockState state, ItemStack stack, EnumFacing side, CoverType type) {
this.state = state;
this.stack = stack;
this.side = side;
this.hollow = hollow;
this.type = type;
}
@Override
@@ -52,7 +53,7 @@ public class BakedModelCover extends BakedModelCableCover {
BakedModelCover.CacheKey cacheKey = (BakedModelCover.CacheKey) o;
return cacheKey.hollow == hollow && cacheKey.stack.getItem() == stack.getItem() && cacheKey.stack.getItemDamage() == stack.getItemDamage() && cacheKey.side == side && Objects.equals(cacheKey.state, state);
return cacheKey.type == type && cacheKey.stack.getItem() == stack.getItem() && cacheKey.stack.getItemDamage() == stack.getItemDamage() && cacheKey.side == side && Objects.equals(cacheKey.state, state);
}
@Override
@@ -61,7 +62,7 @@ public class BakedModelCover extends BakedModelCableCover {
result = 31 * result + stack.getItemDamage();
result = 31 * result + (side != null ? side.hashCode() : 0);
result = 31 * result + (state != null ? state.hashCode() : 0);
result = 31 * result + Boolean.hashCode(hollow);
result = 31 * result + type.hashCode();
return result;
}
}
@@ -71,7 +72,7 @@ public class BakedModelCover extends BakedModelCableCover {
public List<BakedQuad> load(CacheKey key) {
List<BakedQuad> quads = new ArrayList<>();
addCoverOrHollow(quads, new Cover(key.stack, key.hollow), EnumFacing.NORTH, key.side, 0, false, false, false, false, false);
addCover(quads, new Cover(key.stack, key.type), EnumFacing.NORTH, key.side, 0, false, false, false, false, false);
return quads;
}
@@ -79,13 +80,13 @@ public class BakedModelCover extends BakedModelCableCover {
@Nullable
private ItemStack stack;
private boolean hollow;
private CoverType type;
public BakedModelCover(@Nullable ItemStack stack, boolean hollow) {
public BakedModelCover(@Nullable ItemStack stack, CoverType type) {
super(null);
this.stack = stack;
this.hollow = hollow;
this.type = type;
}
@Override
@@ -94,7 +95,7 @@ public class BakedModelCover extends BakedModelCableCover {
return Collections.emptyList();
}
CacheKey key = new CacheKey(state, ItemCover.getItem(stack), side, hollow);
CacheKey key = new CacheKey(state, ItemCover.getItem(stack), side, type);
return CACHE.getUnchecked(key);
}
@@ -108,7 +109,7 @@ public class BakedModelCover extends BakedModelCableCover {
return new ItemOverrideList(Collections.emptyList()) {
@Override
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity) {
return new BakedModelCover(stack, hollow);
return new BakedModelCover(stack, type);
}
};
}

View File

@@ -1,21 +1,36 @@
package com.raoulvdberge.refinedstorage.render.model.loader;
import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverType;
import com.raoulvdberge.refinedstorage.render.model.ModelCover;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ICustomModelLoader;
import net.minecraftforge.client.model.IModel;
import javax.annotation.Nullable;
public class CustomModelLoaderCover implements ICustomModelLoader {
@Override
public boolean accepts(ResourceLocation modelLocation) {
return modelLocation.getResourceDomain().equals(RS.ID) && (modelLocation.getResourcePath().equals("cover") || modelLocation.getResourcePath().equals("hollow_cover"));
return modelLocation.getResourceDomain().equals(RS.ID) && getType(modelLocation) != null;
}
@Override
public IModel loadModel(ResourceLocation modelLocation) {
return new ModelCover(modelLocation.getResourcePath().equals("hollow_cover"));
return new ModelCover(getType(modelLocation));
}
@Nullable
private CoverType getType(ResourceLocation modelLocation) {
switch (modelLocation.getResourcePath()) {
case "cover":
return CoverType.NORMAL;
case "hollow_wide_cover":
return CoverType.HOLLOW_WIDE;
default:
return null;
}
}
@Override

View File

@@ -2,31 +2,41 @@ package com.raoulvdberge.refinedstorage.util;
import com.google.common.collect.ImmutableMap;
import com.raoulvdberge.refinedstorage.apiimpl.API;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.client.event.RenderTooltipEvent;
import net.minecraftforge.common.ForgeModContainer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.model.TRSRTransformation;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.client.config.GuiUtils;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@@ -48,6 +58,8 @@ public final class RenderUtils {
private static ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> DEFAULT_ITEM_TRANSFORM;
private static ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> DEFAULT_BLOCK_TRANSFORM;
private static final VertexFormat ITEM_FORMAT_WITH_LIGHTMAP = new VertexFormat(DefaultVertexFormats.ITEM).addElement(DefaultVertexFormats.TEX_2S);
public static AxisAlignedBB getBounds(int fromX, int fromY, int fromZ, int toX, int toY, int toZ) {
return new AxisAlignedBB((float) fromX / 16F, (float) fromY / 16F, (float) fromZ / 16F, (float) toX / 16F, (float) toY / 16F, (float) toZ / 16F);
}
@@ -483,4 +495,70 @@ public final class RenderUtils {
return lines;
}
@SideOnly(Side.CLIENT)
public static VertexFormat getFormatWithLightMap(VertexFormat format) {
if (FMLClientHandler.instance().hasOptifine() || !ForgeModContainer.forgeLightPipelineEnabled) {
return format;
}
if (format == DefaultVertexFormats.BLOCK) {
return DefaultVertexFormats.BLOCK;
} else if (format == DefaultVertexFormats.ITEM) {
return ITEM_FORMAT_WITH_LIGHTMAP;
} else if (!format.hasUvOffset(1)) {
VertexFormat result = new VertexFormat(format);
result.addElement(DefaultVertexFormats.TEX_2S);
return result;
}
return format;
}
@SideOnly(Side.CLIENT)
public static TextureAtlasSprite getSprite(IBakedModel coverModel, IBlockState coverState, EnumFacing facing, long rand) {
TextureAtlasSprite sprite = null;
BlockRenderLayer originalLayer = MinecraftForgeClient.getRenderLayer();
try {
for (BlockRenderLayer layer : BlockRenderLayer.values()) {
ForgeHooksClient.setRenderLayer(layer);
for (BakedQuad bakedQuad : coverModel.getQuads(coverState, facing, rand)) {
return bakedQuad.getSprite();
}
for (BakedQuad bakedQuad : coverModel.getQuads(coverState, null, rand)) {
if (sprite == null) {
sprite = bakedQuad.getSprite();
}
if (bakedQuad.getFace() == facing) {
return bakedQuad.getSprite();
}
}
}
} catch (Exception e) {
// NO OP
} finally {
ForgeHooksClient.setRenderLayer(originalLayer);
}
if (sprite == null) {
try {
sprite = coverModel.getParticleTexture();
} catch (Exception e) {
// NO OP
}
}
if (sprite == null) {
sprite = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
}
return sprite;
}
}

View File

@@ -292,7 +292,7 @@ item.refinedstorage:security_card.name=Security Card
item.refinedstorage:security_card.owner=Bound to: %s
item.refinedstorage:cutting_tool.name=Cutting Tool
item.refinedstorage:cover.name=Cover
item.refinedstorage:hollow_cover.name=Hollow Cover
item.refinedstorage:hollow_wide_cover.name=Hollow Wide Cover
commands.refinedstorage.createdisk.usage=/createdisk <player> <item> <metadata> <id>
commands.refinedstorage.createdisk.error.notADisk=The given disk item is not a disk.