2017-02-26 13:56:36 +01:00
|
|
|
/*
|
2016-09-29 16:19:16 +02:00
|
|
|
* This file is part of Industrial Wires.
|
2018-02-28 21:06:33 +01:00
|
|
|
* Copyright (C) 2016-2018 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-09-03 20:48:10 +02:00
|
|
|
import blusunrize.immersiveengineering.api.ManualPageMultiblock;
|
2018-01-30 21:59:09 +01:00
|
|
|
import blusunrize.immersiveengineering.api.energy.wires.WireApi;
|
2017-02-26 13:56:36 +01:00
|
|
|
import blusunrize.immersiveengineering.client.ClientUtils;
|
2017-03-03 19:04:08 +01:00
|
|
|
import blusunrize.immersiveengineering.common.Config;
|
2017-09-03 20:48:10 +02:00
|
|
|
import blusunrize.immersiveengineering.common.util.Utils;
|
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-15 20:43:18 +02:00
|
|
|
import malte0811.industrialWires.CommonProxy;
|
2017-03-03 19:04:08 +01:00
|
|
|
import malte0811.industrialWires.IWConfig;
|
2017-06-16 22:04:30 +02:00
|
|
|
import malte0811.industrialWires.IWPotions;
|
2016-09-15 20:43:18 +02:00
|
|
|
import malte0811.industrialWires.IndustrialWires;
|
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;
|
2018-04-22 22:14:08 +02:00
|
|
|
import malte0811.industrialWires.blocks.converter.TileEntityMechMB;
|
2017-05-25 17:49:06 +02:00
|
|
|
import malte0811.industrialWires.blocks.hv.TileEntityJacobsLadder;
|
2017-06-02 17:57:17 +02:00
|
|
|
import malte0811.industrialWires.blocks.hv.TileEntityMarx;
|
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-10-20 17:36:17 +02:00
|
|
|
import malte0811.industrialWires.client.manual.TextSplitter;
|
2017-03-24 17:40:05 +01:00
|
|
|
import malte0811.industrialWires.client.panelmodel.PanelModelLoader;
|
2018-02-17 20:37:53 +01:00
|
|
|
import malte0811.industrialWires.client.render.*;
|
2017-04-27 18:15:11 +02:00
|
|
|
import malte0811.industrialWires.controlpanel.PanelComponent;
|
2018-04-22 22:14:08 +02:00
|
|
|
import malte0811.industrialWires.converter.MechEnergy;
|
2017-09-04 22:04:53 +02:00
|
|
|
import malte0811.industrialWires.crafting.IC2TRHelper;
|
2018-02-17 20:37:53 +01:00
|
|
|
import malte0811.industrialWires.entities.EntityBrokenPart;
|
2017-09-03 20:48:10 +02:00
|
|
|
import malte0811.industrialWires.hv.MarxOreHandler;
|
|
|
|
import malte0811.industrialWires.hv.MultiblockMarx;
|
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;
|
2017-11-26 13:52:52 +01:00
|
|
|
import malte0811.industrialWires.util.CommandIWClient;
|
2017-02-26 13:56:36 +01:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.audio.ISound;
|
2017-06-16 22:04:30 +02:00
|
|
|
import net.minecraft.client.audio.MovingSound;
|
2017-02-26 13:56:36 +01:00
|
|
|
import net.minecraft.client.audio.PositionedSoundRecord;
|
2018-04-22 22:14:08 +02:00
|
|
|
import net.minecraft.client.audio.SoundHandler;
|
2017-04-10 16:20:39 +02:00
|
|
|
import net.minecraft.client.gui.Gui;
|
2017-09-03 20:48:10 +02:00
|
|
|
import net.minecraft.client.resources.I18n;
|
2017-10-04 17:05:04 +02:00
|
|
|
import net.minecraft.client.resources.IReloadableResourceManager;
|
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.ItemStack;
|
2017-08-22 18:33:05 +02:00
|
|
|
import net.minecraft.item.crafting.Ingredient;
|
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-06-16 22:04:30 +02:00
|
|
|
import net.minecraft.util.SoundEvent;
|
2017-02-28 17:32:40 +01:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2018-04-22 22:14:08 +02:00
|
|
|
import net.minecraft.util.math.MathHelper;
|
2017-02-26 13:56:36 +01:00
|
|
|
import net.minecraft.util.math.Vec3d;
|
|
|
|
import net.minecraft.world.World;
|
2017-11-26 13:52:52 +01:00
|
|
|
import net.minecraftforge.client.ClientCommandHandler;
|
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;
|
|
|
|
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
2018-02-17 20:37:53 +01:00
|
|
|
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
2018-04-04 20:47:44 +02:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2017-02-26 13:56:36 +01:00
|
|
|
|
2018-04-22 22:14:08 +02:00
|
|
|
import java.util.*;
|
2016-09-15 20:43:18 +02:00
|
|
|
|
2018-04-04 20:47:44 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
2016-09-15 20:43:18 +02:00
|
|
|
public class ClientProxy extends CommonProxy {
|
|
|
|
@Override
|
|
|
|
public void preInit() {
|
|
|
|
super.preInit();
|
2017-09-02 18:03:16 +02:00
|
|
|
if (IndustrialWires.hasIC2) {
|
2018-01-30 21:59:09 +01:00
|
|
|
WireApi.registerConnectorForRender("ic2_conn_tin", new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"),
|
|
|
|
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv",
|
2017-09-02 18:03:16 +02:00
|
|
|
IndustrialWires.MODID + ":blocks/ic2_conn_tin"));
|
2018-01-30 21:59:09 +01:00
|
|
|
WireApi.registerConnectorForRender("ic2_relay_tin", new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"),
|
|
|
|
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv",
|
2017-09-02 18:03:16 +02:00
|
|
|
IndustrialWires.MODID + ":blocks/ic2_relay_tin"));
|
2016-09-15 20:43:18 +02:00
|
|
|
|
2018-01-30 21:59:09 +01:00
|
|
|
WireApi.registerConnectorForRender("ic2_conn_copper", new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"),
|
|
|
|
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv",
|
2017-09-02 18:03:16 +02:00
|
|
|
IndustrialWires.MODID + ":blocks/ic2_conn_copper"));
|
2018-01-30 21:59:09 +01:00
|
|
|
WireApi.registerConnectorForRender("ic2_relay_copper", new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"),
|
|
|
|
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv",
|
2017-09-02 18:03:16 +02:00
|
|
|
IndustrialWires.MODID + ":blocks/ic2_relay_copper"));
|
2016-09-15 20:43:18 +02:00
|
|
|
|
2018-01-30 21:59:09 +01:00
|
|
|
WireApi.registerConnectorForRender("ic2_conn_gold", new ResourceLocation("immersiveengineering:block/connector/connector_mv.obj"),
|
|
|
|
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_mv",
|
2017-09-02 18:03:16 +02:00
|
|
|
IndustrialWires.MODID + ":blocks/ic2_conn_gold"));
|
2018-01-30 21:59:09 +01:00
|
|
|
WireApi.registerConnectorForRender("ic2_relay_gold", new ResourceLocation("immersiveengineering:block/connector/connector_mv.obj"),
|
|
|
|
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_mv",
|
2017-09-02 18:03:16 +02:00
|
|
|
IndustrialWires.MODID + ":blocks/ic2_relay_gold"));
|
2016-09-15 20:43:18 +02:00
|
|
|
|
2018-01-30 21:59:09 +01:00
|
|
|
WireApi.registerConnectorForRender("ic2_conn_hv", new ResourceLocation("immersiveengineering:block/connector/connector_hv.obj"),
|
|
|
|
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_hv",
|
2017-09-02 18:03:16 +02:00
|
|
|
IndustrialWires.MODID + ":blocks/ic2_conn_hv"));
|
2018-01-30 21:59:09 +01:00
|
|
|
WireApi.registerConnectorForRender("ic2_relay_hv", new ResourceLocation("immersiveengineering:block/connector/relay_hv.obj"), null);
|
2016-09-15 20:43:18 +02:00
|
|
|
|
2018-01-30 21:59:09 +01:00
|
|
|
WireApi.registerConnectorForRender("ic2_conn_glass", new ResourceLocation("immersiveengineering:block/connector/connector_hv.obj"),
|
|
|
|
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_hv",
|
2017-09-02 18:03:16 +02:00
|
|
|
IndustrialWires.MODID + ":blocks/ic2_conn_glass"));
|
2018-01-30 21:59:09 +01:00
|
|
|
WireApi.registerConnectorForRender("ic2_relay_glass", new ResourceLocation("immersiveengineering:block/connector/relay_hv.obj"),
|
|
|
|
ImmutableMap.of("#immersiveengineering:blocks/connector_relay_hv",
|
2017-09-02 18:03:16 +02:00
|
|
|
IndustrialWires.MODID + ":blocks/ic2_relay_glass"));
|
|
|
|
}
|
2018-01-30 21:59:09 +01:00
|
|
|
WireApi.registerConnectorForRender("rs_panel_conn", new ResourceLocation("industrialwires:block/rs_panel_conn.obj"), null);
|
2017-08-13 18:46:46 +02:00
|
|
|
|
2018-01-30 21:59:09 +01:00
|
|
|
WireApi.registerConnectorForRender("empty", new ResourceLocation("builtin/generated"), null);
|
2017-08-13 18:46:46 +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());
|
2017-02-26 13:56:36 +01:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityJacobsLadder.class, new TileRenderJacobsLadder());
|
2017-06-02 17:57:17 +02:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMarx.class, new TileRenderMarx());
|
2017-10-04 17:05:04 +02:00
|
|
|
TileRenderMBConverter tesr = new TileRenderMBConverter();
|
2018-04-22 22:14:08 +02:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMechMB.class, tesr);
|
2017-10-04 17:05:04 +02:00
|
|
|
((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(tesr);
|
2018-02-17 20:37:53 +01:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntityBrokenPart.class, EntityRenderBrokenPart::new);
|
|
|
|
|
2017-10-07 16:27:51 +02:00
|
|
|
Shaders.initShaders(true);
|
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();
|
2017-10-21 21:15:01 +02:00
|
|
|
if (IndustrialWires.hasIC2) {
|
2017-09-02 18:03:16 +02:00
|
|
|
PositionedItemStack[][] wireRecipes = new PositionedItemStack[3][10];
|
|
|
|
int xBase = 15;
|
|
|
|
Ingredient tinCable = IC2TRHelper.getStack("cable", "type:tin,insulation:0");
|
|
|
|
List<ItemStack> tinCableList = Arrays.asList(tinCable.getMatchingStacks());
|
2017-10-21 21:15:01 +02:00
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
for (int j = 0; j < 3; j++) {
|
2017-09-02 18:03:16 +02:00
|
|
|
wireRecipes[0][3 * i + j] = new PositionedItemStack(tinCableList, 18 * i + xBase, 18 * j);
|
|
|
|
}
|
2016-09-22 19:52:01 +02:00
|
|
|
}
|
2017-09-02 18:03:16 +02:00
|
|
|
ItemStack tmp = new ItemStack(IndustrialWires.coil);
|
|
|
|
ItemIC2Coil.setLength(tmp, 9);
|
|
|
|
wireRecipes[0][9] = new PositionedItemStack(tmp, 18 * 4 + xBase, 18);
|
|
|
|
Random r = new Random();
|
2017-10-21 21:15:01 +02:00
|
|
|
for (int i = 1; i < 3; i++) {
|
2017-09-02 18:03:16 +02:00
|
|
|
int lengthSum = 0;
|
2017-10-21 21:15:01 +02:00
|
|
|
for (int j1 = 0; j1 < 3; j1++) {
|
|
|
|
for (int j2 = 0; j2 < 3; j2++) {
|
|
|
|
if (r.nextBoolean()) {
|
2017-09-02 18:03:16 +02:00
|
|
|
// cable
|
|
|
|
lengthSum++;
|
|
|
|
wireRecipes[i][3 * j1 + j2] = new PositionedItemStack(tinCableList, 18 * j1 + xBase, 18 * j2);
|
2017-10-21 21:15:01 +02:00
|
|
|
} else {
|
2017-09-02 18:03:16 +02:00
|
|
|
// wire coil
|
|
|
|
int length = r.nextInt(99) + 1;
|
|
|
|
tmp = new ItemStack(IndustrialWires.coil);
|
|
|
|
ItemIC2Coil.setLength(tmp, length);
|
|
|
|
wireRecipes[i][3 * j1 + j2] = new PositionedItemStack(tmp, 18 * j1 + xBase, 18 * j2);
|
|
|
|
lengthSum += length;
|
|
|
|
}
|
2016-09-22 19:52:01 +02:00
|
|
|
}
|
|
|
|
}
|
2017-09-02 18:03:16 +02:00
|
|
|
tmp = new ItemStack(IndustrialWires.coil);
|
|
|
|
ItemIC2Coil.setLength(tmp, lengthSum);
|
|
|
|
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
|
|
|
|
2017-09-02 18:03:16 +02: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),
|
|
|
|
new ItemStack(IndustrialWires.ic2conn, 1, 4), new ItemStack(IndustrialWires.ic2conn, 1, 5), new ItemStack(IndustrialWires.ic2conn, 1, 6), new ItemStack(IndustrialWires.ic2conn, 1, 7)),
|
|
|
|
new ManualPages.Text(m, "industrialwires.wires1"),
|
|
|
|
new ManualPages.CraftingMulti(m, "industrialwires.wires2", (Object[]) wireRecipes)
|
|
|
|
);
|
2017-10-21 21:15:01 +02:00
|
|
|
if (IndustrialWires.mechConv != null) {
|
2017-09-02 18:03:16 +02: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-10-21 21:15:01 +02:00
|
|
|
int oldLength = Config.IEConfig.Tools.earDefenders_SoundBlacklist.length;
|
|
|
|
Config.IEConfig.Tools.earDefenders_SoundBlacklist =
|
|
|
|
Arrays.copyOf(Config.IEConfig.Tools.earDefenders_SoundBlacklist, oldLength + 1);
|
|
|
|
Config.IEConfig.Tools.earDefenders_SoundBlacklist[oldLength] = TINNITUS_LOC.toString();
|
2017-04-27 18:15:11 +02:00
|
|
|
|
2017-10-21 21:15:01 +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);
|
|
|
|
|
2018-04-06 17:29:26 +02:00
|
|
|
Config.manual_doubleA.put("iwJacobsUsage", IWConfig.HVStuff.jacobsUsageWatt);
|
2017-07-13 17:53:05 +02:00
|
|
|
Config.manual_int.put("iwKeysOnRing", IWConfig.maxKeysOnRing);
|
2017-09-03 20:48:10 +02:00
|
|
|
m.addEntry("industrialwires.jacobs", IndustrialWires.MODID,
|
2017-05-10 17:56:05 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
2017-05-10 17:56:05 +02:00
|
|
|
m.addEntry("industrialwires.intro", "control_panels",
|
|
|
|
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())),
|
2017-07-02 20:37:47 +02:00
|
|
|
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")
|
2017-05-08 21:29:45 +02:00
|
|
|
);
|
2017-05-10 17:56:05 +02:00
|
|
|
m.addEntry("industrialwires.panel_creator", "control_panels",
|
|
|
|
new ManualPages.Crafting(m, "industrialwires.panel_creator0", new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.CREATOR.ordinal())),
|
|
|
|
new ManualPages.Text(m, "industrialwires.panel_creator1"),
|
|
|
|
new ManualPages.Text(m, "industrialwires.panel_creator2")
|
2017-05-08 21:29:45 +02:00
|
|
|
);
|
2017-05-10 17:56:05 +02:00
|
|
|
m.addEntry("industrialwires.redstone", "control_panels",
|
|
|
|
new ManualPages.Crafting(m, "industrialwires.redstone0", new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.RS_WIRE.ordinal())),
|
|
|
|
new ManualPages.Text(m, "industrialwires.redstone1")
|
2017-05-08 21:29:45 +02:00
|
|
|
);
|
2017-05-10 17:56:05 +02:00
|
|
|
m.addEntry("industrialwires.components", "control_panels",
|
2017-05-19 17:45:30 +02:00
|
|
|
new ManualPages.Text(m, "industrialwires.components.general"),
|
2017-05-10 17:56:05 +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)),
|
|
|
|
new ManualPages.Text(m, "industrialwires.toggle_switch1"),
|
2017-05-19 17:45:30 +02:00
|
|
|
new ManualPages.Crafting(m, "industrialwires.variac", new ItemStack(IndustrialWires.panelComponent, 1, 4)),
|
2017-05-27 17:00:26 +02:00
|
|
|
new ManualPages.CraftingMulti(m, "industrialwires.lock", new ItemStack(IndustrialWires.panelComponent, 1, 7), new ItemStack(IndustrialWires.key)),
|
2017-07-13 17:53:05 +02:00
|
|
|
new ManualPages.Crafting(m, "industrialwires.lock1", new ItemStack(IndustrialWires.key, 1, 2)),
|
2017-10-31 16:29:38 +01:00
|
|
|
new ManualPages.Crafting(m, "industrialwires.panel_meter", new ItemStack(IndustrialWires.panelComponent, 1, 8)),
|
|
|
|
new ManualPages.Crafting(m, "industrialwires.7seg", new ItemStack(IndustrialWires.panelComponent, 1, 9))
|
2017-05-08 21:29:45 +02:00
|
|
|
);
|
2017-09-03 20:48:10 +02:00
|
|
|
List<MarxOreHandler.OreInfo> ores = MarxOreHandler.getRecipes();
|
2017-10-20 17:36:17 +02:00
|
|
|
String text = I18n.format("ie.manual.entry.industrialwires.marx");
|
|
|
|
for (int i = 0; i < ores.size(); i++) {
|
|
|
|
MarxOreHandler.OreInfo curr = ores.get(i);
|
|
|
|
if (!curr.exampleInput.isEmpty()) {
|
|
|
|
text += I18n.format(IndustrialWires.MODID + ".desc.input") + ": §l" + curr.exampleInput.get(0).getDisplayName() + "§r<br>";
|
|
|
|
text += I18n.format(IndustrialWires.MODID + ".desc.output") + ": " + Utils.formatDouble(curr.maxYield, "0.#") + "x" + curr.output.get().getDisplayName() + "<br>";
|
|
|
|
if (curr.outputSmall != null && !curr.outputSmall.get().isEmpty()) {
|
|
|
|
text += I18n.format(IndustrialWires.MODID + ".desc.alt") + ": " + curr.smallMax + "x" + curr.outputSmall.get().getDisplayName() + "<br>";
|
2017-09-03 20:48:10 +02:00
|
|
|
}
|
2017-10-20 17:36:17 +02:00
|
|
|
text += I18n.format(IndustrialWires.MODID + ".desc.ideal_e") + ": " + Utils.formatDouble(curr.avgEnergy * MarxOreHandler.defaultEnergy / 1000, "0.#") + " kJ<br><br>";
|
2017-09-03 20:48:10 +02:00
|
|
|
}
|
|
|
|
}
|
2017-10-20 17:36:17 +02:00
|
|
|
boolean uni = m.fontRenderer.getUnicodeFlag();
|
|
|
|
m.fontRenderer.setUnicodeFlag(true);
|
|
|
|
m.entryRenderPre();
|
|
|
|
TextSplitter splitter = new TextSplitter(m.fontRenderer::getStringWidth, 16, 120,
|
2017-10-21 21:15:01 +02:00
|
|
|
(s) -> new ManualPages.Text(m, s));
|
2017-10-20 17:36:17 +02:00
|
|
|
splitter.addSpecialPage(0, 0, 6,
|
2017-10-21 21:15:01 +02:00
|
|
|
(s) -> new ManualPageMultiblock(m, s,
|
2017-10-20 17:36:17 +02:00
|
|
|
MultiblockMarx.INSTANCE));
|
|
|
|
splitter.split(text);
|
|
|
|
m.entryRenderPost();
|
|
|
|
m.fontRenderer.setUnicodeFlag(uni);
|
|
|
|
List<ManualPages> marxEntry = splitter.toManualEntry();
|
2017-09-03 20:48:10 +02:00
|
|
|
m.addEntry("industrialwires.marx", IndustrialWires.MODID, marxEntry.toArray(new ManualPages[marxEntry.size()]));
|
2017-11-26 13:52:52 +01:00
|
|
|
ClientCommandHandler.instance.registerCommand(new CommandIWClient());
|
2017-02-26 13:56:36 +01:00
|
|
|
}
|
|
|
|
|
2017-08-13 18:46:46 +02:00
|
|
|
private static final ResourceLocation TINNITUS_LOC = new ResourceLocation(IndustrialWires.MODID, "tinnitus");
|
|
|
|
private static ISound playingTinnitus = null;
|
2017-06-16 22:04:30 +02:00
|
|
|
@Override
|
|
|
|
public void startTinnitus() {
|
|
|
|
final Minecraft mc = Minecraft.getMinecraft();
|
2017-09-15 19:36:14 +02:00
|
|
|
if (playingTinnitus==null||!mc.getSoundHandler().isSoundPlaying(playingTinnitus)) {
|
2017-08-13 18:46:46 +02:00
|
|
|
playingTinnitus = getTinnitus();
|
|
|
|
mc.getSoundHandler().playSound(playingTinnitus);
|
|
|
|
}
|
|
|
|
}
|
2017-06-16 22:04:30 +02:00
|
|
|
|
2017-08-13 18:46:46 +02:00
|
|
|
private ISound getTinnitus() {
|
|
|
|
final Minecraft mc = Minecraft.getMinecraft();
|
|
|
|
return new MovingSound(new SoundEvent(TINNITUS_LOC), SoundCategory.PLAYERS) {
|
|
|
|
@Override
|
|
|
|
public void update() {
|
|
|
|
if (mc.player.getActivePotionEffect(IWPotions.tinnitus)==null) {
|
|
|
|
donePlaying = true;
|
|
|
|
playingTinnitus = null;
|
2017-06-23 17:40:49 +02:00
|
|
|
}
|
2017-08-13 18:46:46 +02:00
|
|
|
}
|
2017-06-23 17:40:49 +02:00
|
|
|
|
2017-08-13 18:46:46 +02:00
|
|
|
@Override
|
|
|
|
public float getVolume() {
|
2017-09-15 19:36:14 +02:00
|
|
|
return .5F;
|
2017-08-13 18:46:46 +02:00
|
|
|
}
|
2017-06-16 22:04:30 +02:00
|
|
|
|
2017-08-13 18:46:46 +02:00
|
|
|
@Override
|
|
|
|
public float getXPosF() {
|
|
|
|
return (float) mc.player.posX;
|
|
|
|
}
|
2017-06-16 22:04:30 +02:00
|
|
|
|
2017-08-13 18:46:46 +02:00
|
|
|
@Override
|
|
|
|
public float getYPosF() {
|
|
|
|
return (float) mc.player.posY;
|
|
|
|
}
|
2017-06-16 22:04:30 +02:00
|
|
|
|
2017-08-13 18:46:46 +02:00
|
|
|
@Override
|
|
|
|
public float getZPosF() {
|
|
|
|
return (float) mc.player.posZ;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canRepeat() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
2017-02-26 13:56:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public World getClientWorld() {
|
2017-05-10 17:56:05 +02:00
|
|
|
return Minecraft.getMinecraft().world;
|
2017-02-26 13:56:36 +01:00
|
|
|
}
|
|
|
|
|
2018-04-22 22:14:08 +02:00
|
|
|
private Map<BlockPos, List<ISound>> playingSounds = new HashMap<>();
|
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-06-16 22:04:30 +02:00
|
|
|
private static ResourceLocation marxBang = new ResourceLocation(IndustrialWires.MODID, "marx_bang");
|
2017-08-27 18:09:58 +02:00
|
|
|
private static ResourceLocation marxPop = new ResourceLocation(IndustrialWires.MODID, "marx_pop");
|
2018-04-22 22:14:08 +02:00
|
|
|
private static ResourceLocation mmbBang = new ResourceLocation(IndustrialWires.MODID, "mech_mb_breaking");
|
|
|
|
private static ResourceLocation turnFast = new ResourceLocation(IndustrialWires.MODID, "mech_mb_fast");
|
|
|
|
private static ResourceLocation turnSlow = new ResourceLocation(IndustrialWires.MODID, "mech_mb_slow");
|
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) {
|
2018-04-22 22:14:08 +02:00
|
|
|
stopAllSounds(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-06-25 18:34:10 +02:00
|
|
|
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);
|
2017-02-26 13:56:36 +01:00
|
|
|
ClientUtils.mc().getSoundHandler().playSound(sound);
|
2018-04-22 22:14:08 +02:00
|
|
|
addSound(te.getPos(), sound);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void playMechMBBang(TileEntityMechMB te, float volume) {
|
|
|
|
PositionedSoundRecord sound = new PositionedSoundRecord(mmbBang, SoundCategory.BLOCKS, volume, 1,
|
|
|
|
false, 0, ISound.AttenuationType.LINEAR, te.getPos().getX(), te.getPos().getY(),
|
|
|
|
te.getPos().getZ());
|
|
|
|
ClientUtils.mc().getSoundHandler().playSound(sound);
|
|
|
|
//This won't be added to the list since it's short and will play while the TE is being destroyed
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void playMechMBTurning(TileEntityMechMB te, MechEnergy energy) {
|
|
|
|
stopAllSounds(te.getPos());
|
|
|
|
float lambda = MathHelper.clamp((float) energy.getSpeed()/20-.5F, 0, 1);
|
|
|
|
float totalVolume = (float) (energy.weight/50e3*Math.sqrt(energy.getSpeed()));
|
|
|
|
if (lambda>0) {
|
|
|
|
PositionedSoundRecord sound = new PositionedSoundRecord(turnFast, SoundCategory.BLOCKS, lambda*totalVolume, 1,
|
|
|
|
false, 0, ISound.AttenuationType.LINEAR, te.getPos().getX(), te.getPos().getY(),
|
|
|
|
te.getPos().getZ());
|
|
|
|
ClientUtils.mc().getSoundHandler().playSound(sound);
|
|
|
|
addSound(te.getPos(), sound);
|
|
|
|
}
|
|
|
|
if (lambda<1) {
|
|
|
|
PositionedSoundRecord sound = new PositionedSoundRecord(turnSlow, SoundCategory.BLOCKS, (1-lambda)*totalVolume, 1,
|
|
|
|
false, 0, ISound.AttenuationType.LINEAR, te.getPos().getX(), te.getPos().getY(),
|
|
|
|
te.getPos().getZ());
|
|
|
|
ClientUtils.mc().getSoundHandler().playSound(sound);
|
|
|
|
addSound(te.getPos(), sound);
|
|
|
|
}
|
2016-09-15 20:43:18 +02:00
|
|
|
}
|
2017-04-09 16:59:57 +02:00
|
|
|
|
2017-06-16 22:04:30 +02:00
|
|
|
@Override
|
|
|
|
public void playMarxBang(TileEntityMarx te, Vec3d pos, float energy) {
|
2017-08-27 18:09:58 +02:00
|
|
|
ResourceLocation soundLoc = marxBang;
|
2017-08-15 21:37:53 +02:00
|
|
|
if (energy<0) {
|
2017-08-27 18:09:58 +02:00
|
|
|
energy = -energy;
|
|
|
|
soundLoc = marxPop;
|
2017-08-15 21:37:53 +02:00
|
|
|
}
|
2018-04-22 22:14:08 +02:00
|
|
|
PositionedSoundRecord sound = new PositionedSoundRecord(soundLoc, SoundCategory.BLOCKS, 5*energy, 1,
|
|
|
|
false, 0, ISound.AttenuationType.LINEAR, (float) pos.x, (float) pos.y, (float) pos.z);
|
2017-06-16 22:04:30 +02:00
|
|
|
ClientUtils.mc().getSoundHandler().playSound(sound);
|
2018-04-22 22:14:08 +02:00
|
|
|
addSound(te.getPos(), sound);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void addSound(BlockPos pos, ISound sound) {
|
|
|
|
List<ISound> allForPos = playingSounds.get(pos);
|
|
|
|
if (allForPos==null) {
|
|
|
|
allForPos = new ArrayList<>();
|
|
|
|
}
|
|
|
|
allForPos.add(sound);
|
|
|
|
if (allForPos.size()==1) {
|
|
|
|
playingSounds.put(pos, allForPos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void stopAllSounds(BlockPos pos) {
|
|
|
|
if (playingSounds.containsKey(pos)) {
|
|
|
|
SoundHandler manager = Minecraft.getMinecraft().getSoundHandler();
|
|
|
|
for (ISound sound:playingSounds.get(pos)) {
|
|
|
|
manager.stopSound(sound);
|
|
|
|
}
|
|
|
|
playingSounds.remove(pos);
|
|
|
|
}
|
2017-06-16 22:04:30 +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.isEmpty()) {
|
|
|
|
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-09-15 19:36:14 +02:00
|
|
|
}
|