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;
|
2018-06-02 21:22:26 +02:00
|
|
|
import blusunrize.lib.manual.IManualPage;
|
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;
|
2018-05-27 13:32:43 +02:00
|
|
|
import com.google.common.collect.ImmutableList;
|
2017-02-26 13:56:36 +01:00
|
|
|
import com.google.common.collect.ImmutableMap;
|
2018-05-06 20:33:24 +02:00
|
|
|
import com.google.common.collect.ImmutableSet;
|
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;
|
2018-08-01 17:29:24 +02:00
|
|
|
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelIE;
|
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;
|
2018-06-16 19:15:15 +02:00
|
|
|
import malte0811.industrialWires.client.multiblock_io_model.MBIOModelLoader;
|
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;
|
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;
|
2018-06-15 16:15:06 +02:00
|
|
|
import malte0811.industrialWires.mech_mb.*;
|
2017-11-26 13:52:52 +01:00
|
|
|
import malte0811.industrialWires.util.CommandIWClient;
|
2018-06-04 18:10:52 +02:00
|
|
|
import malte0811.industrialWires.util.ConversionUtil;
|
2018-06-02 21:22:26 +02:00
|
|
|
import malte0811.industrialWires.util.MiscUtils;
|
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;
|
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-06-13 19:09:35 +02:00
|
|
|
import static malte0811.industrialWires.IndustrialWires.*;
|
|
|
|
|
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();
|
2018-06-02 21:22:26 +02:00
|
|
|
|
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());
|
2018-06-16 19:15:15 +02:00
|
|
|
ModelLoaderRegistry.registerLoader(new MBIOModelLoader());
|
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());
|
2018-05-13 18:54:26 +02:00
|
|
|
TileRenderMechMB tesr = new TileRenderMechMB();
|
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))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2018-06-27 22:49:20 +02:00
|
|
|
addUnblockableSounds(TINNITUS, TURN_FAST, TURN_SLOW);
|
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);
|
2018-06-04 18:10:52 +02:00
|
|
|
Config.manual_double.put("iwFluxPerJoule", ConversionUtil.ifPerJoule());
|
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();
|
2018-06-02 21:22:26 +02:00
|
|
|
TextSplitter splitter = new TextSplitter(m);
|
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);
|
2018-06-02 21:22:26 +02:00
|
|
|
List<IManualPage> marxEntry = splitter.toManualEntry();
|
|
|
|
m.addEntry("industrialwires.marx", IndustrialWires.MODID, marxEntry.toArray(new IManualPage[0]));
|
|
|
|
|
|
|
|
text = I18n.format("ie.manual.entry.industrialwires.mech_mb");
|
|
|
|
splitter = new TextSplitter(m);
|
2018-06-04 18:10:52 +02:00
|
|
|
splitter.addSpecialPage(0, 0, 8, (s) -> new ManualPageMultiblock(m, s,
|
2018-06-02 21:22:26 +02:00
|
|
|
MiscUtils.getMBFromName(MechMBPart.EXAMPLE_MECHMB_LOC.toString())));
|
|
|
|
splitter.split(text);
|
|
|
|
List<IManualPage> mechMBEntry = splitter.toManualEntry();
|
|
|
|
m.addEntry("industrialwires.mech_mb", IndustrialWires.MODID, mechMBEntry.toArray(new IManualPage[0]));
|
|
|
|
|
2018-06-04 18:10:52 +02:00
|
|
|
String[][] flywheelTable;
|
|
|
|
{
|
|
|
|
List<String[]> flywheelTableList = new ArrayList<>(1+Material.values().length);
|
|
|
|
flywheelTableList.add(new String[]{"industrialwires.desc.material", "industrialwires.desc.inertia", "industrialwires.desc.max_speed"});
|
|
|
|
for (Material mat:Material.values()) {
|
|
|
|
MechPartFlywheel f = new MechPartFlywheel(mat);
|
|
|
|
flywheelTableList.add(new String[]{mat.oreName(), Utils.formatDouble(f.getInertia(), "0.#"),
|
|
|
|
Utils.formatDouble(f.getMaxSpeed(), "0.#")});
|
|
|
|
}
|
|
|
|
flywheelTable = flywheelTableList.toArray(new String[0][]);
|
|
|
|
}
|
2018-06-17 21:06:15 +02:00
|
|
|
text = I18n.format("ie.manual.entry.industrialwires.mech_mb_parts");
|
|
|
|
splitter = new TextSplitter(m);
|
|
|
|
splitter.addSpecialPage(0, 0, 10, (s) -> new ManualPageMultiblock(m, s,
|
|
|
|
MechMBPart.getManualMBForPart(MechPartFlywheel.class)));
|
|
|
|
splitter.addSpecialPage(1, 0, 1, s->new ManualPages.Table(m, "", flywheelTable, true));
|
|
|
|
splitter.addSpecialPage(2, 0, 10, (s) -> new ManualPageMultiblock(m, s,
|
|
|
|
MechMBPart.getManualMBForPart(MechPartSingleCoil.class)));
|
|
|
|
splitter.addSpecialPage(3, 0, 10, (s) -> new ManualPageMultiblock(m, s,
|
|
|
|
MechMBPart.getManualMBForPart(MechPartFourElectrodes.class)));
|
2018-06-04 18:10:52 +02:00
|
|
|
if (IWConfig.MechConversion.allowMBEU()) {
|
2018-06-17 21:06:15 +02:00
|
|
|
text += I18n.format("ie.manual.entry.industrialwires.mech_mb_parts.commutator");
|
|
|
|
splitter.addSpecialPage(4, 0, 10, (s) -> new ManualPageMultiblock(m, s,
|
2018-06-04 18:10:52 +02:00
|
|
|
MechMBPart.getManualMBForPart(MechPartCommutator4Phase.class)));
|
|
|
|
}
|
2018-06-17 21:06:15 +02:00
|
|
|
splitter.split(text);
|
|
|
|
List<IManualPage> partsEntry = splitter.toManualEntry();
|
2018-06-04 18:10:52 +02:00
|
|
|
m.addEntry("industrialwires.mech_mb_parts", IndustrialWires.MODID, partsEntry.toArray(new IManualPage[0]));
|
2018-06-17 21:06:15 +02:00
|
|
|
m.entryRenderPost();
|
|
|
|
m.fontRenderer.setUnicodeFlag(uni);
|
2018-06-04 18:10:52 +02:00
|
|
|
|
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 ISound playingTinnitus = null;
|
2018-06-13 18:29:10 +02:00
|
|
|
|
2018-06-27 22:49:20 +02:00
|
|
|
private void addUnblockableSounds(SoundEvent... sounds) {
|
2018-06-13 18:29:10 +02:00
|
|
|
int oldLength = Config.IEConfig.Tools.earDefenders_SoundBlacklist.length;
|
|
|
|
Config.IEConfig.Tools.earDefenders_SoundBlacklist =
|
|
|
|
Arrays.copyOf(Config.IEConfig.Tools.earDefenders_SoundBlacklist, oldLength + sounds.length);
|
|
|
|
for (int i = 0;i<sounds.length;i++) {
|
2018-06-27 22:49:20 +02:00
|
|
|
Config.IEConfig.Tools.earDefenders_SoundBlacklist[oldLength+i] = sounds[i].getSoundName().toString();
|
2018-06-13 18:29:10 +02:00
|
|
|
}
|
|
|
|
}
|
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();
|
2018-06-27 22:49:20 +02:00
|
|
|
return new MovingSound(TINNITUS, SoundCategory.PLAYERS) {
|
2017-08-13 18:46:46 +02:00
|
|
|
@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-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-05-06 20:33:24 +02:00
|
|
|
stopAllSoundsExcept(te.getPos(), ImmutableSet.of());
|
2018-06-27 22:49:20 +02:00
|
|
|
SoundEvent event;
|
2017-02-26 13:56:36 +01:00
|
|
|
switch (phase) {
|
|
|
|
case 0:
|
2018-06-13 18:29:10 +02:00
|
|
|
event = LADDER_START;
|
2017-02-26 13:56:36 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2018-06-13 18:29:10 +02:00
|
|
|
event = LADDER_MIDDLE;
|
2017-02-26 13:56:36 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2018-06-13 18:29:10 +02:00
|
|
|
event = LADDER_END;
|
2017-02-26 13:56:36 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
2016-12-20 17:05:20 +01:00
|
|
|
}
|
2018-06-27 22:49:20 +02:00
|
|
|
PositionedSoundRecord sound = new PositionedSoundRecord(event.getSoundName(), SoundCategory.BLOCKS, te.size.soundVolume, 1,
|
2018-05-06 20:33:24 +02:00
|
|
|
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
|
2018-05-06 20:33:24 +02:00
|
|
|
public void updateMechMBTurningSound(TileEntityMechMB te, MechEnergy energy) {
|
2018-05-27 13:32:43 +02:00
|
|
|
SoundHandler sndHandler = ClientUtils.mc().getSoundHandler();
|
|
|
|
List<ISound> soundsAtPos;
|
|
|
|
if (playingSounds.containsKey(te.getPos())) {
|
|
|
|
soundsAtPos = playingSounds.get(te.getPos());
|
|
|
|
soundsAtPos.removeIf(s -> !sndHandler.isSoundPlaying(s));
|
|
|
|
if (soundsAtPos.isEmpty()) {
|
|
|
|
playingSounds.remove(te.getPos());
|
2018-05-06 20:33:24 +02:00
|
|
|
}
|
2018-05-27 13:32:43 +02:00
|
|
|
} else {
|
|
|
|
soundsAtPos = ImmutableList.of();
|
|
|
|
}
|
|
|
|
boolean hasSlow = false, hasFast = false;
|
|
|
|
for (ISound s:soundsAtPos) {
|
2018-06-27 22:49:20 +02:00
|
|
|
if (s.getSoundLocation().equals(TURN_FAST.getSoundName())) {
|
2018-05-27 13:32:43 +02:00
|
|
|
hasFast = true;
|
2018-06-27 22:49:20 +02:00
|
|
|
} else if (s.getSoundLocation().equals(TURN_SLOW.getSoundName())) {
|
2018-05-27 13:32:43 +02:00
|
|
|
hasSlow = true;
|
2018-05-06 20:33:24 +02:00
|
|
|
}
|
2018-04-22 22:14:08 +02:00
|
|
|
}
|
2018-05-27 13:32:43 +02:00
|
|
|
if (!hasSlow && energy.getVolumeSlow() > 0) {
|
2018-06-13 18:29:10 +02:00
|
|
|
ISound snd = new IWTickableSound(TURN_SLOW, SoundCategory.BLOCKS, energy::getVolumeSlow, energy::getPitch,
|
2018-05-27 13:32:43 +02:00
|
|
|
te.getPos().getX(), te.getPos().getY(), te.getPos().getZ());
|
|
|
|
sndHandler.playSound(snd);
|
|
|
|
addSound(te.getPos(), snd);
|
|
|
|
}
|
|
|
|
if (!hasFast && energy.getVolumeFast() > 0) {
|
2018-06-13 18:29:10 +02:00
|
|
|
ISound snd = new IWTickableSound(TURN_FAST, SoundCategory.BLOCKS, energy::getVolumeFast, energy::getPitch,
|
2018-05-27 13:32:43 +02:00
|
|
|
te.getPos().getX(), te.getPos().getY(), te.getPos().getZ());
|
|
|
|
sndHandler.playSound(snd);
|
|
|
|
addSound(te.getPos(), snd);
|
|
|
|
}
|
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) {
|
2018-06-27 22:49:20 +02:00
|
|
|
SoundEvent soundLoc = MARX_BANG;
|
2017-08-15 21:37:53 +02:00
|
|
|
if (energy<0) {
|
2017-08-27 18:09:58 +02:00
|
|
|
energy = -energy;
|
2018-06-13 18:29:10 +02:00
|
|
|
soundLoc = MARX_POP;
|
2017-08-15 21:37:53 +02:00
|
|
|
}
|
2018-06-27 22:49:20 +02:00
|
|
|
PositionedSoundRecord sound = new PositionedSoundRecord(soundLoc.getSoundName(), SoundCategory.BLOCKS, 5*energy, 1,
|
2018-04-22 22:14:08 +02:00
|
|
|
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
|
2018-06-13 19:09:35 +02:00
|
|
|
public void stopAllSoundsExcept(BlockPos pos, Set<?> excluded) {
|
2018-04-22 22:14:08 +02:00
|
|
|
if (playingSounds.containsKey(pos)) {
|
|
|
|
SoundHandler manager = Minecraft.getMinecraft().getSoundHandler();
|
2018-05-06 20:33:24 +02:00
|
|
|
List<ISound> sounds = playingSounds.get(pos);
|
|
|
|
List<ISound> toRemove = new ArrayList<>(sounds.size()-excluded.size());
|
|
|
|
for (ISound sound:sounds) {
|
|
|
|
if (!excluded.contains(sound)) {
|
|
|
|
manager.stopSound(sound);
|
|
|
|
toRemove.add(sound);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sounds.removeAll(toRemove);
|
|
|
|
if (sounds.isEmpty()) {
|
|
|
|
playingSounds.remove(pos);
|
2018-04-22 22:14:08 +02:00
|
|
|
}
|
|
|
|
}
|
2017-06-16 22:04:30 +02:00
|
|
|
}
|
|
|
|
|
2018-06-16 19:15:15 +02:00
|
|
|
@Override
|
|
|
|
public boolean isSingleplayer() {
|
|
|
|
return Minecraft.getMinecraft().isSingleplayer();
|
|
|
|
}
|
|
|
|
|
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));
|
2018-08-01 17:29:24 +02:00
|
|
|
if (te instanceof TileEntityRSPanelIE) {
|
|
|
|
return new GuiRSPanelConn((TileEntityRSPanelIE) te);
|
2017-04-20 20:44:08 +02:00
|
|
|
}
|
|
|
|
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
|
|
|
}
|