Merge branch 'MC1.12' into marx

# Conflicts:
#	build.gradle
#	src/main/java/malte0811/industrialWires/IndustrialWires.java
#	src/main/java/malte0811/industrialWires/blocks/controlpanel/TileEntityPanel.java
#	src/main/java/malte0811/industrialWires/blocks/hv/BlockJacobsLadder.java
#	src/main/java/malte0811/industrialWires/blocks/hv/TileEntityJacobsLadder.java
#	src/main/java/malte0811/industrialWires/client/ClientProxy.java
#	src/main/java/malte0811/industrialWires/client/render/TileRenderJacobsLadder.java
#	src/main/java/malte0811/industrialWires/controlpanel/PanelComponent.java
This commit is contained in:
malte0811 2017-08-06 18:15:08 +02:00
commit c53b09b6ce
99 changed files with 2553 additions and 772 deletions

View file

@ -1,23 +1,5 @@
def mainVersion = "1.5"
def buildNumber = "11"
/*
* 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/>.
*/
def buildNumber = "15"
// For those who want the bleeding edge
buildscript {
@ -29,7 +11,7 @@ buildscript {
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
@ -48,11 +30,11 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8
minecraft {
version = "13.20.0.2282"
version = "14.21.1.2404"
runDir = "run"
replace '${version}', project.version
mappings = "snapshot_20170323"
mappings = "snapshot_20170628"
}
repositories {
@ -67,8 +49,8 @@ repositories {
}
dependencies {
compile "net.industrial-craft:industrialcraft-2:2.7.+"
deobfCompile "blusunrize:ImmersiveEngineering:0.11-+:deobf"
compile "net.industrial-craft:industrialcraft-2:2.8.+"
deobfCompile "blusunrize:ImmersiveEngineering:0.12-+:deobf"
}
jar {

View file

@ -1,3 +1,27 @@
#####Version 1.5-15
- Components can be placed in the world now to use the as conventional levers/etc.
- Added documentation on the key ring. It also shows all attached keys on the tooltip now
- Fixed some bugs with key ring crafting
- Fixed control panels causing disconnects on servers
#####Version 1.5-14
- Updated to Minecraft 1.12
- Added a recipe for the key ring. Kind of forgot about adding one when I added the ring itself...
- Fixed wire length crafting leaving wrong coils when the output has maximum length
- Fixed some more connection issues with control panels
#####Version 1.5-13
- Labels no longer break the model cache and cause lag
- Labels don't break on dedicated servers any more
#####Version 1.5-12
- Added tilted control panels
- Panels are no longer created from machine casings, there is a dedicated item for that now, the Unfinished Control Panel
- Angle and height can be configured in the Engineer's Workbench
- Fixed a CME when multi-threaded chunk rendering is enabled
- Fixed control panels not connecting or disconnecting properly when a panel connector between the panel and the RS controller is broken/placed
- Improved the performance of the control panel hitbox rendering
#####Version 1.5-11
- Updated to Minecraft 1.11.2
- Added Panel Meters to monitor a redstone signal with reasonable accuracy

View file

@ -33,7 +33,9 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.network.IGuiHandler;
import net.minecraftforge.fml.relauncher.Side;
public class CommonProxy implements IGuiHandler {
public void preInit() {

View file

@ -22,12 +22,18 @@ import malte0811.industrialWires.blocks.controlpanel.BlockPanel;
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelConn;
import malte0811.industrialWires.blocks.BlockIWBase;
import malte0811.industrialWires.blocks.BlockJacobsLadder;
import malte0811.industrialWires.blocks.TileEntityJacobsLadder;
import malte0811.industrialWires.blocks.controlpanel.*;
import malte0811.industrialWires.blocks.converter.BlockMechanicalConverter;
import malte0811.industrialWires.blocks.converter.TileEntityIEMotor;
import malte0811.industrialWires.blocks.converter.TileEntityMechICtoIE;
import malte0811.industrialWires.blocks.converter.TileEntityMechIEtoIC;
import malte0811.industrialWires.blocks.hv.*;
import malte0811.industrialWires.blocks.wire.*;
import malte0811.industrialWires.controlpanel.PanelUtils;
import malte0811.industrialWires.crafting.Recipes;
import malte0811.industrialWires.items.ItemIC2Coil;
import malte0811.industrialWires.items.ItemKey;
import malte0811.industrialWires.items.ItemPanelComponent;
@ -35,10 +41,12 @@ import malte0811.industrialWires.network.MessageGUIInteract;
import malte0811.industrialWires.network.MessageItemSync;
import malte0811.industrialWires.network.MessagePanelInteract;
import malte0811.industrialWires.network.MessageTileSyncIW;
import malte0811.industrialWires.wires.IC2Wiretype;
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.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.SidedProxy;
@ -46,25 +54,38 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
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.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import org.apache.logging.log4j.Logger;
import java.util.ArrayList;
import java.util.List;
@Mod(modid = IndustrialWires.MODID, version = IndustrialWires.VERSION, dependencies = "required-after:immersiveengineering@[0.10-58,);required-after:ic2")
@Mod.EventBusSubscriber
public class IndustrialWires {
public static final String MODID = "industrialwires";
public static final String VERSION = "${version}";
public static final List<BlockIWBase> blocks = new ArrayList<>();
public static final List<Item> items = new ArrayList<>();
public static BlockIC2Connector ic2conn;
public static BlockMechanicalConverter mechConv;
public static BlockJacobsLadder jacobsLadder;
public static BlockHVMultiblocks hvMultiblocks;
public static BlockPanel panel;
public static ItemIC2Coil coil;
public static ItemPanelComponent panelComponent;
public static ItemKey key;
public static final SimpleNetworkWrapper packetHandler = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
public static Logger logger;
@Mod.Instance(MODID)
public static IndustrialWires instance = new IndustrialWires();
public static CreativeTabs creativeTab = new CreativeTabs(MODID) {
@ -79,10 +100,12 @@ public class IndustrialWires {
@EventHandler
public void preInit(FMLPreInitializationEvent e) {
logger = e.getModLog();
new IWConfig();
ic2conn = new BlockIC2Connector();
if (IWConfig.enableConversion)
mechConv = new BlockMechanicalConverter();
if (IWConfig.enableConversion) {
mechConv = new BlockMechanicalConverter();
}
jacobsLadder = new BlockJacobsLadder();
hvMultiblocks = new BlockHVMultiblocks();
panel = new BlockPanel();
@ -101,23 +124,43 @@ public class IndustrialWires {
GameRegistry.registerTileEntity(TileEntityPanel.class, MODID + ":control_panel");
GameRegistry.registerTileEntity(TileEntityRSPanelConn.class, MODID + ":control_panel_rs");
GameRegistry.registerTileEntity(TileEntityPanelCreator.class, MODID + ":panel_creator");
if (mechConv != null) {
GameRegistry.registerTileEntity(TileEntityUnfinishedPanel.class, MODID + ":unfinished_panel");
GameRegistry.registerTileEntity(TileEntityComponentPanel.class, MODID + ":single_component_panel");
if (IWConfig.enableConversion) {
GameRegistry.registerTileEntity(TileEntityIEMotor.class, MODID + ":ieMotor");
GameRegistry.registerTileEntity(TileEntityMechICtoIE.class, MODID + ":mechIcToIe");
GameRegistry.registerTileEntity(TileEntityMechIEtoIC.class, MODID + ":mechIeToIc");
}
if (IC2Wiretype.IC2_TYPES == null) {
throw new IllegalStateException("No IC2 wires registered");
}
MultiblockHandler.registerMultiblock(new MultiblockMarx());
IWPotions.init();
proxy.preInit();
}
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event) {
for (BlockIWBase b: blocks) {
event.getRegistry().register(b);
}
}
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event) {
for (BlockIWBase b:blocks) {
event.getRegistry().register(b.createItemBlock());
}
for (Item i:items) {
event.getRegistry().register(i);
}
}
@SubscribeEvent
public static void registerRecipes(RegistryEvent.Register<IRecipe> event) {
Recipes.addRecipes(event.getRegistry());
}
@EventHandler
public void init(FMLInitializationEvent e) {
Recipes.addRecipes();
ExtraIC2Compat.addToolConmpat();
@ -131,7 +174,8 @@ public class IndustrialWires {
@EventHandler
public void postInit(FMLPostInitializationEvent e) {
proxy.postInit();
PanelUtils.PANEL_ITEM = Item.getItemFromBlock(panel);
proxy.postInit();
}
@EventHandler

View file

@ -1,178 +0,0 @@
/*
* 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;
import blusunrize.immersiveengineering.api.tool.AssemblerHandler;
import blusunrize.immersiveengineering.common.IEContent;
import blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_Connector;
import blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration0;
import blusunrize.immersiveengineering.common.blocks.stone.BlockTypes_StoneDecoration;
import ic2.api.item.IC2Items;
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
import malte0811.industrialWires.controlpanel.PanelUtils;
import malte0811.industrialWires.crafting.*;
import malte0811.industrialWires.wires.IC2Wiretype;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.RecipeSorter;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import java.util.ArrayList;
import java.util.List;
import static malte0811.industrialWires.IndustrialWires.*;
public class Recipes {
public static void addRecipes() {
addCustomRecipes();
addConnectors();
if (mechConv != null) {
addMechConverters();
}
addJacobs();
registerPanels();
}
private static void addConnectors() {
ItemStack glassCable = IC2Items.getItem("cable", "type:glass,insulation:0");
//CONNECTORS
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 0), " t ", "rtr", "rtr", 't', "ingotTin", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 2), " c ", "rcr", "rcr", 'c', "ingotCopper", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 4), " g ", "rgr", "rgr", 'g', "ingotGold", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 6), " i ", "rir", "rir", 'i', "ingotIron", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 8), " c ", "rcr", "rcr", 'c', glassCable, 'r', "itemRubber"));
//RELAYS
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 1), " t ", "rtr", 't', "ingotTin", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 3), " c ", "rcr", 'c', "ingotCopper", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 5), " g ", "rgr", 'g', "ingotGold", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 7), " i ", "gig", "gig", 'i', "ingotIron", 'g', new ItemStack(IEContent.blockStoneDecoration, 1, BlockTypes_StoneDecoration.INSULATING_GLASS.getMeta())));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 2, 9), " c ", "grg", "grg", 'r', "itemRubber", 'c', glassCable, 'g', new ItemStack(IEContent.blockStoneDecoration, 1, BlockTypes_StoneDecoration.INSULATING_GLASS.getMeta())));
}
private static void addMechConverters() {
ItemStack shaftIron = IC2Items.getItem("crafting", "iron_shaft");
ItemStack shaftSteel = IC2Items.getItem("crafting", "steel_shaft");
ItemStack ironMechComponent = new ItemStack(IEContent.itemMaterial, 1, 8);
ItemStack steelMechComponent = new ItemStack(IEContent.itemMaterial, 1, 9);
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(mechConv, 1, 0), " s ", "ici", "mum", 's', "stickIron",
'i', "ingotIron", 'c', new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.COIL_LV.getMeta()),
'u', "ingotCopper", 'm', ironMechComponent));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(mechConv, 1, 2), "iIi", "sbS", "mrm", 's', "blockSheetmetalIron",
'i', "plateIron", 'I', shaftIron,
'b', "ingotBronze", 'm', steelMechComponent,
'S', "blockSheetmetalSteel", 'r', "stickSteel"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(mechConv, 1, 1), "mrm", "sbS", "iIi", 's', "blockSheetmetalIron",
'i', "plateSteel", 'I', shaftSteel,
'b', "ingotBronze", 'm', ironMechComponent,
'S', "blockSheetmetalSteel", 'r', "stickIron"));
}
private static void addCustomRecipes() {
RecipeSorter.register("industrialwires:key_ring", RecipeKeyRing.class, RecipeSorter.Category.SHAPELESS, "after:forge:shapelessore");
RecipeSorter.register("industrialwires:key_lock", RecipeKeyLock.class, RecipeSorter.Category.SHAPELESS, "after:forge:shapelessore");
RecipeSorter.register("industrialwires:cmp_copy", RecipeComponentCopy.class, RecipeSorter.Category.SHAPED, "after:forge:shapelessore");
RecipeSorter.register("industrialwires:coilLength", RecipeCoilLength.class, RecipeSorter.Category.SHAPELESS, "after:forge:shapelessore");
RecipeSorter.register("industrialwires:init_pc", RecipeInitPC.class, RecipeSorter.Category.SHAPED, "after:forge:shapedore");
GameRegistry.addRecipe(new RecipeKeyLock());
GameRegistry.addRecipe(new RecipeKeyRing());
GameRegistry.addRecipe(new RecipeComponentCopy());
for (int i = 0; i < IC2Wiretype.IC2_TYPES.length; i++) {
GameRegistry.addRecipe(new RecipeCoilLength(i));
}
AssemblerHandler.registerRecipeAdapter(RecipeCoilLength.class, new AllRecipeAdapter<>());
AssemblerHandler.registerRecipeAdapter(RecipeComponentCopy.class, new AllRecipeAdapter<>());
AssemblerHandler.registerRecipeAdapter(RecipeKeyLock.class, new AllRecipeAdapter<>());
AssemblerHandler.registerRecipeAdapter(RecipeKeyRing.class, new AllRecipeAdapter<>());
}
private static void registerPanels() {
// CONTROL PANELS
ItemStack drillHeadIron = new ItemStack(IEContent.itemDrillhead, 1, 1);
ItemStack motor = IC2Items.getItem("crafting", "electric_motor");
ItemStack advAlloy = IC2Items.getItem("crafting", "alloy");
ItemStack coil = IC2Items.getItem("crafting", "coil");
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(panel, 1, BlockTypes_Panel.CREATOR.ordinal()),
"rmr", "rdr", "rar", 'r', "stickSteel", 'm', motor, 'd', drillHeadIron, 'a', advAlloy));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(panel, 8, BlockTypes_Panel.DUMMY.ordinal()),
" r ", "rmr", " r ", 'r', "dustRedstone", 'm', PanelUtils.getPanelBase()));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(panel, 1, BlockTypes_Panel.RS_WIRE.ordinal()),
"c", "d", 'd', new ItemStack(panel, 1, BlockTypes_Panel.DUMMY.ordinal()), 'c',
new ItemStack(IEContent.blockConnectors, 1, BlockTypes_Connector.CONNECTOR_REDSTONE.ordinal())));
// PANEL COMPONENTS
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(panelComponent, 1, 0),
"dustGlowstone", Blocks.STONE_BUTTON, "wireCopper"));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(panelComponent, 4, 1),
"paper", "plateIron"));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(panelComponent, 1, 2),
"dustGlowstone", "dustRedstone", "wireCopper"));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(panelComponent, 1, 3),
Blocks.STONE_BUTTON, new ItemStack(IEContent.itemWireCoil, 1, 2), "wireCopper"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(panelComponent, 1, 4),
"r", "g", "c", 'r', "itemRubber", 'g', "ingotHOPGraphite", 'c', coil));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(panelComponent, 1, 5),
"stickIron", Blocks.LEVER, "wireCopper"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(panelComponent, 1, 6),
"aaa", "asa", 'a', "plateAluminum", 's', new ItemStack(panelComponent, 2, 5)));
GameRegistry.addRecipe(new RecipeInitPC(new ItemStack(panelComponent, 1, 7),
"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");
ItemStack copperCable = IC2Items.getItem("cable", "type:copper,insulation:0");
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(jacobsLadder, 1, 0), "c c", " h ", "sts", 'c', copperCable, 'h', Blocks.HARDENED_CLAY,
's', "ingotSteel", 't', mvTransformer));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(jacobsLadder, 1, 1), "c c", "h h", "sts", 'c', "ingotCopper", 'h', Blocks.HARDENED_CLAY,
's', "ingotSteel", 't', new ItemStack(IEContent.blockConnectors, 1, BlockTypes_Connector.TRANSFORMER.ordinal())));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(jacobsLadder, 1, 2), "c c", "hhh", "sts", 'c', "blockCopper", 'h', Blocks.HARDENED_CLAY,
's', "ingotSteel", 't', new ItemStack(IEContent.blockConnectors, 1, BlockTypes_Connector.TRANSFORMER_HV.ordinal())));
}
private static class AllRecipeAdapter<T extends IRecipe> implements AssemblerHandler.IRecipeAdapter<T> {
@Override
public AssemblerHandler.RecipeQuery[] getQueriedInputs(T recipe, NonNullList<ItemStack> in) {
List<AssemblerHandler.RecipeQuery> ret = new ArrayList<>();
for (int i = 0; i < in.size() - 1; i++) {
boolean added = false;
for (AssemblerHandler.RecipeQuery aRet : ret) {
if (ItemStack.areItemStacksEqual((ItemStack) aRet.query, in.get(i))) {
aRet.querySize++;
added = true;
break;
}
}
if (!added) {
ret.add(new AssemblerHandler.RecipeQuery(in.get(i), 1));
}
}
return ret.toArray(new AssemblerHandler.RecipeQuery[ret.size()]);
}
@Override
public AssemblerHandler.RecipeQuery[] getQueriedInputs(T arg0) {
return new AssemblerHandler.RecipeQuery[0];
}
}
}

View file

@ -33,17 +33,16 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.fml.common.registry.GameRegistry;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -58,10 +57,14 @@ public abstract class BlockIWBase extends Block {
super(mat);
setHardness(3.0F);
setResistance(15.0F);
GameRegistry.register(this, new ResourceLocation(IndustrialWires.MODID, name));
GameRegistry.register(new ItemBlockIW(this), new ResourceLocation(IndustrialWires.MODID, name));
setUnlocalizedName(IndustrialWires.MODID + "." + name);
setRegistryName(IndustrialWires.MODID, name);
setCreativeTab(IndustrialWires.creativeTab);
IndustrialWires.blocks.add(this);
}
public ItemBlock createItemBlock() {
return new ItemBlockIW(this);
}
@Nonnull

View file

@ -18,6 +18,7 @@
package malte0811.industrialWires.blocks;
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces;
import malte0811.industrialWires.IndustrialWires;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
@ -41,6 +42,8 @@ public class ItemBlockIW extends ItemBlock {
values = null;
}
hasSubtypes = true;
setRegistryName(b.getRegistryName());
setCreativeTab(IndustrialWires.creativeTab);
}
@Nonnull

View file

@ -23,6 +23,9 @@ import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.BlockIWBase;
import malte0811.industrialWires.blocks.IMetaEnum;
import malte0811.industrialWires.controlpanel.PanelComponent;
import malte0811.industrialWires.controlpanel.PanelUtils;
import malte0811.industrialWires.controlpanel.PropertyComponents;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
@ -30,7 +33,7 @@ import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
@ -46,6 +49,8 @@ import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
public class BlockPanel extends BlockIWBase implements IMetaEnum {
public static final PropertyEnum<BlockTypes_Panel> type = PropertyEnum.create("type", BlockTypes_Panel.class);
@ -55,10 +60,16 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
lightOpacity = 0;
}
@Override
public ItemBlock createItemBlock() {
return new ItemBlockPanel(this);
}
@Override
public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) {
switch (state.getValue(type)) {
case TOP:
case SINGLE_COMP:
return layer == BlockRenderLayer.CUTOUT;
case RS_WIRE:
return layer == BlockRenderLayer.TRANSLUCENT || layer == BlockRenderLayer.SOLID;
@ -70,14 +81,18 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
@Override
public TileEntity createTileEntity(@Nonnull World world, @Nonnull IBlockState state) {
switch (state.getValue(type)) {
case TOP:
return new TileEntityPanel();
case RS_WIRE:
return new TileEntityRSPanelConn();
case CREATOR:
return new TileEntityPanelCreator();
default:
return null;
case TOP:
return new TileEntityPanel();
case RS_WIRE:
return new TileEntityRSPanelConn();
case CREATOR:
return new TileEntityPanelCreator();
case UNFINISHED:
return new TileEntityUnfinishedPanel();
case SINGLE_COMP:
return new TileEntityComponentPanel();
default:
return null;
}
}
@ -105,10 +120,11 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess worldIn, BlockPos pos) {
state = super.getActualState(state, worldIn, pos);
TileEntity te = worldIn.getTileEntity(pos);
if (te instanceof TileEntityPanel) {
if (te instanceof TileEntityComponentPanel) {
state.withProperty(type, BlockTypes_Panel.SINGLE_COMP);
} else if (te instanceof TileEntityPanel) {
state.withProperty(type, BlockTypes_Panel.TOP);
}
if (te instanceof TileEntityRSPanelConn) {
} else if (te instanceof TileEntityRSPanelConn) {
state.withProperty(type, BlockTypes_Panel.RS_WIRE);
}
return state;
@ -132,6 +148,7 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
return state.getValue(type).ordinal();
}
@Nonnull
@Override
public IBlockState getStateFromMeta(int meta) {
return super.getStateFromMeta(meta).withProperty(type, BlockTypes_Panel.values()[meta]);
@ -143,11 +160,13 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
}
@Override
public void getSubBlocks(@Nonnull Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
list.add(new ItemStack(itemIn, 1, 0));
list.add(new ItemStack(itemIn, 1, 1));
list.add(new ItemStack(itemIn, 1, 2));
list.add(new ItemStack(itemIn, 1, 3));
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
BlockTypes_Panel[] values = BlockTypes_Panel.values();
for (int i = 0; i < values.length; i++) {
if (values[i].showInCreative()) {
list.add(new ItemStack(this, 1, i));
}
}
}
@Override
@ -188,17 +207,15 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
}
return false;
}
return state.getValue(type) == BlockTypes_Panel.TOP;
return state.getValue(type) == BlockTypes_Panel.TOP||state.getValue(type) == BlockTypes_Panel.SINGLE_COMP;
}
@Override
@Nonnull
public ItemStack getPickBlock(@Nonnull IBlockState state, RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos, EntityPlayer player) {
if (state.getValue(type) == BlockTypes_Panel.TOP) {
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileEntityPanel) {
return ((TileEntityPanel) te).getTileDrop(player, state);
}
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileEntityPanel) {
return ((TileEntityPanel) te).getTileDrop(player, state);
}
return super.getPickBlock(state, target, world, pos, player);
}
@ -212,4 +229,78 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
}
}
}
@Override
public void breakBlock(@Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockState state) {
super.breakBlock(worldIn, pos, state);
//break connections
List<BlockPos> panels = PanelUtils.discoverPanelParts(worldIn, pos, 11 * 11 * 11);
for (BlockPos p : panels) {
if (!p.equals(pos)) {
TileEntity panelPart = worldIn.getTileEntity(p);
if (panelPart instanceof TileEntityPanel) {
((TileEntityPanel) panelPart).removeAllRSCons();
}
}
}
}
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
super.onBlockAdded(worldIn, pos, state);
List<BlockPos> panels = PanelUtils.discoverPanelParts(worldIn, pos, 11 * 11 * 11);
for (BlockPos p : panels) {
if (!p.equals(pos)) {
TileEntity panelPart = worldIn.getTileEntity(p);
if (panelPart instanceof TileEntityPanel) {
((TileEntityPanel) panelPart).firstTick = true;
}
}
}
}
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
super.neighborChanged(state, world, pos, blockIn, fromPos);
IBlockState blockState = world.getBlockState(pos);
if (blockState.getValue(type)==BlockTypes_Panel.SINGLE_COMP) {
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileEntityComponentPanel) {
((TileEntityComponentPanel)te).updateRS();
}
}
}
@Override
public boolean canProvidePower(IBlockState state) {
return state.getValue(type)==BlockTypes_Panel.SINGLE_COMP;
}
@Override
public boolean canConnectRedstone(IBlockState state, IBlockAccess world, BlockPos pos, @Nullable EnumFacing side) {
return state.getValue(type)==BlockTypes_Panel.SINGLE_COMP;
}
@Override
public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
if (blockState.getValue(type)==BlockTypes_Panel.SINGLE_COMP) {
TileEntity te = blockAccess.getTileEntity(pos);
if (te instanceof TileEntityComponentPanel&&side==((TileEntityComponentPanel) te).getComponents().getTop()) {
return ((TileEntityComponentPanel)te).getRSOutput();
}
}
return 0;
}
@Override
public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
if (blockState.getValue(type)==BlockTypes_Panel.SINGLE_COMP) {
TileEntity te = blockAccess.getTileEntity(pos);
if (te instanceof TileEntityComponentPanel) {
return ((TileEntityComponentPanel)te).getRSOutput();
}
}
return 0;
}
}

View file

@ -26,10 +26,20 @@ public enum BlockTypes_Panel implements IStringSerializable {
TOP,
RS_WIRE,
DUMMY,
CREATOR;
CREATOR,
UNFINISHED,
SINGLE_COMP;
@Override
public String getName() {
return toString().toLowerCase(Locale.ENGLISH);
}
public boolean isPanelConnector() {
return this != CREATOR && this != UNFINISHED;
}
public boolean showInCreative() {
return this != SINGLE_COMP;
}
}

View file

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

View file

@ -1,144 +0,0 @@
/*
* 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.common.util.chickenbones.Matrix4;
import malte0811.industrialWires.controlpanel.PanelComponent;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.property.IUnlistedProperty;
import java.util.ArrayList;
public class PropertyComponents implements IUnlistedProperty<PropertyComponents.PanelRenderProperties> {
public static PropertyComponents INSTANCE = new PropertyComponents();
@Override
public String getName() {
return "components";
}
@Override
public boolean isValid(PanelRenderProperties value) {
return value != null;
}
@Override
public Class<PanelRenderProperties> getType() {
return PanelRenderProperties.class;
}
@Override
public String valueToString(PanelRenderProperties value) {
return value.toString();
}
public static class PanelRenderProperties extends ArrayList<PanelComponent> {
public EnumFacing facing = EnumFacing.NORTH;
public float height = .5F;
public EnumFacing top = EnumFacing.UP;
public PanelRenderProperties() {
super();
}
public PanelRenderProperties(int length) {
super(length);
}
@Override
public String toString() {
StringBuilder ret = new StringBuilder("[");
for (int i = 0; i < size(); i++) {
ret.append(get(i));
if (i < size() - 1) {
ret.append(", ");
}
}
return ret + "]";
}
public Matrix4 getPanelTopTransform() {
return getPanelBaseTransform().translate(0, height, 0);
}
public Matrix4 getPanelBaseTransform() {
Matrix4 ret = new Matrix4();
ret.translate(.5, .5, .5);
switch (top) {
case DOWN:
ret.rotate(Math.PI, 0, 0, 1);
case UP:
ret.rotate(-facing.getHorizontalAngle() * Math.PI / 180 + Math.PI, 0, 1, 0);
break;
case NORTH:
case SOUTH:
case WEST:
case EAST:
ret.rotate(Math.PI / 2, 1, 0, 0);
ret.rotate(top.getHorizontalAngle() * Math.PI / 180, 0, 0, 1);
break;
}
ret.translate(-.5, -.5, -.5);
return ret;
}
public float getMaxHeight() {
float ret = 0;
for (PanelComponent pc : this) {
float hHere = pc.getHeight();
if (hHere > ret) {
ret = hHere;
}
}
return ret + height;
}
public PanelRenderProperties copyOf() {
PanelRenderProperties ret = new PanelRenderProperties(size());
for (PanelComponent pc : this) {
ret.add(pc.copyOf());
}
ret.facing = facing;
ret.top = top;
return ret;
}
@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;
PanelRenderProperties that = (PanelRenderProperties) o;
if (Float.compare(that.height, height) != 0) return false;
if (facing != that.facing) return false;
return top == that.top;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + facing.hashCode();
result = 31 * result + (height != +0.0f ? Float.floatToIntBits(height) : 0);
result = 31 * result + top.hashCode();
return result;
}
}
}

View file

@ -0,0 +1,125 @@
/*
* 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 malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.controlpanel.PanelComponent;
import malte0811.industrialWires.controlpanel.PropertyComponents;
import malte0811.industrialWires.items.ItemPanelComponent;
import net.minecraft.block.BlockRedstoneWire;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import javax.annotation.Nonnull;
import java.util.function.Consumer;
public class TileEntityComponentPanel extends TileEntityPanel {
private int rsOut = 0;
private Consumer<byte[]> rsIn;
public TileEntityComponentPanel() {
components = new PropertyComponents.AABBPanelProperties();
}
@Override
public void update() {
for (PanelComponent pc : components) {
pc.update(this);
}
if (!world.isRemote) {
if (firstTick&&components.size()>0) {
PanelComponent pc = components.get(0);
pc.registerRSOutput(-1, (channel, value, pcTmp)->{
rsOut = value;
markBlockForUpdate(pos);
markBlockForUpdate(pos.offset(components.getTop(), -1));
});
rsIn = pc.getRSInputHandler(-1, this);
updateRS();
firstTick = false;
}
}
}
public void updateRS() {
if (rsIn != null) {
int value = world.isBlockIndirectlyGettingPowered(pos);
if (value == 0) {
for (EnumFacing f : EnumFacing.HORIZONTALS) {
IBlockState state = world.getBlockState(pos.offset(f));
if (state.getBlock() == Blocks.REDSTONE_WIRE && state.getValue(BlockRedstoneWire.POWER) > value)
value = state.getValue(BlockRedstoneWire.POWER);
}
}
byte[] tmp = new byte[16];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = (byte) value;
}
rsIn.accept(tmp);
}
}
public void markBlockForUpdate(BlockPos pos)
{
IBlockState state = world.getBlockState(getPos());
world.notifyBlockUpdate(pos,state,state,3);
world.notifyNeighborsOfStateChange(pos, state.getBlock(), true);
}
@Override
public AxisAlignedBB getBoundingBox() {
if (defAABB == null) {
AxisAlignedBB base = ((PropertyComponents.AABBPanelProperties)components).getPanelBoundingBox();
defAABB = apply(components.getPanelBaseTransform(), base.setMaxY(components.getMaxHeight()));
}
return defAABB;
}
@Override
public void registerRS(TileEntityRSPanelConn te) {
//NO-OP
}
@Override
public void unregisterRS(TileEntityRSPanelConn te) {
//NO-OP
}
@Override
public boolean interactsWithRSWires() {
return false;
}
public int getRSOutput() {
return rsOut;
}
@Nonnull
@Override
public ItemStack getTileDrop(@Nonnull EntityPlayer player, @Nonnull IBlockState state) {
if (components.size()<1) {
return ItemStack.EMPTY;
}
return ItemPanelComponent.stackFromComponent(components.get(0));
}
}

View file

@ -28,7 +28,6 @@ import malte0811.industrialWires.blocks.TileEntityIWBase;
import malte0811.industrialWires.controlpanel.*;
import malte0811.industrialWires.network.MessagePanelInteract;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@ -56,26 +55,30 @@ import java.util.Set;
import static malte0811.industrialWires.util.MiscUtils.apply;
public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTile, IBlockBoundsIW, IPlayerInteraction, ITickable, IEBlockInterfaces.ITileDrop {
private PropertyComponents.PanelRenderProperties components = new PropertyComponents.PanelRenderProperties();
private boolean firstTick = true;
protected PropertyComponents.PanelRenderProperties components = new PropertyComponents.PanelRenderProperties();
public boolean firstTick = true;
// non-rendered properties
private Set<TileEntityRSPanelConn> rsPorts = new HashSet<>();
{
int[] colors = {
16383998, 16351261, 13061821, 3847130, 16701501, 8439583, 15961002,
4673362, 10329495, 1481884, 8991416, 3949738, 8606770, 6192150
};
for (int i = 2; i < 14; i++) {
int color = EnumDyeColor.byMetadata(i - 2).getMapColor().colorValue;
int color = colors[i];
IndicatorLight ind = new IndicatorLight(0, (byte) (i - 2), color);
LightedButton btn = new LightedButton(color, false, true, 1, i - 2);
Label lbl = new Label("->", color);
ind.setX(0);
ind.setY(i / 16F);
ind.setPanelHeight(components.height);
ind.setPanelHeight(components.getHeight());
lbl.setX(2 / 16F);
lbl.setY(i / 16F);
lbl.setPanelHeight(components.height);
lbl.setPanelHeight(components.getHeight());
btn.setX(5 / 16F);
btn.setY(i / 16F);
btn.setPanelHeight(components.height);
btn.setPanelHeight(components.getHeight());
components.add(ind);
components.add(lbl);
components.add(btn);
@ -89,7 +92,7 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
}
if (!world.isRemote) {
if (firstTick) {
List<BlockPos> parts = PanelUtils.discoverPanelParts(world, pos);
List<BlockPos> parts = PanelUtils.discoverPanelParts(world, pos, 100);
for (BlockPos bp : parts) {
TileEntity te = world.getTileEntity(bp);
if (te instanceof TileEntityRSPanelConn && !rsPorts.contains(te)) {
@ -104,15 +107,15 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
@Override
public void writeNBT(NBTTagCompound out, boolean updatePacket) {
writeToItemNBT(out, false);
out.setInteger("facing", components.facing.getHorizontalIndex());
out.setInteger("top", components.top.getIndex());
out.setInteger("facing", components.getFacing().getHorizontalIndex());
out.setInteger("top", components.getTop().getIndex());
}
@Override
public void readNBT(NBTTagCompound in, boolean updatePacket) {
readFromItemNBT(in);
components.facing = EnumFacing.getHorizontal(in.getInteger("facing"));
components.top = EnumFacing.getFront(in.getInteger("top"));
components.setFacing(EnumFacing.getHorizontal(in.getInteger("facing")));
components.setTop(EnumFacing.getFront(in.getInteger("top")));
}
@Override
@ -136,7 +139,8 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
if (nbt != null) {
NBTTagList l = nbt.getTagList("components", 10);
PanelUtils.readListFromNBT(l, components);
components.height = nbt.getFloat("height");
components.setHeight(nbt.getFloat("height"));
components.setAngle(nbt.getFloat("angle"));
}
defAABB = null;
}
@ -149,18 +153,19 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
comps.appendTag(nbtInner);
}
nbt.setTag("components", comps);
nbt.setFloat("height", components.height);
nbt.setFloat("height", components.getHeight());
nbt.setFloat("angle", components.getAngle());
}
@Nonnull
@Override
public EnumFacing getFacing() {
return components.facing;
return components.getFacing();
}
@Override
public void setFacing(@Nonnull EnumFacing facing) {
this.components.facing = facing;
this.components.setFacing(facing);
}
@Override
@ -173,19 +178,19 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
public EnumFacing getFacingForPlacement(@Nonnull EntityLivingBase placer, @Nonnull BlockPos pos, @Nonnull EnumFacing side, float hitX, float hitY, float hitZ) {
switch (side) {
case UP:
components.top = EnumFacing.UP;
components.setTop(EnumFacing.UP);
return EnumFacing.fromAngle(placer.rotationYaw);
case DOWN:
components.top = EnumFacing.DOWN;
return EnumFacing.fromAngle(placer.rotationYaw);
components.setTop(EnumFacing.DOWN);
return EnumFacing.fromAngle(-placer.rotationYaw);
case NORTH:
case SOUTH:
case WEST:
case EAST:
components.top = side;
components.setTop(side);
return EnumFacing.SOUTH;//Should not matter
}
return components.facing;
return components.getFacing();
}
@Override
@ -203,7 +208,7 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
return false;
}
private AxisAlignedBB defAABB;
protected AxisAlignedBB defAABB;
@Override
public AxisAlignedBB getBoundingBox() {
@ -217,28 +222,39 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
return components;
}
public AxisAlignedBB apply(Matrix4 mat, AxisAlignedBB in) {
Vec3d min = new Vec3d(in.minX, in.minY, in.minZ);
Vec3d max = new Vec3d(in.maxX, in.maxY, in.maxZ);
min = mat.apply(min);
max = mat.apply(max);
return new AxisAlignedBB(min.x, min.y, min.z, max.x, max.y, max.z);
}
@Nullable
public Pair<PanelComponent, RayTraceResult> getSelectedComponent(EntityPlayer player, Vec3d hit, boolean hitAbs) {
Matrix4 mat = components.getPanelTopTransform();
//TODO prevent clicking through the back of the panel
Matrix4 mat = components.getPanelTopTransformInverse();
PanelComponent retPc = null;
RayTraceResult retRay = null;
Vec3d playerPos = Minecraft.getMinecraft().player.getPositionVector().addVector(-pos.getX(), player.getEyeHeight() - pos.getY(), -pos.getZ());
Vec3d playerPosRelative = player.getPositionVector().addVector(-pos.getX(), player.getEyeHeight() - pos.getY(), -pos.getZ());
Vec3d playerPosTransformed = mat.apply(playerPosRelative);
for (PanelComponent pc : components) {
AxisAlignedBB box = pc.getBlockRelativeAABB();
if (box.maxY > box.minY) {
box = apply(mat, box.expandXyz(.002));
box = box.grow(.002);
Vec3d hitVec = hitAbs ? hit.addVector(-pos.getX(), -pos.getY(), -pos.getZ()) : hit;
hitVec = hitVec.scale(2).subtract(playerPos);
RayTraceResult ray = box.calculateIntercept(playerPos, hitVec);
hitVec = hitVec.subtract(playerPosRelative.subtract(hitVec).scale(10));
RayTraceResult ray = box.calculateIntercept(playerPosTransformed, mat.apply(hitVec));
if (ray != null) {
if (retPc == null) {
ray.hitVec = ray.hitVec.subtract(pc.getX(), 0, pc.getY());
retPc = pc;
retRay = ray;
} else {
double oldDist = retRay.hitVec.subtract(playerPos).lengthSquared();
double newDist = ray.hitVec.subtract(playerPos).lengthSquared();
double oldDist = retRay.hitVec.subtract(playerPosRelative).lengthSquared();
double newDist = ray.hitVec.subtract(playerPosRelative).lengthSquared();
if (newDist < oldDist) {
ray.hitVec = ray.hitVec.subtract(pc.getX(), 0, pc.getY());
retPc = pc;
retRay = ray;
}
@ -254,12 +270,7 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
if (world.isRemote) {
Pair<PanelComponent, RayTraceResult> pc = getSelectedComponent(player, new Vec3d(hitX, hitY, hitZ), false);
if (pc != null) {
Matrix4 inv = components.getPanelTopTransform();
inv.translate(pc.getLeft().getX(), 0, pc.getLeft().getY());
inv.invert();
Vec3d hitVec = inv.apply(pc.getRight().hitVec);
hitVec.subtract(pc.getLeft().getX(), 0, -pc.getLeft().getY());
IndustrialWires.packetHandler.sendToServer(new MessagePanelInteract(this, components.indexOf(pc.getKey()), hitVec));
IndustrialWires.packetHandler.sendToServer(new MessagePanelInteract(this, components.indexOf(pc.getKey()), pc.getRight().hitVec));
}
}
return true;
@ -293,9 +304,15 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
for (PanelComponent pc : components) {
pc.invalidate(this);
}
removeAllRSCons();
}
public void removeAllRSCons() {
for (TileEntityRSPanelConn rs : rsPorts) {
rs.unregisterPanel(this, true);
rs.unregisterPanel(this, true, false);
}
rsPorts.clear();
firstTick = true;
}
@Override
@ -304,8 +321,10 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
for (PanelComponent pc : components) {
pc.invalidate(this);
}
for (TileEntityRSPanelConn rs : rsPorts) {
rs.unregisterPanel(this, true);
}
removeAllRSCons();
}
public boolean interactsWithRSWires() {
return true;
}
}

View file

@ -18,7 +18,6 @@
package malte0811.industrialWires.blocks.controlpanel;
import blusunrize.immersiveengineering.common.util.IELogger;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.IBlockBoundsIW;
import malte0811.industrialWires.blocks.INetGUI;
@ -41,7 +40,6 @@ import java.util.List;
public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI, IBlockBoundsIW {
public List<PanelComponent> components = new ArrayList<>();
public float height = 0.5F;
@Nonnull
public ItemStack inv = ItemStack.EMPTY;
@ -49,7 +47,6 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI,
public void readNBT(NBTTagCompound nbt, boolean updatePacket) {
NBTTagList l = nbt.getTagList("components", 10);
PanelUtils.readListFromNBT(l, components);
height = nbt.getFloat("height");
NBTTagCompound invTag;
if (nbt.hasKey("inventory", 9)) {
invTag = nbt.getTagList("inventory", 10).getCompoundTagAt(0);
@ -73,7 +70,8 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI,
comps.appendTag(nbtInner);
}
nbt.setTag("components", comps);
nbt.setFloat("height", height);
nbt.setFloat("height", PanelUtils.getHeight(inv));
nbt.setFloat("angle", PanelUtils.getAngle(inv));
}
@Override
@ -86,7 +84,6 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI,
if (pc != null) {
pc.setX(nbt.getFloat("x"));
pc.setY(nbt.getFloat("y"));
pc.setPanelHeight(height);
components.add(pc);
if (!curr.isEmpty()) {
curr.shrink(1);
@ -96,7 +93,7 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI,
p.inventory.markDirty();
}
} else {
IELogger.info("(IndustrialWires) Failed to load panel component send by " + p.getDisplayNameString());
IndustrialWires.logger.info("(IndustrialWires) Failed to load panel component send by " + p.getDisplayNameString());
}
break;
case REMOVE:
@ -110,13 +107,24 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI,
}
break;
case CREATE_PANEL:
if (ItemStack.areItemStacksEqual(PanelUtils.getPanelBase(), inv)) {
NBTTagCompound panelNBT = new NBTTagCompound();
writeToItemNBT(panelNBT, true);
ItemStack panel = new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.TOP.ordinal());
panel.setTagCompound(panelNBT);
inv = panel;
components.clear();
if (ItemStack.areItemsEqual(PanelUtils.getPanelBase(), inv) && !components.isEmpty()) {
float height = PanelUtils.getHeight(inv);
float angle = PanelUtils.getAngle(inv);
boolean valid = true;
for (PanelComponent comp : components) {
if (!comp.isValidPos(components, height, angle)) {
valid = false;
break;
}
}
if (valid) {
NBTTagCompound panelNBT = new NBTTagCompound();
writeToItemNBT(panelNBT, true);
ItemStack panel = new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.TOP.ordinal());
panel.setTagCompound(panelNBT);
inv = panel;
components.clear();
}
}
break;
case REMOVE_ALL:
@ -138,7 +146,6 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI,
TileEntityPanel te = new TileEntityPanel();
te.readFromItemNBT(inv.getTagCompound());
components = new ArrayList<>(te.getComponents());
height = te.getComponents().height;
inv = ItemStack.EMPTY;
}
break;

View file

@ -30,6 +30,7 @@ import malte0811.industrialWires.blocks.IBlockBoundsIW;
import malte0811.industrialWires.blocks.INetGUI;
import malte0811.industrialWires.controlpanel.PanelComponent;
import malte0811.industrialWires.controlpanel.PanelUtils;
import malte0811.industrialWires.controlpanel.PropertyComponents;
import malte0811.industrialWires.util.TriConsumer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
@ -76,7 +77,7 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
loaded = true;
// completely reload the network
network.removeFromNetwork(null);
List<BlockPos> parts = PanelUtils.discoverPanelParts(world, pos);
List<BlockPos> parts = PanelUtils.discoverPanelParts(world, pos, 100);
for (BlockPos bp : parts) {
TileEntity te = world.getTileEntity(bp);
if (te instanceof TileEntityPanel) {
@ -160,31 +161,45 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
}
public void registerPanel(TileEntityPanel panel) {
PropertyComponents.PanelRenderProperties p = panel.getComponents();
for (PanelComponent pc : p) {
Consumer<byte[]> listener = pc.getRSInputHandler(id, panel);
if (listener != null) {
changeListeners.add(listener);
if (panel.interactsWithRSWires()) {
PropertyComponents.PanelRenderProperties p = panel.getComponents();
for (PanelComponent pc : p) {
Consumer<byte[]> listener = pc.getRSInputHandler(id, panel);
if (listener != null) {
changeListeners.add(listener);
listener.accept(network.channelValues);
}
pc.registerRSOutput(id, rsOut);
}
pc.registerRSOutput(id, rsOut);
panel.registerRS(this);
connectedPanels.add(panel);
}
panel.registerRS(this);
connectedPanels.add(panel);
}
public void unregisterPanel(TileEntityPanel panel, boolean remove) {
public void unregisterPanel(TileEntityPanel panel, boolean remove, boolean callPanel) {
out = new byte[16];
PropertyComponents.PanelRenderProperties p = panel.getComponents();
for (PanelComponent pc : p) {
Consumer<byte[]> listener = pc.getRSInputHandler(id, panel);
if (listener != null) {
listener.accept(new byte[16]);
changeListeners.remove(listener);
}
pc.unregisterRSOutput(id, rsOut);
outputs.remove(new PCWrapper(pc));
}
if (callPanel) {
panel.unregisterRS(this);
}
panel.unregisterRS(this);
if (remove) {
connectedPanels.remove(panel);
}
for (TileEntityPanel te : connectedPanels) {
for (PanelComponent pc : te.getComponents()) {
pc.registerRSOutput(id, rsOut);
}
}
network.updateValues();
}
@Override
@ -271,7 +286,7 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
public void onChunkUnload() {
super.onChunkUnload();
for (TileEntityPanel panel : connectedPanels) {
unregisterPanel(panel, false);
unregisterPanel(panel, false, true);
}
}
@ -279,20 +294,20 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
public void invalidate() {
super.invalidate();
for (TileEntityPanel panel : connectedPanels) {
unregisterPanel(panel, false);
unregisterPanel(panel, false, true);
}
}
@Override
public void onChange(NBTTagCompound nbt, EntityPlayer p) {
if (nbt.hasKey("rsId")) {
List<BlockPos> parts = PanelUtils.discoverPanelParts(world, pos);
List<BlockPos> parts = PanelUtils.discoverPanelParts(world, pos, 100);
List<TileEntityPanel> tes = new ArrayList<>(parts.size());
for (BlockPos bp : parts) {
TileEntity te = world.getTileEntity(bp);
if (te instanceof TileEntityPanel) {
tes.add((TileEntityPanel) te);
unregisterPanel((TileEntityPanel) te, true);
unregisterPanel((TileEntityPanel) te, true, true);
}
}
id = nbt.getInteger("rsId");

View file

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

View file

@ -18,6 +18,7 @@
package malte0811.industrialWires.blocks.converter;
import blusunrize.immersiveengineering.api.IEProperties;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.BlockIWBase;
import malte0811.industrialWires.blocks.IMetaEnum;
import net.minecraft.block.material.Material;
@ -47,9 +48,9 @@ public class BlockMechanicalConverter extends BlockIWBase implements IMetaEnum {
}
@Override
public void getSubBlocks(@Nonnull Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
for (int i = 0; i < 3; i++) {
list.add(new ItemStack(itemIn, 1, i));
list.add(new ItemStack(this, 1, i));
}
}

View file

@ -22,6 +22,8 @@ import blusunrize.immersiveengineering.api.IEProperties;
import malte0811.industrialWires.blocks.BlockIWBase;
import malte0811.industrialWires.blocks.IMetaEnum;
import malte0811.industrialWires.blocks.IPlacementCheck;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.TileEntityJacobsLadder.LadderSize;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
@ -45,7 +47,7 @@ import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class BlockJacobsLadder extends BlockIWBase implements IMetaEnum, IPlacementCheck {
private static PropertyEnum<TileEntityJacobsLadder.LadderSize> size_property = PropertyEnum.create("size", TileEntityJacobsLadder.LadderSize.class);
private static PropertyEnum<LadderSize> size_property = PropertyEnum.create("size", LadderSize.class);
public BlockJacobsLadder() {
super(Material.IRON, "jacobs_ladder");
@ -81,15 +83,15 @@ public class BlockJacobsLadder extends BlockIWBase implements IMetaEnum, IPlacem
}
@Override
public void getSubBlocks(@Nonnull Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
for (int i = 0; i < TileEntityJacobsLadder.LadderSize.values().length; i++) {
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
for (int i = 0; i < LadderSize.values().length; i++) {
list.add(new ItemStack(this, 1, i));
}
}
@Override
public Object[] getValues() {
return TileEntityJacobsLadder.LadderSize.values();
return LadderSize.values();
}
@Override
@ -103,7 +105,7 @@ public class BlockJacobsLadder extends BlockIWBase implements IMetaEnum, IPlacem
}
@Override
public boolean isFullyOpaque(IBlockState state) {
public boolean isTopSolid(IBlockState state) {
return false;
}
@ -165,7 +167,7 @@ public class BlockJacobsLadder extends BlockIWBase implements IMetaEnum, IPlacem
@Override
public boolean canPlaceBlockAt(World w, BlockPos pos, ItemStack stack) {
int dummyCount = TileEntityJacobsLadder.LadderSize.values()[stack.getMetadata()].dummyCount;
int dummyCount = LadderSize.values()[stack.getMetadata()].dummyCount;
for (int i = 1; i <= dummyCount; i++) {
if (!w.isAirBlock(pos.up(i))) {
return false;

View file

@ -44,10 +44,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.ITickable;
import net.minecraft.util.*;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
@ -266,9 +263,9 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
NBTTagList ret = new NBTTagList();
for (Vec3d point : array) {
NBTTagCompound vec = new NBTTagCompound();
vec.setDouble("x", point.xCoord);
vec.setDouble("y", point.yCoord);
vec.setDouble("z", point.zCoord);
vec.setDouble("x", point.x);
vec.setDouble("y", point.y);
vec.setDouble("z", point.z);
ret.appendTag(vec);
}
return ret;
@ -478,7 +475,7 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
min = new Vec3d(distZ, 0, distX);
max = new Vec3d(1 - distZ, h, 1 - distX);
}
return new AxisAlignedBB(min.xCoord, min.yCoord, min.zCoord, max.xCoord, max.yCoord, max.zCoord);
return new AxisAlignedBB(min.x, min.y, min.z, max.x, max.y, max.z);
}
}

View file

@ -28,6 +28,7 @@ import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
@ -43,6 +44,7 @@ import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.List;
@ -54,7 +56,6 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
setHardness(3.0F);
setResistance(15.0F);
lightOpacity = 0;
this.setCreativeTab(IndustrialWires.creativeTab);
}
@Override
@ -70,9 +71,9 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
}
@Override
public void getSubBlocks(@Nonnull Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
for (int i = 0; i < type.getAllowedValues().size(); i++) {
list.add(new ItemStack(itemIn, 1, i));
list.add(new ItemStack(this, 1, i));
}
}
@ -146,8 +147,8 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag advanced) {
super.addInformation(stack, world, tooltip, advanced);
if (!stack.isEmpty() && stack.getMetadata() % 2 == 0) {
int type = stack.getMetadata() / 2;
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.power_tier", type + 1));

View file

@ -21,30 +21,44 @@ import blusunrize.immersiveengineering.api.Lib;
import blusunrize.immersiveengineering.client.ClientUtils;
import blusunrize.immersiveengineering.common.util.ItemNBTHelper;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.IMetaEnum;
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
import malte0811.industrialWires.client.panelmodel.PanelModel;
import malte0811.industrialWires.controlpanel.PanelComponent;
import malte0811.industrialWires.items.ItemIC2Coil;
import malte0811.industrialWires.items.ItemKey;
import malte0811.industrialWires.items.ItemPanelComponent;
import malte0811.industrialWires.wires.IC2Wiretype;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.RayTraceResult;
import net.minecraftforge.client.GuiIngameForge;
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.oredict.OreDictionary;
import org.apache.commons.lang3.tuple.Pair;
import java.util.Locale;
@Mod.EventBusSubscriber(modid = IndustrialWires.MODID, value = Side.CLIENT)
public class ClientEventHandler {
@SubscribeEvent
public void renderOverlayPost(RenderGameOverlayEvent.Post e) {
public static void renderOverlayPost(RenderGameOverlayEvent.Post e) {
if (ClientUtils.mc().player != null && e.getType() == RenderGameOverlayEvent.ElementType.TEXT) {
EntityPlayer player = ClientUtils.mc().player;
@ -81,7 +95,7 @@ public class ClientEventHandler {
}
@SubscribeEvent
public void renderBoundingBoxes(DrawBlockHighlightEvent event) {
public static void renderBoundingBoxes(DrawBlockHighlightEvent event) {
if (!event.isCanceled() && event.getSubID() == 0 && event.getTarget().typeOfHit == RayTraceResult.Type.BLOCK) {
TileEntity tile = event.getPlayer().world.getTileEntity(event.getTarget().getBlockPos());
if (tile instanceof TileEntityPanel) {
@ -96,7 +110,46 @@ public class ClientEventHandler {
}
@SubscribeEvent
public void bakeModel(ModelBakeEvent event) {
public static void bakeModel(ModelBakeEvent event) {
event.getModelRegistry().putObject(new ModelResourceLocation(IndustrialWires.MODID + ":control_panel", "inventory,type=top"), new PanelModel());
event.getModelRegistry().putObject(new ModelResourceLocation(IndustrialWires.MODID + ":control_panel", "inventory,type=unfinished"), new PanelModel());
}
@SubscribeEvent
public static void registerModels(ModelRegistryEvent evt) {
for (int meta = 0; meta < ItemIC2Coil.subNames.length; meta++) {
ResourceLocation loc = new ResourceLocation(IndustrialWires.MODID, "ic2_wire_coil/" + ItemIC2Coil.subNames[meta]);
ModelBakery.registerItemVariants(IndustrialWires.coil, loc);
ModelLoader.setCustomModelResourceLocation(IndustrialWires.coil, meta, new ModelResourceLocation(loc, "inventory"));
}
for (int meta = 0; meta < ItemPanelComponent.types.length; meta++) {
ResourceLocation loc = new ResourceLocation(IndustrialWires.MODID, "panel_component/" + ItemPanelComponent.types[meta]);
ModelBakery.registerItemVariants(IndustrialWires.panelComponent, loc);
ModelLoader.setCustomModelResourceLocation(IndustrialWires.panelComponent, meta, new ModelResourceLocation(loc, "inventory"));
}
for (int meta = 0; meta < ItemKey.types.length; meta++) {
ResourceLocation loc = new ResourceLocation(IndustrialWires.MODID, "key/" + ItemKey.types[meta]);
ModelBakery.registerItemVariants(IndustrialWires.key, loc);
ModelLoader.setCustomModelResourceLocation(IndustrialWires.key, meta, new ModelResourceLocation(loc, "inventory"));
}
Block[] blocks = {IndustrialWires.ic2conn, IndustrialWires.mechConv, IndustrialWires.jacobsLadder, IndustrialWires.panel};
for (Block b : blocks) {
if (b != null) {
Item blockItem = Item.getItemFromBlock(b);
final ResourceLocation loc = b.getRegistryName();
assert loc != null;
ModelLoader.setCustomMeshDefinition(blockItem, stack -> new ModelResourceLocation(loc, "inventory"));
Object[] v = ((IMetaEnum) b).getValues();
for (int meta = 0; meta < v.length; meta++) {
String location = loc.toString();
String prop = "inventory,type=" + v[meta].toString().toLowerCase(Locale.US);
try {
ModelLoader.setCustomModelResourceLocation(blockItem, meta, new ModelResourceLocation(location, prop));
} catch (NullPointerException npe) {
throw new RuntimeException(b + " lacks an item!", npe);
}
}
}
}
}
}

View file

@ -71,6 +71,8 @@ import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.client.model.obj.OBJLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.relauncher.Side;
import java.util.Arrays;
import java.util.Locale;
@ -115,47 +117,8 @@ public class ClientProxy extends CommonProxy {
IndustrialWires.MODID + ":blocks/ic2_relay_glass"));
ConnLoader.baseModels.put("rs_panel_conn", new ResourceLocation("industrialwires:block/rs_panel_conn.obj"));
ConnLoader.baseModels.put("empty", new ResourceLocation("builtin/generated"));
for (int meta = 0; meta < ItemIC2Coil.subNames.length; meta++) {
ResourceLocation loc = new ResourceLocation(IndustrialWires.MODID, "ic2_wire_coil/" + ItemIC2Coil.subNames[meta]);
ModelBakery.registerItemVariants(IndustrialWires.coil, loc);
ModelLoader.setCustomModelResourceLocation(IndustrialWires.coil, meta, new ModelResourceLocation(loc, "inventory"));
}
for (int meta = 0; meta < ItemPanelComponent.types.length; meta++) {
ResourceLocation loc = new ResourceLocation(IndustrialWires.MODID, "panel_component/" + ItemPanelComponent.types[meta]);
ModelBakery.registerItemVariants(IndustrialWires.panelComponent, loc);
ModelLoader.setCustomModelResourceLocation(IndustrialWires.panelComponent, meta, new ModelResourceLocation(loc, "inventory"));
}
for (int meta = 0; meta < ItemKey.types.length; meta++) {
ResourceLocation loc = new ResourceLocation(IndustrialWires.MODID, "key/" + ItemKey.types[meta]);
ModelBakery.registerItemVariants(IndustrialWires.key, loc);
ModelLoader.setCustomModelResourceLocation(IndustrialWires.key, meta, new ModelResourceLocation(loc, "inventory"));
}
Block[] blocks = {IndustrialWires.ic2conn, IndustrialWires.mechConv, IndustrialWires.jacobsLadder, IndustrialWires.panel};
for (Block b : blocks) {
if (b != null) {
Item blockItem = Item.getItemFromBlock(b);
final ResourceLocation loc = b.getRegistryName();
assert loc != null;
ModelLoader.setCustomMeshDefinition(blockItem, stack -> new ModelResourceLocation(loc, "inventory"));
Object[] v = ((IMetaEnum) b).getValues();
for (int meta = 0; meta < v.length; meta++) {
String location = loc.toString();
String prop = "inventory,type=" + v[meta].toString().toLowerCase(Locale.US);
try {
ModelLoader.setCustomModelResourceLocation(blockItem, meta, new ModelResourceLocation(location, prop));
} catch (NullPointerException npe) {
throw new RuntimeException(b + " lacks an item!", npe);
}
}
}
}
OBJLoader.INSTANCE.addDomain(IndustrialWires.MODID);
ModelLoaderRegistry.registerLoader(new PanelModelLoader());
MinecraftForge.EVENT_BUS.register(new ClientEventHandler());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityJacobsLadder.class, new TileRenderJacobsLadder());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMarx.class, new TileRenderMarx());
}
@ -223,6 +186,7 @@ public class ClientProxy extends CommonProxy {
);
}
Config.manual_doubleA.put("iwJacobsUsage", IWConfig.HVStuff.jacobsUsageEU);
Config.manual_int.put("iwKeysOnRing", IWConfig.maxKeysOnRing);
m.addEntry("industrialwires.jacobs", "industrialwires",
new ManualPages.CraftingMulti(m, "industrialwires.jacobs0", new ItemStack(IndustrialWires.jacobsLadder, 1, 0), new ItemStack(IndustrialWires.jacobsLadder, 1, 1), new ItemStack(IndustrialWires.jacobsLadder, 1, 2)),
new ManualPages.Text(m, "industrialwires.jacobs1"));
@ -232,7 +196,9 @@ public class ClientProxy extends CommonProxy {
new ManualPages.Text(m, "industrialwires.intro0"),
new ManualPages.Text(m, "industrialwires.intro1"),
new ManualPages.Crafting(m, "industrialwires.intro2", new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.DUMMY.ordinal())),
new ManualPages.Text(m, "industrialwires.intro3")
new ManualPages.Text(m, "industrialwires.intro3"),
new ManualPages.Crafting(m, "industrialwires.intro4", new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.UNFINISHED.ordinal())),
new ManualPages.Text(m, "industrialwires.intro5")
);
m.addEntry("industrialwires.panel_creator", "control_panels",
new ManualPages.Crafting(m, "industrialwires.panel_creator0", new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.CREATOR.ordinal())),
@ -253,6 +219,7 @@ public class ClientProxy extends CommonProxy {
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.Crafting(m, "industrialwires.lock1", new ItemStack(IndustrialWires.key, 1, 2)),
new ManualPages.Crafting(m, "industrialwires.panel_meter", new ItemStack(IndustrialWires.panelComponent, 1, 8))
);
}
@ -336,7 +303,7 @@ public class ClientProxy extends CommonProxy {
default:
return;
}
PositionedSoundRecord sound = new PositionedSoundRecord(event, SoundCategory.BLOCKS, te.size.soundVolume, 1, false, 0, ISound.AttenuationType.LINEAR, (float) soundPos.xCoord, (float) soundPos.yCoord, (float) soundPos.zCoord);
PositionedSoundRecord sound = new PositionedSoundRecord(event, SoundCategory.BLOCKS, te.size.soundVolume, 1, false, 0, ISound.AttenuationType.LINEAR, (float) soundPos.x, (float) soundPos.y, (float) soundPos.z);
ClientUtils.mc().getSoundHandler().playSound(sound);
playingSounds.put(te.getPos(), sound);
}
@ -371,5 +338,4 @@ public class ClientProxy extends CommonProxy {
}
return null;
}
}

View file

@ -23,15 +23,19 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.EnumFacing;
import org.lwjgl.util.vector.Vector3f;
import javax.annotation.Nullable;
import java.util.Arrays;
import static org.lwjgl.util.vector.Vector3f.cross;
import static org.lwjgl.util.vector.Vector3f.sub;
public class RawQuad {
public final Vector3f[] vertices = new Vector3f[4];
public final EnumFacing facing;
public final TextureAtlasSprite tex;
public final float[] colorA;
public final Vector3f normal;
public final float[] uvs;
public final float[][] uvs;
public int light;
public RawQuad(Vector3f v0, Vector3f v1, Vector3f v2, Vector3f v3,
@ -43,6 +47,15 @@ public class RawQuad {
public RawQuad(Vector3f v0, Vector3f v1, Vector3f v2, Vector3f v3,
EnumFacing facing, TextureAtlasSprite tex, float[] colorA,
Vector3f normal, float[] uvs, int light) {
this(v0, v1, v2, v3, facing, tex, colorA, normal, new float[][]{
{uvs[0], uvs[1]}, {uvs[0], uvs[3]},
{uvs[2], uvs[3]}, {uvs[2], uvs[1]}
}, light);
}
public RawQuad(Vector3f v0, Vector3f v1, Vector3f v2, Vector3f v3,
EnumFacing facing, TextureAtlasSprite tex, float[] colorA,
@Nullable Vector3f normal, float[][] uvs, int light) {
vertices[0] = v0;
vertices[1] = v1;
vertices[2] = v2;
@ -55,7 +68,12 @@ public class RawQuad {
} else {
this.colorA = colorA;
}
this.normal = normal;
if (normal != null) {
this.normal = normal;
} else {
this.normal = cross(sub(v1, v3, null), sub(v2, v0, null), null);
this.normal.normalise(this.normal);
}
this.uvs = uvs;
this.light = light;
}
@ -64,6 +82,6 @@ public class RawQuad {
Matrix4 matNormal = mat.copy().transpose();
matNormal.invert();
return new RawQuad(mat.apply(vertices[0]), mat.apply(vertices[1]), mat.apply(vertices[2]), mat.apply(vertices[3]),
facing, tex, colorA, matNormal.apply(normal), uvs);
facing, tex, colorA, matNormal.apply(normal), uvs, light);
}
}

View file

@ -187,14 +187,16 @@ public class GuiPanelComponent extends GuiContainer {
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground();
super.drawScreen(mouseX, mouseY, partialTicks);
this.renderHoveredToolTip(mouseX, mouseY);
GlStateManager.color(1, 1, 1, 1);
RenderHelper.disableStandardItemLighting();
for (GuiChannelPicker pick : rsChannelChoosers) {
pick.drawButton(mc, mouseX, mouseY);
pick.drawButton(mc, mouseX, mouseY, partialTicks);
}
for (GuiButtonCheckbox box : boolButtons) {
box.drawButton(mc, mouseX, mouseY);
box.drawButton(mc, mouseX, mouseY, partialTicks);
}
for (GuiTextField field : stringTexts) {
field.drawTextBox();
@ -203,7 +205,7 @@ public class GuiPanelComponent extends GuiContainer {
choose.drawChooser();
}
for (GuiSliderIE choose : floatSliders) {
choose.drawButton(mc, mouseX, mouseY);
choose.drawButton(mc, mouseX, mouseY, partialTicks);
}
//TOOLTIPS
for (int i = 0; i < rsChannelChoosers.size(); i++) {
@ -223,8 +225,8 @@ public class GuiPanelComponent extends GuiContainer {
for (int i = 0; i < stringTexts.size(); i++) {
GuiTextField field = stringTexts.get(i);
String tooltip = confComp.fomatConfigDescription(IConfigurableComponent.ConfigType.STRING, i);
if (tooltip != null && mouseX >= field.xPosition && mouseX < field.xPosition + field.width &&
mouseY >= field.yPosition && mouseY < field.yPosition + field.height) {
if (tooltip != null && mouseX >= field.x && mouseX < field.x + field.width &&
mouseY >= field.y && mouseY < field.y + field.height) {
ClientUtils.drawHoveringText(ImmutableList.of(tooltip), mouseX, mouseY, mc.fontRenderer);
}
}

View file

@ -25,8 +25,10 @@ import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
import malte0811.industrialWires.containers.ContainerPanelCreator;
import malte0811.industrialWires.controlpanel.MessageType;
import malte0811.industrialWires.controlpanel.PanelComponent;
import malte0811.industrialWires.controlpanel.PanelUtils;
import malte0811.industrialWires.items.ItemPanelComponent;
import malte0811.industrialWires.network.MessageGUIInteract;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
@ -77,7 +79,9 @@ public class GuiPanelCreator extends GuiContainer {
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground();
super.drawScreen(mouseX, mouseY, partialTicks);
this.renderHoveredToolTip(mouseX, mouseY);
String tooltip = null;
if (buttonList.get(0).isMouseOver()) {
tooltip = I18n.format(IndustrialWires.MODID + ".desc.create_panel");
@ -103,7 +107,9 @@ public class GuiPanelCreator extends GuiContainer {
pc.setX(x / (float) panelSize);
pc.setY(y / (float) panelSize);
}
if (!pc.isValidPos(container.tile.components)) {
ItemStack unfinishedPanel = container.getInventory().get(0);
boolean red = (512 & (Minecraft.getSystemTime())) != 0;
if (red && !pc.isValidPos(container.tile.components, PanelUtils.getHeight(unfinishedPanel), PanelUtils.getAngle(unfinishedPanel))) {
AxisAlignedBB aabb = pc.getBlockRelativeAABB();
int left = (int) (getX0() + aabb.minX * panelSize) - 1;
int top = (int) (getY0() + aabb.minZ * panelSize) - 1;
@ -137,7 +143,8 @@ public class GuiPanelCreator extends GuiContainer {
if (0 <= xRel && xRel <= panelSize && 0 <= yRel && yRel <= panelSize) {
List<PanelComponent> components = container.tile.components;
if (curr != null) {
if (curr.isValidPos(components)) {
ItemStack unfinishedPanel = container.getInventory().get(0);
if (curr.isValidPos(components, PanelUtils.getHeight(unfinishedPanel), PanelUtils.getAngle(unfinishedPanel))) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setFloat("x", curr.getX());
nbt.setFloat("y", curr.getY());

View file

@ -59,7 +59,9 @@ public class GuiRSPanelConn extends GuiContainer {
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground();
super.drawScreen(mouseX, mouseY, partialTicks);
this.renderHoveredToolTip(mouseX, mouseY);
GlStateManager.color(1, 1, 1, 1);
RenderHelper.disableStandardItemLighting();
chooser.drawChooser();

View file

@ -59,7 +59,9 @@ public class GuiRenameKey extends GuiContainer {
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground();
super.drawScreen(mouseX, mouseY, partialTicks);
this.renderHoveredToolTip(mouseX, mouseY);
GlStateManager.color(1, 1, 1, 1);
RenderHelper.disableStandardItemLighting();
field.drawTextBox();

View file

@ -17,13 +17,13 @@ public class GuiChannelPicker extends GuiButton {
}
@Override
public void drawButton(@Nonnull Minecraft mc, int mouseX, int mouseY) {
public void drawButton(@Nonnull Minecraft mc, int mouseX, int mouseY, float patrtialTicks) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
mouseX -= xPosition;
mouseY -= yPosition;
mouseX -= x;
mouseY -= y;
currHovered = -1;
for (byte i = 0; i < 16; i++) {
int xMin = width / 4 * (i % 4);
@ -31,24 +31,24 @@ public class GuiChannelPicker extends GuiButton {
int xMax = xMin + width / 4;
int yMax = yMin + height / 4;
EnumDyeColor color = EnumDyeColor.byMetadata(i);
int colorVal = color.getMapColor().colorValue | 0xff000000;
int colorVal = color.getColorValue() | 0xff000000;
if (mouseX >= xMin && mouseX < xMax && mouseY >= yMin && mouseY < yMax) {
currHovered = i;
}
if (selected == i) {
drawRect(xMin + xPosition, yMin + yPosition, xMax + xPosition, yMax + yPosition, 0xff000000 | ~colorVal);
drawRect(xMin + x, yMin + y, xMax + x, yMax + y, 0xff000000 | ~colorVal);
}
if (currHovered == i) {
drawRect(xMin + xPosition, yMin + yPosition, xMax + xPosition, yMax + yPosition, colorVal);
drawRect(xMin + x, yMin + y, xMax + x, yMax + y, colorVal);
} else {
final int offset = width / 20;
drawRect(xMin + offset + xPosition, yMin + offset + yPosition, xMax - offset + xPosition, yMax - offset + yPosition, colorVal);
drawRect(xMin + offset + x, yMin + offset + y, xMax - offset + x, yMax - offset + y, colorVal);
}
}
}
public boolean click(int x, int y) {
if (xPosition <= x && xPosition + width >= x && yPosition <= y && yPosition + height >= y) {
public boolean click(int xMouse, int yMouse) {
if (x <= xMouse && x + width >= xMouse && y <= yMouse && y + height >= yMouse) {
select();
return true;
}
@ -65,7 +65,7 @@ public class GuiChannelPicker extends GuiButton {
return selected;
}
public boolean isHovered(int x, int y) {
return xPosition <= x && xPosition + width >= x && yPosition <= y && yPosition + height >= y;
public boolean isHovered(int xMouse, int yMouse) {
return x <= xMouse && x + width >= xMouse && y <= yMouse && y + height >= yMouse;
}
}

View file

@ -36,24 +36,24 @@ public class GuiChannelPickerSmall extends GuiChannelPicker {
}
@Override
public void drawButton(@Nonnull Minecraft mc, int mouseX, int mouseY) {
public void drawButton(@Nonnull Minecraft mc, int mouseX, int mouseY, float partialTicks) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
if (open) {
super.drawButton(mc, mouseX, mouseY);
super.drawButton(mc, mouseX, mouseY, partialTicks);
} else {
EnumDyeColor color = EnumDyeColor.byMetadata(selected);
int colorVal = color.getMapColor().colorValue | 0xff000000;
drawRect(xPosition, yPosition, xPosition + width, yPosition + height, colorVal);
int colorVal = color.getColorValue() | 0xff000000;
drawRect(x, y, x + width, y + height, colorVal);
}
}
@Override
public boolean click(int x, int y) {
public boolean click(int xMouse, int yMouse) {
if (!open) {
if (xPosition <= x && xPosition + width >= x && yPosition <= y && yPosition + height >= y) {
if (x <= xMouse && x + width >= xMouse && y <= yMouse && y + height >= yMouse) {
open = true;
width = onSize;
height = onSize;
@ -62,7 +62,7 @@ public class GuiChannelPickerSmall extends GuiChannelPicker {
return false;
} else {
boolean ret = false;
if (xPosition <= x && xPosition + width >= x && yPosition <= y && yPosition + height >= y) {
if (x <= xMouse && x + width >= xMouse && y <= yMouse && y + height >= yMouse) {
select();
ret = true;
}

View file

@ -22,11 +22,13 @@ import blusunrize.immersiveengineering.api.IEApi;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.ImmutableList;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
import malte0811.industrialWires.blocks.controlpanel.PropertyComponents;
import malte0811.industrialWires.blocks.controlpanel.PropertyComponents.PanelRenderProperties;
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
import malte0811.industrialWires.blocks.controlpanel.TileEntityUnfinishedPanel;
import malte0811.industrialWires.controlpanel.PanelUtils;
import malte0811.industrialWires.controlpanel.PropertyComponents;
import malte0811.industrialWires.controlpanel.PropertyComponents.PanelRenderProperties;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.*;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
@ -188,10 +190,10 @@ public class PanelModel implements IBakedModel {
@Nonnull
@Override
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) {
if (stack != null && stack.getItem() == PanelUtils.PANEL_ITEM && stack.getMetadata() == BlockTypes_Panel.TOP.ordinal()) {
if (stack != null && stack.getItem() == PanelUtils.PANEL_ITEM) {
try {
return ITEM_MODEL_CACHE.get(stack, () -> {
TileEntityPanel te = new TileEntityPanel();
TileEntityPanel te = stack.getMetadata() == BlockTypes_Panel.TOP.ordinal() ? new TileEntityPanel() : new TileEntityUnfinishedPanel();
te.readFromItemNBT(stack.getTagCompound());
return new AssembledBakedModel(te.getComponents());
});

View file

@ -18,7 +18,6 @@
package malte0811.industrialWires.client.panelmodel;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.controlpanel.PanelUtils;
@ -37,6 +36,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.Function;
public class PanelModelLoader implements ICustomModelLoader {
public static final String RESOURCE_BASE = "models/block/";
@ -49,12 +49,13 @@ public class PanelModelLoader implements ICustomModelLoader {
}
@Override
public boolean accepts(ResourceLocation modelLocation) {
public boolean accepts(@Nonnull ResourceLocation modelLocation) {
return modelLocation.getResourcePath().contains(RESOURCE_BASE + RESOURCE_LOCATION);
}
@Nonnull
@Override
public IModel loadModel(ResourceLocation modelLocation) throws IOException {
public IModel loadModel(@Nonnull ResourceLocation modelLocation) throws IOException {
String resourcePath = modelLocation.getResourcePath();
int pos = resourcePath.indexOf(RESOURCE_LOCATION);
if (pos >= 0) {
@ -65,11 +66,13 @@ public class PanelModelLoader implements ICustomModelLoader {
private class PanelModelBase implements IModel {
@Nonnull
@Override
public Collection<ResourceLocation> getDependencies() {
return ImmutableList.of();
}
@Nonnull
@Override
public Collection<ResourceLocation> getTextures() {
try {
@ -82,8 +85,9 @@ public class PanelModelLoader implements ICustomModelLoader {
}
}
@Nonnull
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
public IBakedModel bake(@Nonnull IModelState state, @Nonnull VertexFormat format, @Nonnull Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
try {
return new PanelModel();
} catch (Exception e) {
@ -91,10 +95,5 @@ public class PanelModelLoader implements ICustomModelLoader {
}
}
@Override
public IModelState getDefaultState() {
return null;
}
}
}

View file

@ -66,7 +66,7 @@ public class RawModelFontRenderer extends FontRenderer {
Vector3f v3 = new Vector3f(posX + w, h0, posY);
v3.scale(scale);
RawQuad quad = new RawQuad(v0, v1, v2, v3,
EnumFacing.UP, sprite, colorA, new Vector3f(0, 1, 0),
EnumFacing.UP, sprite, colorA, normal,
new float[]{x, y, x + wt, y + ht});
if (transform!=null) {
quad = quad.apply(transform);

View file

@ -21,6 +21,7 @@ package malte0811.industrialWires.client.render;
import malte0811.industrialWires.blocks.hv.TileEntityJacobsLadder;
import malte0811.industrialWires.blocks.hv.TileEntityJacobsLadder.LadderSize;
import malte0811.industrialWires.util.Beziers;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
@ -32,8 +33,8 @@ import org.lwjgl.opengl.GL11;
public class TileRenderJacobsLadder extends TileEntitySpecialRenderer<TileEntityJacobsLadder> {
@Override
public void renderTileEntityAt(TileEntityJacobsLadder tile, double x, double y, double z, float partialTicks, int destroyStage) {
super.renderTileEntityAt(tile, x, y, z, partialTicks, destroyStage);
public void render(TileEntityJacobsLadder tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
super.render(tile, x, y, z, partialTicks, destroyStage, alpha);
if (!tile.isDummy() && tile.timeTillActive == 0 && tile.controls[0] != null) {
GlStateManager.pushMatrix();
@ -50,7 +51,7 @@ public class TileRenderJacobsLadder extends TileEntitySpecialRenderer<TileEntity
Vec3d[] controls = new Vec3d[tile.size.arcPoints];
for (int i = 0; i < tile.size.arcPoints; i++) {
Vec3d speed = tile.controlMovement[i];
controls[i] = tile.controls[i].addVector(speed.xCoord * partialTicks, speed.yCoord * partialTicks, speed.zCoord * partialTicks);
controls[i] = tile.controls[i].addVector(speed.x * partialTicks, speed.y * partialTicks, speed.z * partialTicks);
}
drawBezier(controls, tile.salt, tile.size);
//DEBUG CODE
@ -84,7 +85,7 @@ public class TileRenderJacobsLadder extends TileEntitySpecialRenderer<TileEntity
Vec3d radY = new Vec3d(0, diameter / 2, 0);
Vec3d radZ = new Vec3d(0, 0, diameter / 2);
Tessellator tes = Tessellator.getInstance();
VertexBuffer vertBuffer = tes.getBuffer();
BufferBuilder vertBuffer = tes.getBuffer();
float[][] colors = new float[steps + 1][];
vertBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
Vec3d last = Beziers.getPoint(0, controls);
@ -133,19 +134,19 @@ public class TileRenderJacobsLadder extends TileEntitySpecialRenderer<TileEntity
return ret;
}
private void drawQuad(Vec3d v0, Vec3d v1, Vec3d rad, float[] color0, float[] color1, VertexBuffer vertexBuffer) {
color(color1, vertexBuffer.pos(v1.xCoord - rad.xCoord, v1.yCoord - rad.yCoord, v1.zCoord - rad.zCoord)).endVertex();
color(color0, vertexBuffer.pos(v0.xCoord - rad.xCoord, v0.yCoord - rad.yCoord, v0.zCoord - rad.zCoord)).endVertex();
color(color0, vertexBuffer.pos(v0.xCoord + rad.xCoord, v0.yCoord + rad.yCoord, v0.zCoord + rad.zCoord)).endVertex();
color(color1, vertexBuffer.pos(v1.xCoord + rad.xCoord, v1.yCoord + rad.yCoord, v1.zCoord + rad.zCoord)).endVertex();
private void drawQuad(Vec3d v0, Vec3d v1, Vec3d rad, float[] color0, float[] color1, BufferBuilder vertexBuffer) {
color(color1, vertexBuffer.pos(v1.x - rad.x, v1.y - rad.y, v1.z - rad.z)).endVertex();
color(color0, vertexBuffer.pos(v0.x - rad.x, v0.y - rad.y, v0.z - rad.z)).endVertex();
color(color0, vertexBuffer.pos(v0.x + rad.x, v0.y + rad.y, v0.z + rad.z)).endVertex();
color(color1, vertexBuffer.pos(v1.x + rad.x, v1.y + rad.y, v1.z + rad.z)).endVertex();
color(color1, vertexBuffer.pos(v1.xCoord + rad.xCoord, v1.yCoord + rad.yCoord, v1.zCoord + rad.zCoord)).endVertex();
color(color0, vertexBuffer.pos(v0.xCoord + rad.xCoord, v0.yCoord + rad.yCoord, v0.zCoord + rad.zCoord)).endVertex();
color(color0, vertexBuffer.pos(v0.xCoord - rad.xCoord, v0.yCoord - rad.yCoord, v0.zCoord - rad.zCoord)).endVertex();
color(color1, vertexBuffer.pos(v1.xCoord - rad.xCoord, v1.yCoord - rad.yCoord, v1.zCoord - rad.zCoord)).endVertex();
color(color1, vertexBuffer.pos(v1.x + rad.x, v1.y + rad.y, v1.z + rad.z)).endVertex();
color(color0, vertexBuffer.pos(v0.x + rad.x, v0.y + rad.y, v0.z + rad.z)).endVertex();
color(color0, vertexBuffer.pos(v0.x - rad.x, v0.y - rad.y, v0.z - rad.z)).endVertex();
color(color1, vertexBuffer.pos(v1.x - rad.x, v1.y - rad.y, v1.z - rad.z)).endVertex();
}
private VertexBuffer color(float[] color, VertexBuffer vb) {
private BufferBuilder color(float[] color, BufferBuilder vb) {
vb.color(color[0], color[1], color[2], 1);
return vb;
}

View file

@ -19,6 +19,7 @@
package malte0811.industrialWires.containers;
import blusunrize.immersiveengineering.api.ApiUtils;
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
import malte0811.industrialWires.controlpanel.PanelUtils;
import net.minecraft.entity.player.EntityPlayer;
@ -52,7 +53,9 @@ public class ContainerPanelCreator extends Container {
@Override
public boolean isItemValid(ItemStack stack) {
return ItemStack.areItemStacksEqual(ApiUtils.copyStackWithAmount(stack, 1), PanelUtils.getPanelBase()) || stack.getItem() == PanelUtils.PANEL_ITEM;
if (ItemStack.areItemsEqual(ApiUtils.copyStackWithAmount(stack, 1), PanelUtils.getPanelBase()))
return true;
return stack.getItem() == PanelUtils.PANEL_ITEM && stack.getMetadata() == BlockTypes_Panel.TOP.ordinal();
}
});

View file

@ -132,7 +132,7 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
@Nullable
@Override
public Consumer<byte[]> getRSInputHandler(int id, TileEntityPanel panel) {
if (id == rsInputId) {
if (matchesId(rsInputId, id)) {
this.panel = panel;
return handler;
}

View file

@ -33,6 +33,8 @@ import net.minecraft.nbt.NBTTagString;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -87,10 +89,14 @@ public class Label extends PanelComponent implements IConfigurableComponent {
@Override
public AxisAlignedBB getBlockRelativeAABB() {
if (aabb == null) {
RawModelFontRenderer fr = fontRenderer();
float width = fr.getStringWidth(text) * fr.scale;
float height = fr.FONT_HEIGHT * fr.scale;
aabb = new AxisAlignedBB(getX(), 0, getY(), getX() + width, 0, getY() + height);
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
RawModelFontRenderer fr = fontRenderer();
float width = fr.getStringWidth(text) * fr.scale;
float height = fr.FONT_HEIGHT * fr.scale;
aabb = new AxisAlignedBB(getX(), 0, getY(), getX() + width, 0, getY() + height);
} else {
aabb = new AxisAlignedBB(getX(), 0, getY(), getX() + .001, 0, getY() + .001);
}
}
return aabb;
}
@ -184,4 +190,24 @@ public class Label extends PanelComponent implements IConfigurableComponent {
new FloatConfig("blue", 0, 70, color[2], 60)
};
}
@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;
Label label = (Label) o;
if (color != label.color) return false;
return text.equals(label.text);
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + text.hashCode();
result = 31 * result + color;
return result;
}
}

View file

@ -116,11 +116,12 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
@Override
public void interactWith(Vec3d hitRel, TileEntityPanel tile, EntityPlayerMP player) {
if (!latching && active) {
return;
}
setOut(!active, tile);
if (!latching) {
ticksTillOff = 10;
} else {
setOut(!active, tile);
if (!latching) {
ticksTillOff = 10;
}
}
tile.markDirty();
tile.triggerRenderUpdate();
@ -139,7 +140,7 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
@Override
public void registerRSOutput(int id, @Nonnull TriConsumer<Integer, Byte, PanelComponent> out) {
if (id == rsOutputId) {
if (matchesId(rsOutputId, id)) {
super.registerRSOutput(id, out);
out.accept(rsOutputChannel, (byte) (active ? 15 : 0), this);
}

View file

@ -217,7 +217,7 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
@Override
public void registerRSOutput(int id, @Nonnull TriConsumer<Integer, Byte, PanelComponent> out) {
if (id == rsOutputId) {
if (matchesId(rsOutputId, id)) {
super.registerRSOutput(id, out);
out.accept(rsOutputChannel, (byte) (turned ? 15 : 0), this);
}

View file

@ -18,7 +18,7 @@
package malte0811.industrialWires.controlpanel;
import blusunrize.immersiveengineering.common.util.IELogger;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
import malte0811.industrialWires.client.RawQuad;
import malte0811.industrialWires.client.gui.GuiPanelCreator;
@ -27,11 +27,13 @@ import malte0811.industrialWires.util.TriConsumer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.logging.log4j.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -106,6 +108,10 @@ public abstract class PanelComponent {
outputs.remove(out);
}
protected boolean matchesId(int myId, int theirId) {
return myId==theirId||theirId<0;
}
public void dropItems(TileEntityPanel te) {
}
@ -148,31 +154,36 @@ public abstract class PanelComponent {
String type = nbt.getString("type");
if (baseCreaters.containsKey(type)) {
PanelComponent ret = baseCreaters.get(type).get();
ret.readCustomNBT(nbt);
ret.setX(nbt.getFloat("x"));
ret.setY(nbt.getFloat("y"));
ret.setPanelHeight(nbt.getFloat("panelHeight"));
ret.readFromNBT(nbt);
return ret;
} else {
IELogger.info("(IndustrialWires) Unknown panel component: " + type);//TODO own logger?
IndustrialWires.logger.warn("Unknown panel component: " + type);
return null;
}
}
public final void readFromNBT(NBTTagCompound nbt) {
readCustomNBT(nbt);
setX(nbt.getFloat("x"));
setY(nbt.getFloat("y"));
setPanelHeight(nbt.getFloat("panelHeight"));
}
@SideOnly(Side.CLIENT)
public void renderBox(TileEntityPanel te) {
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.glLineWidth(2.0F);
GlStateManager.disableTexture2D();
GlStateManager.depthMask(false);
double px = te.getPos().getX() - TileEntityRendererDispatcher.staticPlayerX;
double py = te.getPos().getY() - TileEntityRendererDispatcher.staticPlayerY;
double pz = te.getPos().getZ() - TileEntityRendererDispatcher.staticPlayerZ;
RenderGlobal.drawSelectionBoundingBox(MiscUtils.apply(te.getComponents().getPanelTopTransform(), getBlockRelativeAABB()).expandXyz(0.002).offset(px, py, pz),
te.getComponents().transformGLForTop(te.getPos());
RenderGlobal.drawSelectionBoundingBox(getBlockRelativeAABB().grow(0.002),
0.0F, 0.0F, 0.0F, 0.4F);
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
public abstract void renderInGUI(GuiPanelCreator gui);
@ -188,18 +199,20 @@ public abstract class PanelComponent {
}
public boolean isValidPos(List<PanelComponent> components) {
AxisAlignedBB aabb = getBlockRelativeAABB().offset(0, panelHeight, 0);
if (aabb.minX < 0 || aabb.maxX > 1) {
public boolean isValidPos(List<PanelComponent> components, float height, float angle) {
float h = PanelUtils.getHeightWithComponent(this, angle, height);
if (h < 0 || h > 1) {
return false;
}
if (aabb.minY < 0 || aabb.maxY > 1) {
AxisAlignedBB aabb = getBlockRelativeAABB();
if (aabb.minX < 0 || aabb.maxX > 1) {
return false;
}
if (aabb.minZ < 0 || aabb.maxZ > 1) {
return false;
}
aabb = getBlockRelativeAABB();
for (PanelComponent pc : components) {
if (pc == this) {
continue;

View file

@ -41,6 +41,7 @@ import org.lwjgl.util.vector.Vector3f;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
@ -116,7 +117,8 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
new Vector3f(wHalf, 0, length), EnumFacing.UP, BLACK, mat);
return ret;
}
private static RawModelFontRenderer renderer;
private RawModelFontRenderer renderer;
private RawModelFontRenderer fontRenderer() {
if (renderer == null) {
renderer = new RawModelFontRenderer(Minecraft.getMinecraft().gameSettings, Label.FONT, Minecraft.getMinecraft().getTextureManager(),
@ -198,7 +200,7 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
@Nullable
@Override
public Consumer<byte[]> getRSInputHandler(int id, TileEntityPanel panel) {
if (id == rsInputId) {
if (matchesId(rsInputId, id)) {
this.panel = panel;
return handler;
}

View file

@ -20,13 +20,13 @@ package malte0811.industrialWires.controlpanel;
import blusunrize.immersiveengineering.api.Lib;
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
import ic2.api.item.IC2Items;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.controlpanel.BlockPanel;
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
import malte0811.industrialWires.blocks.controlpanel.PropertyComponents.PanelRenderProperties;
import malte0811.industrialWires.client.RawQuad;
import malte0811.industrialWires.client.panelmodel.SmartLightingQuadIW;
import malte0811.industrialWires.controlpanel.PropertyComponents.PanelRenderProperties;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.BakedQuad;
@ -64,7 +64,7 @@ import static malte0811.industrialWires.util.MiscUtils.discoverLocal;
public final class PanelUtils {
public static TextureAtlasSprite PANEL_TEXTURE;
public static final Item PANEL_ITEM = new ItemStack(IndustrialWires.panel).getItem();
public static Item PANEL_ITEM;
private static ItemStack panelBase;
private PanelUtils() {
@ -80,11 +80,14 @@ public final class PanelUtils {
Matrix4 m4RotOnly = m4.copy();
m4RotOnly.invert();
m4RotOnly.transpose();
for (PanelComponent pc : components) {
//Intentionally not a for-each to help with CME's
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < components.size(); i++) {
PanelComponent pc = components.get(i);
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));
ret.add(bakeQuad(bq, m4Here, m4RotOnly));
}
}
Matrix4 baseTrans = components.getPanelBaseTransform();
@ -93,51 +96,74 @@ public final class PanelUtils {
baseNorm.transpose();
List<RawQuad> rawOut = new ArrayList<>();
//addTexturedBox(new Vector3f(0, 0, 0), new Vector3f(1, components.height, 1), rawOut, UV_FULL, PANEL_TEXTURE);
float vMax = 16 * components.height;
addQuad(rawOut, new Vector3f(0, components.height, 0), new Vector3f(0, components.height, 1),
new Vector3f(1, components.height, 1), new Vector3f(1, components.height, 0),
EnumFacing.UP, WHITE, PANEL_TEXTURE, UV_FULL, null, false);
addQuad(rawOut, new Vector3f(0, 0, 0), new Vector3f(1, 0, 0),
new Vector3f(1, 0, 1), new Vector3f(0, 0, 1),
EnumFacing.DOWN, WHITE, PANEL_TEXTURE, new float[]{0, 16, 16, 0}, null, false);
addQuad(rawOut, new Vector3f(0, 0, 0), new Vector3f(0, 0, 1),
new Vector3f(0, components.height, 1), new Vector3f(0, components.height, 0),
EnumFacing.WEST, WHITE, PANEL_TEXTURE, new float[]{0, vMax, 16, 0}, null, false);
addQuad(rawOut, new Vector3f(1, 0, 0), new Vector3f(1, components.height, 0),
new Vector3f(1, components.height, 1), new Vector3f(1, 0, 1),
EnumFacing.EAST, WHITE, PANEL_TEXTURE, new float[]{16, vMax, 0, 0}, null, false);
addQuad(rawOut, new Vector3f(1, 0, 0), new Vector3f(0, 0, 0),
new Vector3f(0, components.height, 0), new Vector3f(1, components.height, 0),
EnumFacing.NORTH, WHITE, PANEL_TEXTURE, new float[]{0, vMax, 16, 0}, null, false);
addQuad(rawOut, new Vector3f(0, 0, 1), new Vector3f(1, 0, 1),
new Vector3f(1, components.height, 1), new Vector3f(0, components.height, 1),
EnumFacing.SOUTH, WHITE, PANEL_TEXTURE, new float[]{0, vMax, 16, 0}, null, false);
float height1 = getLocalHeightFromZ(1, components.getHeight(), components.getAngle());
float height0 = getLocalHeightFromZ(0, components.getHeight(), components.getAngle());
float vMax1 = 16 * height1;
float vMax0 = 16 * height0;
float xMin = 0;
float xMax = 1;
float zMin = 0;
float zMax = 1;
if (components instanceof PropertyComponents.AABBPanelProperties) {
AxisAlignedBB xzAABB = ((PropertyComponents.AABBPanelProperties) components).getPanelBoundingBox();
xMin = (float) xzAABB.minX;
zMin = (float) xzAABB.minZ;
xMax = (float) xzAABB.maxX;
zMax = (float) xzAABB.maxZ;
}
float uMaxX = 16*(xMax-xMin);
float uMaxZ = 16*(zMax-zMin);
//TOP
rawOut.add(new RawQuad(new Vector3f(xMin, height0, zMin), new Vector3f(xMin, height1, zMax),
new Vector3f(xMax, height1, zMax), new Vector3f(xMax, height0, zMin),
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[]{0, 0, uMaxX, uMaxZ}, -1));
//BOTTOM
rawOut.add(new RawQuad(new Vector3f(xMin, 0, zMin), new Vector3f(xMax, 0, zMin),
new Vector3f(xMax, 0, zMax), new Vector3f(xMin, 0, zMax),
EnumFacing.DOWN, PANEL_TEXTURE, WHITE, null, UV_FULL, -1));
//LEFT
rawOut.add(new RawQuad(new Vector3f(xMin, 0, zMin), new Vector3f(xMin, 0, zMax),
new Vector3f(xMin, height1, zMax), new Vector3f(xMin, height0, zMin),
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[][]{
{0, 0}, {0, uMaxZ},
{vMax1, uMaxZ}, {vMax0, 0}
}, -1));
//RIGHT
rawOut.add(new RawQuad(new Vector3f(xMax, 0, zMin), new Vector3f(xMax, height0, zMin),
new Vector3f(xMax, height1, zMax), new Vector3f(xMax, 0, zMax),
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[][]{
{0, 0}, {vMax0, 0},
{vMax1, uMaxZ}, {0, uMaxZ}
}, -1));
//BACK
rawOut.add(new RawQuad(new Vector3f(xMax, 0, zMin), new Vector3f(xMin, 0, zMin),
new Vector3f(xMin, height0, zMin), new Vector3f(xMax, height0, zMin),
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[]{0, 0, vMax0, uMaxX}, -1));
//FRONT
rawOut.add(new RawQuad(new Vector3f(xMin, 0, zMax), new Vector3f(xMax, 0, zMax),
new Vector3f(xMax, height1, zMax), new Vector3f(xMin, height1, zMax),
EnumFacing.UP, PANEL_TEXTURE, WHITE, null, new float[]{0, 0, vMax1, uMaxX}, -1));
for (RawQuad bq : rawOut) {
ret.add(bakeQuad(bq, baseTrans, baseNorm, bq.facing != EnumFacing.EAST && bq.facing != EnumFacing.UP));//flip south and west
ret.add(bakeQuad(bq, baseTrans, baseNorm));
}
return ret;
}
@SideOnly(Side.CLIENT)
public static BakedQuad bakeQuad(RawQuad raw, Matrix4 transform, Matrix4 transfNormal, boolean flip) {
public static BakedQuad bakeQuad(RawQuad raw, Matrix4 transform, Matrix4 transfNormal) {
VertexFormat format = DefaultVertexFormats.ITEM;
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
builder.setQuadOrientation(raw.facing);
builder.setTexture(raw.tex);
Vector3f[] vertices = raw.vertices;
float[] uvs = raw.uvs;
float[][] uvs = raw.uvs;
Vector3f normal = transfNormal.apply(raw.normal);
OBJModel.Normal faceNormal = new OBJModel.Normal(normal.x, normal.y, normal.z);
putVertexData(format, builder, transform.apply(vertices[0]), faceNormal, uvs[0], uvs[1], raw.tex,
raw.colorA);
putVertexData(format, builder, transform.apply(vertices[1]), faceNormal, uvs[flip ? 2 : 0], uvs[flip ? 1 : 3], raw.tex,
raw.colorA);
putVertexData(format, builder, transform.apply(vertices[2]), faceNormal, uvs[2], uvs[3], raw.tex,
raw.colorA);
putVertexData(format, builder, transform.apply(vertices[3]), faceNormal, uvs[flip ? 0 : 2], uvs[flip ? 3 : 1], raw.tex,
raw.colorA);
for (int i = 0; i < 4; i++) {
putVertexData(format, builder, transform.apply(vertices[i]), faceNormal, uvs[i][0], uvs[i][1], raw.tex,
raw.colorA);
}
BakedQuad ret = builder.build();
if (raw.light>0) {
ret = new SmartLightingQuadIW(ret, raw.light);
@ -308,7 +334,7 @@ public final class PanelUtils {
}
if (rs && data.hasKey(RS_CHANNEL)) {
EnumDyeColor channColor = EnumDyeColor.byMetadata(data.getInteger(RS_CHANNEL));
String hexCol = Integer.toHexString(channColor.getMapColor().colorValue);
String hexCol = Integer.toHexString(channColor.getColorValue());
list.add(I18n.format("desc.immersiveengineering.info.redstoneChannel", "<hexcol=" + hexCol + ":" + channColor.getUnlocalizedName() + ">"));
}
if (rs && data.hasKey(RS_ID)) {
@ -337,37 +363,89 @@ public final class PanelUtils {
}
public static void readListFromNBT(NBTTagList list, @Nonnull List<PanelComponent> base) {
base.clear();
boolean allNew = list.tagCount() != base.size();
if (allNew) {
base.clear();
}
for (int i = 0; i < list.tagCount(); i++) {
PanelComponent pc = PanelComponent.read(list.getCompoundTagAt(i));
NBTTagCompound nbt = list.getCompoundTagAt(i);
PanelComponent pc = PanelComponent.read(nbt);
if (pc != null) {
base.add(pc);
if (allNew) {
base.add(pc);
} else {
PanelComponent oldPc = base.get(i);
if (pc.getClass() != oldPc.getClass()) {
base.set(i, pc);
} else {
oldPc.readFromNBT(nbt);
}
}
}
}
}
public static ItemStack getPanelBase() {
if (panelBase == null) {
panelBase = IC2Items.getItem("resource", "machine");
panelBase = new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.UNFINISHED.ordinal());
}
return panelBase;
}
public static List<BlockPos> discoverPanelParts(World w, BlockPos here) {
public static List<BlockPos> discoverPanelParts(World w, BlockPos here, int maxCount) {
BiPredicate<BlockPos, Integer> isValid = (pos, count) -> {
if (here.distanceSq(pos) > 25 || count > 100 || !w.isBlockLoaded(pos)) {
if (pos.equals(here)) {
return true;
}
if (here.distanceSq(pos) > 25 || count > maxCount || !w.isBlockLoaded(pos)) {
return false;
}
IBlockState state = w.getBlockState(pos);
return state.getBlock() == IndustrialWires.panel && state.getValue(BlockPanel.type) != BlockTypes_Panel.CREATOR;
return state.getBlock() == IndustrialWires.panel && state.getValue(BlockPanel.type).isPanelConnector();
};
List<BlockPos> all = discoverLocal(w, here, isValid);
List<BlockPos> ret = new ArrayList<>();
for (BlockPos pos : all) {
if (w.getBlockState(pos).getValue(BlockPanel.type) != BlockTypes_Panel.DUMMY) {
if (w.getBlockState(pos).getBlock() == IndustrialWires.panel && w.getBlockState(pos).getValue(BlockPanel.type) != BlockTypes_Panel.DUMMY) {
ret.add(pos);
}
}
return ret;
}
public static float getAngle(ItemStack inv) {
float angle = 0;
NBTTagCompound nbt = inv.getTagCompound();
if (nbt != null && nbt.hasKey("angle")) {
angle = nbt.getFloat("angle");
}
return angle;
}
public static float getHeight(ItemStack inv) {
float height = .5F;
NBTTagCompound nbt = inv.getTagCompound();
if (nbt != null && nbt.hasKey("height")) {
height = nbt.getFloat("height");
}
return height;
}
public static float getHeightWithComponent(PanelComponent pc, float angle, float height) {
AxisAlignedBB aabb = pc.getBlockRelativeAABB();
double y = angle > 0 ? aabb.minZ : aabb.maxZ;
float hComp = (float) (pc.getHeight() * Math.cos(angle));
float localPanelHeight = getLocalHeight(y, angle, height);
return hComp + localPanelHeight;
}
public static float getLocalHeight(double y, float angle, float height) {
double centerOffset = .5 * (1 / Math.cos(angle) - 1);
y += centerOffset;
return getLocalHeightFromZ(Math.cos(angle) * y, height, angle);
}
public static float getLocalHeightFromZ(double z, float height, float angle) {
return (float) (height + (.5 - z) * Math.tan(angle));
}
}

View file

@ -0,0 +1,312 @@
/*
* 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 net.minecraft.block.Block;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnull;
import java.util.ArrayList;
public class PropertyComponents implements IUnlistedProperty<PropertyComponents.PanelRenderProperties> {
public static PropertyComponents INSTANCE = new PropertyComponents();
@Override
public String getName() {
return "components";
}
@Override
public boolean isValid(PanelRenderProperties value) {
return value != null;
}
@Override
public Class<PanelRenderProperties> getType() {
return PanelRenderProperties.class;
}
@Override
public String valueToString(PanelRenderProperties value) {
return value.toString();
}
public static class PanelRenderProperties extends ArrayList<PanelComponent> {
private EnumFacing facing = EnumFacing.NORTH;
private float height = .5F;
private EnumFacing top = EnumFacing.UP;
// as radians!
private float angle = 0;
private Matrix4 topTransform;
private Matrix4 topTransformInverse;
private Matrix4 baseTransform;
public PanelRenderProperties() {
super();
}
public PanelRenderProperties(int length) {
super(length);
}
@Override
public String toString() {
StringBuilder ret = new StringBuilder("[");
for (int i = 0; i < size(); i++) {
ret.append(get(i));
if (i < size() - 1) {
ret.append(", ");
}
}
return ret + "]";
}
@Nonnull
public Matrix4 getPanelTopTransform() {
if (topTransform == null) {
topTransform = getPanelBaseTransform().copy().translate(0, getHeight(), .5)
.rotate(angle, 1, 0, 0).translate(0, 0, -.5);
}
return topTransform;
}
@Nonnull
public Matrix4 getPanelTopTransformInverse() {
if (topTransformInverse == null) {
topTransformInverse = getPanelTopTransform().copy();
topTransformInverse.invert();
}
return topTransformInverse;
}
@SideOnly(Side.CLIENT)
public void transformGLForTop(BlockPos panelPos) {
double px = panelPos.getX() - TileEntityRendererDispatcher.staticPlayerX;
double py = panelPos.getY() - TileEntityRendererDispatcher.staticPlayerY;
double pz = panelPos.getZ() - TileEntityRendererDispatcher.staticPlayerZ;
GlStateManager.translate(px + .5, py + .5, pz + .5);
switch (top) {
case DOWN:
GlStateManager.rotate(180, 1, 0, 0);
GlStateManager.rotate(-facing.getHorizontalAngle(), 0, 1, 0);
break;
case UP:
GlStateManager.rotate(180 - facing.getHorizontalAngle(), 0, 1, 0);
break;
case NORTH:
case SOUTH:
case WEST:
case EAST:
GlStateManager.rotate(90, 1, 0, 0);
GlStateManager.rotate(top.getHorizontalAngle(), 0, 0, 1);
break;
}
GlStateManager.translate(-.5, getHeight() - .5, 0);
GlStateManager.rotate((float) (angle * 180 / Math.PI), 1, 0, 0);
GlStateManager.translate(0, 0, -.5);
}
@Nonnull
public Matrix4 getPanelBaseTransform() {
if (baseTransform == null) {
baseTransform = new Matrix4();
baseTransform.translate(.5, .5, .5);
switch (top) {
case DOWN:
baseTransform.rotate(Math.PI, 0, 0, 1);
case UP:
baseTransform.rotate(-facing.getHorizontalAngle() * Math.PI / 180 + Math.PI, 0, 1, 0);
break;
case NORTH:
case SOUTH:
case WEST:
case EAST:
baseTransform.rotate(Math.PI / 2, 1, 0, 0);
baseTransform.rotate(top.getHorizontalAngle() * Math.PI / 180, 0, 0, 1);
break;
}
baseTransform.translate(-.5, -.5, -.5);
}
return baseTransform;
}
public float getMaxHeight() {
float max = getPanelMaxHeight();
for (PanelComponent pc : this) {
float h = PanelUtils.getHeightWithComponent(pc, angle, getHeight());
if (h > max) {
max = h;
}
}
return max;
}
public PanelRenderProperties copyOf() {
PanelRenderProperties ret = new PanelRenderProperties(size());
for (PanelComponent pc : this) {
ret.add(pc.copyOf());
}
ret.facing = facing;
ret.top = top;
ret.angle = angle;
return ret;
}
public float getPanelMaxHeight() {
return (float) (getHeight() + Math.abs(Math.tan(angle) / 2));
}
private void resetMatrixes() {
baseTransform = null;
topTransformInverse = null;
topTransform = null;
}
public EnumFacing getFacing() {
return facing;
}
public void setFacing(EnumFacing facing) {
if (facing != this.facing) {
this.facing = facing;
resetMatrixes();
}
}
public float getHeight() {
return height;
}
public void setHeight(float height) {
if (height != this.height) {
this.height = height;
resetMatrixes();
}
}
public EnumFacing getTop() {
return top;
}
public void setTop(EnumFacing top) {
if (top != this.top) {
this.top = top;
resetMatrixes();
}
}
public float getAngle() {
return angle;
}
public void setAngle(float angle) {
if (angle != this.angle) {
this.angle = angle;
resetMatrixes();
}
}
@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;
PanelRenderProperties that = (PanelRenderProperties) o;
if (Float.compare(that.height, height) != 0) return false;
if (Float.compare(that.angle, angle) != 0) return false;
if (facing != that.facing) return false;
return top == that.top;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + facing.hashCode();
result = 31 * result + (height != +0.0f ? Float.floatToIntBits(height) : 0);
result = 31 * result + top.hashCode();
result = 31 * result + (angle != +0.0f ? Float.floatToIntBits(angle) : 0);
return result;
}
}
public static class AABBPanelProperties extends PanelRenderProperties {
private AxisAlignedBB aabb;
private int lastHash;
public AABBPanelProperties() {
super(1);
}
public AxisAlignedBB getPanelBoundingBox() {
if (size()<1) {
aabb = Block.FULL_BLOCK_AABB;
} else if (aabb!=null||get(0).hashCode()!=lastHash) {
aabb = getPanelBoundingBox(get(0));
lastHash = get(0).hashCode();
}
return aabb;
}
@Override
public PanelComponent set(int index, PanelComponent pc) {
AxisAlignedBB aabb = pc.getBlockRelativeAABB();
pc.setX((float) ((1-aabb.maxX+aabb.minX)/2));
pc.setY((float) ((1-aabb.maxZ+aabb.minZ)/2));
return super.set(index, pc);
}
@Override
public boolean add(PanelComponent pc) {
AxisAlignedBB aabb = pc.getBlockRelativeAABB();
pc.setX((float) ((1-aabb.maxX+aabb.minX)/2));
pc.setY((float) ((1-aabb.maxZ+aabb.minZ)/2));
return super.add(pc);
}
private AxisAlignedBB getPanelBoundingBox(PanelComponent element) {
AxisAlignedBB compAABB = element.getBlockRelativeAABB();
float height = 6/16F;
double width = 3*(compAABB.maxX-compAABB.minX);
double length = 3*(compAABB.maxZ-compAABB.minZ);
width = MathHelper.clamp(width, 7/16F, 1);
length = MathHelper.clamp(length, 7/16F, 1);
double minX = (1-width)/2;
double minZ = (1-length)/2;
return new AxisAlignedBB(minX, 0, minZ, minX+width, height, minZ+length);
}
@Override
public float getHeight() {
return (float) getPanelBoundingBox().maxY;
}
}
}

View file

@ -129,7 +129,7 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
@Override
public void interactWith(Vec3d hitRelative, TileEntityPanel tile, EntityPlayerMP player) {
double pos = horizontal ? hitRelative.xCoord : (length - hitRelative.zCoord);
double pos = horizontal ? hitRelative.x : (length - hitRelative.z);
byte newLevel = (byte) (Math.min(pos * 16 / length, 15));
if (newLevel != out) {
setOut(rsChannel, newLevel);
@ -141,7 +141,7 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
@Override
public void registerRSOutput(int id, @Nonnull TriConsumer<Integer, Byte, PanelComponent> out) {
if (id == rsId) {
if (matchesId(rsId, id)) {
super.registerRSOutput(id, out);
out.accept((int) rsChannel, this.out, this);
}

View file

@ -130,7 +130,7 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
@Override
public void registerRSOutput(int id, @Nonnull TriConsumer<Integer, Byte, PanelComponent> out) {
if (id == rsOutputId) {
if (matchesId(rsOutputId, id)) {
super.registerRSOutput(id, out);
out.accept((int) rsOutputChannel, (byte) (active ? 15 : 0), this);
}

View file

@ -129,8 +129,8 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
@Override
public void interactWith(Vec3d hitRelative, TileEntityPanel tile, EntityPlayerMP player) {
double xRel = hitRelative.xCoord - SIZE / 2;
double yRel = -(hitRelative.zCoord - SIZE / 2);
double xRel = hitRelative.x - SIZE / 2;
double yRel = -(hitRelative.z - SIZE / 2);
double angle = 1.5 * Math.PI - Math.atan2(yRel, xRel);
if (angle < 0) {
angle += 2 * Math.PI;
@ -159,7 +159,7 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
@Override
public void registerRSOutput(int id, @Nonnull TriConsumer<Integer, Byte, PanelComponent> out) {
if (id == rsId) {
if (matchesId(rsId, id)) {
super.registerRSOutput(id, out);
out.accept((int) rsChannel, this.out, this);
}
@ -177,6 +177,7 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
@Override
public void renderInGUI(GuiPanelCreator gui) {
AxisAlignedBB aabb = getBlockRelativeAABB();
int left = (int) Math.ceil(gui.getX0() + (offset + aabb.minX) * gui.panelSize);
int top = (int) Math.ceil(gui.getY0() + (offset + aabb.minZ) * gui.panelSize);
int right = (int) Math.floor(gui.getX0() + (aabb.maxX - offset) * gui.panelSize);

View file

@ -17,26 +17,34 @@
*/
package malte0811.industrialWires.crafting;
import blusunrize.immersiveengineering.api.ApiUtils;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.items.ItemIC2Coil;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import net.minecraftforge.common.crafting.IngredientNBT;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.registries.IForgeRegistryEntry;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Random;
public class RecipeCoilLength implements IRecipe {
public class RecipeCoilLength extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
public final ItemStack coil;
public final ItemStack cable;
public final Ingredient cable;
private final int maxLength;
public RecipeCoilLength(int meta) {
coil = new ItemStack(IndustrialWires.coil, 1, meta);
cable = ItemIC2Coil.getUninsulatedCable(coil);
maxLength = ItemIC2Coil.getMaxWireLength(coil);
public RecipeCoilLength(ItemStack coil, Ingredient cable) {
this.coil = coil;
this.cable = cable;
maxLength = ItemIC2Coil.getMaxWireLength(this.coil);
}
@Override
@ -54,14 +62,14 @@ public class RecipeCoilLength implements IRecipe {
}
@Override
public int getRecipeSize() {
return 1;
public boolean canFit(int width, int height) {
return width>0 && height>0;
}
@Nonnull
@Override
public ItemStack getRecipeOutput() {
return ItemStack.EMPTY;
return coil;
}
@Nonnull
@ -74,11 +82,11 @@ public class RecipeCoilLength implements IRecipe {
if (OreDictionary.itemMatches(curr, coil, false)) {
length -= ItemIC2Coil.getLength(curr);
if (length < 0) {
ItemStack currStack = new ItemStack(IndustrialWires.coil, 1);
ItemStack currStack = coil.copy();
ret.set(i, currStack);
ItemIC2Coil.setLength(currStack, -length);
}
} else if (OreDictionary.itemMatches(curr, cable, false)) {
} else if (isCable(curr)) {
length--;
}
}
@ -91,7 +99,7 @@ public class RecipeCoilLength implements IRecipe {
ItemStack curr = inv.getStackInSlot(i);
if (OreDictionary.itemMatches(curr, coil, false)) {
cableLength += ItemIC2Coil.getLength(curr);
} else if (OreDictionary.itemMatches(curr, cable, false)) {
} else if (isCable(curr)) {
cableLength++;
} else if (!curr.isEmpty()) {
return -1;
@ -99,4 +107,58 @@ public class RecipeCoilLength implements IRecipe {
}
return cableLength;
}
@Nonnull
@Override
public NonNullList<Ingredient> getIngredients() {
Random r = new Random();
NonNullList<Ingredient> ret = NonNullList.withSize(9, Ingredient.EMPTY);
for (int i = 0;i<ret.size();i++) {
ItemStack[] types = new ItemStack[cable.getMatchingStacks().length+1];
int length = types.length;
int cablePos = 0;
if (r.nextBoolean()) {
types[length-1] = coil;
} else {
types[0] = coil;
cablePos = 1;
}
System.arraycopy(cable.getMatchingStacks(), 0, types, cablePos, length-1);
ret.set(i, new UnmatchedIngredient(types));
}
return ret;
}
private boolean isCable(ItemStack stack) {
for (ItemStack curr:cable.getMatchingStacks()) {
if (ItemStack.areItemsEqual(stack, curr) && ItemStack.areItemStackTagsEqual(stack, curr)) {
return true;
}
}
return false;
}
//There is probably a better way to do this...
private static class UnmatchedIngredient extends Ingredient {
public UnmatchedIngredient(ItemStack[] in) {
super(in);
}
@Override
public boolean apply(@Nullable ItemStack input) {
if (input == null)
return false;
for (ItemStack stack:getMatchingStacks()) {
if (ItemStack.areItemsEqual(stack, input) && ItemStack.areItemStackTagsEqual(stack, input)) {
return true;
}
}
return false;
}
@Nonnull
@Override
public IntList getValidItemStacksPacked() {
return new IntArrayList(0);
}
}
}

View file

@ -26,11 +26,12 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import net.minecraftforge.registries.IForgeRegistryEntry;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class RecipeComponentCopy implements IRecipe {
public class RecipeComponentCopy extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
@Override
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) {
@ -78,8 +79,8 @@ public class RecipeComponentCopy implements IRecipe {
}
@Override
public int getRecipeSize() {
return 2;
public boolean canFit(int width, int height) {
return width>0&&height>1;
}
@Nonnull
@ -106,4 +107,9 @@ public class RecipeComponentCopy implements IRecipe {
}
return null;
}
@Override
public boolean isHidden() {
return true;
}
}

View file

@ -22,15 +22,18 @@ import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.items.ItemPanelComponent;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.common.crafting.CraftingHelper.ShapedPrimer;
import net.minecraftforge.oredict.ShapedOreRecipe;
import javax.annotation.Nonnull;
public class RecipeInitPC extends ShapedOreRecipe {
public RecipeInitPC(ItemStack result, Object... recipe) {
super(result, recipe);
public RecipeInitPC(ShapedOreRecipe factory) {
super(factory.getRegistryName(), factory.getRecipeOutput(), primerFromRecipe(factory));
}
@Nonnull
@ -44,8 +47,12 @@ public class RecipeInitPC extends ShapedOreRecipe {
return ret;
}
@Override
public boolean matches(InventoryCrafting inv, World world) {
return super.matches(inv, world);
private static ShapedPrimer primerFromRecipe(ShapedOreRecipe recipe) {
ShapedPrimer ret = new ShapedPrimer();
ret.height = recipe.getHeight();
ret.width = recipe.getWidth();
ret.input = recipe.getIngredients();
ret.mirrored = true;
return ret;
}
}

View file

@ -26,12 +26,14 @@ import malte0811.industrialWires.items.ItemPanelComponent;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import net.minecraftforge.registries.IForgeRegistryEntry;
import javax.annotation.Nonnull;
public class RecipeKeyLock implements IRecipe {
public class RecipeKeyLock extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
@Override
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) {
@ -47,8 +49,8 @@ public class RecipeKeyLock implements IRecipe {
}
@Override
public int getRecipeSize() {
return 2;
public boolean canFit(int width, int height) {
return width*height>=2;
}
@Nonnull
@ -109,4 +111,13 @@ public class RecipeKeyLock implements IRecipe {
}
return ItemStack.EMPTY;
}
@Nonnull
@Override
public NonNullList<Ingredient> getIngredients() {
NonNullList<Ingredient> ret = NonNullList.withSize(2, Ingredient.EMPTY);
ret.set(0, Ingredient.fromStacks(new ItemStack(IndustrialWires.key, 1, 0)));
ret.set(1, Ingredient.fromStacks(new ItemStack(IndustrialWires.panelComponent, 1, 7)));
return ret;
}
}

View file

@ -22,59 +22,66 @@ import malte0811.industrialWires.IndustrialWires;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import net.minecraftforge.registries.IForgeRegistryEntry;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import static malte0811.industrialWires.items.ItemKey.*;
public class RecipeKeyRing implements IRecipe {
public class RecipeKeyRing extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
private final boolean addToRing;
public RecipeKeyRing(boolean add) {
addToRing = add;
}
@Override
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) {
return getType(inv) != null;
return isValid(inv);
}
@Nonnull
@Override
public ItemStack getCraftingResult(@Nonnull InventoryCrafting inv) {
Boolean recipeType = getType(inv);
if (recipeType==Boolean.TRUE) {//add key to ring
ItemStack ring = inv.getStackInSlot(getRingPos(inv)).copy();
NBTTagCompound nbt = ring.getTagCompound();
ItemStack key = inv.getStackInSlot(getKeyPos(inv));
NBTTagCompound keyNBT = key.getTagCompound();
if (nbt==null) {
nbt = new NBTTagCompound();
ring.setTagCompound(nbt);
}
if (!nbt.hasKey(RING_KEYS)) {
nbt.setTag(RING_KEYS, new NBTTagList());
}
if (keyNBT!=null) {
NBTTagList keys = nbt.getTagList(RING_KEYS, 10);
if (keys.tagCount()>= IWConfig.maxKeysOnRing) {
return ItemStack.EMPTY;
if (isValid(inv)) {
if (addToRing) {//add key to ring
ItemStack ring = inv.getStackInSlot(getRingPos(inv)).copy();
NBTTagCompound nbt = ring.getTagCompound();
ItemStack key = inv.getStackInSlot(getKeyPos(inv));
NBTTagCompound keyNBT = key.getTagCompound();
if (nbt == null) {
nbt = new NBTTagCompound();
ring.setTagCompound(nbt);
}
keys.appendTag(keyNBT.copy());
nbt.setInteger(LOCK_ID, keyNBT.getInteger(LOCK_ID));
nbt.setString(NAME, keyNBT.getString(NAME));
}
return ring;
} else {//remove key from ring
ItemStack ring = inv.getStackInSlot(getRingPos(inv)).copy();
NBTTagCompound nbt = ring.getTagCompound();
ItemStack key = new ItemStack(IndustrialWires.key, 1, 1);
if (nbt!=null) {
NBTTagList keys = nbt.getTagList(RING_KEYS, 10);
if (keys.tagCount()>0) {
NBTTagCompound first = keys.getCompoundTagAt(keys.tagCount()-1);
key.setTagCompound(first);
return key;
if (!nbt.hasKey(RING_KEYS)) {
nbt.setTag(RING_KEYS, new NBTTagList());
}
if (keyNBT != null) {
NBTTagList keys = nbt.getTagList(RING_KEYS, 10);
if (keys.tagCount() >= IWConfig.maxKeysOnRing) {
return ItemStack.EMPTY;
}
keys.appendTag(keyNBT.copy());
nbt.setInteger(LOCK_ID, keyNBT.getInteger(LOCK_ID));
nbt.setString(NAME, keyNBT.getString(NAME));
}
return ring;
} else {//remove key from ring
ItemStack ring = inv.getStackInSlot(getRingPos(inv)).copy();
NBTTagCompound nbt = ring.getTagCompound();
ItemStack key = new ItemStack(IndustrialWires.key, 1, 1);
if (nbt != null) {
NBTTagList keys = nbt.getTagList(RING_KEYS, 10);
if (keys.tagCount() > 0) {
NBTTagCompound first = keys.getCompoundTagAt(keys.tagCount() - 1);
key.setTagCompound(first);
return key;
}
}
}
}
@ -82,21 +89,22 @@ public class RecipeKeyRing implements IRecipe {
}
@Override
public int getRecipeSize() {
return 2;
public boolean canFit(int width, int height) {
return width>0&&height>0;
}
@Nonnull
@Override
public ItemStack getRecipeOutput() {
return ItemStack.EMPTY;
return new ItemStack(IndustrialWires.key, 1, addToRing?2:1);
}
@Nonnull
@Override
public NonNullList<ItemStack> getRemainingItems(@Nonnull InventoryCrafting inv) {
NonNullList<ItemStack> ret = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
if (getType(inv)==Boolean.FALSE) {
if (!addToRing) {
int ringId = getRingPos(inv);
ItemStack ring = inv.getStackInSlot(ringId).copy();
NBTTagCompound nbt = ring.getTagCompound();
@ -105,6 +113,8 @@ public class RecipeKeyRing implements IRecipe {
keys.removeTag(keys.tagCount()-1);
if (keys.tagCount() > 0) {
NBTTagCompound first = keys.getCompoundTagAt(0);
keys.removeTag(0);
keys.appendTag(first);
nbt.setInteger(LOCK_ID, first.getInteger(LOCK_ID));
nbt.setString(NAME, first.getString(NAME));
} else {
@ -117,8 +127,7 @@ public class RecipeKeyRing implements IRecipe {
return ret;
}
@Nullable
private Boolean getType(@Nonnull InventoryCrafting inv) {
private boolean isValid(@Nonnull InventoryCrafting inv) {
boolean hasRing = false;
boolean hasKey = false;
for (int i = 0;i<inv.getSizeInventory();i++) {
@ -131,12 +140,16 @@ public class RecipeKeyRing implements IRecipe {
hasRing = true;
continue;
}
return null;
return false;
} else if (!here.isEmpty()) {
return null;
return false;
}
}
return hasRing?hasKey:null;
if (addToRing) {
return hasKey&&hasRing;
} else {
return !hasKey&&hasRing;
}
}
private int getRingPos(@Nonnull InventoryCrafting inv) {
@ -157,4 +170,16 @@ public class RecipeKeyRing implements IRecipe {
}
return -1;
}
@Nonnull
@Override
public NonNullList<Ingredient> getIngredients() {
if (addToRing) {
NonNullList<Ingredient> ret = NonNullList.withSize(2, Ingredient.fromStacks(new ItemStack(IndustrialWires.key, 1, 1)));;
ret.set(1, Ingredient.fromStacks(new ItemStack(IndustrialWires.key, 1, 2)));
return ret;
} else {
return NonNullList.withSize(1, Ingredient.fromStacks(new ItemStack(IndustrialWires.key, 1, 2)));
}
}
}

View file

@ -0,0 +1,69 @@
/*
* 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.crafting;
import blusunrize.immersiveengineering.api.tool.AssemblerHandler;
import ic2.api.item.IC2Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.NonNullList;
import net.minecraftforge.registries.IForgeRegistry;
import java.util.*;
import static malte0811.industrialWires.IndustrialWires.MODID;
public class Recipes {
public static void addRecipes(IForgeRegistry<IRecipe> registry) {
registry.register(new RecipeKeyRing(true).setRegistryName(MODID, "add_key_ring"));
registry.register(new RecipeKeyRing(false).setRegistryName(MODID, "remove_key_ring"));
registry.register(new RecipeKeyLock().setRegistryName(MODID, "key_lock"));
registry.register(new RecipeComponentCopy().setRegistryName(MODID, "component_copy"));
AssemblerHandler.registerRecipeAdapter(RecipeCoilLength.class, new Recipes.AllRecipeAdapter<>());
AssemblerHandler.registerRecipeAdapter(RecipeComponentCopy.class, new Recipes.AllRecipeAdapter<>());
AssemblerHandler.registerRecipeAdapter(RecipeKeyLock.class, new Recipes.AllRecipeAdapter<>());
AssemblerHandler.registerRecipeAdapter(RecipeKeyRing.class, new Recipes.AllRecipeAdapter<>());
AssemblerHandler.registerRecipeAdapter(RecipeInitPC.class, new Recipes.AllRecipeAdapter<>());
}
private static class AllRecipeAdapter<T extends IRecipe> implements AssemblerHandler.IRecipeAdapter<T> {
@Override
public AssemblerHandler.RecipeQuery[] getQueriedInputs(T recipe, NonNullList<ItemStack> in) {
List<AssemblerHandler.RecipeQuery> ret = new ArrayList<>();
for (int i = 0; i < in.size() - 1; i++) {
boolean added = false;
for (AssemblerHandler.RecipeQuery aRet : ret) {
if (ItemStack.areItemStacksEqual((ItemStack) aRet.query, in.get(i))) {
aRet.querySize++;
added = true;
break;
}
}
if (!added) {
ret.add(new AssemblerHandler.RecipeQuery(in.get(i), 1));
}
}
return ret.toArray(new AssemblerHandler.RecipeQuery[ret.size()]);
}
@Override
public AssemblerHandler.RecipeQuery[] getQueriedInputs(T arg0) {
return new AssemblerHandler.RecipeQuery[0];
}
}
}

View file

@ -0,0 +1,27 @@
package malte0811.industrialWires.crafting.factories;
import com.google.gson.JsonObject;
import ic2.api.item.IC2Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.common.crafting.IIngredientFactory;
import net.minecraftforge.common.crafting.IngredientNBT;
import net.minecraftforge.common.crafting.JsonContext;
import javax.annotation.Nonnull;
public class IC2ItemFactory implements IIngredientFactory {
@Nonnull
@Override
public Ingredient parse(JsonContext context, JsonObject json) {
String name = json.get("name").getAsString();
String variant = json.get("variant").getAsString();
return new MyNBTIngredient(IC2Items.getItem(name, variant));
}
private class MyNBTIngredient extends IngredientNBT {
public MyNBTIngredient(ItemStack stack) {
super(stack);
}
}
}

View file

@ -0,0 +1,15 @@
package malte0811.industrialWires.crafting.factories;
import com.google.gson.JsonObject;
import malte0811.industrialWires.crafting.RecipeInitPC;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.common.crafting.IRecipeFactory;
import net.minecraftforge.common.crafting.JsonContext;
import net.minecraftforge.oredict.ShapedOreRecipe;
public class InitPCFactory implements IRecipeFactory {
@Override
public IRecipe parse(JsonContext context, JsonObject json) {
return new RecipeInitPC(ShapedOreRecipe.factory(context, json));
}
}

View file

@ -0,0 +1,16 @@
package malte0811.industrialWires.crafting.factories;
import com.google.gson.JsonObject;
import malte0811.industrialWires.IWConfig;
import net.minecraftforge.common.crafting.IConditionFactory;
import net.minecraftforge.common.crafting.JsonContext;
import java.util.function.BooleanSupplier;
public class IsConversionEnabled implements IConditionFactory {
@Override
public BooleanSupplier parse(JsonContext context, JsonObject json) {
return () -> IWConfig.enableConversion;
}
}

View file

@ -0,0 +1,20 @@
package malte0811.industrialWires.crafting.factories;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import malte0811.industrialWires.crafting.RecipeCoilLength;
import malte0811.industrialWires.crafting.RecipeInitPC;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.common.crafting.IRecipeFactory;
import net.minecraftforge.common.crafting.JsonContext;
import net.minecraftforge.oredict.ShapedOreRecipe;
public class WireCoilFactory implements IRecipeFactory {
@Override
public RecipeCoilLength parse(JsonContext context, JsonObject json) {
JsonObject coil = json.getAsJsonObject("coil");
JsonObject cable = json.getAsJsonObject("cable");
return new RecipeCoilLength(CraftingHelper.getItemStack(coil, context), CraftingHelper.getIngredient(cable, context));
}
}

View file

@ -25,7 +25,6 @@ import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
import blusunrize.immersiveengineering.api.energy.wires.WireType;
import blusunrize.immersiveengineering.common.IESaveData;
import blusunrize.immersiveengineering.common.util.IEAchievements;
import blusunrize.immersiveengineering.common.util.ItemNBTHelper;
import blusunrize.immersiveengineering.common.util.Utils;
import ic2.api.item.IC2Items;
@ -34,6 +33,7 @@ import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.wires.IC2Wiretype;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
@ -45,9 +45,9 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -62,15 +62,18 @@ public class ItemIC2Coil extends Item implements IWireCoil {
this.setCreativeTab(IndustrialWires.creativeTab);
setMaxStackSize(64);
setRegistryName(new ResourceLocation(IndustrialWires.MODID, "ic2_wire_coil"));
GameRegistry.register(this);
IndustrialWires.items.add(this);
}
@Override
public void getSubItems(@Nonnull Item itemIn, CreativeTabs tab, NonNullList<ItemStack> subItems) {
for (int i = 0; i < subNames.length; i++) {
ItemStack tmp = new ItemStack(this, 1, i);
setLength(tmp, getMaxWireLength(tmp));
subItems.add(tmp);
public void getSubItems(@Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems) {
if (isInCreativeTab(tab)) {
for (int i = 0; i < subNames.length; i++) {
ItemStack tmp = new ItemStack(this, 1, i);
setLength(tmp, getMaxWireLength(tmp));
subItems.add(tmp);
}
}
}
@ -86,18 +89,19 @@ public class ItemIC2Coil extends Item implements IWireCoil {
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean adv) {
list.add(I18n.format(IndustrialWires.MODID + ".desc.wireLength", getLength(stack)));
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
tooltip.add(I18n.format(IndustrialWires.MODID + ".desc.wireLength", getLength(stack)));
int transferRate = IC2Wiretype.IC2_TYPES[stack.getMetadata()].getTransferRate();
list.add(I18n.format(IndustrialWires.MODID + ".tooltip.transfer_rate", transferRate));
list.add(I18n.format(IndustrialWires.MODID + ".tooltip.input_rate", transferRate / 8));
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.transfer_rate", transferRate));
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.input_rate", transferRate / 8));
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("linkingPos")) {
int[] link = stack.getTagCompound().getIntArray("linkingPos");
if (link.length > 3) {
list.add(I18n.format(Lib.DESC_INFO + "attachedToDim", link[1], link[2], link[3], link[0]));
tooltip.add(I18n.format(Lib.DESC_INFO + "attachedToDim", link[1], link[2], link[3], link[0]));
}
}
list.add(I18n.format(IndustrialWires.MODID + ".desc.recipe"));
tooltip.add(I18n.format(IndustrialWires.MODID + ".desc.recipe"));
}
//mostly copied from IE
@ -173,7 +177,7 @@ public class ItemIC2Coil extends Item implements IWireCoil {
nodeHere.connectCable(type, target, nodeLink);
nodeLink.connectCable(type, targetLink, nodeHere);
IESaveData.setDirty(world.provider.getDimension());
player.addStat(IEAchievements.connectWire);
Utils.unlockIEAdvancement(player, "main/connect_wire");
if (!player.capabilities.isCreativeMode) {
if (length < lengthOnStack) {
@ -224,20 +228,4 @@ public class ItemIC2Coil extends Item implements IWireCoil {
public static int getMaxWireLength(ItemStack i) {
return IWConfig.maxLengthOnCoil[i.getItemDamage()];
}
public static ItemStack getUninsulatedCable(ItemStack i) {
switch (i.getMetadata()) {
case 0:
return IC2Items.getItem("cable", "type:tin,insulation:0");
case 1:
return IC2Items.getItem("cable", "type:copper,insulation:0");
case 2:
return IC2Items.getItem("cable", "type:gold,insulation:0");
case 3:
return IC2Items.getItem("cable", "type:iron,insulation:0");
case 4:
return IC2Items.getItem("cable", "type:glass,insulation:0");
}
return null;
}
}

View file

@ -20,6 +20,7 @@ package malte0811.industrialWires.items;
import malte0811.industrialWires.IndustrialWires;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
@ -33,6 +34,8 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
public class ItemKey extends Item implements INetGUIItem {
public static final String LOCK_ID = "lockId";
@ -46,7 +49,7 @@ public class ItemKey extends Item implements INetGUIItem {
this.setCreativeTab(IndustrialWires.creativeTab);
setMaxStackSize(64);
setRegistryName(new ResourceLocation(IndustrialWires.MODID, "key"));
GameRegistry.register(this);
IndustrialWires.items.add(this);
}
@Nonnull
@ -60,15 +63,27 @@ public class ItemKey extends Item implements INetGUIItem {
}
@Override
public void getSubItems(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> subItems) {
subItems.add(new ItemStack(this, 1, 0));
subItems.add(new ItemStack(this, 1, 2));
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
super.addInformation(stack, worldIn, tooltip, flagIn);
if (stack.getMetadata()==2&&stack.getTagCompound()!=null) {
NBTTagList keys = stack.getTagCompound().getTagList(RING_KEYS, 10);
for (int i = 0;i< keys.tagCount()-1;i++) {
tooltip.add(I18n.format("item."+IndustrialWires.MODID+".key.key_named.name")+" "+keys.getCompoundTagAt(i).getString(NAME));
}
}
}
@Override
public void getSubItems(@Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems) {
if (isInCreativeTab(tab)) {
subItems.add(new ItemStack(this, 1, 0));
subItems.add(new ItemStack(this, 1, 2));
}
}
@Nonnull
@Override
public String getUnlocalizedName(ItemStack stack) {
NBTTagCompound nbt = stack.getTagCompound();
return "item."+IndustrialWires.MODID+".key."+types[stack.getMetadata()];
}

View file

@ -20,22 +20,31 @@ package malte0811.industrialWires.items;
import blusunrize.immersiveengineering.api.ApiUtils;
import blusunrize.immersiveengineering.client.ClientProxy;
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
import malte0811.industrialWires.controlpanel.IConfigurableComponent;
import malte0811.industrialWires.controlpanel.PanelComponent;
import malte0811.industrialWires.controlpanel.PanelUtils;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -58,11 +67,11 @@ public class ItemPanelComponent extends Item implements INetGUIItem {
this.setCreativeTab(IndustrialWires.creativeTab);
setMaxStackSize(64);
setRegistryName(new ResourceLocation(IndustrialWires.MODID, "panel_component"));
GameRegistry.register(this);
IndustrialWires.items.add(this);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean adv) {
public void addInformation(ItemStack stack, World world, List<String> list, ITooltipFlag flag) {
if (GuiScreen.isShiftKeyDown()) {
NBTTagCompound nbt = getTagCompound(stack);
NBTTagCompound data = nbt.getCompoundTag("data");
@ -86,9 +95,11 @@ public class ItemPanelComponent extends Item implements INetGUIItem {
}
@Override
public void getSubItems(@Nonnull Item itemIn, CreativeTabs tab, NonNullList<ItemStack> subItems) {
for (int i = 0; i < types.length; i++) {
subItems.add(new ItemStack(itemIn, 1, i));
public void getSubItems(@Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems) {
if (isInCreativeTab(tab)) {
for (int i = 0; i < types.length; i++) {
subItems.add(new ItemStack(this, 1, i));
}
}
}
@ -162,6 +173,49 @@ public class ItemPanelComponent extends Item implements INetGUIItem {
return new ActionResult<>(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand));
}
/**
* mostly copied from {@link net.minecraft.item.ItemBlock}
*/
@Nonnull
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
if (!block.isReplaceable(worldIn, pos)) {
pos = pos.offset(facing);
}
ItemStack itemstack = player.getHeldItem(hand);
if (!itemstack.isEmpty() && player.canPlayerEdit(pos, facing, itemstack) && worldIn.mayPlace(IndustrialWires.panel, pos, false, facing, (Entity) null)) {
placeBlockAt(itemstack, player, worldIn, pos, facing, hitX, hitY, hitZ);
SoundType soundtype = worldIn.getBlockState(pos).getBlock().getSoundType(worldIn.getBlockState(pos), worldIn, pos, player);
worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
itemstack.shrink(1);
return EnumActionResult.SUCCESS;
} else {
return EnumActionResult.FAIL;
}
}
private void placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
IBlockState state = IndustrialWires.panel.getStateFromMeta(BlockTypes_Panel.SINGLE_COMP.ordinal());
world.setBlockState(pos, state);
TileEntity te = world.getTileEntity(pos);
if (te instanceof IEBlockInterfaces.IDirectionalTile) {
EnumFacing dir = ((IEBlockInterfaces.IDirectionalTile) te).getFacingForPlacement(player, pos, side, hitX, hitY, hitZ);
((IEBlockInterfaces.IDirectionalTile) te).setFacing(dir);
}
if (te instanceof IEBlockInterfaces.ITileDrop) {
((IEBlockInterfaces.ITileDrop) te).readOnPlacement(player, stack);
}
if (te instanceof TileEntityPanel) {
((TileEntityPanel) te).getComponents().clear();
((TileEntityPanel) te).getComponents().add(componentFromStack(stack));
}
}
@Override
public void onChange(NBTTagCompound data, EntityPlayer player, EnumHand hand) {
ItemStack held = player.getHeldItem(hand);

View file

@ -55,7 +55,7 @@ public class MessagePanelInteract implements IMessage {
buf.writeInt(this.pos.getY());
buf.writeInt(this.pos.getZ());
buf.writeInt(pcId);
buf.writeDouble(hitRelative.xCoord).writeDouble(hitRelative.yCoord).writeDouble(hitRelative.zCoord);
buf.writeDouble(hitRelative.x).writeDouble(hitRelative.y).writeDouble(hitRelative.z);
}
public static class HandlerServer implements IMessageHandler<MessagePanelInteract, IMessage> {

View file

@ -34,7 +34,7 @@ public final class Beziers {
int n = controls.length - 1;
for (int i = 0; i <= n; i++) {
double coeff = binomialCoeff(n, i) * Math.pow(t, i) * Math.pow(1 - t, n - i);
ret = ret.addVector(coeff * controls[i].xCoord, coeff * controls[i].yCoord, coeff * controls[i].zCoord);
ret = ret.addVector(coeff * controls[i].x, coeff * controls[i].y, coeff * controls[i].z);
}
return ret;
}

View file

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

View file

@ -21,6 +21,7 @@ tile.industrialwires.control_panel.top.name=Control Panel
tile.industrialwires.control_panel.rs_wire.name=Redstone Wire Controller
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
item.industrialwires.ic2_wire_coil.tin.name=Tin Wire Coil
item.industrialwires.ic2_wire_coil.copper.name=Copper Wire Coil
@ -60,6 +61,10 @@ industrialwires.desc.green=Green
industrialwires.desc.blue=Blue
industrialwires.desc.length=Length
industrialwires.desc.wide_info=Wide Format
industrialwires.desc.height=Height
industrialwires.desc.height_info=The Height of the panel in the middle
industrialwires.desc.angle=Angle
industrialwires.desc.angle_info=The panel's angle to the surface it is placed on. 0=-45°, 100=45°
industrialwires.tooltip.wide=Wide
industrialwires.tooltip.narrow=Narrow
@ -109,16 +114,18 @@ ie.manual.entry.industrialwires.jacobs1=These are the required power values in E
ie.manual.entry.industrialwires.intro.name=Introduction
ie.manual.entry.industrialwires.intro.subtext=
ie.manual.entry.industrialwires.intro0=Control Panels allow you to monitor and control a large amount of redstone signals using only a few blocks. Those signals can currently be connected using redstone wires and connectors.<br>Buttons, switches, indicator lights and other things that can be placed on a control panel are called §l(Panel) Components§r<br>To create a control panel you will need a Panel Creator, the individual components and a basic machine casing as the enclosure of the panel. Each
ie.manual.entry.industrialwires.intro1=component is described in the entry "Panel Components". Right-clicking with a panel component opens up a GUI in which the properties of the component, like the redstone channel and ID or the color, can be configured.
ie.manual.entry.industrialwires.intro0=Control Panels allow you to monitor and control a large amount of redstone signals using only a few blocks. Those signals can currently be connected using redstone wires and connectors.<br>Buttons, switches, indicator lights and other things that can be placed on a control panel are called §l(Panel) Components§r<br>To create a control panel you will need a Panel Creator, the individual components and an Unfinished Panel (which determines the shape of the
ie.manual.entry.industrialwires.intro1=panel). Each component is described in the entry "Panel Components". Right-clicking with a panel component opens up a GUI in which the properties of the component, like the redstone channel and ID or the color, can be configured.
ie.manual.entry.industrialwires.intro2=A §l(panel) network§r is formed by panel blocks connected to each other, directly or through other panel blocks. Panel blocks include the control panel itself, the panel connector and the Redstone Wire Controller. If multiple components in one network are configured to modify the same
ie.manual.entry.industrialwires.intro3=redstone signal, the resulting signal will be the highest of the individual signals. Having multiple components accepting the same signal on a network is valid as well.
ie.manual.entry.industrialwires.intro4=The §lUnfinished Control Panel§r is used as the casing of a control panel. It can be configured by putting it into an Engineer's Workbench. The slider labeled "Height" changes the height in the middle of the panel. The "Angle" slider changes the angle of the panel relative to the surface it is
ie.manual.entry.industrialwires.intro5=placed on, creating tilted panels. The sliders will automatically clamp to the highest/lowest angle/height the panel can have without being partially outside the block. The values might not visually clamp due to the way the Workbench works, closing and re-opening the GUI should fix this.
ie.manual.entry.industrialwires.panel_creator.name=Panel Creator
ie.manual.entry.industrialwires.panel_creator.subtext=
ie.manual.entry.industrialwires.panel_creator0=The GUI of the panel creator consists of two major sections: The controls on the left and the panel on the right. Components can be placed on the panel by "placing" the items in the corresponding point in the GUI. If the component is surrounded by a red area, it can not be placed in that
ie.manual.entry.industrialwires.panel_creator1=position on the panel. This usually means that it is either overlapping with an other component or isn't completely on the panel. The top button on the left (D) disassembles an existing control panel when it is placed in the slot beneath the button: The components of that panel are placed in the GUI, allowing them to be repositioned. The machine casing is lost in this process. The next button (C) turns a machine casing in the slot into a control panel with the components as positioned in the right of the GUI. The button
ie.manual.entry.industrialwires.panel_creator2=labeled R removes all components from the GUI panel area and places them in your inventory. Finally the last button (S) changes between being able to place components anywhere on the panel to only being able to place them on a 16x16 grid.
ie.manual.entry.industrialwires.panel_creator1=position on the panel. This usually means that it is either overlapping with an other component or isn't completely on the panel.<br>The top button on the left (D) disassembles an existing control panel when it is placed in the slot beneath the button: The components of that panel are placed in the GUI, allowing them to be repositioned. The casing is lost in this process.<br>The next button (C) places the components from the right of the GUI on an Unfinished Control Panel in the slot in the
ie.manual.entry.industrialwires.panel_creator2=left of the GUI, turning it into a regular Control Panel.<br>The button labeled R removes all components from the GUI panel area and places them in your inventory.<br>Finally the last button (S) changes between being able to place components anywhere on the panel to only being able to place them on a 16x16 grid.
ie.manual.entry.industrialwires.redstone.name=Redstone Connections
ie.manual.entry.industrialwires.redstone.subtext=Could also be blood vessels
@ -127,7 +134,7 @@ ie.manual.entry.industrialwires.redstone1=connectors from Immersive Engineering.
ie.manual.entry.industrialwires.components.name=Panel Components
ie.manual.entry.industrialwires.components.subtext=More than just two
ie.manual.entry.industrialwires.components.general=The settings of any component can be copied to a component of the same type by placing the components directly above each other in a crafting bench. The settings of the upper component will be copied to the lower.
ie.manual.entry.industrialwires.components.general=The settings of any component can be copied to a component of the same type by placing the components directly above each other in a crafting bench. The settings of the upper component will be copied to the lower.<br>Components can be placed in the world to create small control panels containing just that component. These interact with redstone signals in the world directly, just like a lever does, rather than through redstone wire controllers, like normal control panels.
ie.manual.entry.industrialwires.button=A simple button that activates a redstone signal when pressed. Its color can be changed. The button either stays on until clicked again (latching) or tuns off after half a second (non-latching).
ie.manual.entry.industrialwires.label=A text that can be placed on the control panel, for example to indicate the purpose of some other component. The color and obviously the text can be edited.
ie.manual.entry.industrialwires.indicator_light=A small indicator that brightens as the input redstone signal is increased. The color can be changed.
@ -136,4 +143,5 @@ ie.manual.entry.industrialwires.toggle_switch=A switch to turn a signal on or of
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.lock1=Up to <config;I;iwKeysOnRing> can be combined on a key ring. Keys are added to the ring by placing both in a crafting table. Shift-right-click the key ring to cycle through the keys on the ring. The selected key can be removed from the ring by placing the ring in a crafting table. The key ring will work just as the selected key would on lock switches.
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,12 @@
{
"conditions" : {
"conversion": "malte0811.industrialWires.crafting.factories.IsConversionEnabled"
},
"recipes": {
"component_init": "malte0811.industrialWires.crafting.factories.InitPCFactory",
"wire_coil": "malte0811.industrialWires.crafting.factories.WireCoilFactory"
},
"ingredients": {
"ic2_item": "malte0811.industrialWires.crafting.factories.IC2ItemFactory"
}
}

View file

@ -0,0 +1,22 @@
{
"result": {
"item": "industrialwires:control_panel",
"data": 2,
"count": 4
},
"pattern": [
" r ",
"rmr",
" r "
],
"type": "forge:ore_shaped",
"key": {
"r": {
"type": "forge:ore_dict", "ore": "dustRedstone"
},
"m": {
"item": "industrialwires:control_panel",
"data": 4
}
}
}

View file

@ -0,0 +1,31 @@
{
"result": {
"item": "industrialwires:control_panel",
"data": 3
},
"pattern": [
"rmr",
"rdr",
"rar"
],
"type": "forge:ore_shaped",
"key": {
"a": {
"type": "industrialwires:ic2_item",
"name": "crafting",
"variant": "alloy"
},
"r": {
"type": "forge:ore_dict", "ore": "stickSteel"
},
"d": {
"item": "immersiveengineering:drillhead",
"data": 1
},
"m": {
"type": "industrialwires:ic2_item",
"name": "crafting",
"variant": "electric_motor"
}
}
}

View file

@ -0,0 +1,21 @@
{
"result": {
"item": "industrialwires:control_panel",
"data": 1
},
"pattern": [
"c",
"d"
],
"type": "minecraft:crafting_shaped",
"key": {
"c": {
"item": "immersiveengineering:connector",
"data": 12
},
"d": {
"item": "industrialwires:control_panel",
"data": 2
}
}
}

View file

@ -0,0 +1,20 @@
{
"result": {
"item": "industrialwires:control_panel",
"data": 4
},
"pattern": [
"ppp",
"www",
"ppp"
],
"type": "forge:ore_shaped",
"key": {
"p": {
"type": "forge:ore_dict", "ore": "plateIron"
},
"w": {
"type": "forge:ore_dict", "ore": "wireCopper"
}
}
}

View file

@ -0,0 +1,21 @@
{
"result": {
"item": "industrialwires:ic2_connector",
"data": 2,
"count": 4
},
"pattern": [
" c ",
"rcr",
"rcr"
],
"type": "forge:ore_shaped",
"key": {
"r": {
"type": "forge:ore_dict", "ore": "itemRubber"
},
"c": {
"type": "forge:ore_dict", "ore": "ingotCopper"
}
}
}

View file

@ -0,0 +1,20 @@
{
"result": {
"item": "industrialwires:ic2_connector",
"data": 3,
"count": 4
},
"pattern": [
" c ",
"rcr"
],
"type": "forge:ore_shaped",
"key": {
"r": {
"type": "forge:ore_dict", "ore": "itemRubber"
},
"c": {
"type": "forge:ore_dict", "ore": "ingotCopper"
}
}
}

View file

@ -0,0 +1,23 @@
{
"result": {
"item": "industrialwires:ic2_connector",
"data": 8,
"count": 4
},
"pattern": [
" c ",
"rcr",
"rcr"
],
"type": "forge:ore_shaped",
"key": {
"r": {
"type": "forge:ore_dict", "ore": "itemRubber"
},
"c": {
"type": "industrialwires:ic2_item",
"name": "cable",
"variant": "type:glass,insulation:0"
}
}
}

View file

@ -0,0 +1,27 @@
{
"result": {
"item": "industrialwires:ic2_connector",
"data": 9,
"count": 4
},
"pattern": [
" c ",
"grg",
"grg"
],
"type": "forge:ore_shaped",
"key": {
"r": {
"type": "forge:ore_dict", "ore": "itemRubber"
},
"c": {
"type": "industrialwires:ic2_item",
"name": "cable",
"variant": "type:glass,insulation:0"
},
"g": {
"item": "immersiveengineering:stone_decoration",
"data": 8
}
}
}

View file

@ -0,0 +1,21 @@
{
"result": {
"item": "industrialwires:ic2_connector",
"data": 4,
"count": 4
},
"pattern": [
" g ",
"rgr",
"rgr"
],
"type": "forge:ore_shaped",
"key": {
"r": {
"type": "forge:ore_dict", "ore": "itemRubber"
},
"g": {
"type": "forge:ore_dict", "ore": "ingotGold"
}
}
}

View file

@ -0,0 +1,20 @@
{
"result": {
"item": "industrialwires:ic2_connector",
"data": 5,
"count": 4
},
"pattern": [
" g ",
"rgr"
],
"type": "forge:ore_shaped",
"key": {
"r": {
"type": "forge:ore_dict", "ore": "itemRubber"
},
"g": {
"type": "forge:ore_dict", "ore": "ingotGold"
}
}
}

View file

@ -0,0 +1,21 @@
{
"result": {
"item": "industrialwires:ic2_connector",
"data": 6,
"count": 4
},
"pattern": [
" i ",
"rir",
"rir"
],
"type": "forge:ore_shaped",
"key": {
"r": {
"type": "forge:ore_dict", "ore": "itemRubber"
},
"i": {
"type": "forge:ore_dict", "ore": "ingotIron"
}
}
}

View file

@ -0,0 +1,22 @@
{
"result": {
"item": "industrialwires:ic2_connector",
"data": 7,
"count": 4
},
"pattern": [
" i ",
"gig",
"gig"
],
"type": "forge:ore_shaped",
"key": {
"g": {
"item": "immersiveengineering:stone_decoration",
"data": 8
},
"i": {
"type": "forge:ore_dict", "ore": "ingotIron"
}
}
}

View file

@ -0,0 +1,23 @@
{
"result": {
"item": "industrialwires:ic2_connector",
"data": 0,
"count": 4
},
"pattern": [
" t ",
"rtr",
"rtr"
],
"type": "forge:ore_shaped",
"key": {
"r": {
"type": "forge:ore_dict",
"ore": "itemRubber"
},
"t": {
"type": "forge:ore_dict",
"ore": "ingotTin"
}
}
}

View file

@ -0,0 +1,20 @@
{
"result": {
"item": "industrialwires:ic2_connector",
"data": 1,
"count": 4
},
"pattern": [
" t ",
"rtr"
],
"type": "forge:ore_shaped",
"key": {
"r": {
"type": "forge:ore_dict", "ore": "itemRubber"
},
"t": {
"type": "forge:ore_dict", "ore": "ingotTin"
}
}
}

View file

@ -0,0 +1,27 @@
{
"result": {
"item": "industrialwires:jacobs_ladder",
"data": 2
},
"pattern": [
"c c",
"hhh",
"sts"
],
"type": "forge:ore_shaped",
"key": {
"c": {
"type": "forge:ore_dict", "ore": "blockCopper"
},
"s": {
"type": "forge:ore_dict", "ore": "ingotSteel"
},
"t": {
"item": "immersiveengineering:connector",
"data": 8
},
"h": {
"item": "minecraft:hardened_clay"
}
}
}

View file

@ -0,0 +1,27 @@
{
"result": {
"item": "industrialwires:jacobs_ladder",
"data": 1
},
"pattern": [
"c c",
"h h",
"sts"
],
"type": "forge:ore_shaped",
"key": {
"c": {
"type": "forge:ore_dict", "ore": "ingotCopper"
},
"s": {
"type": "forge:ore_dict", "ore": "ingotSteel"
},
"t": {
"item": "immersiveengineering:connector",
"data": 7
},
"h": {
"item": "minecraft:hardened_clay"
}
}
}

View file

@ -0,0 +1,30 @@
{
"result": {
"item": "industrialwires:jacobs_ladder",
"data": 0
},
"pattern": [
"c c",
" h ",
"sts"
],
"type": "forge:ore_shaped",
"key": {
"c": {
"type": "industrialwires:ic2_item",
"name": "cable",
"variant": "type:copper,insulation:0"
},
"s": {
"type": "forge:ore_dict", "ore": "ingotSteel"
},
"t": {
"type": "industrialwires:ic2_item",
"name": "te",
"variant": "mv_transformer"
},
"h": {
"item": "minecraft:hardened_clay"
}
}
}

View file

@ -0,0 +1,18 @@
{
"result": {
"item": "industrialwires:key",
"data": 0
},
"pattern": [
"rrp"
],
"type": "forge:ore_shaped",
"key": {
"p": {
"type": "forge:ore_dict", "ore": "plateSteel"
},
"r": {
"type": "forge:ore_dict", "ore": "stickSteel"
}
}
}

View file

@ -0,0 +1,17 @@
{
"result": {
"item": "industrialwires:key",
"data": 2
},
"pattern": [
" r ",
"r r",
" r "
],
"type": "forge:ore_shaped",
"key": {
"r": {
"type": "forge:ore_dict", "ore": "stickSteel"
}
}
}

View file

@ -0,0 +1,41 @@
{
"result": {
"item": "industrialwires:mechanical_converter",
"data": 2
},
"pattern": [
"iIi",
"sbS",
"mrm"
],
"type": "forge:ore_shaped",
"key": {
"b": {
"type": "forge:ore_dict", "ore": "ingotBronze"
},
"r": {
"type": "forge:ore_dict", "ore": "stickSteel"
},
"s": {
"type": "forge:ore_dict", "ore": "blockSheetmetalIron"
},
"S": {
"type": "forge:ore_dict", "ore": "blockSheetmetalSteel"
},
"i": {
"type": "forge:ore_dict", "ore": "plateIron"
},
"I": {
"type": "industrialwires:ic2_item",
"name": "crafting",
"variant": "iron_shaft"
},
"m": {
"item": "immersiveengineering:material",
"data": 9
}
},
"conditions": [{
"type": "industrialwires:conversion"
}]
}

View file

@ -0,0 +1,37 @@
{
"result": {
"item": "industrialwires:mechanical_converter",
"data": 0
},
"pattern": [
" s ",
"ici",
"mum"
],
"type": "forge:ore_shaped",
"key": {
"s": {
"type": "forge:ore_dict",
"ore": "stickIron"
},
"c": {
"item": "immersiveengineering:metal_decoration0",
"data": 0
},
"u": {
"type": "forge:ore_dict",
"ore": "ingotCopper"
},
"i": {
"type": "forge:ore_dict",
"ore": "ingotIron"
},
"m": {
"item": "immersiveengineering:material",
"data": 8
}
},
"conditions": [{
"type": "industrialwires:conversion"
}]
}

View file

@ -0,0 +1,41 @@
{
"result": {
"item": "industrialwires:mechanical_converter",
"data": 1
},
"pattern": [
"mrm",
"sbS",
"iIi"
],
"type": "forge:ore_shaped",
"key": {
"b": {
"type": "forge:ore_dict", "ore": "ingotBronze"
},
"r": {
"type": "forge:ore_dict", "ore": "stickIron"
},
"s": {
"type": "forge:ore_dict", "ore": "blockSheetmetalIron"
},
"S": {
"type": "forge:ore_dict", "ore": "blockSheetmetalSteel"
},
"i": {
"type": "forge:ore_dict", "ore": "plateSteel"
},
"I": {
"type": "industrialwires:ic2_item",
"name": "crafting",
"variant": "steel_shaft"
},
"m": {
"item": "immersiveengineering:material",
"data": 8
}
},
"conditions": [{
"type": "industrialwires:conversion"
}]
}

View file

@ -0,0 +1,18 @@
{
"result": {
"item": "industrialwires:panel_component",
"data": 0
},
"ingredients": [
{
"type": "forge:ore_dict", "ore": "dustGlowstone"
},
{
"item": "minecraft:stone_button"
},
{
"type": "forge:ore_dict", "ore": "wireCopper"
}
],
"type": "forge:ore_shapeless"
}

View file

@ -0,0 +1,21 @@
{
"result": {
"item": "industrialwires:panel_component",
"data": 6
},
"pattern": [
"aaa",
"asa"
],
"type": "forge:ore_shaped",
"key": {
"a": {
"type": "forge:ore_dict", "ore": "plateAluminum"
},
"s": {
"item": "industrialwires:panel_component",
"data": 5,
"count": 2
}
}
}

View file

@ -0,0 +1,18 @@
{
"result": {
"item": "industrialwires:panel_component",
"data": 2
},
"ingredients": [
{
"type": "forge:ore_dict", "ore": "dustGlowstone"
},
{
"type": "forge:ore_dict", "ore": "dustRedstone"
},
{
"type": "forge:ore_dict", "ore": "wireCopper"
}
],
"type": "forge:ore_shapeless"
}

View file

@ -0,0 +1,16 @@
{
"result": {
"item": "industrialwires:panel_component",
"data": 1,
"count": 4
},
"ingredients": [
{
"type": "forge:ore_dict", "ore": "paper"
},
{
"type": "forge:ore_dict", "ore": "plateIron"
}
],
"type": "forge:ore_shapeless"
}

View file

@ -0,0 +1,22 @@
{
"result": {
"item": "industrialwires:panel_component",
"data": 7
},
"pattern": [
"rdr",
" w "
],
"type": "industrialwires:component_init",
"key": {
"r": {
"type": "forge:ore_dict", "ore": "stickSteel"
},
"d": {
"item": "minecraft:iron_door"
},
"w": {
"type": "forge:ore_dict", "ore": "wireCopper"
}
}
}

View file

@ -0,0 +1,16 @@
{
"result": {
"item": "industrialwires:panel_component",
"data": 8
},
"ingredients": [
{
"type": "forge:ore_dict", "ore": "wireCopper"
},
{
"item": "immersiveengineering:tool",
"data": 2
}
],
"type": "forge:ore_shapeless"
}

View file

@ -0,0 +1,19 @@
{
"result": {
"item": "industrialwires:panel_component",
"data": 3
},
"ingredients": [
{
"item": "minecraft:stone_button"
},
{
"item": "immersiveengineering:wirecoil",
"data": 2
},
{
"type": "forge:ore_dict", "ore": "wireCopper"
}
],
"type": "forge:ore_shapeless"
}

View file

@ -0,0 +1,18 @@
{
"result": {
"item": "industrialwires:panel_component",
"data": 5
},
"ingredients": [
{
"type": "forge:ore_dict", "ore": "stickIron"
},
{
"item": "minecraft:lever"
},
{
"type": "forge:ore_dict", "ore": "wireCopper"
}
],
"type": "forge:ore_shapeless"
}

View file

@ -0,0 +1,26 @@
{
"result": {
"item": "industrialwires:panel_component",
"data": 4
},
"pattern": [
"r",
"g",
"c"
],
"type": "forge:ore_shaped",
"key": {
"r": {
"type": "forge:ore_dict", "ore": "itemRubber"
},
"c": {
"type": "industrialwires:ic2_item",
"name": "crafting",
"variant": "coil"
},
"g": {
"type": "forge:ore_dict",
"ore": "ingotHOPGraphite"
}
}
}

View file

@ -0,0 +1,12 @@
{
"type": "industrialwires:wire_coil",
"cable": {
"type": "industrialwires:ic2_item",
"name": "cable",
"variant": "type:copper,insulation:0"
},
"coil": {
"item": "industrialwires:ic2_wire_coil",
"data": 1
}
}

View file

@ -0,0 +1,12 @@
{
"type": "industrialwires:wire_coil",
"cable": {
"type": "industrialwires:ic2_item",
"name": "cable",
"variant": "type:glass,insulation:0"
},
"coil": {
"item": "industrialwires:ic2_wire_coil",
"data": 4
}
}

View file

@ -0,0 +1,12 @@
{
"type": "industrialwires:wire_coil",
"cable": {
"type": "industrialwires:ic2_item",
"name": "cable",
"variant": "type:gold,insulation:0"
},
"coil": {
"item": "industrialwires:ic2_wire_coil",
"data": 2
}
}

View file

@ -0,0 +1,12 @@
{
"type": "industrialwires:wire_coil",
"cable": {
"type": "industrialwires:ic2_item",
"name": "cable",
"variant": "type:iron,insulation:0"
},
"coil": {
"item": "industrialwires:ic2_wire_coil",
"data": 3
}
}

View file

@ -0,0 +1,12 @@
{
"type": "industrialwires:wire_coil",
"cable": {
"type": "industrialwires:ic2_item",
"name": "cable",
"variant": "type:tin,insulation:0"
},
"coil": {
"item": "industrialwires:ic2_wire_coil",
"data": 0
}
}