2017-02-26 13:56:36 +01:00
|
|
|
/*
|
2016-09-29 16:19:16 +02:00
|
|
|
* This file is part of Industrial Wires.
|
2017-02-26 13:56:36 +01:00
|
|
|
* Copyright (C) 2016-2017 malte0811
|
2016-09-29 16:19:16 +02:00
|
|
|
*
|
|
|
|
* 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/>.
|
2017-02-26 13:56:36 +01:00
|
|
|
*/
|
2016-09-15 20:43:18 +02:00
|
|
|
package malte0811.industrialWires.client;
|
|
|
|
|
|
|
|
import blusunrize.immersiveengineering.api.ManualHelper;
|
2017-02-26 13:56:36 +01:00
|
|
|
import blusunrize.immersiveengineering.client.ClientUtils;
|
2016-09-15 20:43:18 +02:00
|
|
|
import blusunrize.immersiveengineering.client.models.smart.ConnLoader;
|
2017-03-03 19:04:08 +01:00
|
|
|
import blusunrize.immersiveengineering.common.Config;
|
2016-09-15 20:43:18 +02:00
|
|
|
import blusunrize.lib.manual.ManualInstance;
|
|
|
|
import blusunrize.lib.manual.ManualPages;
|
2016-09-22 19:52:01 +02:00
|
|
|
import blusunrize.lib.manual.ManualPages.PositionedItemStack;
|
2017-02-26 13:56:36 +01:00
|
|
|
import com.google.common.collect.ImmutableMap;
|
2016-09-22 19:52:01 +02:00
|
|
|
import ic2.api.item.IC2Items;
|
2016-09-15 20:43:18 +02:00
|
|
|
import malte0811.industrialWires.CommonProxy;
|
2017-03-03 19:04:08 +01:00
|
|
|
import malte0811.industrialWires.IWConfig;
|
2016-09-15 20:43:18 +02:00
|
|
|
import malte0811.industrialWires.IndustrialWires;
|
2016-12-08 17:52:34 +01:00
|
|
|
import malte0811.industrialWires.blocks.IMetaEnum;
|
2017-02-26 13:56:36 +01:00
|
|
|
import malte0811.industrialWires.blocks.TileEntityJacobsLadder;
|
2017-05-09 17:25:03 +02:00
|
|
|
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
|
2017-04-10 16:20:39 +02:00
|
|
|
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
|
2017-04-09 16:59:57 +02:00
|
|
|
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelConn;
|
2017-04-20 20:44:08 +02:00
|
|
|
import malte0811.industrialWires.client.gui.GuiPanelComponent;
|
2017-04-10 16:20:39 +02:00
|
|
|
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
2017-04-12 15:55:37 +02:00
|
|
|
import malte0811.industrialWires.client.gui.GuiRSPanelConn;
|
2017-05-18 18:13:08 +02:00
|
|
|
import malte0811.industrialWires.client.gui.GuiRenameKey;
|
2017-03-24 17:40:05 +01:00
|
|
|
import malte0811.industrialWires.client.panelmodel.PanelModelLoader;
|
2017-02-26 13:56:36 +01:00
|
|
|
import malte0811.industrialWires.client.render.TileRenderJacobsLadder;
|
2017-04-27 18:15:11 +02:00
|
|
|
import malte0811.industrialWires.controlpanel.PanelComponent;
|
2016-09-15 20:43:18 +02:00
|
|
|
import malte0811.industrialWires.items.ItemIC2Coil;
|
2017-04-27 18:15:11 +02:00
|
|
|
import malte0811.industrialWires.items.ItemPanelComponent;
|
2016-12-08 17:52:34 +01:00
|
|
|
import net.minecraft.block.Block;
|
2017-02-26 13:56:36 +01:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.audio.ISound;
|
|
|
|
import net.minecraft.client.audio.PositionedSoundRecord;
|
2017-04-10 16:20:39 +02:00
|
|
|
import net.minecraft.client.gui.Gui;
|
2016-09-15 20:43:18 +02:00
|
|
|
import net.minecraft.client.renderer.block.model.ModelBakery;
|
|
|
|
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
2017-04-09 16:59:57 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2016-09-15 20:43:18 +02:00
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2017-04-09 16:59:57 +02:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2017-04-20 20:44:08 +02:00
|
|
|
import net.minecraft.util.EnumHand;
|
2016-09-15 20:43:18 +02:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2017-02-26 13:56:36 +01:00
|
|
|
import net.minecraft.util.SoundCategory;
|
2017-02-28 17:32:40 +01:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2017-02-26 13:56:36 +01:00
|
|
|
import net.minecraft.util.math.Vec3d;
|
|
|
|
import net.minecraft.world.World;
|
2016-09-15 20:43:18 +02:00
|
|
|
import net.minecraftforge.client.model.ModelLoader;
|
2017-03-24 17:40:05 +01:00
|
|
|
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
2017-02-26 13:56:36 +01:00
|
|
|
import net.minecraftforge.client.model.obj.OBJLoader;
|
2016-09-15 20:43:18 +02:00
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
2017-02-26 13:56:36 +01:00
|
|
|
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
|
|
|
|
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.Random;
|
|
|
|
import java.util.WeakHashMap;
|
2016-09-15 20:43:18 +02:00
|
|
|
|
|
|
|
public class ClientProxy extends CommonProxy {
|
|
|
|
@Override
|
|
|
|
public void preInit() {
|
|
|
|
super.preInit();
|
|
|
|
ConnLoader.baseModels.put("ic2_conn_tin", new ResourceLocation("immersiveengineering:block/connector/connectorLV.obj"));
|
|
|
|
ConnLoader.textureReplacements.put("ic2_conn_tin", ImmutableMap.of("#immersiveengineering:blocks/connector_connectorLV",
|
2017-02-26 13:56:36 +01:00
|
|
|
IndustrialWires.MODID + ":blocks/ic2_connTin"));
|
2016-09-15 20:43:18 +02:00
|
|
|
ConnLoader.baseModels.put("ic2_relay_tin", new ResourceLocation("immersiveengineering:block/connector/connectorLV.obj"));
|
|
|
|
ConnLoader.textureReplacements.put("ic2_relay_tin", ImmutableMap.of("#immersiveengineering:blocks/connector_connectorLV",
|
2017-02-26 13:56:36 +01:00
|
|
|
IndustrialWires.MODID + ":blocks/ic2_relayTin"));
|
2016-09-15 20:43:18 +02:00
|
|
|
|
|
|
|
ConnLoader.baseModels.put("ic2_conn_copper", new ResourceLocation("immersiveengineering:block/connector/connectorLV.obj"));
|
|
|
|
ConnLoader.textureReplacements.put("ic2_conn_copper", ImmutableMap.of("#immersiveengineering:blocks/connector_connectorLV",
|
2017-02-26 13:56:36 +01:00
|
|
|
IndustrialWires.MODID + ":blocks/ic2_connCopper"));
|
2016-09-15 20:43:18 +02:00
|
|
|
ConnLoader.baseModels.put("ic2_relay_copper", new ResourceLocation("immersiveengineering:block/connector/connectorLV.obj"));
|
|
|
|
ConnLoader.textureReplacements.put("ic2_relay_copper", ImmutableMap.of("#immersiveengineering:blocks/connector_connectorLV",
|
2017-02-26 13:56:36 +01:00
|
|
|
IndustrialWires.MODID + ":blocks/ic2_relayCopper"));
|
2016-09-15 20:43:18 +02:00
|
|
|
|
|
|
|
ConnLoader.baseModels.put("ic2_conn_gold", new ResourceLocation("immersiveengineering:block/connector/connectorMV.obj"));
|
|
|
|
ConnLoader.textureReplacements.put("ic2_conn_gold", ImmutableMap.of("#immersiveengineering:blocks/connector_connectorMV",
|
2017-02-26 13:56:36 +01:00
|
|
|
IndustrialWires.MODID + ":blocks/ic2_connGold"));
|
2016-09-15 20:43:18 +02:00
|
|
|
ConnLoader.baseModels.put("ic2_relay_gold", new ResourceLocation("immersiveengineering:block/connector/connectorMV.obj"));
|
|
|
|
ConnLoader.textureReplacements.put("ic2_relay_gold", ImmutableMap.of("#immersiveengineering:blocks/connector_connectorMV",
|
2017-02-26 13:56:36 +01:00
|
|
|
IndustrialWires.MODID + ":blocks/ic2_relayGold"));
|
2016-09-15 20:43:18 +02:00
|
|
|
|
|
|
|
ConnLoader.baseModels.put("ic2_conn_hv", new ResourceLocation("immersiveengineering:block/connector/connectorHV.obj"));
|
|
|
|
ConnLoader.textureReplacements.put("ic2_conn_hv", ImmutableMap.of("#immersiveengineering:blocks/connector_connectorHV",
|
2017-02-26 13:56:36 +01:00
|
|
|
IndustrialWires.MODID + ":blocks/ic2_connHV"));
|
2016-09-15 20:43:18 +02:00
|
|
|
ConnLoader.baseModels.put("ic2_relay_hv", new ResourceLocation("immersiveengineering:block/connector/relayHV.obj"));
|
2016-09-22 19:52:01 +02:00
|
|
|
|
|
|
|
ConnLoader.baseModels.put("ic2_conn_glass", new ResourceLocation("immersiveengineering:block/connector/connectorHV.obj"));
|
|
|
|
ConnLoader.textureReplacements.put("ic2_conn_glass", ImmutableMap.of("#immersiveengineering:blocks/connector_connectorHV",
|
2017-02-26 13:56:36 +01:00
|
|
|
IndustrialWires.MODID + ":blocks/ic2_connGlass"));
|
2016-09-22 19:52:01 +02:00
|
|
|
ConnLoader.baseModels.put("ic2_relay_glass", new ResourceLocation("immersiveengineering:block/connector/relayHV.obj"));
|
|
|
|
ConnLoader.textureReplacements.put("ic2_relay_glass", ImmutableMap.of("#immersiveengineering:blocks/connector_relayHV",
|
2017-02-26 13:56:36 +01:00
|
|
|
IndustrialWires.MODID + ":blocks/ic2_relayGlass"));
|
2016-09-15 20:43:18 +02:00
|
|
|
|
2017-04-24 17:26:42 +02:00
|
|
|
ConnLoader.baseModels.put("rs_panel_conn", new ResourceLocation("industrialwires:block/rs_panel_conn.obj"));
|
2017-02-26 13:56:36 +01:00
|
|
|
for (int meta = 0; meta < ItemIC2Coil.subNames.length; meta++) {
|
2016-09-15 20:43:18 +02:00
|
|
|
ResourceLocation loc = new ResourceLocation(IndustrialWires.MODID, "ic2wireCoil/" + ItemIC2Coil.subNames[meta]);
|
|
|
|
ModelBakery.registerItemVariants(IndustrialWires.coil, loc);
|
|
|
|
ModelLoader.setCustomModelResourceLocation(IndustrialWires.coil, meta, new ModelResourceLocation(loc, "inventory"));
|
|
|
|
}
|
2017-04-27 18:15:11 +02:00
|
|
|
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"));
|
|
|
|
}
|
|
|
|
|
2017-04-28 20:20:52 +02:00
|
|
|
Block[] blocks = {IndustrialWires.ic2conn, IndustrialWires.mechConv, IndustrialWires.jacobsLadder, IndustrialWires.panel};
|
2017-02-26 13:56:36 +01:00
|
|
|
for (Block b : blocks) {
|
|
|
|
if (b != null) {
|
2016-12-20 17:05:20 +01:00
|
|
|
Item blockItem = Item.getItemFromBlock(b);
|
|
|
|
final ResourceLocation loc = b.getRegistryName();
|
2017-02-26 13:56:36 +01:00
|
|
|
ModelLoader.setCustomMeshDefinition(blockItem, stack -> new ModelResourceLocation(loc, "inventory"));
|
|
|
|
Object[] v = ((IMetaEnum) b).getValues();
|
|
|
|
for (int meta = 0; meta < v.length; meta++) {
|
2016-12-20 17:05:20 +01:00
|
|
|
String location = loc.toString();
|
|
|
|
String prop = "inventory,type=" + v[meta].toString().toLowerCase(Locale.US);
|
|
|
|
try {
|
|
|
|
ModelLoader.setCustomModelResourceLocation(blockItem, meta, new ModelResourceLocation(location, prop));
|
2017-02-26 13:56:36 +01:00
|
|
|
} catch (NullPointerException npe) {
|
2016-12-20 17:05:20 +01:00
|
|
|
throw new RuntimeException(b + " lacks an item!", npe);
|
|
|
|
}
|
2016-12-08 17:52:34 +01:00
|
|
|
}
|
2016-09-15 20:43:18 +02:00
|
|
|
}
|
|
|
|
}
|
2017-02-26 13:56:36 +01:00
|
|
|
OBJLoader.INSTANCE.addDomain(IndustrialWires.MODID);
|
2017-03-24 17:40:05 +01:00
|
|
|
ModelLoaderRegistry.registerLoader(new PanelModelLoader());
|
2016-09-15 20:43:18 +02:00
|
|
|
MinecraftForge.EVENT_BUS.register(new ClientEventHandler());
|
2017-02-26 13:56:36 +01:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityJacobsLadder.class, new TileRenderJacobsLadder());
|
2016-09-15 20:43:18 +02:00
|
|
|
}
|
2017-02-26 13:56:36 +01:00
|
|
|
|
2016-09-15 20:43:18 +02:00
|
|
|
@Override
|
|
|
|
public void postInit() {
|
|
|
|
super.postInit();
|
|
|
|
ManualInstance m = ManualHelper.getManual();
|
2016-09-22 19:52:01 +02:00
|
|
|
PositionedItemStack[][] wireRecipes = new PositionedItemStack[3][10];
|
|
|
|
int xBase = 15;
|
|
|
|
ItemStack tinCable = IC2Items.getItem("cable", "type:tin,insulation:0");
|
2017-02-26 13:56:36 +01:00
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
for (int j = 0; j < 3; j++) {
|
|
|
|
wireRecipes[0][3 * i + j] = new PositionedItemStack(tinCable.copy(), 18 * i + xBase, 18 * j);
|
2016-09-22 19:52:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ItemStack tmp = new ItemStack(IndustrialWires.coil);
|
|
|
|
ItemIC2Coil.setLength(tmp, 9);
|
2017-02-26 13:56:36 +01:00
|
|
|
wireRecipes[0][9] = new PositionedItemStack(tmp, 18 * 4 + xBase, 18);
|
2016-09-22 19:52:01 +02:00
|
|
|
Random r = new Random();
|
2017-02-26 13:56:36 +01:00
|
|
|
for (int i = 1; i < 3; i++) {
|
2016-09-22 19:52:01 +02:00
|
|
|
int lengthSum = 0;
|
2017-02-26 13:56:36 +01:00
|
|
|
for (int j1 = 0; j1 < 3; j1++) {
|
|
|
|
for (int j2 = 0; j2 < 3; j2++) {
|
2016-09-22 19:52:01 +02:00
|
|
|
if (r.nextBoolean()) {
|
|
|
|
// cable
|
|
|
|
lengthSum++;
|
2017-02-26 13:56:36 +01:00
|
|
|
wireRecipes[i][3 * j1 + j2] = new PositionedItemStack(tinCable.copy(), 18 * j1 + xBase, 18 * j2);
|
2016-09-22 19:52:01 +02:00
|
|
|
} else {
|
|
|
|
// wire coil
|
2017-02-26 13:56:36 +01:00
|
|
|
int length = r.nextInt(99) + 1;
|
2016-09-22 19:52:01 +02:00
|
|
|
tmp = new ItemStack(IndustrialWires.coil);
|
|
|
|
ItemIC2Coil.setLength(tmp, length);
|
2017-02-26 13:56:36 +01:00
|
|
|
wireRecipes[i][3 * j1 + j2] = new PositionedItemStack(tmp, 18 * j1 + xBase, 18 * j2);
|
|
|
|
lengthSum += length;
|
2016-09-22 19:52:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tmp = new ItemStack(IndustrialWires.coil);
|
|
|
|
ItemIC2Coil.setLength(tmp, lengthSum);
|
2017-02-26 13:56:36 +01:00
|
|
|
wireRecipes[i][9] = new PositionedItemStack(tmp, 18 * 4 + xBase, 18);
|
2016-09-22 19:52:01 +02:00
|
|
|
}
|
2017-04-27 18:15:11 +02:00
|
|
|
|
|
|
|
ClientUtils.mc().getItemColors().registerItemColorHandler((stack, pass) -> {
|
2017-05-11 16:39:20 +02:00
|
|
|
if (pass == 1) {
|
2017-04-27 18:15:11 +02:00
|
|
|
PanelComponent pc = ItemPanelComponent.componentFromStack(stack);
|
|
|
|
if (pc != null) {
|
|
|
|
return 0xff000000 | pc.getColor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ~0;
|
|
|
|
}, IndustrialWires.panelComponent);
|
|
|
|
|
2016-12-15 21:32:28 +01:00
|
|
|
m.addEntry("industrialWires.wires", "industrialWires",
|
|
|
|
new ManualPages.CraftingMulti(m, "industrialWires.wires0", new ItemStack(IndustrialWires.ic2conn, 1, 0), new ItemStack(IndustrialWires.ic2conn, 1, 1), new ItemStack(IndustrialWires.ic2conn, 1, 2), new ItemStack(IndustrialWires.ic2conn, 1, 3),
|
2016-09-22 19:52:01 +02:00
|
|
|
new ItemStack(IndustrialWires.ic2conn, 1, 4), new ItemStack(IndustrialWires.ic2conn, 1, 5), new ItemStack(IndustrialWires.ic2conn, 1, 6), new ItemStack(IndustrialWires.ic2conn, 1, 7)),
|
2016-12-15 21:32:28 +01:00
|
|
|
new ManualPages.Text(m, "industrialWires.wires1"),
|
2017-02-26 13:56:36 +01:00
|
|
|
new ManualPages.CraftingMulti(m, "industrialWires.wires2", (Object[]) wireRecipes)
|
|
|
|
);
|
|
|
|
if (IndustrialWires.mechConv != null) {
|
2016-12-20 17:05:20 +01:00
|
|
|
m.addEntry("industrialWires.mechConv", "industrialWires",
|
|
|
|
new ManualPages.Crafting(m, "industrialWires.mechConv0", new ItemStack(IndustrialWires.mechConv, 1, 1)),
|
|
|
|
new ManualPages.Crafting(m, "industrialWires.mechConv1", new ItemStack(IndustrialWires.mechConv, 1, 2)),
|
|
|
|
new ManualPages.Crafting(m, "industrialWires.mechConv2", new ItemStack(IndustrialWires.mechConv, 1, 0))
|
2017-02-26 13:56:36 +01:00
|
|
|
);
|
|
|
|
}
|
2017-03-03 19:04:08 +01:00
|
|
|
Config.manual_doubleA.put("iwJacobsUsage", IWConfig.HVStuff.jacobsUsageEU);
|
|
|
|
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"));
|
2017-05-08 21:29:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
m.addEntry("industrialWires.intro", "control_panels",
|
|
|
|
new ManualPages.Text(m, "industrialWires.intro0"),
|
|
|
|
new ManualPages.Text(m, "industrialWires.intro1"),
|
2017-05-09 17:25:03 +02:00
|
|
|
new ManualPages.Crafting(m, "industrialWires.intro2", new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.DUMMY.ordinal())),
|
|
|
|
new ManualPages.Text(m, "industrialWires.intro3")
|
2017-05-08 21:29:45 +02:00
|
|
|
);
|
|
|
|
m.addEntry("industrialWires.panel_creator", "control_panels",
|
2017-05-09 17:25:03 +02:00
|
|
|
new ManualPages.Crafting(m, "industrialWires.panel_creator0", new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.CREATOR.ordinal())),
|
2017-05-08 21:29:45 +02:00
|
|
|
new ManualPages.Text(m, "industrialWires.panel_creator1"),
|
|
|
|
new ManualPages.Text(m, "industrialWires.panel_creator2")
|
|
|
|
);
|
|
|
|
m.addEntry("industrialWires.redstone", "control_panels",
|
2017-05-09 17:25:03 +02:00
|
|
|
new ManualPages.Crafting(m, "industrialWires.redstone0", new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.RS_WIRE.ordinal())),
|
2017-05-08 21:29:45 +02:00
|
|
|
new ManualPages.Text(m, "industrialWires.redstone1")
|
|
|
|
);
|
|
|
|
m.addEntry("industrialWires.components", "control_panels",
|
2017-05-09 17:25:03 +02:00
|
|
|
new ManualPages.Crafting(m, "industrialWires.button", new ItemStack(IndustrialWires.panelComponent, 1, 0)),
|
|
|
|
new ManualPages.Crafting(m, "industrialWires.label", new ItemStack(IndustrialWires.panelComponent, 1, 1)),
|
|
|
|
new ManualPages.Crafting(m, "industrialWires.indicator_light", new ItemStack(IndustrialWires.panelComponent, 1, 2)),
|
|
|
|
new ManualPages.Crafting(m, "industrialWires.slider", new ItemStack(IndustrialWires.panelComponent, 1, 3)),
|
|
|
|
new ManualPages.CraftingMulti(m, "industrialWires.toggle_switch", new ItemStack(IndustrialWires.panelComponent, 1, 5), new ItemStack(IndustrialWires.panelComponent, 1, 6)),
|
2017-05-08 21:29:45 +02:00
|
|
|
new ManualPages.Text(m, "industrialWires.toggle_switch1"),
|
2017-05-09 17:25:03 +02:00
|
|
|
new ManualPages.Crafting(m, "industrialWires.variac", new ItemStack(IndustrialWires.panelComponent, 1, 4))
|
2017-05-08 21:29:45 +02:00
|
|
|
);
|
2017-02-26 13:56:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public World getClientWorld() {
|
|
|
|
return Minecraft.getMinecraft().theWorld;
|
|
|
|
}
|
|
|
|
|
2017-02-28 17:32:40 +01:00
|
|
|
private WeakHashMap<BlockPos, ISound> playingSounds = new WeakHashMap<>();
|
2017-02-26 13:56:36 +01:00
|
|
|
private static ResourceLocation jacobsStart = new ResourceLocation(IndustrialWires.MODID, "jacobs_ladder_start");//~470 ms ~=9 ticks
|
|
|
|
private static ResourceLocation jacobsMiddle = new ResourceLocation(IndustrialWires.MODID, "jacobs_ladder_middle");
|
|
|
|
private static ResourceLocation jacobsEnd = new ResourceLocation(IndustrialWires.MODID, "jacobs_ladder_end");//~210 ms ~= 4 ticks
|
2017-05-11 16:39:20 +02:00
|
|
|
|
2017-02-26 13:56:36 +01:00
|
|
|
@Override
|
|
|
|
public void playJacobsLadderSound(TileEntityJacobsLadder te, int phase, Vec3d soundPos) {
|
2017-02-28 17:32:40 +01:00
|
|
|
if (playingSounds.containsKey(te.getPos())) {
|
|
|
|
Minecraft.getMinecraft().getSoundHandler().stopSound(playingSounds.get(te.getPos()));
|
|
|
|
playingSounds.remove(te.getPos());
|
2017-02-26 13:56:36 +01:00
|
|
|
}
|
|
|
|
ResourceLocation event;
|
|
|
|
switch (phase) {
|
|
|
|
case 0:
|
|
|
|
event = jacobsStart;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
event = jacobsMiddle;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
event = jacobsEnd;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
2016-12-20 17:05:20 +01:00
|
|
|
}
|
2017-05-11 16:39:20 +02:00
|
|
|
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);
|
2017-02-26 13:56:36 +01:00
|
|
|
ClientUtils.mc().getSoundHandler().playSound(sound);
|
2017-02-28 17:32:40 +01:00
|
|
|
playingSounds.put(te.getPos(), sound);
|
2016-09-15 20:43:18 +02:00
|
|
|
}
|
2017-04-09 16:59:57 +02:00
|
|
|
|
|
|
|
@Override
|
2017-04-10 16:20:39 +02:00
|
|
|
public Gui getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
2017-05-11 16:39:20 +02:00
|
|
|
if (ID == 0) {
|
2017-04-20 20:44:08 +02:00
|
|
|
TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
|
|
|
|
if (te instanceof TileEntityRSPanelConn) {
|
|
|
|
return new GuiRSPanelConn((TileEntityRSPanelConn) te);
|
|
|
|
}
|
|
|
|
if (te instanceof TileEntityPanelCreator) {
|
|
|
|
return new GuiPanelCreator(player.inventory, (TileEntityPanelCreator) te);
|
|
|
|
}
|
2017-05-11 16:39:20 +02:00
|
|
|
} else if (ID == 1) {
|
2017-04-20 20:44:08 +02:00
|
|
|
EnumHand h = z == 1 ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND;
|
|
|
|
ItemStack held = player.getHeldItem(h);
|
2017-05-18 18:13:08 +02:00
|
|
|
if (held!=null) {
|
|
|
|
if (held.getItem() == IndustrialWires.panelComponent) {
|
|
|
|
return new GuiPanelComponent(h, ItemPanelComponent.componentFromStack(held));
|
|
|
|
} else if (held.getItem() == IndustrialWires.key) {
|
|
|
|
return new GuiRenameKey(h);
|
|
|
|
}
|
2017-04-20 20:44:08 +02:00
|
|
|
}
|
2017-04-10 16:20:39 +02:00
|
|
|
}
|
2017-04-09 16:59:57 +02:00
|
|
|
return null;
|
|
|
|
}
|
2017-04-20 20:44:08 +02:00
|
|
|
}
|