Some fixes and a (possibly temporary) texture for the redstone controller

This commit is contained in:
malte0811 2018-08-04 14:46:50 +02:00
parent fc2e9dca4d
commit 7599b5cd31
13 changed files with 65 additions and 26 deletions

View File

@ -15,7 +15,7 @@
package malte0811.industrialWires;
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelIE;
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanel;
import malte0811.industrialWires.blocks.converter.TileEntityMechMB;
import malte0811.industrialWires.blocks.hv.TileEntityJacobsLadder;
import malte0811.industrialWires.blocks.hv.TileEntityMarx;
@ -59,8 +59,8 @@ public class CommonProxy implements IGuiHandler {
if (te instanceof TileEntityPanelCreator) {
return new ContainerPanelCreator(player.inventory, (TileEntityPanelCreator) te);
}
if (te instanceof TileEntityRSPanelIE) {
return new ContainerRSPanelConn((TileEntityRSPanelIE) te);
if (te instanceof TileEntityRSPanel) {
return new ContainerRSPanelConn((TileEntityRSPanel) te);
}
} else if (ID == 1) {//ITEM GUI
EnumHand h = z == 1 ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND;

View File

@ -194,7 +194,7 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (!super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ) && hand == EnumHand.MAIN_HAND) {
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileEntityRSPanelIE) {
if (te instanceof TileEntityRSPanel) {
if (!world.isRemote) {
player.openGui(IndustrialWires.instance, 0, te.getWorld(), te.getPos().getX(), te.getPos().getY(), te.getPos().getZ());
}

View File

@ -34,6 +34,9 @@ public enum BlockTypes_Panel implements IStringSerializable {
}
public boolean showInCreative() {
if (this==OTHER_RS_WIRES) {
}
return this != SINGLE_COMP;
}
}

View File

@ -17,6 +17,7 @@ package malte0811.industrialWires.blocks.controlpanel;
import malte0811.industrialWires.blocks.INetGUI;
import malte0811.industrialWires.controlpanel.ControlPanelNetwork;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ITickable;
@ -66,7 +67,7 @@ public abstract class TileEntityRSPanel extends TileEntityGeneralCP implements I
controller = nbt.getInteger("rsId");
updateChannelsArray();
}
protected void markRSDirty() {
dirty = true;
}
@ -102,8 +103,12 @@ public abstract class TileEntityRSPanel extends TileEntityGeneralCP implements I
@Override
public void onChange(NBTTagCompound nbt, EntityPlayer p) {
if (nbt.hasKey("rsId")) {
controller = nbt.getInteger("rsId");
markDirty();
panelNetwork.removeIOFor(this);
setNetworkAndInit(panelNetwork);
IBlockState state = world.getBlockState(pos);
world.notifyBlockUpdate(pos, state, state, 3);
}
}

View File

@ -47,12 +47,14 @@ public class TileEntityRSPanelIE extends TileEntityRSPanel//TODO what parts of T
@Override
public void writeNBT(NBTTagCompound nbt, boolean updatePacket) {
super.writeNBT(nbt, updatePacket);
nbt.setBoolean("hasConn", hasConn);
nbt.setInteger("facing", facing.getIndex());
}
@Override
public void readNBT(NBTTagCompound nbt, boolean updatePacket) {
super.readNBT(nbt, updatePacket);
hasConn = nbt.getBoolean("hasConn");
facing = EnumFacing.VALUES[nbt.getInteger("facing")];
aabb = null;

View File

@ -15,7 +15,7 @@
package malte0811.industrialWires.blocks.controlpanel;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.compat.Compat;
import mrtjp.projectred.api.IBundledTile;
import mrtjp.projectred.api.ProjectRedAPI;
import net.minecraft.util.EnumFacing;
@ -40,17 +40,14 @@ public class TileEntityRSPanelOthers extends TileEntityRSPanel implements IBundl
public void updateInput() {
byte[] data = new byte[16];
//TODO make safe without P:R
for (EnumFacing f:EnumFacing.VALUES) {
byte[] tmp = ProjectRedAPI.transmissionAPI.getBundledInput(world, pos, f);
byte[] tmp = Compat.getBundledRS.getBundledInput(world, pos, f);
if (tmp!=null) {
for (int i = 0;i<16;i++) {
byte actual = (byte) ((tmp[i]&255)/17);
if (actual>data[i]) {
data[i] = actual;
if (tmp[i]>data[i]) {
data[i] = tmp[i];
}
}
IndustrialWires.logger.info("Side: {}, PR input: {}, proper input: {}", f, tmp, data);
}
}
inputUpdate(data);

View File

@ -33,7 +33,7 @@ import malte0811.industrialWires.IWPotions;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelIE;
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanel;
import malte0811.industrialWires.blocks.converter.TileEntityMechMB;
import malte0811.industrialWires.blocks.hv.TileEntityJacobsLadder;
import malte0811.industrialWires.blocks.hv.TileEntityMarx;
@ -490,8 +490,8 @@ public class ClientProxy extends CommonProxy {
public Gui getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID == 0) {
TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
if (te instanceof TileEntityRSPanelIE) {
return new GuiRSPanelConn((TileEntityRSPanelIE) te);
if (te instanceof TileEntityRSPanel) {
return new GuiRSPanelConn((TileEntityRSPanel) te);
}
if (te instanceof TileEntityPanelCreator) {
return new GuiPanelCreator(player.inventory, (TileEntityPanelCreator) te);

View File

@ -27,6 +27,7 @@ import ic2.api.item.IC2Items;
import ic2.core.block.TileEntityBlock;
import malte0811.industrialWires.hv.MarxOreHandler;
import malte0811.industrialWires.mech_mb.MechPartCommutator;
import mrtjp.projectred.api.ProjectRedAPI;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -53,9 +54,10 @@ public class Compat {
};
public static Consumer<TileEntity> unloadIC2Tile = te -> {
};
public static IBundledRSGetter getBundledRS = (w, p, f) -> new byte[16];
public static boolean enableOtherRS = false;
private static Map<String, Class<? extends CompatModule>> modules = ImmutableMap.of("ic2", CompatIC2.class,
"crafttweaker", CompatCT.class);
"crafttweaker", CompatCT.class, ProjectRedAPI.modIDCore, CompatProjectRed.class);
private static Method preInit;
private static Method init;
@ -155,4 +157,23 @@ public class Compat {
}
}
public static class CompatProjectRed extends CompatModule {
@Override
public void init() {
super.init();
IBundledRSGetter old = getBundledRS;
enableOtherRS = true;
getBundledRS = (w, p, f) -> {
byte[] oldIn = old.getBundledInput(w, p, f);
byte[] prIn = ProjectRedAPI.transmissionAPI.getBundledInput(w, p, f);
if (prIn!=null) {
for (int i = 0; i < 16; i++) {
oldIn[i] = (byte)((prIn[i]&255)/17);
}
}
return oldIn;
};
}
}
}

View File

@ -13,8 +13,12 @@
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
*/
package malte0811.industrialWires.util;
package malte0811.industrialWires.compat;
public interface TriConsumer<A, B, C> {
void accept(A a, B b, C c);
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public interface IBundledRSGetter {
byte[] getBundledInput(World w, BlockPos pos, EnumFacing f);
}

View File

@ -20,7 +20,6 @@ import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
import malte0811.industrialWires.client.RawQuad;
import malte0811.industrialWires.client.gui.GuiPanelCreator;
import malte0811.industrialWires.controlpanel.ControlPanelNetwork.IOwner;
import malte0811.industrialWires.util.TriConsumer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderGlobal;
@ -33,7 +32,9 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnull;
import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
public abstract class PanelComponent implements IOwner {
@ -48,8 +49,6 @@ public abstract class PanelComponent implements IOwner {
protected TileEntityPanel panel;
protected ControlPanelNetwork network;
private Set<TriConsumer<Integer, Byte, PanelComponent>> outputs = new HashSet<>();
protected PanelComponent(String type) {
this.type = type;
}

View File

@ -70,6 +70,10 @@
},
"single_comp": {
"model": "industrialwires:smartmodel/panel_single_comp"
},
"other_rs_wires": {
"model": "cube_all",
"textures": {"all": "industrialwires:blocks/rs_panel_others"}
}
},
"inventory,type=rs_wire": {
@ -107,7 +111,10 @@
"inventory,type=unfinished": {
"model": "industrialwires:block/panel_creator.obj"
//Doesn't matter, this will be overridden in code
},
"other_rs_wires": {
"model": "cube_all",
"textures": {"all": "industrialwires:blocks/rs_panel_others"}
}
}
}

View File

@ -20,10 +20,11 @@ tile.industrialwires.jacobs_ladder.normal.name=Jacob's ladder
tile.industrialwires.jacobs_ladder.huge.name=Huge Jacob's ladder
tile.industrialwires.control_panel.top.name=Control Panel
tile.industrialwires.control_panel.rs_wire.name=Redstone Wire Controller
tile.industrialwires.control_panel.rs_wire.name=Redstone Controller: Redstone Wires
tile.industrialwires.control_panel.dummy.name=Panel Connector
tile.industrialwires.control_panel.creator.name=Control Panel Creator
tile.industrialwires.control_panel.unfinished.name=Unfinished Control Panel
tile.industrialwires.control_panel.other_rs_wires.name=Redstone Controller: Others
item.industrialwires.ic2_wire_coil.tin.name=Tin Wire Coil
item.industrialwires.ic2_wire_coil.copper.name=Copper Wire Coil

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B