Single-component panels are complete, just docs and probably bugfixes to do
This commit is contained in:
parent
92b00f199c
commit
1def161870
|
@ -25,6 +25,7 @@ import malte0811.industrialWires.blocks.IMetaEnum;
|
|||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.controlpanel.PanelUtils;
|
||||
import malte0811.industrialWires.controlpanel.PropertyComponents;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
|
@ -48,6 +49,7 @@ import net.minecraftforge.common.property.IExtendedBlockState;
|
|||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
||||
|
@ -67,6 +69,7 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) {
|
||||
switch (state.getValue(type)) {
|
||||
case TOP:
|
||||
case SINGLE_COMP:
|
||||
return layer == BlockRenderLayer.CUTOUT;
|
||||
case RS_WIRE:
|
||||
return layer == BlockRenderLayer.TRANSLUCENT || layer == BlockRenderLayer.SOLID;
|
||||
|
@ -117,10 +120,11 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess worldIn, BlockPos pos) {
|
||||
state = super.getActualState(state, worldIn, pos);
|
||||
TileEntity te = worldIn.getTileEntity(pos);
|
||||
if (te instanceof TileEntityPanel) {
|
||||
if (te instanceof TileEntityComponentPanel) {
|
||||
state.withProperty(type, BlockTypes_Panel.SINGLE_COMP);
|
||||
} else if (te instanceof TileEntityPanel) {
|
||||
state.withProperty(type, BlockTypes_Panel.TOP);
|
||||
}
|
||||
if (te instanceof TileEntityRSPanelConn) {
|
||||
} else if (te instanceof TileEntityRSPanelConn) {
|
||||
state.withProperty(type, BlockTypes_Panel.RS_WIRE);
|
||||
}
|
||||
return state;
|
||||
|
@ -203,7 +207,7 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
return state.getValue(type) == BlockTypes_Panel.TOP;
|
||||
return state.getValue(type) == BlockTypes_Panel.TOP||state.getValue(type) == BlockTypes_Panel.SINGLE_COMP;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -254,4 +258,49 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
|
||||
super.neighborChanged(state, world, pos, blockIn, fromPos);
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
if (blockState.getValue(type)==BlockTypes_Panel.SINGLE_COMP) {
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if (te instanceof TileEntityComponentPanel) {
|
||||
((TileEntityComponentPanel)te).updateRS();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvidePower(IBlockState state) {
|
||||
return state.getValue(type)==BlockTypes_Panel.SINGLE_COMP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone(IBlockState state, IBlockAccess world, BlockPos pos, @Nullable EnumFacing side) {
|
||||
return state.getValue(type)==BlockTypes_Panel.SINGLE_COMP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
|
||||
if (blockState.getValue(type)==BlockTypes_Panel.SINGLE_COMP) {
|
||||
TileEntity te = blockAccess.getTileEntity(pos);
|
||||
if (te instanceof TileEntityComponentPanel&&side==((TileEntityComponentPanel) te).getComponents().getTop()) {
|
||||
return ((TileEntityComponentPanel)te).getRSOutput();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
|
||||
if (blockState.getValue(type)==BlockTypes_Panel.SINGLE_COMP) {
|
||||
TileEntity te = blockAccess.getTileEntity(pos);
|
||||
if (te instanceof TileEntityComponentPanel) {
|
||||
return ((TileEntityComponentPanel)te).getRSOutput();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,108 @@
|
|||
|
||||
package malte0811.industrialWires.blocks.controlpanel;
|
||||
|
||||
public class TileEntityComponentPanel extends TileEntityPanel {
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.controlpanel.PropertyComponents;
|
||||
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||
import net.minecraft.block.BlockRedstoneWire;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class TileEntityComponentPanel extends TileEntityPanel {
|
||||
private int rsOut = 0;
|
||||
private Consumer<byte[]> rsIn;
|
||||
public TileEntityComponentPanel() {
|
||||
components = new PropertyComponents.AABBPanelProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
for (PanelComponent pc : components) {
|
||||
pc.update(this);
|
||||
}
|
||||
if (!world.isRemote) {
|
||||
if (firstTick&&components.size()>0) {
|
||||
PanelComponent pc = components.get(0);
|
||||
pc.registerRSOutput(-1, (channel, value, pcTmp)->{
|
||||
rsOut = value;
|
||||
markBlockForUpdate(pos);
|
||||
markBlockForUpdate(pos.offset(components.getTop(), -1));
|
||||
});
|
||||
rsIn = pc.getRSInputHandler(-1, this);
|
||||
updateRS();
|
||||
firstTick = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateRS() {
|
||||
if (rsIn != null) {
|
||||
int value = world.isBlockIndirectlyGettingPowered(pos);
|
||||
if (value == 0) {
|
||||
for (EnumFacing f : EnumFacing.HORIZONTALS) {
|
||||
IBlockState state = world.getBlockState(pos.offset(f));
|
||||
if (state.getBlock() == Blocks.REDSTONE_WIRE && state.getValue(BlockRedstoneWire.POWER) > value)
|
||||
value = state.getValue(BlockRedstoneWire.POWER);
|
||||
}
|
||||
}
|
||||
byte[] tmp = new byte[16];
|
||||
for (int i = 0; i < tmp.length; i++) {
|
||||
tmp[i] = (byte) value;
|
||||
}
|
||||
rsIn.accept(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
public void markBlockForUpdate(BlockPos pos)
|
||||
{
|
||||
IBlockState state = world.getBlockState(getPos());
|
||||
world.notifyBlockUpdate(pos,state,state,3);
|
||||
world.notifyNeighborsOfStateChange(pos, state.getBlock(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox() {
|
||||
if (defAABB == null) {
|
||||
AxisAlignedBB base = ((PropertyComponents.AABBPanelProperties)components).getPanelBoundingBox();
|
||||
defAABB = apply(components.getPanelBaseTransform(), base.setMaxY(components.getMaxHeight()));
|
||||
}
|
||||
return defAABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRS(TileEntityRSPanelConn te) {
|
||||
//NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterRS(TileEntityRSPanelConn te) {
|
||||
//NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean interactsWithRSWires() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getRSOutput() {
|
||||
return rsOut;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getTileDrop(@Nonnull EntityPlayer player, @Nonnull IBlockState state) {
|
||||
if (components.size()<1) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
return ItemPanelComponent.stackFromComponent(components.get(0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTile, IBlockBoundsIW, IPlayerInteraction, ITickable, IEBlockInterfaces.ITileDrop {
|
||||
private PropertyComponents.PanelRenderProperties components = new PropertyComponents.PanelRenderProperties();
|
||||
protected PropertyComponents.PanelRenderProperties components = new PropertyComponents.PanelRenderProperties();
|
||||
public boolean firstTick = true;
|
||||
// non-rendered properties
|
||||
private Set<TileEntityRSPanelConn> rsPorts = new HashSet<>();
|
||||
|
@ -202,7 +202,7 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
|
|||
return false;
|
||||
}
|
||||
|
||||
private AxisAlignedBB defAABB;
|
||||
protected AxisAlignedBB defAABB;
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox() {
|
||||
|
@ -317,4 +317,8 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
|
|||
}
|
||||
removeAllRSCons();
|
||||
}
|
||||
|
||||
public boolean interactsWithRSWires() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,17 +161,19 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
|
|||
}
|
||||
|
||||
public void registerPanel(TileEntityPanel panel) {
|
||||
PropertyComponents.PanelRenderProperties p = panel.getComponents();
|
||||
for (PanelComponent pc : p) {
|
||||
Consumer<byte[]> listener = pc.getRSInputHandler(id, panel);
|
||||
if (listener != null) {
|
||||
changeListeners.add(listener);
|
||||
listener.accept(network.channelValues);
|
||||
if (panel.interactsWithRSWires()) {
|
||||
PropertyComponents.PanelRenderProperties p = panel.getComponents();
|
||||
for (PanelComponent pc : p) {
|
||||
Consumer<byte[]> listener = pc.getRSInputHandler(id, panel);
|
||||
if (listener != null) {
|
||||
changeListeners.add(listener);
|
||||
listener.accept(network.channelValues);
|
||||
}
|
||||
pc.registerRSOutput(id, rsOut);
|
||||
}
|
||||
pc.registerRSOutput(id, rsOut);
|
||||
panel.registerRS(this);
|
||||
connectedPanels.add(panel);
|
||||
}
|
||||
panel.registerRS(this);
|
||||
connectedPanels.add(panel);
|
||||
}
|
||||
|
||||
public void unregisterPanel(TileEntityPanel panel, boolean remove, boolean callPanel) {
|
||||
|
|
|
@ -132,7 +132,7 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
|
|||
@Nullable
|
||||
@Override
|
||||
public Consumer<byte[]> getRSInputHandler(int id, TileEntityPanel panel) {
|
||||
if (id == rsInputId) {
|
||||
if (matchesId(rsInputId, id)) {
|
||||
this.panel = panel;
|
||||
return handler;
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
|
|||
|
||||
@Override
|
||||
public void registerRSOutput(int id, @Nonnull TriConsumer<Integer, Byte, PanelComponent> out) {
|
||||
if (id == rsOutputId) {
|
||||
if (matchesId(rsOutputId, id)) {
|
||||
super.registerRSOutput(id, out);
|
||||
out.accept(rsOutputChannel, (byte) (active ? 15 : 0), this);
|
||||
}
|
||||
|
|
|
@ -217,7 +217,7 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
|
|||
|
||||
@Override
|
||||
public void registerRSOutput(int id, @Nonnull TriConsumer<Integer, Byte, PanelComponent> out) {
|
||||
if (id == rsOutputId) {
|
||||
if (matchesId(rsOutputId, id)) {
|
||||
super.registerRSOutput(id, out);
|
||||
out.accept(rsOutputChannel, (byte) (turned ? 15 : 0), this);
|
||||
}
|
||||
|
|
|
@ -107,6 +107,10 @@ public abstract class PanelComponent {
|
|||
outputs.remove(out);
|
||||
}
|
||||
|
||||
protected boolean matchesId(int myId, int theirId) {
|
||||
return myId==theirId||theirId<0;
|
||||
}
|
||||
|
||||
public void dropItems(TileEntityPanel te) {
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.lwjgl.util.vector.Vector3f;
|
|||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
@ -199,7 +200,7 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
|
|||
@Nullable
|
||||
@Override
|
||||
public Consumer<byte[]> getRSInputHandler(int id, TileEntityPanel panel) {
|
||||
if (id == rsInputId) {
|
||||
if (matchesId(rsInputId, id)) {
|
||||
this.panel = panel;
|
||||
return handler;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
|
|||
import malte0811.industrialWires.client.RawQuad;
|
||||
import malte0811.industrialWires.client.panelmodel.SmartLightingQuadIW;
|
||||
import malte0811.industrialWires.controlpanel.PropertyComponents.PanelRenderProperties;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
|
@ -99,36 +100,49 @@ public final class PanelUtils {
|
|||
float height0 = getLocalHeightFromZ(0, components.getHeight(), components.getAngle());
|
||||
float vMax1 = 16 * height1;
|
||||
float vMax0 = 16 * height0;
|
||||
float xMin = 0;
|
||||
float xMax = 1;
|
||||
float zMin = 0;
|
||||
float zMax = 1;
|
||||
if (components instanceof PropertyComponents.AABBPanelProperties) {
|
||||
AxisAlignedBB xzAABB = ((PropertyComponents.AABBPanelProperties) components).getPanelBoundingBox();
|
||||
xMin = (float) xzAABB.minX;
|
||||
zMin = (float) xzAABB.minZ;
|
||||
xMax = (float) xzAABB.maxX;
|
||||
zMax = (float) xzAABB.maxZ;
|
||||
}
|
||||
float uMaxX = 16*(xMax-xMin);
|
||||
float uMaxZ = 16*(zMax-zMin);
|
||||
//TOP
|
||||
rawOut.add(new RawQuad(new Vector3f(0, height0, 0), new Vector3f(0, height1, 1),
|
||||
new Vector3f(1, height1, 1), new Vector3f(1, height0, 0),
|
||||
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, UV_FULL, -1));
|
||||
rawOut.add(new RawQuad(new Vector3f(xMin, height0, zMin), new Vector3f(xMin, height1, zMax),
|
||||
new Vector3f(xMax, height1, zMax), new Vector3f(xMax, height0, zMin),
|
||||
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[]{0, 0, uMaxX, uMaxZ}, -1));
|
||||
//BOTTOM
|
||||
rawOut.add(new RawQuad(new Vector3f(0, 0, 0), new Vector3f(1, 0, 0),
|
||||
new Vector3f(1, 0, 1), new Vector3f(0, 0, 1),
|
||||
rawOut.add(new RawQuad(new Vector3f(xMin, 0, zMin), new Vector3f(xMax, 0, zMin),
|
||||
new Vector3f(xMax, 0, zMax), new Vector3f(xMin, 0, zMax),
|
||||
EnumFacing.DOWN, PANEL_TEXTURE, WHITE, null, UV_FULL, -1));
|
||||
//LEFT
|
||||
rawOut.add(new RawQuad(new Vector3f(0, 0, 0), new Vector3f(0, 0, 1),
|
||||
new Vector3f(0, height1, 1), new Vector3f(0, height0, 0),
|
||||
rawOut.add(new RawQuad(new Vector3f(xMin, 0, zMin), new Vector3f(xMin, 0, zMax),
|
||||
new Vector3f(xMin, height1, zMax), new Vector3f(xMin, height0, zMin),
|
||||
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[][]{
|
||||
{0, 0}, {0, 16},
|
||||
{vMax1, 16}, {vMax0, 0}
|
||||
{0, 0}, {0, uMaxZ},
|
||||
{vMax1, uMaxZ}, {vMax0, 0}
|
||||
}, -1));
|
||||
//RIGHT
|
||||
rawOut.add(new RawQuad(new Vector3f(1, 0, 0), new Vector3f(1, height0, 0),
|
||||
new Vector3f(1, height1, 1), new Vector3f(1, 0, 1),
|
||||
rawOut.add(new RawQuad(new Vector3f(xMax, 0, zMin), new Vector3f(xMax, height0, zMin),
|
||||
new Vector3f(xMax, height1, zMax), new Vector3f(xMax, 0, zMax),
|
||||
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[][]{
|
||||
{0, 0}, {vMax0, 0},
|
||||
{vMax1, 16}, {0, 16}
|
||||
{vMax1, uMaxZ}, {0, uMaxZ}
|
||||
}, -1));
|
||||
//BACK
|
||||
rawOut.add(new RawQuad(new Vector3f(1, 0, 0), new Vector3f(0, 0, 0),
|
||||
new Vector3f(0, height0, 0), new Vector3f(1, height0, 0),
|
||||
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[]{0, 0, vMax0, 16}, -1));
|
||||
rawOut.add(new RawQuad(new Vector3f(xMax, 0, zMin), new Vector3f(xMin, 0, zMin),
|
||||
new Vector3f(xMin, height0, zMin), new Vector3f(xMax, height0, zMin),
|
||||
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[]{0, 0, vMax0, uMaxX}, -1));
|
||||
//FRONT
|
||||
rawOut.add(new RawQuad(new Vector3f(0, 0, 1), new Vector3f(1, 0, 1),
|
||||
new Vector3f(1, height1, 1), new Vector3f(0, height1, 1),
|
||||
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[]{0, 0, vMax1, 16}, -1));
|
||||
rawOut.add(new RawQuad(new Vector3f(xMin, 0, zMax), new Vector3f(xMax, 0, zMax),
|
||||
new Vector3f(xMax, height1, zMax), new Vector3f(xMin, height1, zMax),
|
||||
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[]{0, 0, vMax1, uMaxX}, -1));
|
||||
for (RawQuad bq : rawOut) {
|
||||
ret.add(bakeQuad(bq, baseTrans, baseNorm));
|
||||
}
|
||||
|
|
|
@ -19,10 +19,13 @@
|
|||
package malte0811.industrialWires.controlpanel;
|
||||
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
@ -87,7 +90,7 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
|
|||
@Nonnull
|
||||
public Matrix4 getPanelTopTransform() {
|
||||
if (topTransform == null) {
|
||||
topTransform = getPanelBaseTransform().copy().translate(0, height, .5)
|
||||
topTransform = getPanelBaseTransform().copy().translate(0, getHeight(), .5)
|
||||
.rotate(angle, 1, 0, 0).translate(0, 0, -.5);
|
||||
}
|
||||
return topTransform;
|
||||
|
@ -125,7 +128,7 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
|
|||
GlStateManager.rotate(top.getHorizontalAngle(), 0, 0, 1);
|
||||
break;
|
||||
}
|
||||
GlStateManager.translate(-.5, height - .5, 0);
|
||||
GlStateManager.translate(-.5, getHeight() - .5, 0);
|
||||
GlStateManager.rotate((float) (angle * 180 / Math.PI), 1, 0, 0);
|
||||
GlStateManager.translate(0, 0, -.5);
|
||||
|
||||
|
@ -158,7 +161,7 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
|
|||
public float getMaxHeight() {
|
||||
float max = getPanelMaxHeight();
|
||||
for (PanelComponent pc : this) {
|
||||
float h = PanelUtils.getHeightWithComponent(pc, angle, height);
|
||||
float h = PanelUtils.getHeightWithComponent(pc, angle, getHeight());
|
||||
if (h > max) {
|
||||
max = h;
|
||||
}
|
||||
|
@ -178,7 +181,7 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
|
|||
}
|
||||
|
||||
public float getPanelMaxHeight() {
|
||||
return (float) (height + Math.abs(Math.tan(angle) / 2));
|
||||
return (float) (getHeight() + Math.abs(Math.tan(angle) / 2));
|
||||
}
|
||||
|
||||
private void resetMatrixes() {
|
||||
|
@ -256,4 +259,54 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
|
|||
return result;
|
||||
}
|
||||
}
|
||||
public static class AABBPanelProperties extends PanelRenderProperties {
|
||||
private AxisAlignedBB aabb;
|
||||
private int lastHash;
|
||||
public AABBPanelProperties() {
|
||||
super(1);
|
||||
}
|
||||
|
||||
public AxisAlignedBB getPanelBoundingBox() {
|
||||
if (size()<1) {
|
||||
aabb = Block.FULL_BLOCK_AABB;
|
||||
} else if (aabb!=null||get(0).hashCode()!=lastHash) {
|
||||
aabb = getPanelBoundingBox(get(0));
|
||||
lastHash = get(0).hashCode();
|
||||
}
|
||||
return aabb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PanelComponent set(int index, PanelComponent pc) {
|
||||
AxisAlignedBB aabb = pc.getBlockRelativeAABB();
|
||||
pc.setX((float) ((1-aabb.maxX+aabb.minX)/2));
|
||||
pc.setY((float) ((1-aabb.maxZ+aabb.minZ)/2));
|
||||
return super.set(index, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(PanelComponent pc) {
|
||||
AxisAlignedBB aabb = pc.getBlockRelativeAABB();
|
||||
pc.setX((float) ((1-aabb.maxX+aabb.minX)/2));
|
||||
pc.setY((float) ((1-aabb.maxZ+aabb.minZ)/2));
|
||||
return super.add(pc);
|
||||
}
|
||||
|
||||
private AxisAlignedBB getPanelBoundingBox(PanelComponent element) {
|
||||
AxisAlignedBB compAABB = element.getBlockRelativeAABB();
|
||||
float height = 6/16F;
|
||||
double width = 3*(compAABB.maxX-compAABB.minX);
|
||||
double length = 3*(compAABB.maxZ-compAABB.minZ);
|
||||
width = MathHelper.clamp(width, 7/16F, 1);
|
||||
length = MathHelper.clamp(length, 7/16F, 1);
|
||||
double minX = (1-width)/2;
|
||||
double minZ = (1-length)/2;
|
||||
return new AxisAlignedBB(minX, 0, minZ, minX+width, height, minZ+length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHeight() {
|
||||
return (float) getPanelBoundingBox().maxY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
|
||||
@Override
|
||||
public void registerRSOutput(int id, @Nonnull TriConsumer<Integer, Byte, PanelComponent> out) {
|
||||
if (id == rsId) {
|
||||
if (matchesId(rsId, id)) {
|
||||
super.registerRSOutput(id, out);
|
||||
out.accept((int) rsChannel, this.out, this);
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
|
|||
|
||||
@Override
|
||||
public void registerRSOutput(int id, @Nonnull TriConsumer<Integer, Byte, PanelComponent> out) {
|
||||
if (id == rsOutputId) {
|
||||
if (matchesId(rsOutputId, id)) {
|
||||
super.registerRSOutput(id, out);
|
||||
out.accept((int) rsOutputChannel, (byte) (active ? 15 : 0), this);
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
|
|||
|
||||
@Override
|
||||
public void registerRSOutput(int id, @Nonnull TriConsumer<Integer, Byte, PanelComponent> out) {
|
||||
if (id == rsId) {
|
||||
if (matchesId(rsId, id)) {
|
||||
super.registerRSOutput(id, out);
|
||||
out.accept((int) rsChannel, this.out, this);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue