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:
parent
15674f7ae3
commit
b716c23e3d
|
@ -1,2 +0,0 @@
|
||||||
LV conn=rel item model
|
|
||||||
RS conns don't update color instantly
|
|
|
@ -19,10 +19,7 @@ package malte0811.industrialWires;
|
||||||
|
|
||||||
import malte0811.industrialWires.blocks.BlockJacobsLadder;
|
import malte0811.industrialWires.blocks.BlockJacobsLadder;
|
||||||
import malte0811.industrialWires.blocks.TileEntityJacobsLadder;
|
import malte0811.industrialWires.blocks.TileEntityJacobsLadder;
|
||||||
import malte0811.industrialWires.blocks.controlpanel.BlockPanel;
|
import malte0811.industrialWires.blocks.controlpanel.*;
|
||||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
|
||||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
|
|
||||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelConn;
|
|
||||||
import malte0811.industrialWires.blocks.converter.BlockMechanicalConverter;
|
import malte0811.industrialWires.blocks.converter.BlockMechanicalConverter;
|
||||||
import malte0811.industrialWires.blocks.converter.TileEntityIEMotor;
|
import malte0811.industrialWires.blocks.converter.TileEntityIEMotor;
|
||||||
import malte0811.industrialWires.blocks.converter.TileEntityMechICtoIE;
|
import malte0811.industrialWires.blocks.converter.TileEntityMechICtoIE;
|
||||||
|
@ -97,6 +94,7 @@ public class IndustrialWires {
|
||||||
GameRegistry.registerTileEntity(TileEntityPanel.class, MODID + ":control_panel");
|
GameRegistry.registerTileEntity(TileEntityPanel.class, MODID + ":control_panel");
|
||||||
GameRegistry.registerTileEntity(TileEntityRSPanelConn.class, MODID + ":control_panel_rs");
|
GameRegistry.registerTileEntity(TileEntityRSPanelConn.class, MODID + ":control_panel_rs");
|
||||||
GameRegistry.registerTileEntity(TileEntityPanelCreator.class, MODID + ":panel_creator");
|
GameRegistry.registerTileEntity(TileEntityPanelCreator.class, MODID + ":panel_creator");
|
||||||
|
GameRegistry.registerTileEntity(TileEntityUnfinishedPanel.class, MODID + ":unfinished_panel");
|
||||||
if (mechConv != null) {
|
if (mechConv != null) {
|
||||||
GameRegistry.registerTileEntity(TileEntityIEMotor.class, MODID + ":ieMotor");
|
GameRegistry.registerTileEntity(TileEntityIEMotor.class, MODID + ":ieMotor");
|
||||||
GameRegistry.registerTileEntity(TileEntityMechICtoIE.class, MODID + ":mechIcToIe");
|
GameRegistry.registerTileEntity(TileEntityMechICtoIE.class, MODID + ":mechIcToIe");
|
||||||
|
|
|
@ -32,6 +32,7 @@ import net.minecraft.block.state.BlockStateContainer;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
@ -56,11 +57,15 @@ public abstract class BlockIWBase extends Block {
|
||||||
setHardness(3.0F);
|
setHardness(3.0F);
|
||||||
setResistance(15.0F);
|
setResistance(15.0F);
|
||||||
GameRegistry.register(this, new ResourceLocation(IndustrialWires.MODID, name));
|
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);
|
setUnlocalizedName(IndustrialWires.MODID + "." + name);
|
||||||
setCreativeTab(IndustrialWires.creativeTab);
|
setCreativeTab(IndustrialWires.creativeTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ItemBlock createItemBlock() {
|
||||||
|
return new ItemBlockIW(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected BlockStateContainer createBlockState() {
|
protected BlockStateContainer createBlockState() {
|
||||||
|
|
|
@ -32,6 +32,7 @@ import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.BlockRenderLayer;
|
import net.minecraft.util.BlockRenderLayer;
|
||||||
|
@ -56,6 +57,11 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
||||||
lightOpacity = 0;
|
lightOpacity = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ItemBlock createItemBlock() {
|
||||||
|
return new ItemBlockPanel(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) {
|
public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) {
|
||||||
switch (state.getValue(type)) {
|
switch (state.getValue(type)) {
|
||||||
|
@ -77,6 +83,8 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
||||||
return new TileEntityRSPanelConn();
|
return new TileEntityRSPanelConn();
|
||||||
case CREATOR:
|
case CREATOR:
|
||||||
return new TileEntityPanelCreator();
|
return new TileEntityPanelCreator();
|
||||||
|
case UNFINISHED:
|
||||||
|
return new TileEntityUnfinishedPanel();
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -145,10 +153,9 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getSubBlocks(@Nonnull Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
|
public void getSubBlocks(@Nonnull Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
|
||||||
list.add(new ItemStack(itemIn, 1, 0));
|
for (int i = 0; i < BlockTypes_Panel.values().length; i++) {
|
||||||
list.add(new ItemStack(itemIn, 1, 1));
|
list.add(new ItemStack(itemIn, 1, i));
|
||||||
list.add(new ItemStack(itemIn, 1, 2));
|
}
|
||||||
list.add(new ItemStack(itemIn, 1, 3));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -195,11 +202,9 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public ItemStack getPickBlock(@Nonnull IBlockState state, RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos, EntityPlayer player) {
|
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);
|
||||||
TileEntity te = world.getTileEntity(pos);
|
if (te instanceof TileEntityPanel) {
|
||||||
if (te instanceof TileEntityPanel) {
|
return ((TileEntityPanel) te).getTileDrop(player, state);
|
||||||
return ((TileEntityPanel) te).getTileDrop(player, state);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return super.getPickBlock(state, target, world, pos, player);
|
return super.getPickBlock(state, target, world, pos, player);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,8 @@ public enum BlockTypes_Panel implements IStringSerializable {
|
||||||
TOP,
|
TOP,
|
||||||
RS_WIRE,
|
RS_WIRE,
|
||||||
DUMMY,
|
DUMMY,
|
||||||
CREATOR;
|
CREATOR,
|
||||||
|
UNFINISHED;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -226,7 +226,7 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Pair<PanelComponent, RayTraceResult> getSelectedComponent(EntityPlayer player, Vec3d hit, boolean hitAbs) {
|
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();
|
Matrix4 mat = components.getPanelTopTransform();
|
||||||
mat.invert();
|
mat.invert();
|
||||||
PanelComponent retPc = null;
|
PanelComponent retPc = null;
|
||||||
|
|
|
@ -41,7 +41,6 @@ import java.util.List;
|
||||||
|
|
||||||
public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI, IBlockBoundsIW {
|
public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI, IBlockBoundsIW {
|
||||||
public List<PanelComponent> components = new ArrayList<>();
|
public List<PanelComponent> components = new ArrayList<>();
|
||||||
public float height = 0.5F;
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public ItemStack inv = ItemStack.EMPTY;
|
public ItemStack inv = ItemStack.EMPTY;
|
||||||
|
|
||||||
|
@ -49,7 +48,6 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI,
|
||||||
public void readNBT(NBTTagCompound nbt, boolean updatePacket) {
|
public void readNBT(NBTTagCompound nbt, boolean updatePacket) {
|
||||||
NBTTagList l = nbt.getTagList("components", 10);
|
NBTTagList l = nbt.getTagList("components", 10);
|
||||||
PanelUtils.readListFromNBT(l, components);
|
PanelUtils.readListFromNBT(l, components);
|
||||||
height = nbt.getFloat("height");
|
|
||||||
NBTTagCompound invTag;
|
NBTTagCompound invTag;
|
||||||
if (nbt.hasKey("inventory", 9)) {
|
if (nbt.hasKey("inventory", 9)) {
|
||||||
invTag = nbt.getTagList("inventory", 10).getCompoundTagAt(0);
|
invTag = nbt.getTagList("inventory", 10).getCompoundTagAt(0);
|
||||||
|
@ -73,7 +71,8 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI,
|
||||||
comps.appendTag(nbtInner);
|
comps.appendTag(nbtInner);
|
||||||
}
|
}
|
||||||
nbt.setTag("components", comps);
|
nbt.setTag("components", comps);
|
||||||
nbt.setFloat("height", height);
|
nbt.setFloat("height", PanelUtils.getHeight(inv));
|
||||||
|
nbt.setFloat("angle", PanelUtils.getAngle(inv));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -86,7 +85,6 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI,
|
||||||
if (pc != null) {
|
if (pc != null) {
|
||||||
pc.setX(nbt.getFloat("x"));
|
pc.setX(nbt.getFloat("x"));
|
||||||
pc.setY(nbt.getFloat("y"));
|
pc.setY(nbt.getFloat("y"));
|
||||||
pc.setPanelHeight(height);
|
|
||||||
components.add(pc);
|
components.add(pc);
|
||||||
if (!curr.isEmpty()) {
|
if (!curr.isEmpty()) {
|
||||||
curr.shrink(1);
|
curr.shrink(1);
|
||||||
|
@ -110,13 +108,24 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CREATE_PANEL:
|
case CREATE_PANEL:
|
||||||
if (ItemStack.areItemStacksEqual(PanelUtils.getPanelBase(), inv)) {
|
if (ItemStack.areItemsEqual(PanelUtils.getPanelBase(), inv)) {
|
||||||
NBTTagCompound panelNBT = new NBTTagCompound();
|
float height = PanelUtils.getHeight(inv);
|
||||||
writeToItemNBT(panelNBT, true);
|
float angle = PanelUtils.getAngle(inv);
|
||||||
ItemStack panel = new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.TOP.ordinal());
|
boolean valid = true;
|
||||||
panel.setTagCompound(panelNBT);
|
for (PanelComponent comp : components) {
|
||||||
inv = panel;
|
if (!comp.isValidPos(components, height, angle)) {
|
||||||
components.clear();
|
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;
|
break;
|
||||||
case REMOVE_ALL:
|
case REMOVE_ALL:
|
||||||
|
@ -138,7 +147,6 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI,
|
||||||
TileEntityPanel te = new TileEntityPanel();
|
TileEntityPanel te = new TileEntityPanel();
|
||||||
te.readFromItemNBT(inv.getTagCompound());
|
te.readFromItemNBT(inv.getTagCompound());
|
||||||
components = new ArrayList<>(te.getComponents());
|
components = new ArrayList<>(te.getComponents());
|
||||||
height = te.getComponents().height;
|
|
||||||
inv = ItemStack.EMPTY;
|
inv = ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -98,5 +98,6 @@ public class ClientEventHandler {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void bakeModel(ModelBakeEvent event) {
|
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=top"), new PanelModel());
|
||||||
|
event.getModelRegistry().putObject(new ModelResourceLocation(IndustrialWires.MODID + ":control_panel", "inventory,type=unfinished"), new PanelModel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class RawQuad {
|
||||||
if (normal != null) {
|
if (normal != null) {
|
||||||
this.normal = normal;
|
this.normal = normal;
|
||||||
} else {
|
} 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.normal.normalise(this.normal);
|
||||||
}
|
}
|
||||||
this.uvs = uvs;
|
this.uvs = uvs;
|
||||||
|
|
|
@ -25,8 +25,10 @@ import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
|
||||||
import malte0811.industrialWires.containers.ContainerPanelCreator;
|
import malte0811.industrialWires.containers.ContainerPanelCreator;
|
||||||
import malte0811.industrialWires.controlpanel.MessageType;
|
import malte0811.industrialWires.controlpanel.MessageType;
|
||||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||||
|
import malte0811.industrialWires.controlpanel.PanelUtils;
|
||||||
import malte0811.industrialWires.items.ItemPanelComponent;
|
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||||
import malte0811.industrialWires.network.MessageGUIInteract;
|
import malte0811.industrialWires.network.MessageGUIInteract;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Gui;
|
import net.minecraft.client.gui.Gui;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||||
|
@ -103,7 +105,9 @@ public class GuiPanelCreator extends GuiContainer {
|
||||||
pc.setX(x / (float) panelSize);
|
pc.setX(x / (float) panelSize);
|
||||||
pc.setY(y / (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();
|
AxisAlignedBB aabb = pc.getBlockRelativeAABB();
|
||||||
int left = (int) (getX0() + aabb.minX * panelSize) - 1;
|
int left = (int) (getX0() + aabb.minX * panelSize) - 1;
|
||||||
int top = (int) (getY0() + aabb.minZ * 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) {
|
if (0 <= xRel && xRel <= panelSize && 0 <= yRel && yRel <= panelSize) {
|
||||||
List<PanelComponent> components = container.tile.components;
|
List<PanelComponent> components = container.tile.components;
|
||||||
if (curr != null) {
|
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();
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
nbt.setFloat("x", curr.getX());
|
nbt.setFloat("x", curr.getX());
|
||||||
nbt.setFloat("y", curr.getY());
|
nbt.setFloat("y", curr.getY());
|
||||||
|
|
|
@ -24,6 +24,7 @@ import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
|
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
|
||||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
||||||
|
import malte0811.industrialWires.blocks.controlpanel.TileEntityUnfinishedPanel;
|
||||||
import malte0811.industrialWires.controlpanel.PanelUtils;
|
import malte0811.industrialWires.controlpanel.PanelUtils;
|
||||||
import malte0811.industrialWires.controlpanel.PropertyComponents;
|
import malte0811.industrialWires.controlpanel.PropertyComponents;
|
||||||
import malte0811.industrialWires.controlpanel.PropertyComponents.PanelRenderProperties;
|
import malte0811.industrialWires.controlpanel.PropertyComponents.PanelRenderProperties;
|
||||||
|
@ -188,10 +189,10 @@ public class PanelModel implements IBakedModel {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) {
|
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 {
|
try {
|
||||||
return ITEM_MODEL_CACHE.get(stack, () -> {
|
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());
|
te.readFromItemNBT(stack.getTagCompound());
|
||||||
return new AssembledBakedModel(te.getComponents());
|
return new AssembledBakedModel(te.getComponents());
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
package malte0811.industrialWires.controlpanel;
|
package malte0811.industrialWires.controlpanel;
|
||||||
|
|
||||||
import blusunrize.immersiveengineering.common.util.IELogger;
|
import malte0811.industrialWires.IndustrialWires;
|
||||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
||||||
import malte0811.industrialWires.client.RawQuad;
|
import malte0811.industrialWires.client.RawQuad;
|
||||||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||||
|
@ -30,8 +30,10 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import net.minecraftforge.fml.common.FMLLog;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
import org.apache.logging.log4j.Level;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -154,7 +156,7 @@ public abstract class PanelComponent {
|
||||||
ret.setPanelHeight(nbt.getFloat("panelHeight"));
|
ret.setPanelHeight(nbt.getFloat("panelHeight"));
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
IELogger.info("(IndustrialWires) Unknown panel component: " + type);//TODO own logger?
|
FMLLog.log(IndustrialWires.MODID, Level.WARN, "Unknown panel component: " + type);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,18 +191,20 @@ public abstract class PanelComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isValidPos(List<PanelComponent> components) {
|
public boolean isValidPos(List<PanelComponent> components, float height, float angle) {
|
||||||
AxisAlignedBB aabb = getBlockRelativeAABB().offset(0, panelHeight, 0);
|
float h = PanelUtils.getHeightWithComponent(this, angle, height);
|
||||||
if (aabb.minX < 0 || aabb.maxX > 1) {
|
if (h < 0 || h > 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (aabb.minY < 0 || aabb.maxY > 1) {
|
|
||||||
|
AxisAlignedBB aabb = getBlockRelativeAABB();
|
||||||
|
if (aabb.minX < 0 || aabb.maxX > 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (aabb.minZ < 0 || aabb.maxZ > 1) {
|
if (aabb.minZ < 0 || aabb.maxZ > 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
aabb = getBlockRelativeAABB();
|
|
||||||
for (PanelComponent pc : components) {
|
for (PanelComponent pc : components) {
|
||||||
if (pc == this) {
|
if (pc == this) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -20,7 +20,6 @@ package malte0811.industrialWires.controlpanel;
|
||||||
|
|
||||||
import blusunrize.immersiveengineering.api.Lib;
|
import blusunrize.immersiveengineering.api.Lib;
|
||||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||||
import ic2.api.item.IC2Items;
|
|
||||||
import malte0811.industrialWires.IndustrialWires;
|
import malte0811.industrialWires.IndustrialWires;
|
||||||
import malte0811.industrialWires.blocks.controlpanel.BlockPanel;
|
import malte0811.industrialWires.blocks.controlpanel.BlockPanel;
|
||||||
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
|
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
|
||||||
|
@ -93,13 +92,13 @@ public final class PanelUtils {
|
||||||
baseNorm.transpose();
|
baseNorm.transpose();
|
||||||
|
|
||||||
List<RawQuad> rawOut = new ArrayList<>();
|
List<RawQuad> rawOut = new ArrayList<>();
|
||||||
//addTexturedBox(new Vector3f(0, 0, 0), new Vector3f(1, components.height, 1), rawOut, UV_FULL, PANEL_TEXTURE);
|
float height1 = getLocalHeightFromZ(1, components.height, components.angle);
|
||||||
float maxHeight = components.getPanelMaxHeight();
|
float height0 = getLocalHeightFromZ(0, components.height, components.angle);
|
||||||
float vMaxLower = 16 * components.height;
|
float vMax1 = 16 * height1;
|
||||||
float vMaxUpper = 16 * maxHeight;
|
float vMax0 = 16 * height0;
|
||||||
//TOP
|
//TOP
|
||||||
rawOut.add(new RawQuad(new Vector3f(0, maxHeight, 0), new Vector3f(0, components.height, 1),
|
rawOut.add(new RawQuad(new Vector3f(0, height0, 0), new Vector3f(0, height1, 1),
|
||||||
new Vector3f(1, components.height, 1), new Vector3f(1, maxHeight, 0),
|
new Vector3f(1, height1, 1), new Vector3f(1, height0, 0),
|
||||||
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, UV_FULL, -1));
|
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, UV_FULL, -1));
|
||||||
//BOTTOM
|
//BOTTOM
|
||||||
rawOut.add(new RawQuad(new Vector3f(0, 0, 0), new Vector3f(1, 0, 0),
|
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));
|
EnumFacing.DOWN, PANEL_TEXTURE, WHITE, null, UV_FULL, -1));
|
||||||
//LEFT
|
//LEFT
|
||||||
rawOut.add(new RawQuad(new Vector3f(0, 0, 0), new Vector3f(0, 0, 1),
|
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[][]{
|
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[][]{
|
||||||
{0, 0}, {0, 16},
|
{0, 0}, {0, 16},
|
||||||
{vMaxLower, 16}, {vMaxUpper, 0}
|
{vMax1, 16}, {vMax0, 0}
|
||||||
}, -1));
|
}, -1));
|
||||||
//RIGHT
|
//RIGHT
|
||||||
rawOut.add(new RawQuad(new Vector3f(1, 0, 0), new Vector3f(1, maxHeight, 0),
|
rawOut.add(new RawQuad(new Vector3f(1, 0, 0), new Vector3f(1, height0, 0),
|
||||||
new Vector3f(1, components.height, 1), new Vector3f(1, 0, 1),
|
new Vector3f(1, height1, 1), new Vector3f(1, 0, 1),
|
||||||
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[][]{
|
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[][]{
|
||||||
{0, 0}, {vMaxUpper, 0},
|
{0, 0}, {vMax0, 0},
|
||||||
{vMaxLower, 16}, {0, 16}
|
{vMax1, 16}, {0, 16}
|
||||||
}, -1));
|
}, -1));
|
||||||
//BACK
|
//BACK
|
||||||
rawOut.add(new RawQuad(new Vector3f(1, 0, 0), new Vector3f(0, 0, 0),
|
rawOut.add(new RawQuad(new Vector3f(1, 0, 0), new Vector3f(0, 0, 0),
|
||||||
new Vector3f(0, maxHeight, 0), new Vector3f(1, maxHeight, 0),
|
new Vector3f(0, height0, 0), new Vector3f(1, height0, 0),
|
||||||
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[]{0, 0, vMaxUpper, 16}, -1));
|
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[]{0, 0, vMax0, 16}, -1));
|
||||||
//FRONT
|
//FRONT
|
||||||
rawOut.add(new RawQuad(new Vector3f(0, 0, 1), new Vector3f(1, 0, 1),
|
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),
|
new Vector3f(1, height1, 1), new Vector3f(0, height1, 1),
|
||||||
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[]{0, 0, vMaxLower, 16}, -1));
|
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[]{0, 0, vMax1, 16}, -1));
|
||||||
for (RawQuad bq : rawOut) {
|
for (RawQuad bq : rawOut) {
|
||||||
ret.add(bakeQuad(bq, baseTrans, baseNorm));
|
ret.add(bakeQuad(bq, baseTrans, baseNorm));
|
||||||
}
|
}
|
||||||
|
@ -358,7 +357,7 @@ public final class PanelUtils {
|
||||||
|
|
||||||
public static ItemStack getPanelBase() {
|
public static ItemStack getPanelBase() {
|
||||||
if (panelBase == null) {
|
if (panelBase == null) {
|
||||||
panelBase = IC2Items.getItem("resource", "machine");
|
panelBase = new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.UNFINISHED.ordinal());
|
||||||
}
|
}
|
||||||
return panelBase;
|
return panelBase;
|
||||||
}
|
}
|
||||||
|
@ -380,4 +379,38 @@ public final class PanelUtils {
|
||||||
}
|
}
|
||||||
return ret;
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -22,7 +22,6 @@ import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
@ -81,9 +80,8 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
|
||||||
}
|
}
|
||||||
|
|
||||||
public Matrix4 getPanelTopTransform() {
|
public Matrix4 getPanelTopTransform() {
|
||||||
double centerOffset = -.5 * (1 / Math.cos(angle) - 1);
|
return getPanelBaseTransform().translate(0, height, .5)
|
||||||
return getPanelBaseTransform().translate(0, height, 1)
|
.rotate(angle, 1, 0, 0).translate(0, 0, -.5);
|
||||||
.rotate(angle, 1, 0, 0).translate(0, 0, centerOffset - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
|
@ -94,10 +92,10 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
|
||||||
GlStateManager.translate(px + .5, py + .5, pz + .5);
|
GlStateManager.translate(px + .5, py + .5, pz + .5);
|
||||||
switch (top) {
|
switch (top) {
|
||||||
case DOWN:
|
case DOWN:
|
||||||
GlStateManager.rotate(180, 0, 0, 1);
|
GlStateManager.rotate(180, 1, 0, 0);
|
||||||
case UP:
|
|
||||||
GlStateManager.rotate(-facing.getHorizontalAngle(), 0, 1, 0);
|
GlStateManager.rotate(-facing.getHorizontalAngle(), 0, 1, 0);
|
||||||
break;
|
break;
|
||||||
|
case UP:
|
||||||
case NORTH:
|
case NORTH:
|
||||||
case SOUTH:
|
case SOUTH:
|
||||||
case WEST:
|
case WEST:
|
||||||
|
@ -106,12 +104,10 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
|
||||||
GlStateManager.rotate(top.getHorizontalAngle(), 0, 0, 1);
|
GlStateManager.rotate(top.getHorizontalAngle(), 0, 0, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
GlStateManager.translate(-.5, height - .5, -.5);
|
GlStateManager.translate(-.5, height - .5, 0);
|
||||||
GlStateManager.rotate((float) (-angle * 180 / Math.PI), 1, 0, 0);
|
GlStateManager.rotate((float) (angle * 180 / Math.PI), 1, 0, 0);
|
||||||
GlStateManager.translate(.5, 0, .5);
|
GlStateManager.translate(0, 0, -.5);
|
||||||
GlStateManager.rotate(180, 0, 1, 0);
|
|
||||||
double centerOffset = .5 * (1 / Math.cos(angle) - 1);
|
|
||||||
GlStateManager.translate(-.5, 0, -.5 - centerOffset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Matrix4 getPanelBaseTransform() {
|
public Matrix4 getPanelBaseTransform() {
|
||||||
|
@ -137,14 +133,10 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
|
||||||
|
|
||||||
public float getMaxHeight() {
|
public float getMaxHeight() {
|
||||||
float max = getPanelMaxHeight();
|
float max = getPanelMaxHeight();
|
||||||
double centerOffset = .5 * (1 / Math.cos(angle) - 1);
|
|
||||||
for (PanelComponent pc : this) {
|
for (PanelComponent pc : this) {
|
||||||
AxisAlignedBB aabb = pc.getBlockRelativeAABB();
|
float h = PanelUtils.getHeightWithComponent(pc, angle, height);
|
||||||
double y = angle > 0 ? aabb.minY : aabb.maxY;
|
if (h > max) {
|
||||||
float hComp = (float) (pc.getHeight() * Math.cos(angle));
|
max = h;
|
||||||
float localPanelHeight = (float) (height + (1 - (y + centerOffset)) * Math.sin(angle));
|
|
||||||
if (hComp + localPanelHeight > max) {
|
|
||||||
max = hComp + localPanelHeight;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return max;
|
return max;
|
||||||
|
@ -162,7 +154,7 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getPanelMaxHeight() {
|
public float getPanelMaxHeight() {
|
||||||
return (float) (height + Math.tan(angle));
|
return (float) (height + Math.abs(Math.tan(angle) / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -177,6 +177,7 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderInGUI(GuiPanelCreator gui) {
|
public void renderInGUI(GuiPanelCreator gui) {
|
||||||
|
AxisAlignedBB aabb = getBlockRelativeAABB();
|
||||||
int left = (int) Math.ceil(gui.getX0() + (offset + aabb.minX) * gui.panelSize);
|
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 top = (int) Math.ceil(gui.getY0() + (offset + aabb.minZ) * gui.panelSize);
|
||||||
int right = (int) Math.floor(gui.getX0() + (aabb.maxX - offset) * gui.panelSize);
|
int right = (int) Math.floor(gui.getX0() + (aabb.maxX - offset) * gui.panelSize);
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
"model": "immersiveengineering:smartmodel/conn_rs_panel_conn"
|
"model": "immersiveengineering:smartmodel/conn_rs_panel_conn"
|
||||||
},
|
},
|
||||||
"top": {
|
"top": {
|
||||||
"model": "industrialwires:smartmodel/panel_normal"
|
"model": "industrialwires:smartmodel/panel"
|
||||||
},
|
},
|
||||||
"dummy": {
|
"dummy": {
|
||||||
"model": "cube_all",
|
"model": "cube_all",
|
||||||
|
@ -64,7 +64,10 @@
|
||||||
},
|
},
|
||||||
"creator": {
|
"creator": {
|
||||||
"model":"industrialwires:panel_creator.obj"
|
"model":"industrialwires:panel_creator.obj"
|
||||||
}
|
},
|
||||||
|
"unfinished": {
|
||||||
|
"model": "industrialwires:smartmodel/panel"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"inventory,type=rs_wire": {
|
"inventory,type=rs_wire": {
|
||||||
"model":"industrialwires:rs_panel_conn.obj",
|
"model":"industrialwires:rs_panel_conn.obj",
|
||||||
|
@ -96,6 +99,10 @@
|
||||||
},
|
},
|
||||||
"inventory,type=top": {
|
"inventory,type=top": {
|
||||||
"model":"industrialwires:block/panel_creator.obj"//Doesn't matter, this will be overridden in code
|
"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
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,10 @@ industrialwires.desc.green=Green
|
||||||
industrialwires.desc.blue=Blue
|
industrialwires.desc.blue=Blue
|
||||||
industrialwires.desc.length=Length
|
industrialwires.desc.length=Length
|
||||||
industrialwires.desc.wide_info=Wide Format
|
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.wide=Wide
|
||||||
industrialwires.tooltip.narrow=Narrow
|
industrialwires.tooltip.narrow=Narrow
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue