Initial version of a redstone controller for Project:Red bundled cables (no texture, localization, probably crashes without P:R)
This commit is contained in:
parent
b5826d226b
commit
fc2e9dca4d
19
build.gradle
19
build.gradle
|
@ -32,7 +32,7 @@ sourceCompatibility = 1.8
|
|||
targetCompatibility = 1.8
|
||||
|
||||
minecraft {
|
||||
version = "14.23.3.2655"
|
||||
version = "14.23.4.2745"
|
||||
runDir = "run"
|
||||
|
||||
replace '${version}', project.version
|
||||
|
@ -69,16 +69,33 @@ repositories {
|
|||
name "TehNut"
|
||||
url "http://tehnut.info/maven/"
|
||||
}
|
||||
repositories {//Curseforge maven for project red
|
||||
maven {
|
||||
name = "CurseForge"
|
||||
url = "https://minecraft.curseforge.com/api/maven/"
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = "chickenbones"
|
||||
url = "http://chickenbones.net/maven"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
deobfCompile 'net.industrial-craft:industrialcraft-2:2.8.+'
|
||||
deobfCompile "blusunrize:ImmersiveEngineering:0.12-+"
|
||||
deobfCompile "project-red-base:ProjectRed-1.12.2:4.9.1.92:Base"
|
||||
runtime "project-red-integration:ProjectRed-1.12.2:4.9.1.92:integration"
|
||||
runtime "forge-multipart-cbe:ForgeMultipart-1.12.2:2.5.0.69:universal"
|
||||
runtime "codechicken:CodeChickenLib:1.12.2-3.2.1.349:universal"
|
||||
runtime "codechicken:ChickenASM:1.12-1.0.2.7"
|
||||
runtime "mrtjpcore:MrTJPCore-1.12.2:2.1.3.35:universal"
|
||||
compileOnly "TechReborn:TechReborn-1.12:2.6.+:dev"
|
||||
compileOnly "RebornCore:RebornCore-1.12:3.2.+:dev"
|
||||
compileOnly 'com.elytradev:mirage:2.0.1-SNAPSHOT'
|
||||
compileOnly "mezz.jei:jei_1.12:4.+"
|
||||
compileOnly "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.8.460"
|
||||
|
||||
}
|
||||
|
||||
jar {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
package malte0811.industrialWires;
|
||||
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelConn;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelIE;
|
||||
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 TileEntityRSPanelConn) {
|
||||
return new ContainerRSPanelConn((TileEntityRSPanelConn) te);
|
||||
if (te instanceof TileEntityRSPanelIE) {
|
||||
return new ContainerRSPanelConn((TileEntityRSPanelIE) te);
|
||||
}
|
||||
} else if (ID == 1) {//ITEM GUI
|
||||
EnumHand h = z == 1 ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND;
|
||||
|
|
|
@ -15,67 +15,71 @@
|
|||
package malte0811.industrialWires;
|
||||
|
||||
import blusunrize.immersiveengineering.ImmersiveEngineering;
|
||||
import blusunrize.immersiveengineering.api.MultiblockHandler;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireApi;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import malte0811.industrialWires.blocks.BlockIWBase;
|
||||
import malte0811.industrialWires.blocks.controlpanel.*;
|
||||
import malte0811.industrialWires.blocks.converter.*;
|
||||
import malte0811.industrialWires.blocks.hv.*;
|
||||
import malte0811.industrialWires.blocks.wire.*;
|
||||
import malte0811.industrialWires.compat.Compat;
|
||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.controlpanel.PanelUtils;
|
||||
import malte0811.industrialWires.crafting.Recipes;
|
||||
import malte0811.industrialWires.entities.EntityBrokenPart;
|
||||
import malte0811.industrialWires.hv.MarxOreHandler;
|
||||
import malte0811.industrialWires.hv.MultiblockMarx;
|
||||
import malte0811.industrialWires.items.ItemIC2Coil;
|
||||
import malte0811.industrialWires.items.ItemKey;
|
||||
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||
import malte0811.industrialWires.mech_mb.EUCapability;
|
||||
import malte0811.industrialWires.mech_mb.MechMBPart;
|
||||
import malte0811.industrialWires.mech_mb.MultiblockMechMB;
|
||||
import malte0811.industrialWires.network.MessageGUIInteract;
|
||||
import malte0811.industrialWires.network.MessageItemSync;
|
||||
import malte0811.industrialWires.network.MessagePanelInteract;
|
||||
import malte0811.industrialWires.network.MessageTileSyncIW;
|
||||
import malte0811.industrialWires.util.CommandIW;
|
||||
import malte0811.industrialWires.util.MultiblockTemplateManual;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraft.network.datasync.EntityDataManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import net.minecraftforge.fml.common.registry.EntityRegistry;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import blusunrize.immersiveengineering.api.MultiblockHandler;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireApi;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import malte0811.industrialWires.blocks.BlockIWBase;
|
||||
import malte0811.industrialWires.blocks.TEDataFixer;
|
||||
import malte0811.industrialWires.blocks.controlpanel.*;
|
||||
import malte0811.industrialWires.blocks.converter.*;
|
||||
import malte0811.industrialWires.blocks.hv.*;
|
||||
import malte0811.industrialWires.blocks.wire.*;
|
||||
import malte0811.industrialWires.compat.Compat;
|
||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.controlpanel.PanelUtils;
|
||||
import malte0811.industrialWires.crafting.Recipes;
|
||||
import malte0811.industrialWires.entities.EntityBrokenPart;
|
||||
import malte0811.industrialWires.hv.MarxOreHandler;
|
||||
import malte0811.industrialWires.hv.MultiblockMarx;
|
||||
import malte0811.industrialWires.items.ItemIC2Coil;
|
||||
import malte0811.industrialWires.items.ItemKey;
|
||||
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||
import malte0811.industrialWires.mech_mb.EUCapability;
|
||||
import malte0811.industrialWires.mech_mb.MechMBPart;
|
||||
import malte0811.industrialWires.mech_mb.MultiblockMechMB;
|
||||
import malte0811.industrialWires.network.MessageGUIInteract;
|
||||
import malte0811.industrialWires.network.MessageItemSync;
|
||||
import malte0811.industrialWires.network.MessagePanelInteract;
|
||||
import malte0811.industrialWires.network.MessageTileSyncIW;
|
||||
import malte0811.industrialWires.util.CommandIW;
|
||||
import malte0811.industrialWires.util.MultiblockTemplateManual;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraft.network.datasync.EntityDataManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.datafix.FixTypes;
|
||||
import net.minecraftforge.common.util.ModFixs;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import net.minecraftforge.fml.common.registry.EntityRegistry;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static malte0811.industrialWires.blocks.wire.BlockTypes_IC2_Connector.*;
|
||||
import static malte0811.industrialWires.entities.EntityBrokenPart.MARKER_TEXTURE;
|
||||
import static malte0811.industrialWires.entities.EntityBrokenPart.RES_LOC_SERIALIZER;
|
||||
import static malte0811.industrialWires.mech_mb.MechMBPart.EXAMPLE_MECHMB_LOC;
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.*;
|
||||
import static malte0811.industrialWires.blocks.wire.BlockTypes_IC2_Connector.*;
|
||||
import static malte0811.industrialWires.entities.EntityBrokenPart.MARKER_TEXTURE;
|
||||
import static malte0811.industrialWires.entities.EntityBrokenPart.RES_LOC_SERIALIZER;
|
||||
import static malte0811.industrialWires.mech_mb.MechMBPart.EXAMPLE_MECHMB_LOC;
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.*;
|
||||
|
||||
@Mod(modid = IndustrialWires.MODID, version = IndustrialWires.VERSION, dependencies = "required-after:immersiveengineering@[0.12-77,);after:ic2",
|
||||
certificateFingerprint = "7e11c175d1e24007afec7498a1616bef0000027d",
|
||||
|
@ -85,6 +89,7 @@ public class IndustrialWires {
|
|||
public static final String MODID = "industrialwires";
|
||||
public static final String VERSION = "${version}";
|
||||
public static final String MODNAME = "Industrial Wires";
|
||||
public static final int DATAFIXER_VER = 1;
|
||||
public static final SoundEvent TINNITUS = createSoundEvent(new ResourceLocation(IndustrialWires.MODID, "tinnitus"));
|
||||
public static final SoundEvent LADDER_START = createSoundEvent(new ResourceLocation(IndustrialWires.MODID, "jacobs_ladder_start"));//~470 ms ~=9 ticks
|
||||
public static final SoundEvent LADDER_MIDDLE = createSoundEvent(new ResourceLocation(IndustrialWires.MODID, "jacobs_ladder_middle"));
|
||||
|
@ -168,33 +173,28 @@ public class IndustrialWires {
|
|||
logger = e.getModLog();
|
||||
new IWConfig();
|
||||
if (hasIC2) {
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorTin.class, MODID + ":ic2ConnectorTin");
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorCopper.class, MODID + ":ic2ConnectorCopper");
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorGold.class, MODID + ":ic2ConnectorGold");
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorHV.class, MODID + ":ic2ConnectorHV");
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorGlass.class, MODID + ":ic2ConnectorGlass");
|
||||
// Dummy TE's with bad names used to update old TE's to the proper names
|
||||
GameRegistry.registerTileEntity(DummyTEs.TinDummy.class, MODID + "ic2ConnectorTin");
|
||||
GameRegistry.registerTileEntity(DummyTEs.CopperDummy.class, MODID + "ic2ConnectorCopper");
|
||||
GameRegistry.registerTileEntity(DummyTEs.GoldDummy.class, MODID + "ic2ConnectorGold");
|
||||
GameRegistry.registerTileEntity(DummyTEs.HVDummy.class, MODID + "ic2ConnectorHV");
|
||||
GameRegistry.registerTileEntity(DummyTEs.GlassDummy.class, MODID + "ic2ConnectorGlass");
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorTin.class, new ResourceLocation(MODID, "ic2ConnectorTin"));
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorCopper.class, new ResourceLocation(MODID, "ic2ConnectorCopper"));
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorGold.class, new ResourceLocation(MODID, "ic2ConnectorGold"));
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorHV.class, new ResourceLocation(MODID, "ic2ConnectorHV"));
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorGlass.class, new ResourceLocation(MODID, "ic2ConnectorGlass"));
|
||||
|
||||
if (IWConfig.enableConversion) {
|
||||
GameRegistry.registerTileEntity(TileEntityIEMotor.class, MODID + ":ieMotor");
|
||||
GameRegistry.registerTileEntity(TileEntityMechICtoIE.class, MODID + ":mechIcToIe");
|
||||
GameRegistry.registerTileEntity(TileEntityMechIEtoIC.class, MODID + ":mechIeToIc");
|
||||
GameRegistry.registerTileEntity(TileEntityIEMotor.class, new ResourceLocation(MODID, "ieMotor"));
|
||||
GameRegistry.registerTileEntity(TileEntityMechICtoIE.class, new ResourceLocation(MODID, "mechIcToIe"));
|
||||
GameRegistry.registerTileEntity(TileEntityMechIEtoIC.class, new ResourceLocation(MODID, "mechIeToIc"));
|
||||
}
|
||||
}
|
||||
GameRegistry.registerTileEntity(TileEntityMechMB.class, MODID + ":mechMB");
|
||||
GameRegistry.registerTileEntity(TileEntityJacobsLadder.class, MODID + ":jacobsLadder");
|
||||
GameRegistry.registerTileEntity(TileEntityMarx.class, MODID + ":marx_generator");
|
||||
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");
|
||||
GameRegistry.registerTileEntity(TileEntityComponentPanel.class, MODID + ":single_component_panel");
|
||||
GameRegistry.registerTileEntity(TileEntityDischargeMeter.class, MODID + ":discharge_meter");
|
||||
GameRegistry.registerTileEntity(TileEntityMechMB.class, new ResourceLocation(MODID, "mechMB"));
|
||||
GameRegistry.registerTileEntity(TileEntityJacobsLadder.class, new ResourceLocation(MODID, "jacobsLadder"));
|
||||
GameRegistry.registerTileEntity(TileEntityMarx.class, new ResourceLocation(MODID, "marx_generator"));
|
||||
GameRegistry.registerTileEntity(TileEntityPanel.class, new ResourceLocation(MODID, "control_panel"));
|
||||
GameRegistry.registerTileEntity(TileEntityRSPanelIE.class, new ResourceLocation(MODID, "control_panel_rs"));
|
||||
GameRegistry.registerTileEntity(TileEntityRSPanelOthers.class, new ResourceLocation(MODID, "control_panel_rs_compat"));
|
||||
GameRegistry.registerTileEntity(TileEntityPanelCreator.class, new ResourceLocation(MODID, "panel_creator"));
|
||||
GameRegistry.registerTileEntity(TileEntityUnfinishedPanel.class, new ResourceLocation(MODID, "unfinished_panel"));
|
||||
GameRegistry.registerTileEntity(TileEntityComponentPanel.class, new ResourceLocation(MODID, "single_component_panel"));
|
||||
GameRegistry.registerTileEntity(TileEntityDischargeMeter.class, new ResourceLocation(MODID, "discharge_meter"));
|
||||
|
||||
DataSerializers.registerSerializer(RES_LOC_SERIALIZER);
|
||||
MARKER_TEXTURE = EntityDataManager.createKey(EntityBrokenPart.class, RES_LOC_SERIALIZER);
|
||||
|
@ -310,6 +310,8 @@ public class IndustrialWires {
|
|||
if (hasIC2) {
|
||||
EUCapability.register();
|
||||
}
|
||||
ModFixs fixer = FMLCommonHandler.instance().getDataFixer().init(MODID, DATAFIXER_VER);
|
||||
fixer.registerFix(FixTypes.BLOCK_ENTITY, new TEDataFixer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 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;
|
||||
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TEDataFixer implements IFixableData {
|
||||
private static final String PREFIX = "minecraft:"+IndustrialWires.MODID;
|
||||
private static final int PREFIX_LEN = PREFIX.length();
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound fixTagCompound(@Nonnull NBTTagCompound compound) {
|
||||
String id = compound.getString("id");
|
||||
if (id.startsWith(PREFIX)) {
|
||||
compound.setString("id", IndustrialWires.MODID+":"+id.substring(PREFIX_LEN));
|
||||
}
|
||||
return compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFixVersion() {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -81,7 +81,7 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
case TOP:
|
||||
return new TileEntityPanel();
|
||||
case RS_WIRE:
|
||||
return new TileEntityRSPanelConn();
|
||||
return new TileEntityRSPanelIE();
|
||||
case CREATOR:
|
||||
return new TileEntityPanelCreator();
|
||||
case UNFINISHED:
|
||||
|
@ -90,6 +90,8 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
return new TileEntityComponentPanel();
|
||||
case DUMMY:
|
||||
return new TileEntityGeneralCP();
|
||||
case OTHER_RS_WIRES:
|
||||
return new TileEntityRSPanelOthers();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -123,7 +125,7 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
state.withProperty(type, BlockTypes_Panel.SINGLE_COMP);
|
||||
} else if (te instanceof TileEntityPanel) {
|
||||
state.withProperty(type, BlockTypes_Panel.TOP);
|
||||
} else if (te instanceof TileEntityRSPanelConn) {
|
||||
} else if (te instanceof TileEntityRSPanelIE) {
|
||||
state.withProperty(type, BlockTypes_Panel.RS_WIRE);
|
||||
}
|
||||
return state;
|
||||
|
@ -192,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 TileEntityRSPanelConn) {
|
||||
if (te instanceof TileEntityRSPanelIE) {
|
||||
if (!world.isRemote) {
|
||||
player.openGui(IndustrialWires.instance, 0, te.getWorld(), te.getPos().getX(), te.getPos().getY(), te.getPos().getZ());
|
||||
}
|
||||
|
@ -266,9 +268,11 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
|
||||
super.neighborChanged(state, worldIn, pos, blockIn, fromPos);
|
||||
if (!worldIn.isRemote) {
|
||||
TileEntityComponentPanel panel = MiscUtils.getExistingTE(worldIn, pos, TileEntityComponentPanel.class);
|
||||
if (panel != null) {
|
||||
panel.updateRSInput();
|
||||
TileEntityGeneralCP panel = MiscUtils.getExistingTE(worldIn, pos, TileEntityGeneralCP.class);
|
||||
if (panel instanceof TileEntityComponentPanel) {
|
||||
((TileEntityComponentPanel) panel).updateRSInput();
|
||||
} else if (panel instanceof TileEntityRSPanelOthers) {
|
||||
((TileEntityRSPanelOthers)panel).updateInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,17 +25,14 @@ public enum BlockTypes_Panel implements IStringSerializable {
|
|||
DUMMY,
|
||||
CREATOR,
|
||||
UNFINISHED,
|
||||
SINGLE_COMP;
|
||||
SINGLE_COMP,
|
||||
OTHER_RS_WIRES;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return toString().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public boolean isPanelConnector() {
|
||||
return this != CREATOR && this != UNFINISHED;
|
||||
}
|
||||
|
||||
public boolean showInCreative() {
|
||||
return this != SINGLE_COMP;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 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 malte0811.industrialWires.blocks.INetGUI;
|
||||
import malte0811.industrialWires.controlpanel.ControlPanelNetwork;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ITickable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public abstract class TileEntityRSPanel extends TileEntityGeneralCP implements INetGUI, ITickable {
|
||||
protected byte[] out = new byte[16];
|
||||
private boolean dirty = true;
|
||||
private byte[] currInput = new byte[16];
|
||||
private final ControlPanelNetwork.RSChannel[] channels = new ControlPanelNetwork.RSChannel[16];
|
||||
private int controller = 0;
|
||||
|
||||
|
||||
{
|
||||
for (int i = 0; i < 16; i++) {
|
||||
currInput[i] = -1;
|
||||
}
|
||||
updateChannelsArray();
|
||||
}
|
||||
|
||||
private void updateChannelsArray() {
|
||||
for (byte i = 0;i<16;i++) {
|
||||
channels[i] = new ControlPanelNetwork.RSChannel(controller, i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (dirty) {
|
||||
updateOutput();
|
||||
dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound nbt, boolean updatePacket) {
|
||||
nbt.setByteArray("out", this.out);
|
||||
nbt.setInteger("rsId", controller);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound nbt, boolean updatePacket) {
|
||||
out = nbt.getByteArray("out");
|
||||
controller = nbt.getInteger("rsId");
|
||||
updateChannelsArray();
|
||||
}
|
||||
|
||||
protected void markRSDirty() {
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
protected void inputUpdate(byte[] newIn) {
|
||||
if (!Arrays.equals(currInput, newIn)) {
|
||||
ControlPanelNetwork.RSChannelState[] newStates = new ControlPanelNetwork.RSChannelState[16];
|
||||
for (byte i = 0; i < 16; i++) {
|
||||
if (newIn[i]>out[i]) {
|
||||
newStates[i] = new ControlPanelNetwork.RSChannelState(channels[i], newIn[i]);
|
||||
} else {
|
||||
newStates[i] = new ControlPanelNetwork.RSChannelState(channels[i], (byte) 0);
|
||||
}
|
||||
}
|
||||
panelNetwork.setOutputs(this, newStates);
|
||||
currInput = Arrays.copyOf(newIn, 16);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetworkAndInit(ControlPanelNetwork newNet) {
|
||||
super.setNetworkAndInit(newNet);
|
||||
inputUpdate(currInput);
|
||||
Consumer<ControlPanelNetwork.RSChannelState> listener = state -> {
|
||||
if (out[state.getColor()] != state.getStrength()) {
|
||||
out[state.getColor()] = state.getStrength();
|
||||
dirty = true;
|
||||
}
|
||||
};
|
||||
panelNetwork.addListener(this, listener, channels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange(NBTTagCompound nbt, EntityPlayer p) {
|
||||
if (nbt.hasKey("rsId")) {
|
||||
panelNetwork.removeIOFor(this);
|
||||
setNetworkAndInit(panelNetwork);
|
||||
}
|
||||
}
|
||||
|
||||
public int getRsId() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
|
||||
protected abstract void updateOutput();
|
||||
}
|
|
@ -23,16 +23,10 @@ import blusunrize.immersiveengineering.api.energy.wires.redstone.IRedstoneConnec
|
|||
import blusunrize.immersiveengineering.api.energy.wires.redstone.RedstoneWireNetwork;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces;
|
||||
import malte0811.industrialWires.blocks.IBlockBoundsIW;
|
||||
import malte0811.industrialWires.blocks.INetGUI;
|
||||
import malte0811.industrialWires.controlpanel.ControlPanelNetwork;
|
||||
import malte0811.industrialWires.controlpanel.ControlPanelNetwork.RSChannel;
|
||||
import malte0811.industrialWires.controlpanel.ControlPanelNetwork.RSChannelState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
@ -41,63 +35,34 @@ import net.minecraft.world.World;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static blusunrize.immersiveengineering.api.energy.wires.WireType.REDSTONE_CATEGORY;
|
||||
|
||||
public class TileEntityRSPanelConn extends TileEntityGeneralCP//TODO what parts of TEIIC do I need?
|
||||
implements IRedstoneConnector, INetGUI, IEBlockInterfaces.IDirectionalTile, IBlockBoundsIW,
|
||||
ITickable {
|
||||
private byte[] out = new byte[16];
|
||||
private boolean dirty = true;
|
||||
private byte[] oldInput = new byte[16];
|
||||
private final RSChannel[] channels = new RSChannel[16];
|
||||
public class TileEntityRSPanelIE extends TileEntityRSPanel//TODO what parts of TEIIC do I need?
|
||||
implements IRedstoneConnector, IEBlockInterfaces.IDirectionalTile, IBlockBoundsIW {
|
||||
private EnumFacing facing = EnumFacing.NORTH;
|
||||
@Nonnull
|
||||
private RedstoneWireNetwork wireNetwork = new RedstoneWireNetwork().add(this);
|
||||
private boolean hasConn = false;
|
||||
private int controller = 0;
|
||||
|
||||
{
|
||||
for (int i = 0; i < 16; i++) {
|
||||
oldInput[i] = -1;
|
||||
}
|
||||
updateChannelsArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (dirty) {
|
||||
wireNetwork.updateValues();
|
||||
dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateChannelsArray() {
|
||||
for (byte i = 0;i<16;i++) {
|
||||
channels[i] = new RSChannel(controller, i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound nbt, boolean updatePacket) {
|
||||
nbt.setByteArray("out", this.out);
|
||||
nbt.setBoolean("hasConn", hasConn);
|
||||
nbt.setInteger("rsId", controller);
|
||||
nbt.setInteger("facing", facing.getIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound nbt, boolean updatePacket) {
|
||||
out = nbt.getByteArray("out");
|
||||
hasConn = nbt.getBoolean("hasConn");
|
||||
controller = nbt.getInteger("rsId");
|
||||
updateChannelsArray();
|
||||
facing = EnumFacing.VALUES[nbt.getInteger("facing")];
|
||||
aabb = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateOutput() {
|
||||
wireNetwork.updateValues();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(@Nonnull RedstoneWireNetwork net) {
|
||||
wireNetwork = net;
|
||||
|
@ -111,23 +76,11 @@ public class TileEntityRSPanelConn extends TileEntityGeneralCP//TODO what parts
|
|||
|
||||
@Override
|
||||
public void onChange() {
|
||||
if (!Arrays.equals(oldInput, wireNetwork.channelValues)) {
|
||||
RSChannelState[] newStates = new RSChannelState[16];
|
||||
for (byte i = 0; i < 16; i++) {
|
||||
if (wireNetwork.channelValues[i]>out[i]) {
|
||||
newStates[i] = new RSChannelState(channels[i], wireNetwork.channelValues[i]);
|
||||
} else {
|
||||
newStates[i] = new RSChannelState(channels[i], (byte) 0);
|
||||
}
|
||||
}
|
||||
panelNetwork.setOutputs(this, newStates);
|
||||
oldInput = Arrays.copyOf(wireNetwork.channelValues, 16);
|
||||
}
|
||||
inputUpdate(wireNetwork.channelValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInput(byte[] currIn) {
|
||||
byte[] oldIn = Arrays.copyOf(currIn, 16);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
currIn[i] = (byte) Math.max(currIn[i], out[i]);
|
||||
}
|
||||
|
@ -194,37 +147,11 @@ public class TileEntityRSPanelConn extends TileEntityGeneralCP//TODO what parts
|
|||
return new Vec3d(.5 - conRadius * side.getFrontOffsetX(), .5 - conRadius * side.getFrontOffsetY(), .5 - conRadius * side.getFrontOffsetZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetworkAndInit(ControlPanelNetwork newNet) {
|
||||
super.setNetworkAndInit(newNet);
|
||||
onChange();
|
||||
Consumer<RSChannelState> listener = state -> {
|
||||
if (out[state.getColor()] != state.getStrength()) {
|
||||
out[state.getColor()] = state.getStrength();
|
||||
dirty = true;
|
||||
Thread.dumpStack();
|
||||
}
|
||||
};
|
||||
panelNetwork.addListener(this, listener, channels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange(NBTTagCompound nbt, EntityPlayer p) {
|
||||
if (nbt.hasKey("rsId")) {
|
||||
panelNetwork.removeIOFor(this);
|
||||
setNetworkAndInit(panelNetwork);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getConnectorWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public int getRsId() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumFacing getFacing() {
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 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 malte0811.industrialWires.IndustrialWires;
|
||||
import mrtjp.projectred.api.IBundledTile;
|
||||
import mrtjp.projectred.api.ProjectRedAPI;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
@Optional.Interface(iface = "mrtjp.projectred.api.IBundledTile", modid = ProjectRedAPI.modIDCore)
|
||||
public class TileEntityRSPanelOthers extends TileEntityRSPanel implements IBundledTile {
|
||||
|
||||
@Override
|
||||
public boolean canConnectBundled(int i) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBundledSignal(int side) {
|
||||
byte[] ret = new byte[16];
|
||||
for (int i = 0;i<16;i++) {
|
||||
ret[i] = (byte) (17*out[i]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
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);
|
||||
if (tmp!=null) {
|
||||
for (int i = 0;i<16;i++) {
|
||||
byte actual = (byte) ((tmp[i]&255)/17);
|
||||
if (actual>data[i]) {
|
||||
data[i] = actual;
|
||||
}
|
||||
}
|
||||
IndustrialWires.logger.info("Side: {}, PR input: {}, proper input: {}", f, tmp, data);
|
||||
}
|
||||
}
|
||||
inputUpdate(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateOutput() {
|
||||
world.notifyNeighborsOfStateChange(pos, getBlockType(), true);
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 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.wire;
|
||||
|
||||
public final class DummyTEs {
|
||||
public static class TinDummy extends TileEntityIC2ConnectorTin {
|
||||
@Override
|
||||
public void update() {
|
||||
TileEntityIC2ConnectorTin newTe = getRaw();
|
||||
newTe.bufferToNet = bufferToNet;
|
||||
newTe.bufferToMachine = bufferToMachine;
|
||||
newTe.maxToNet = maxToNet;
|
||||
newTe.maxToMachine = maxToMachine;
|
||||
newTe.relay = relay;
|
||||
newTe.facing = facing;
|
||||
world.setTileEntity(pos, newTe);
|
||||
}
|
||||
protected TileEntityIC2ConnectorTin getRaw() {
|
||||
return new TileEntityIC2ConnectorTin();
|
||||
}
|
||||
}
|
||||
public static class CopperDummy extends TinDummy {
|
||||
@Override
|
||||
protected TileEntityIC2ConnectorTin getRaw() {
|
||||
return new TileEntityIC2ConnectorCopper();
|
||||
}
|
||||
}
|
||||
public static class GoldDummy extends TinDummy {
|
||||
@Override
|
||||
protected TileEntityIC2ConnectorTin getRaw() {
|
||||
return new TileEntityIC2ConnectorGold();
|
||||
}
|
||||
}
|
||||
public static class HVDummy extends TinDummy {
|
||||
@Override
|
||||
protected TileEntityIC2ConnectorTin getRaw() {
|
||||
return new TileEntityIC2ConnectorHV();
|
||||
}
|
||||
}
|
||||
public static class GlassDummy extends TinDummy {
|
||||
@Override
|
||||
protected TileEntityIC2ConnectorTin getRaw() {
|
||||
return new TileEntityIC2ConnectorGlass();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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.TileEntityRSPanelConn;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelIE;
|
||||
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 TileEntityRSPanelConn) {
|
||||
return new GuiRSPanelConn((TileEntityRSPanelConn) te);
|
||||
if (te instanceof TileEntityRSPanelIE) {
|
||||
return new GuiRSPanelConn((TileEntityRSPanelIE) te);
|
||||
}
|
||||
if (te instanceof TileEntityPanelCreator) {
|
||||
return new GuiPanelCreator(player.inventory, (TileEntityPanelCreator) te);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
package malte0811.industrialWires.client.gui;
|
||||
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelConn;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanel;
|
||||
import malte0811.industrialWires.client.gui.elements.GuiIntChooser;
|
||||
import malte0811.industrialWires.containers.ContainerRSPanelConn;
|
||||
import malte0811.industrialWires.network.MessageGUIInteract;
|
||||
|
@ -30,10 +30,10 @@ import net.minecraft.util.ResourceLocation;
|
|||
import java.io.IOException;
|
||||
|
||||
public class GuiRSPanelConn extends GuiContainer {
|
||||
private TileEntityRSPanelConn te;
|
||||
private TileEntityRSPanel te;
|
||||
private GuiIntChooser chooser;
|
||||
|
||||
public GuiRSPanelConn(TileEntityRSPanelConn tile) {
|
||||
public GuiRSPanelConn(TileEntityRSPanel tile) {
|
||||
super(new ContainerRSPanelConn(tile));
|
||||
te = tile;
|
||||
}
|
||||
|
|
|
@ -15,16 +15,16 @@
|
|||
|
||||
package malte0811.industrialWires.containers;
|
||||
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelConn;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanel;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ContainerRSPanelConn extends Container {
|
||||
private final TileEntityRSPanelConn te;
|
||||
private final TileEntityRSPanel te;
|
||||
|
||||
public ContainerRSPanelConn(TileEntityRSPanelConn tile) {
|
||||
public ContainerRSPanelConn(TileEntityRSPanel tile) {
|
||||
te = tile;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue