Merge branch 'MC1.11' into marx

This commit is contained in:
malte0811 2017-06-05 17:23:18 +02:00
commit 206c1170f1
14 changed files with 377 additions and 16 deletions

View file

@ -137,6 +137,8 @@ public class Recipes {
"rdr", " w ", 'r', "stickSteel", 'd', Items.IRON_DOOR, 'w', "wireCopper"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(key, 1, 0),
"rrp", 'r', "stickSteel", 'p', "plateSteel"));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(panelComponent, 1, 8),
"wireCopper", new ItemStack(IEContent.itemTool, 1, 2)));
}
private static void addJacobs() {
ItemStack mvTransformer = IC2Items.getItem("te", "mv_transformer");

View file

@ -90,7 +90,7 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
for (AbstractConnection c : conns) {
IImmersiveConnectable iic = ApiUtils.toIIC(c.end, world);
if (iic instanceof IIC2Connector) {
double tmp = inBuffer - ((IIC2Connector) iic).insertEnergy(outputMax, true);
double tmp = outputMax - ((IIC2Connector) iic).insertEnergy(outputMax, true);
if (tmp > .00000001) {
maxOutputs.put(c, new ImmutablePair<>((IIC2Connector) iic, tmp));
sum += tmp;

View file

@ -248,7 +248,8 @@ public class ClientProxy extends CommonProxy {
new ManualPages.CraftingMulti(m, "industrialwires.toggle_switch", new ItemStack(IndustrialWires.panelComponent, 1, 5), new ItemStack(IndustrialWires.panelComponent, 1, 6)),
new ManualPages.Text(m, "industrialwires.toggle_switch1"),
new ManualPages.Crafting(m, "industrialwires.variac", new ItemStack(IndustrialWires.panelComponent, 1, 4)),
new ManualPages.CraftingMulti(m, "industrialwires.lock", new ItemStack(IndustrialWires.panelComponent, 1, 7), new ItemStack(IndustrialWires.key))
new ManualPages.CraftingMulti(m, "industrialwires.lock", new ItemStack(IndustrialWires.panelComponent, 1, 7), new ItemStack(IndustrialWires.key)),
new ManualPages.Crafting(m, "industrialwires.panel_meter", new ItemStack(IndustrialWires.panelComponent, 1, 8))
);
}

View file

@ -18,6 +18,7 @@
package malte0811.industrialWires.client.panelmodel;
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
import com.google.common.collect.ImmutableList;
import malte0811.industrialWires.client.RawQuad;
import net.minecraft.client.Minecraft;
@ -37,6 +38,7 @@ public class RawModelFontRenderer extends FontRenderer {
private ImmutableList.Builder<RawQuad> builder = ImmutableList.builder();
private final Vector3f normal = new Vector3f(0, 1, 0);
public final float scale;
public Matrix4 transform = null;
private TextureAtlasSprite sprite;
@ -63,9 +65,13 @@ public class RawModelFontRenderer extends FontRenderer {
v2.scale(scale);
Vector3f v3 = new Vector3f(posX + w, h0, posY);
v3.scale(scale);
builder.add(new RawQuad(v0, v1, v2, v3,
RawQuad quad = new RawQuad(v0, v1, v2, v3,
EnumFacing.UP, sprite, colorA, new Vector3f(0, 1, 0),
new float[]{x, y, x + wt, y + ht}));
new float[]{x, y, x + wt, y + ht});
if (transform!=null) {
quad = quad.apply(transform);
}
builder.add(quad);
return charWidth[pos];
}

View file

@ -75,7 +75,6 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
}
private static final float size = .0625F;
private static final float antiZOffset = .001F;
@Override
public List<RawQuad> getQuads() {
@ -85,7 +84,7 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
color[i] = ((this.colorA >> (8 * (2 - i))) & 255) / 255F * (rsInput + 15F) / 30F;
}
List<RawQuad> ret = new ArrayList<>(1);
PanelUtils.addColoredQuad(ret, new Vector3f(), new Vector3f(0, antiZOffset, size), new Vector3f(size, antiZOffset, size), new Vector3f(size, antiZOffset, 0), EnumFacing.UP, color);
PanelUtils.addColoredQuad(ret, new Vector3f(), new Vector3f(0, 0, size), new Vector3f(size, 0, size), new Vector3f(size, 0, 0), EnumFacing.UP, color);
if (rsInput>0) {
ret.get(ret.size()-1).light = 0xff0ff;
}

View file

@ -39,10 +39,10 @@ import javax.annotation.Nullable;
import java.util.List;
public class Label extends PanelComponent implements IConfigurableComponent {
private static final ResourceLocation font = new ResourceLocation("minecraft", "textures/font/ascii.png");
String text = "Test";
RawModelFontRenderer renderer;
int color = 0x808080;
public static final ResourceLocation FONT = new ResourceLocation("minecraft", "textures/font/ascii.png");
private String text = "Test";
private RawModelFontRenderer renderer;
private int color = 0x808080;
public Label(String text, int color) {
this();
@ -116,7 +116,7 @@ public class Label extends PanelComponent implements IConfigurableComponent {
private RawModelFontRenderer fontRenderer() {
if (renderer == null) {
renderer = new RawModelFontRenderer(Minecraft.getMinecraft().gameSettings, font, Minecraft.getMinecraft().getTextureManager(),
renderer = new RawModelFontRenderer(Minecraft.getMinecraft().gameSettings, FONT, Minecraft.getMinecraft().getTextureManager(),
false, 1);
}
return renderer;

View file

@ -144,6 +144,7 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
public PanelComponent copyOf() {
Lock ret = new Lock(latching, rsOutputId, rsOutputChannel);
ret.turned = turned;
ret.lockID = lockID;
ret.keyNBT = keyNBT == null ? null : keyNBT.copy();
ret.ticksTillOff = ticksTillOff;
ret.setX(x);

View file

@ -71,6 +71,7 @@ public abstract class PanelComponent {
baseCreaters.put("toggle_switch", ToggleSwitch::new);
baseCreaters.put("toggle_switch_covered", CoveredToggleSwitch::new);
baseCreaters.put("lock", Lock::new);
baseCreaters.put("panel_meter", PanelMeter::new);
}
protected abstract void writeCustomNBT(NBTTagCompound nbt, boolean toItem);

View file

@ -0,0 +1,334 @@
/*
* 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.controlpanel;
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
import malte0811.industrialWires.client.RawQuad;
import malte0811.industrialWires.client.gui.GuiPanelCreator;
import malte0811.industrialWires.client.panelmodel.RawModelFontRenderer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagByte;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.Vec3d;
import org.lwjgl.util.vector.Vector3f;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
public class PanelMeter extends PanelComponent implements IConfigurableComponent {
public static final String WIDE = "wide";
private int rsInputId;
private byte rsInputChannel;
private byte rsInput;
private boolean wide = true;
public PanelMeter() {
super("panel_meter");
}
public PanelMeter(int rsId, byte rsChannel, boolean wide) {
this();
rsInputChannel = rsChannel;
rsInputId = rsId;
this.wide = wide;
}
@Override
protected void writeCustomNBT(NBTTagCompound nbt, boolean toItem) {
nbt.setInteger(RS_ID, rsInputId);
nbt.setByte(RS_CHANNEL, rsInputChannel);
nbt.setBoolean(WIDE, wide);
if (!toItem) {
nbt.setInteger("rsInput", rsInput);
}
}
@Override
protected void readCustomNBT(NBTTagCompound nbt) {
rsInputId = nbt.getInteger(RS_ID);
rsInputChannel = nbt.getByte(RS_CHANNEL);
rsInput = nbt.getByte("rsInput");
wide = nbt.getBoolean(WIDE);
}
private static final float SIZE = .25F;
private static final float WIDTH = 1.5F*SIZE;
private static final float BORDER = SIZE /20;
private static final float antiZOffset = .0001F;
private static final float[] BLACK = {0, 0, 0, 1};
private static final float[] WHITE = {1, 1, 1, 1};
@Override
public List<RawQuad> getQuads() {
List<RawQuad> ret = new ArrayList<>();
float width = wide?WIDTH:SIZE;
//main panel
PanelUtils.addColoredQuad(ret, new Vector3f(), new Vector3f(0, 0, SIZE), new Vector3f(width, 0, SIZE),
new Vector3f(width, 0, 0), EnumFacing.UP, BLACK);
PanelUtils.addColoredQuad(ret, new Vector3f(BORDER, antiZOffset, BORDER), new Vector3f(BORDER, antiZOffset, SIZE-BORDER),
new Vector3f(width-BORDER, antiZOffset, SIZE-BORDER), new Vector3f(width-BORDER, antiZOffset, BORDER), EnumFacing.UP, WHITE);
RawModelFontRenderer r = fontRenderer();
r.transform = new Matrix4();
for (int i = 0;i<=3;i++) {
transformNumber(r.transform, (byte)(5*i));
String asString = Integer.toString(5*i);
int lengthHalf = r.getStringWidth(asString)/2;
r.transform.translate(-lengthHalf*r.scale, 0, -3.5*r.scale);
r.drawString(asString, 0, 0, 0xff000000);
ret.addAll(r.build());
}
r.transform = null;
Matrix4 mat = new Matrix4();
transformNeedle(mat, rsInput);
float wHalf = BORDER/2;
float length = getLength();
PanelUtils.addColoredQuad(ret, new Vector3f(wHalf, 0, 0),new Vector3f(-wHalf, 0, 0), new Vector3f(-wHalf, 0, length),
new Vector3f(wHalf, 0, length), EnumFacing.UP, BLACK, mat);
return ret;
}
private static RawModelFontRenderer renderer;
private RawModelFontRenderer fontRenderer() {
if (renderer == null) {
renderer = new RawModelFontRenderer(Minecraft.getMinecraft().gameSettings, Label.FONT, Minecraft.getMinecraft().getTextureManager(),
false, .5F);
}
return renderer;
}
private void transformNumber(Matrix4 mat, byte value) {
if (wide) {
transformNeedle(mat, value);
mat.translate(0, 0, getLength()+1.5*BORDER);
mat.scale(-1, 1, -1);
} else {
mat.setIdentity().translate(0, antiZOffset, SIZE);
mat.translate(SIZE-3*BORDER, 0, -3*BORDER);
float angle = 90*(1-value/15F);
angle = (float) (angle*Math.PI/180);
float length = getLength()+BORDER;
mat.translate((float)(-Math.sin(angle)*length), 0, (float)(-Math.cos(angle)*length));
}
}
private void transformNeedle(Matrix4 mat, byte value) {
mat.setIdentity().translate(0, 2*antiZOffset, SIZE);
float angle;
if (wide) {
mat.translate(WIDTH/2, 0, -2*BORDER);
angle = 50-(100*(value/15F));
} else {
mat.translate(SIZE-3*BORDER, 0, -3*BORDER);
angle = 90-(90*(value/15F));
}
angle = (float) ((180+angle)*Math.PI/180);
mat.rotate(angle, 0, 1, 0);
}
private float getLength() {
return SIZE-(wide?6:7)*BORDER;
}
@Nonnull
@Override
public PanelComponent copyOf() {
PanelMeter ret = new PanelMeter(rsInputId, rsInputChannel, wide);
ret.rsInput = rsInput;
ret.setX(x);
ret.setY(y);
ret.panelHeight = panelHeight;
return ret;
}
@Nonnull
@Override
public AxisAlignedBB getBlockRelativeAABB() {
if (aabb == null) {
aabb = new AxisAlignedBB(x, 0, y, x + (wide?WIDTH:SIZE), 0, y + SIZE);
}
return aabb;
}
@Override
public void interactWith(Vec3d hitRelative, TileEntityPanel tile, EntityPlayerMP player) {
}
@Override
public void update(TileEntityPanel tile) {
}
private TileEntityPanel panel;
private Consumer<byte[]> handler = (input) -> {
if (input[rsInputChannel] != rsInput) {
rsInput = input[rsInputChannel];
panel.markDirty();
panel.triggerRenderUpdate();
}
};
@Nullable
@Override
public Consumer<byte[]> getRSInputHandler(int id, TileEntityPanel panel) {
if (id == rsInputId) {
this.panel = panel;
return handler;
}
return null;
}
@Override
public float getHeight() {
return 0;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
PanelMeter that = (PanelMeter) o;
if (rsInputId != that.rsInputId) return false;
if (rsInputChannel != that.rsInputChannel) return false;
if (rsInput != that.rsInput) return false;
return wide == that.wide;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + rsInputId;
result = 31 * result + (int) rsInputChannel;
result = 31 * result + (int) rsInput;
result = 31 * result + (wide ? 1 : 0);
return result;
}
@Override
public void renderInGUI(GuiPanelCreator gui) {
renderInGUIDefault(gui, 0);
AxisAlignedBB aabb = getBlockRelativeAABB();
int left = (int) Math.ceil(gui.getX0() + (aabb.minX+BORDER) * gui.panelSize);
int top = (int) Math.ceil(gui.getY0() + (aabb.minZ+BORDER) * gui.panelSize);
int right = (int) Math.floor(gui.getX0() + (aabb.maxX-BORDER) * gui.panelSize);
int bottom = (int) Math.floor(gui.getY0() + (aabb.maxZ-BORDER) * gui.panelSize);
Gui.drawRect(left, top, right, bottom, ~0);
GlStateManager.pushMatrix();
int border = (int) Math.ceil(BORDER*gui.panelSize);
int width = right-left;
int height = bottom-top;
if (wide) {
GlStateManager.translate(left+width/2D, bottom-2*border, 0);
GlStateManager.rotate(135, 0, 0, 1);
} else {
GlStateManager.translate(right-2*border, bottom-2*border, 0);
GlStateManager.rotate(120, 0, 0, 1);
}
left = (int) Math.floor(-BORDER * gui.panelSize/2);
top = 0;
right = (int) Math.ceil(BORDER*gui.panelSize/2);
bottom = (int) Math.floor(getLength() * gui.panelSize);
Gui.drawRect(left, top, right, bottom, 0xff000000);
GlStateManager.popMatrix();
}
@Override
public void applyConfigOption(ConfigType type, int id, NBTBase value) {
switch (type) {
case RS_CHANNEL:
rsInputChannel = ((NBTTagByte) value).getByte();
break;
case INT:
rsInputId = ((NBTTagInt) value).getInt();
break;
case BOOL:
wide = ((NBTTagByte)value).getByte()!=0;
}
}
@Nullable
@Override
public String fomatConfigName(ConfigType type, int id) {
switch (type) {
case FLOAT:
return I18n.format(IndustrialWires.MODID + ".desc." + (id == 0 ? "red" : (id == 1 ? "green" : "blue")));
case BOOL:
return I18n.format(IndustrialWires.MODID + ".desc.wide_info");
case RS_CHANNEL:
case INT:
default:
return null;
}
}
@Nullable
@Override
public String fomatConfigDescription(ConfigType type, int id) {
switch (type) {
case FLOAT:
return null;
case RS_CHANNEL:
return I18n.format(IndustrialWires.MODID + ".desc.rschannel_info");
case INT:
return I18n.format(IndustrialWires.MODID + ".desc.rsid_info");
default:
return null;
}
}
@Override
public RSChannelConfig[] getRSChannelOptions() {
return new RSChannelConfig[]{
new RSChannelConfig("channel", 0, 0, rsInputChannel)
};
}
@Override
public IntConfig[] getIntegerOptions() {
return new IntConfig[]{
new IntConfig("rsId", 0, 45, rsInputId, 2, false)
};
}
@Override
public BoolConfig[] getBooleanOptions() {
return new BoolConfig[]{
new BoolConfig("wide", 70, 10, wide)
};
}
@Override
public int getColor() {
return ~0;
}
}

View file

@ -81,7 +81,7 @@ public final class PanelUtils {
m4RotOnly.invert();
m4RotOnly.transpose();
for (PanelComponent pc : components) {
Matrix4 m4Here = m4.copy().translate(pc.getX(), 0, pc.getY());
Matrix4 m4Here = m4.copy().translate(pc.getX(), .0001, pc.getY());
List<RawQuad> compQuads = pc.getQuads();
for (RawQuad bq : compQuads) {
ret.add(bakeQuad(bq, m4Here, m4RotOnly, false));
@ -292,6 +292,12 @@ public final class PanelUtils {
list.add(I18n.format(IndustrialWires.MODID + ".tooltip." + (data.getBoolean(LATCHING) ? "latching" : "instantaneous")));
}
break;
case 8://Panel meter
addCommonInfo(data, list, false, true);
if (data.hasKey(PanelMeter.WIDE)) {
list.add(I18n.format(IndustrialWires.MODID + ".tooltip." + (data.getBoolean(PanelMeter.WIDE) ? "wide" : "narrow")));
}
break;
}
}

View file

@ -45,7 +45,8 @@ import java.util.List;
public class ItemPanelComponent extends Item implements INetGUIItem {
public static final String[] types = {
"lighted_button", "label", "indicator_light", "slider", "variac", "toggle_switch", "toggle_switch_covered", "lock"
"lighted_button", "label", "indicator_light", "slider", "variac", "toggle_switch", "toggle_switch_covered",
"lock", "panel_meter"
};
public static final String TYPE = "type";
public static final String ID = "cfgId";

View file

@ -36,6 +36,7 @@ item.industrialwires.panel_component.variac.name=Variac®
item.industrialwires.panel_component.toggle_switch.name=Toggle Switch
item.industrialwires.panel_component.toggle_switch_covered.name=Covered Toggle Switch
item.industrialwires.panel_component.lock.name=Lock Switch
item.industrialwires.panel_component.panel_meter.name=Panel Meter
item.industrialwires.key.key.name=Key
item.industrialwires.key.key_named.name=Key for
item.industrialwires.key.blank_key.name=Blank Key
@ -50,15 +51,17 @@ industrialwires.desc.enable_snap=Snap new components to the 16*16 grid
industrialwires.desc.disable_snap=Allow free placing of components
industrialwires.desc.latching=Latching
industrialwires.desc.latching_info=Does this button stay on indefinitely?
industrialwires.desc.latching_info=Does this button stay on indefinitely?
industrialwires.desc.disassemble=Disassemble the panel
industrialwires.desc.rsid_info=The ID of the redstone wire controller to output a signal to
industrialwires.desc.rschannel_info=The color of the channel to output the signal to
industrialwires.desc.label_text=The text in this label
industrialwires.desc.red=Red
industrialwires.desc.green=Green
industrialwires.desc.blue=Blue
industrialwires.desc.length=Length
industrialwires.tooltip.rschannel_info=The color of the channel to output the signal to
industrialwires.desc.wide_info=Wide Format
industrialwires.tooltip.wide=Wide
industrialwires.tooltip.narrow=Narrow
industrialwires.tooltip.horizontal=Horizontal
industrialwires.tooltip.vertical=Vertical
@ -131,4 +134,5 @@ ie.manual.entry.industrialwires.slider=A sliding switch that can set an output r
ie.manual.entry.industrialwires.toggle_switch=A switch to turn a signal on or off. The covered version includes a cover to prevent accidental activation: When clicked for the first time the cover will open, the signal will be turned on by clicking once again. Another click will close the cover and turn off the output signal. If the cover was opened by accident it can be closed by shift-right-clicking
ie.manual.entry.industrialwires.toggle_switch1=the switch. The color of the cover can be configured.
ie.manual.entry.industrialwires.variac=A Variac® is a variable autotransformer. The output signal of the transformer increases as the knob is turned to the right. The signal strenght can only be increased by one unit per click.
ie.manual.entry.industrialwires.lock=A lock switch activates a redstone signal when a key is inserted and turned. A newly crafted lock will have a unique key configuration. By placing a blank key and a lock in a crafting table a key for the lock can be created. Multiple locks fitting the same key can be created using component copying (see page 1). Keys can be named in a GUI opened by right-clicking with them.
ie.manual.entry.industrialwires.lock=A lock switch activates a redstone signal when a key is inserted and turned. A newly crafted lock will have a unique key configuration. By placing a blank key and a lock in a crafting table a key for the lock can be created. Multiple locks fitting the same key can be created using component copying (see page 1). Keys can be named in a GUI opened by right-clicking with them.
ie.manual.entry.industrialwires.panel_meter=A panel meter can be used to show display analog redstone signals with some accuracy. Panel meters are available in two different formats, wide and narrow. The wide format gives a slightly bigger angle between redstone level 0 and 15, but is more typical for Multimeters that for panel meters.

View file

@ -0,0 +1,6 @@
{
"parent":"item/generated",
"textures": {
"layer0":"industrialwires:items/panel_meter"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B