Added a way to create tilted panels in-game (no recipe yet)

Panels are no longer created from machine casings, but from unfinished panels
This commit is contained in:
malte0811 2017-06-30 21:04:02 +02:00
parent 15674f7ae3
commit b716c23e3d
19 changed files with 305 additions and 82 deletions

View file

@ -1,2 +0,0 @@
LV conn=rel item model
RS conns don't update color instantly

View file

@ -19,10 +19,7 @@ package malte0811.industrialWires;
import malte0811.industrialWires.blocks.BlockJacobsLadder;
import malte0811.industrialWires.blocks.TileEntityJacobsLadder;
import malte0811.industrialWires.blocks.controlpanel.BlockPanel;
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelConn;
import malte0811.industrialWires.blocks.controlpanel.*;
import malte0811.industrialWires.blocks.converter.BlockMechanicalConverter;
import malte0811.industrialWires.blocks.converter.TileEntityIEMotor;
import malte0811.industrialWires.blocks.converter.TileEntityMechICtoIE;
@ -97,6 +94,7 @@ public class IndustrialWires {
GameRegistry.registerTileEntity(TileEntityPanel.class, MODID + ":control_panel");
GameRegistry.registerTileEntity(TileEntityRSPanelConn.class, MODID + ":control_panel_rs");
GameRegistry.registerTileEntity(TileEntityPanelCreator.class, MODID + ":panel_creator");
GameRegistry.registerTileEntity(TileEntityUnfinishedPanel.class, MODID + ":unfinished_panel");
if (mechConv != null) {
GameRegistry.registerTileEntity(TileEntityIEMotor.class, MODID + ":ieMotor");
GameRegistry.registerTileEntity(TileEntityMechICtoIE.class, MODID + ":mechIcToIe");

View file

@ -32,6 +32,7 @@ import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
@ -56,11 +57,15 @@ public abstract class BlockIWBase extends Block {
setHardness(3.0F);
setResistance(15.0F);
GameRegistry.register(this, new ResourceLocation(IndustrialWires.MODID, name));
GameRegistry.register(new ItemBlockIW(this), new ResourceLocation(IndustrialWires.MODID, name));
GameRegistry.register(createItemBlock(), new ResourceLocation(IndustrialWires.MODID, name));
setUnlocalizedName(IndustrialWires.MODID + "." + name);
setCreativeTab(IndustrialWires.creativeTab);
}
protected ItemBlock createItemBlock() {
return new ItemBlockIW(this);
}
@Nonnull
@Override
protected BlockStateContainer createBlockState() {

View file

@ -32,6 +32,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
@ -56,6 +57,11 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
lightOpacity = 0;
}
@Override
protected ItemBlock createItemBlock() {
return new ItemBlockPanel(this);
}
@Override
public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) {
switch (state.getValue(type)) {
@ -77,6 +83,8 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
return new TileEntityRSPanelConn();
case CREATOR:
return new TileEntityPanelCreator();
case UNFINISHED:
return new TileEntityUnfinishedPanel();
default:
return null;
}
@ -145,10 +153,9 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
@Override
public void getSubBlocks(@Nonnull Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
list.add(new ItemStack(itemIn, 1, 0));
list.add(new ItemStack(itemIn, 1, 1));
list.add(new ItemStack(itemIn, 1, 2));
list.add(new ItemStack(itemIn, 1, 3));
for (int i = 0; i < BlockTypes_Panel.values().length; i++) {
list.add(new ItemStack(itemIn, 1, i));
}
}
@Override
@ -195,11 +202,9 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
@Override
@Nonnull
public ItemStack getPickBlock(@Nonnull IBlockState state, RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos, EntityPlayer player) {
if (state.getValue(type) == BlockTypes_Panel.TOP) {
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileEntityPanel) {
return ((TileEntityPanel) te).getTileDrop(player, state);
}
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileEntityPanel) {
return ((TileEntityPanel) te).getTileDrop(player, state);
}
return super.getPickBlock(state, target, world, pos, player);
}

View file

@ -26,7 +26,8 @@ public enum BlockTypes_Panel implements IStringSerializable {
TOP,
RS_WIRE,
DUMMY,
CREATOR;
CREATOR,
UNFINISHED;
@Override
public String getName() {

View file

@ -0,0 +1,109 @@
/*
* This file is part of Industrial Wires.
* Copyright (C) 2016-2017 malte0811
*
* Industrial Wires is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Industrial Wires is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
*/
package malte0811.industrialWires.blocks.controlpanel;
import blusunrize.immersiveengineering.api.tool.IConfigurableTool;
import malte0811.industrialWires.blocks.ItemBlockIW;
import net.minecraft.block.Block;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.MathHelper;
public class ItemBlockPanel extends ItemBlockIW implements IConfigurableTool {
private static final String HEIGHT = "height";
private static final String ANGLE = "angle";
public ItemBlockPanel(Block b) {
super(b);
}
@Override
public boolean canConfigure(ItemStack stack) {
return stack.getMetadata() == BlockTypes_Panel.UNFINISHED.ordinal();
}
@Override
public ToolConfig.ToolConfigBoolean[] getBooleanOptions(ItemStack stack) {
return new ToolConfig.ToolConfigBoolean[0];
}
@Override
public ToolConfig.ToolConfigFloat[] getFloatOptions(ItemStack stack) {
float height;
float angle;
NBTTagCompound nbt = stack.getTagCompound();
if (nbt == null) {
height = .5F;
angle = 0;
} else {
height = nbt.getFloat(HEIGHT);
angle = nbt.getFloat(ANGLE);
}
angle = (float) ((angle * 180 / Math.PI + 45) / 90);
return new ToolConfig.ToolConfigFloat[]{
new ToolConfig.ToolConfigFloat(HEIGHT, 60, 20, height),
new ToolConfig.ToolConfigFloat(ANGLE, 60, 40, angle)
};
}
@Override
public void applyConfigOption(ItemStack stack, String key, Object value) {
NBTTagCompound nbt = stack.getTagCompound();
if (nbt == null) {
nbt = new NBTTagCompound();
stack.setTagCompound(nbt);
}
switch (key) {
case HEIGHT:
float angle = nbt.getFloat(ANGLE);
float halfH = (float) (.5 * Math.tan(angle));
nbt.setFloat(HEIGHT, MathHelper.clamp((Float) value + .001F, halfH, 1 - halfH));
break;
case ANGLE:
float height = nbt.getFloat(HEIGHT);
float angleMax = (float) Math.atan(2 * Math.min(height, 1 - height));
float newAngle = (float) ((Math.PI / 2 * ((Float) value - .5)));
nbt.setFloat(ANGLE, MathHelper.clamp(newAngle, -angleMax, angleMax));
break;
}
}
@Override
public String fomatConfigName(ItemStack stack, ToolConfig config) {
switch (config.name) {
case HEIGHT:
return I18n.format("industrialwires.desc.height");
case ANGLE:
return I18n.format("industrialwires.desc.angle");
}
return null;
}
@Override
public String fomatConfigDescription(ItemStack stack, ToolConfig config) {
switch (config.name) {
case HEIGHT:
return I18n.format("industrialwires.desc.height_info");
case ANGLE:
return I18n.format("industrialwires.desc.angle_info");//TODO talk to blu to make this less awkward
}
return null;
}
}

View file

@ -226,7 +226,7 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
@Nullable
public Pair<PanelComponent, RayTraceResult> getSelectedComponent(EntityPlayer player, Vec3d hit, boolean hitAbs) {
//TODO prvent clicking through the back of the panel
//TODO prevent clicking through the back of the panel
Matrix4 mat = components.getPanelTopTransform();
mat.invert();
PanelComponent retPc = null;

View file

@ -41,7 +41,6 @@ import java.util.List;
public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI, IBlockBoundsIW {
public List<PanelComponent> components = new ArrayList<>();
public float height = 0.5F;
@Nonnull
public ItemStack inv = ItemStack.EMPTY;
@ -49,7 +48,6 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI,
public void readNBT(NBTTagCompound nbt, boolean updatePacket) {
NBTTagList l = nbt.getTagList("components", 10);
PanelUtils.readListFromNBT(l, components);
height = nbt.getFloat("height");
NBTTagCompound invTag;
if (nbt.hasKey("inventory", 9)) {
invTag = nbt.getTagList("inventory", 10).getCompoundTagAt(0);
@ -73,7 +71,8 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI,
comps.appendTag(nbtInner);
}
nbt.setTag("components", comps);
nbt.setFloat("height", height);
nbt.setFloat("height", PanelUtils.getHeight(inv));
nbt.setFloat("angle", PanelUtils.getAngle(inv));
}
@Override
@ -86,7 +85,6 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI,
if (pc != null) {
pc.setX(nbt.getFloat("x"));
pc.setY(nbt.getFloat("y"));
pc.setPanelHeight(height);
components.add(pc);
if (!curr.isEmpty()) {
curr.shrink(1);
@ -110,13 +108,24 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI,
}
break;
case CREATE_PANEL:
if (ItemStack.areItemStacksEqual(PanelUtils.getPanelBase(), inv)) {
NBTTagCompound panelNBT = new NBTTagCompound();
writeToItemNBT(panelNBT, true);
ItemStack panel = new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.TOP.ordinal());
panel.setTagCompound(panelNBT);
inv = panel;
components.clear();
if (ItemStack.areItemsEqual(PanelUtils.getPanelBase(), inv)) {
float height = PanelUtils.getHeight(inv);
float angle = PanelUtils.getAngle(inv);
boolean valid = true;
for (PanelComponent comp : components) {
if (!comp.isValidPos(components, height, angle)) {
valid = false;
break;
}
}
if (valid) {
NBTTagCompound panelNBT = new NBTTagCompound();
writeToItemNBT(panelNBT, true);
ItemStack panel = new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.TOP.ordinal());
panel.setTagCompound(panelNBT);
inv = panel;
components.clear();
}
}
break;
case REMOVE_ALL:
@ -138,7 +147,6 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI,
TileEntityPanel te = new TileEntityPanel();
te.readFromItemNBT(inv.getTagCompound());
components = new ArrayList<>(te.getComponents());
height = te.getComponents().height;
inv = ItemStack.EMPTY;
}
break;

View file

@ -0,0 +1,51 @@
/*
* This file is part of Industrial Wires.
* Copyright (C) 2016-2017 malte0811
*
* Industrial Wires is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Industrial Wires is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
*/
package malte0811.industrialWires.blocks.controlpanel;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import javax.annotation.Nonnull;
public class TileEntityUnfinishedPanel extends TileEntityPanel {
public TileEntityUnfinishedPanel() {
super();
getComponents().clear();
}
@Override
public boolean interact(@Nonnull EnumFacing side, @Nonnull EntityPlayer player, @Nonnull EnumHand hand, @Nonnull ItemStack heldItem, float hitX, float hitY, float hitZ) {
return false;
}
@Nonnull
@Override
public ItemStack getTileDrop(@Nonnull EntityPlayer player, @Nonnull IBlockState state) {
ItemStack ret = super.getTileDrop(player, state);
ret.setItemDamage(BlockTypes_Panel.UNFINISHED.ordinal());
NBTTagCompound nbt = ret.getTagCompound();
if (nbt != null && nbt.hasKey("components"))
nbt.removeTag("components");
return ret;
}
}

View file

@ -98,5 +98,6 @@ public class ClientEventHandler {
@SubscribeEvent
public void bakeModel(ModelBakeEvent event) {
event.getModelRegistry().putObject(new ModelResourceLocation(IndustrialWires.MODID + ":control_panel", "inventory,type=top"), new PanelModel());
event.getModelRegistry().putObject(new ModelResourceLocation(IndustrialWires.MODID + ":control_panel", "inventory,type=unfinished"), new PanelModel());
}
}

View file

@ -71,7 +71,7 @@ public class RawQuad {
if (normal != null) {
this.normal = normal;
} else {
this.normal = cross(sub(v1, v3, null), sub(v2, v0, null), null);//TODO is this the right way around?
this.normal = cross(sub(v1, v3, null), sub(v2, v0, null), null);
this.normal.normalise(this.normal);
}
this.uvs = uvs;

View file

@ -25,8 +25,10 @@ import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
import malte0811.industrialWires.containers.ContainerPanelCreator;
import malte0811.industrialWires.controlpanel.MessageType;
import malte0811.industrialWires.controlpanel.PanelComponent;
import malte0811.industrialWires.controlpanel.PanelUtils;
import malte0811.industrialWires.items.ItemPanelComponent;
import malte0811.industrialWires.network.MessageGUIInteract;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
@ -103,7 +105,9 @@ public class GuiPanelCreator extends GuiContainer {
pc.setX(x / (float) panelSize);
pc.setY(y / (float) panelSize);
}
if (!pc.isValidPos(container.tile.components)) {
ItemStack unfinishedPanel = container.getInventory().get(0);
boolean red = (512 & (Minecraft.getSystemTime())) != 0;
if (red && !pc.isValidPos(container.tile.components, PanelUtils.getHeight(unfinishedPanel), PanelUtils.getAngle(unfinishedPanel))) {
AxisAlignedBB aabb = pc.getBlockRelativeAABB();
int left = (int) (getX0() + aabb.minX * panelSize) - 1;
int top = (int) (getY0() + aabb.minZ * panelSize) - 1;
@ -137,7 +141,8 @@ public class GuiPanelCreator extends GuiContainer {
if (0 <= xRel && xRel <= panelSize && 0 <= yRel && yRel <= panelSize) {
List<PanelComponent> components = container.tile.components;
if (curr != null) {
if (curr.isValidPos(components)) {
ItemStack unfinishedPanel = container.getInventory().get(0);
if (curr.isValidPos(components, PanelUtils.getHeight(unfinishedPanel), PanelUtils.getAngle(unfinishedPanel))) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setFloat("x", curr.getX());
nbt.setFloat("y", curr.getY());

View file

@ -24,6 +24,7 @@ import com.google.common.cache.CacheBuilder;
import com.google.common.collect.ImmutableList;
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
import malte0811.industrialWires.blocks.controlpanel.TileEntityUnfinishedPanel;
import malte0811.industrialWires.controlpanel.PanelUtils;
import malte0811.industrialWires.controlpanel.PropertyComponents;
import malte0811.industrialWires.controlpanel.PropertyComponents.PanelRenderProperties;
@ -188,10 +189,10 @@ public class PanelModel implements IBakedModel {
@Nonnull
@Override
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) {
if (stack != null && stack.getItem() == PanelUtils.PANEL_ITEM && stack.getMetadata() == BlockTypes_Panel.TOP.ordinal()) {
if (stack != null && stack.getItem() == PanelUtils.PANEL_ITEM) {
try {
return ITEM_MODEL_CACHE.get(stack, () -> {
TileEntityPanel te = new TileEntityPanel();
TileEntityPanel te = stack.getMetadata() == BlockTypes_Panel.TOP.ordinal() ? new TileEntityPanel() : new TileEntityUnfinishedPanel();
te.readFromItemNBT(stack.getTagCompound());
return new AssembledBakedModel(te.getComponents());
});

View file

@ -18,7 +18,7 @@
package malte0811.industrialWires.controlpanel;
import blusunrize.immersiveengineering.common.util.IELogger;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
import malte0811.industrialWires.client.RawQuad;
import malte0811.industrialWires.client.gui.GuiPanelCreator;
@ -30,8 +30,10 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.logging.log4j.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -154,7 +156,7 @@ public abstract class PanelComponent {
ret.setPanelHeight(nbt.getFloat("panelHeight"));
return ret;
} else {
IELogger.info("(IndustrialWires) Unknown panel component: " + type);//TODO own logger?
FMLLog.log(IndustrialWires.MODID, Level.WARN, "Unknown panel component: " + type);
return null;
}
}
@ -189,18 +191,20 @@ public abstract class PanelComponent {
}
public boolean isValidPos(List<PanelComponent> components) {
AxisAlignedBB aabb = getBlockRelativeAABB().offset(0, panelHeight, 0);
if (aabb.minX < 0 || aabb.maxX > 1) {
public boolean isValidPos(List<PanelComponent> components, float height, float angle) {
float h = PanelUtils.getHeightWithComponent(this, angle, height);
if (h < 0 || h > 1) {
return false;
}
if (aabb.minY < 0 || aabb.maxY > 1) {
AxisAlignedBB aabb = getBlockRelativeAABB();
if (aabb.minX < 0 || aabb.maxX > 1) {
return false;
}
if (aabb.minZ < 0 || aabb.maxZ > 1) {
return false;
}
aabb = getBlockRelativeAABB();
for (PanelComponent pc : components) {
if (pc == this) {
continue;

View file

@ -20,7 +20,6 @@ package malte0811.industrialWires.controlpanel;
import blusunrize.immersiveengineering.api.Lib;
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
import ic2.api.item.IC2Items;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.controlpanel.BlockPanel;
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
@ -93,13 +92,13 @@ public final class PanelUtils {
baseNorm.transpose();
List<RawQuad> rawOut = new ArrayList<>();
//addTexturedBox(new Vector3f(0, 0, 0), new Vector3f(1, components.height, 1), rawOut, UV_FULL, PANEL_TEXTURE);
float maxHeight = components.getPanelMaxHeight();
float vMaxLower = 16 * components.height;
float vMaxUpper = 16 * maxHeight;
float height1 = getLocalHeightFromZ(1, components.height, components.angle);
float height0 = getLocalHeightFromZ(0, components.height, components.angle);
float vMax1 = 16 * height1;
float vMax0 = 16 * height0;
//TOP
rawOut.add(new RawQuad(new Vector3f(0, maxHeight, 0), new Vector3f(0, components.height, 1),
new Vector3f(1, components.height, 1), new Vector3f(1, maxHeight, 0),
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));
//BOTTOM
rawOut.add(new RawQuad(new Vector3f(0, 0, 0), new Vector3f(1, 0, 0),
@ -107,26 +106,26 @@ public final class PanelUtils {
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, components.height, 1), new Vector3f(0, maxHeight, 0),
new Vector3f(0, height1, 1), new Vector3f(0, height0, 0),
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[][]{
{0, 0}, {0, 16},
{vMaxLower, 16}, {vMaxUpper, 0}
{vMax1, 16}, {vMax0, 0}
}, -1));
//RIGHT
rawOut.add(new RawQuad(new Vector3f(1, 0, 0), new Vector3f(1, maxHeight, 0),
new Vector3f(1, components.height, 1), new Vector3f(1, 0, 1),
rawOut.add(new RawQuad(new Vector3f(1, 0, 0), new Vector3f(1, height0, 0),
new Vector3f(1, height1, 1), new Vector3f(1, 0, 1),
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[][]{
{0, 0}, {vMaxUpper, 0},
{vMaxLower, 16}, {0, 16}
{0, 0}, {vMax0, 0},
{vMax1, 16}, {0, 16}
}, -1));
//BACK
rawOut.add(new RawQuad(new Vector3f(1, 0, 0), new Vector3f(0, 0, 0),
new Vector3f(0, maxHeight, 0), new Vector3f(1, maxHeight, 0),
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[]{0, 0, vMaxUpper, 16}, -1));
new Vector3f(0, height0, 0), new Vector3f(1, height0, 0),
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[]{0, 0, vMax0, 16}, -1));
//FRONT
rawOut.add(new RawQuad(new Vector3f(0, 0, 1), new Vector3f(1, 0, 1),
new Vector3f(1, components.height, 1), new Vector3f(0, components.height, 1),
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[]{0, 0, vMaxLower, 16}, -1));
new Vector3f(1, height1, 1), new Vector3f(0, height1, 1),
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[]{0, 0, vMax1, 16}, -1));
for (RawQuad bq : rawOut) {
ret.add(bakeQuad(bq, baseTrans, baseNorm));
}
@ -358,7 +357,7 @@ public final class PanelUtils {
public static ItemStack getPanelBase() {
if (panelBase == null) {
panelBase = IC2Items.getItem("resource", "machine");
panelBase = new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.UNFINISHED.ordinal());
}
return panelBase;
}
@ -380,4 +379,38 @@ public final class PanelUtils {
}
return ret;
}
public static float getAngle(ItemStack inv) {
float angle = 0;
if (inv.hasTagCompound()) {
angle = inv.getTagCompound().getFloat("angle");
}
return angle;
}
public static float getHeight(ItemStack inv) {
float height = 0;
if (inv.hasTagCompound()) {
height = inv.getTagCompound().getFloat("height");
}
return height;
}
public static float getHeightWithComponent(PanelComponent pc, float angle, float height) {
AxisAlignedBB aabb = pc.getBlockRelativeAABB();
double y = angle > 0 ? aabb.minZ : aabb.maxZ;
float hComp = (float) (pc.getHeight() * Math.cos(angle));
float localPanelHeight = getLocalHeight(y, angle, height);
return hComp + localPanelHeight;
}
public static float getLocalHeight(double y, float angle, float height) {
double centerOffset = .5 * (1 / Math.cos(angle) - 1);
y += centerOffset;
return getLocalHeightFromZ(Math.cos(angle) * y, height, angle);
}
public static float getLocalHeightFromZ(double z, float height, float angle) {
return (float) (height + (.5 - z) * Math.tan(angle));
}
}

View file

@ -22,7 +22,6 @@ import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
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.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.fml.relauncher.Side;
@ -81,9 +80,8 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
}
public Matrix4 getPanelTopTransform() {
double centerOffset = -.5 * (1 / Math.cos(angle) - 1);
return getPanelBaseTransform().translate(0, height, 1)
.rotate(angle, 1, 0, 0).translate(0, 0, centerOffset - 1);
return getPanelBaseTransform().translate(0, height, .5)
.rotate(angle, 1, 0, 0).translate(0, 0, -.5);
}
@SideOnly(Side.CLIENT)
@ -94,10 +92,10 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
GlStateManager.translate(px + .5, py + .5, pz + .5);
switch (top) {
case DOWN:
GlStateManager.rotate(180, 0, 0, 1);
case UP:
GlStateManager.rotate(180, 1, 0, 0);
GlStateManager.rotate(-facing.getHorizontalAngle(), 0, 1, 0);
break;
case UP:
case NORTH:
case SOUTH:
case WEST:
@ -106,12 +104,10 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
GlStateManager.rotate(top.getHorizontalAngle(), 0, 0, 1);
break;
}
GlStateManager.translate(-.5, height - .5, -.5);
GlStateManager.rotate((float) (-angle * 180 / Math.PI), 1, 0, 0);
GlStateManager.translate(.5, 0, .5);
GlStateManager.rotate(180, 0, 1, 0);
double centerOffset = .5 * (1 / Math.cos(angle) - 1);
GlStateManager.translate(-.5, 0, -.5 - centerOffset);
GlStateManager.translate(-.5, height - .5, 0);
GlStateManager.rotate((float) (angle * 180 / Math.PI), 1, 0, 0);
GlStateManager.translate(0, 0, -.5);
}
public Matrix4 getPanelBaseTransform() {
@ -137,14 +133,10 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
public float getMaxHeight() {
float max = getPanelMaxHeight();
double centerOffset = .5 * (1 / Math.cos(angle) - 1);
for (PanelComponent pc : this) {
AxisAlignedBB aabb = pc.getBlockRelativeAABB();
double y = angle > 0 ? aabb.minY : aabb.maxY;
float hComp = (float) (pc.getHeight() * Math.cos(angle));
float localPanelHeight = (float) (height + (1 - (y + centerOffset)) * Math.sin(angle));
if (hComp + localPanelHeight > max) {
max = hComp + localPanelHeight;
float h = PanelUtils.getHeightWithComponent(pc, angle, height);
if (h > max) {
max = h;
}
}
return max;
@ -162,7 +154,7 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
}
public float getPanelMaxHeight() {
return (float) (height + Math.tan(angle));
return (float) (height + Math.abs(Math.tan(angle) / 2));
}
@Override

View file

@ -177,6 +177,7 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
@Override
public void renderInGUI(GuiPanelCreator gui) {
AxisAlignedBB aabb = getBlockRelativeAABB();
int left = (int) Math.ceil(gui.getX0() + (offset + aabb.minX) * gui.panelSize);
int top = (int) Math.ceil(gui.getY0() + (offset + aabb.minZ) * gui.panelSize);
int right = (int) Math.floor(gui.getX0() + (aabb.maxX - offset) * gui.panelSize);

View file

@ -56,7 +56,7 @@
"model": "immersiveengineering:smartmodel/conn_rs_panel_conn"
},
"top": {
"model": "industrialwires:smartmodel/panel_normal"
"model": "industrialwires:smartmodel/panel"
},
"dummy": {
"model": "cube_all",
@ -64,7 +64,10 @@
},
"creator": {
"model":"industrialwires:panel_creator.obj"
}
},
"unfinished": {
"model": "industrialwires:smartmodel/panel"
}
},
"inventory,type=rs_wire": {
"model":"industrialwires:rs_panel_conn.obj",
@ -96,6 +99,10 @@
},
"inventory,type=top": {
"model":"industrialwires:block/panel_creator.obj"//Doesn't matter, this will be overridden in code
},
"inventory,type=unfinished": {
"model": "industrialwires:block/panel_creator.obj"
//Doesn't matter, this will be overridden in code
}
}

View file

@ -60,6 +60,10 @@ industrialwires.desc.green=Green
industrialwires.desc.blue=Blue
industrialwires.desc.length=Length
industrialwires.desc.wide_info=Wide Format
industrialwires.desc.height=Height
industrialwires.desc.height_info=The Height of the panel in the middle
industrialwires.desc.angle=Angle
industrialwires.desc.angle_info=The panel's angle to the surface it is placed on. 0=-45°, 100=45°
industrialwires.tooltip.wide=Wide
industrialwires.tooltip.narrow=Narrow