Merge branch 'MC1.12' into mechStuff
This commit is contained in:
commit
6c60b4562b
18
README.md
18
README.md
|
@ -1,11 +1,15 @@
|
|||
#Industrial Wires
|
||||
![](Screenshot.png)
|
||||
|
||||
![An example of what Industrial Wires can do](Screenshot.png)
|
||||
An addon for Immersive Engineering. Some features, like the EU-transmitting IE-style wires the mod is named after, will only be enabled if IC2 is installed. All devices added by IndustrialWires can run of IC2 EU as well as ForgeEnergy/RF.
|
||||
|
||||
An addon for Immersive Engineering and IndustrialCraft2. It adds IE-style wires that are able to transmit IC2 energy (EU). This is different from the IC2 compatibility IE had in MC 1.7.10 as it is not possible to convert IC2 power to RF/IF/Tesla/forge energy/etc.
|
||||
The features can be split into to groups: IC2 compat and HV/electronics stuff
|
||||
- IC2 compat:
|
||||
- IE style wires that transmit EU. Check the manual for recipes
|
||||
- Lossy converters between IE's rotational energy (windmills, watermills) and IC2's kinetic energy
|
||||
- HV/electronics:
|
||||
- [Control panels](https://www.youtube.com/watch?v=hV0cN20vCMY)
|
||||
- Jacob's ladders. They don't do anything useful apart from looking nice (Shown in the control panel video)
|
||||
- Marx generators. Ore processing using lightning/high voltage. You need to do a little bit of math to use it for that, but you can still use it to kill things/people without doing any!
|
||||
|
||||
Recipes for the relays, connectors and wires can be found in the Engineer's Manual.
|
||||
|
||||
All textures for the connectors are modified versions of the textures Immersive Engineering uses and the models are loaded out of IE, so all art for the wires is at least based on art Mr. Damien Hazard made.
|
||||
|
||||
The textures for the mechanical converters and the Rotational Motor were made by C8H8O4.
|
||||
The textures and models are partially modified IE resources and partially made by C8H8O4 or me.
|
BIN
Screenshot.png
BIN
Screenshot.png
Binary file not shown.
Before Width: | Height: | Size: 320 KiB After Width: | Height: | Size: 392 KiB |
16
build.gradle
16
build.gradle
|
@ -1,5 +1,5 @@
|
|||
def mainVersion = "1.6"
|
||||
def buildNumber = "22"
|
||||
def mainVersion = "1.7"
|
||||
def buildNumber = "26-pre"
|
||||
|
||||
// For those who want the bleeding edge
|
||||
buildscript {
|
||||
|
@ -30,11 +30,11 @@ sourceCompatibility = 1.8
|
|||
targetCompatibility = 1.8
|
||||
|
||||
minecraft {
|
||||
version = "14.22.1.2479"
|
||||
version = "14.23.1.2555"
|
||||
runDir = "run"
|
||||
|
||||
replace '${version}', project.version
|
||||
mappings = "snapshot_20170628"
|
||||
mappings = "snapshot_20171003"
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
@ -70,12 +70,20 @@ repositories {
|
|||
|
||||
dependencies {
|
||||
deobfCompile 'net.industrial-craft:industrialcraft-2:2.8.+'
|
||||
<<<<<<< HEAD
|
||||
deobfCompile "blusunrize:ImmersiveEngineering:0.12-+:deobf"
|
||||
=======
|
||||
//TODO readd when the wirechanges are on master deobfCompile "blusunrize:ImmersiveEngineering:0.12-+:deobf"
|
||||
>>>>>>> MC1.12
|
||||
compileOnly "TechReborn:TechReborn-1.12:2.6.+:dev"
|
||||
compileOnly "RebornCore:RebornCore-1.12:3.2.+:dev"
|
||||
deobfCompile 'com.elytradev:mirage:2.0.1-SNAPSHOT'
|
||||
compileOnly "mezz.jei:jei_1.12:4.+"
|
||||
<<<<<<< HEAD
|
||||
compileOnly "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.0.10.306"
|
||||
=======
|
||||
compileOnly "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.+"
|
||||
>>>>>>> MC1.12
|
||||
}
|
||||
|
||||
jar {
|
||||
|
|
25
changelog.md
25
changelog.md
|
@ -1,3 +1,28 @@
|
|||
#####Version 1.6-23
|
||||
- Fixed an infinite energy bug
|
||||
- Changed the default value for maximum energy conversion
|
||||
|
||||
#####Version 1.6-23
|
||||
- Added a command to allow taking screenshots of Marx generator discharges (/ciw triggermarxscreenshot)
|
||||
- Panel components have to be shift-clicked to place them in the world
|
||||
- Fixed wire coil crafting
|
||||
- Added a recipe for the Seven-Segment displays
|
||||
|
||||
#####Version 1.6-22
|
||||
- Added a Seven-Segment display for control panels
|
||||
- Panel components update their values as soon as they are changed in the GUI
|
||||
- Fixed a crash when breaking a panel with buttons, locks or toggle switches on it under special circumstances
|
||||
- Fixed server crashes when using panel components with a second controller id, but no channel set
|
||||
- Fixed various NPE crashes with control panel models under heavy load
|
||||
- Fixed wrong panel component ordering with raytracing
|
||||
|
||||
#####Version 1.6-21
|
||||
- Added shaders for the Marx generator and Jacob's ladder
|
||||
- Fixed wires connected to a Marx generator on a server being invisible
|
||||
- The Marx generator actually gives output when processing ores now. Oops...
|
||||
- The "safe distance" formulas for the Marx generator in the manual now match the real safe distance
|
||||
- Improved rendering of the Marx generator in the manual. Some of this is only enabled with maven build 275+ or official build 75+ (not released yet)
|
||||
|
||||
#####Version 1.6-20
|
||||
- Added the Marx Generator, an alternative ore processing method
|
||||
- Hearing protection absolutely required!
|
||||
|
|
69
src/main/java/malte0811/industrialWires/EventHandler.java
Normal file
69
src/main/java/malte0811/industrialWires/EventHandler.java
Normal 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;
|
||||
|
||||
import malte0811.industrialWires.items.ItemIC2Coil;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class EventHandler {
|
||||
@SubscribeEvent
|
||||
public static void onItemPickup(EntityItemPickupEvent ev) {
|
||||
if (ev.getItem().getItem().getItem()==IndustrialWires.coil) {
|
||||
ItemStack stack = ev.getItem().getItem();
|
||||
InventoryPlayer playerInv = ev.getEntityPlayer().inventory;
|
||||
boolean changed = false;
|
||||
int lengthOnEntity = ItemIC2Coil.getLength(stack);
|
||||
IndustrialWires.logger.info(lengthOnEntity+", "+stack);
|
||||
final int lengthPerCoilOrig = lengthOnEntity/stack.getCount();
|
||||
for (int i = 0;i<playerInv.getSizeInventory();i++) {
|
||||
ItemStack inInv = playerInv.getStackInSlot(i);
|
||||
if (ItemStack.areItemsEqual(stack, inInv)) {
|
||||
int oldLength = ItemIC2Coil.getLength(inInv);
|
||||
int newLength = Math.min(oldLength+lengthOnEntity, ItemIC2Coil.getMaxWireLength(inInv));
|
||||
ItemIC2Coil.setLength(inInv, newLength);
|
||||
lengthOnEntity -= newLength-oldLength;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
ev.getEntityPlayer().onItemPickup(ev.getItem(), 1);
|
||||
}
|
||||
if (lengthOnEntity==0) {
|
||||
ev.getItem().setDead();
|
||||
ev.setCanceled(true);
|
||||
} else if (stack.getCount()>1) {
|
||||
int coilsRemaining = lengthOnEntity/lengthPerCoilOrig;
|
||||
stack.setCount(coilsRemaining);
|
||||
int leftover = lengthOnEntity-lengthPerCoilOrig*coilsRemaining;
|
||||
if (leftover>0) {
|
||||
EntityItem old = ev.getItem();
|
||||
ItemStack leftoverItem = new ItemStack(stack.getItem(), 1, stack.getMetadata());
|
||||
ItemIC2Coil.setLength(leftoverItem, leftover);
|
||||
EntityItem newCoil = new EntityItem(old.world, old.posX, old.posY, old.posZ, leftoverItem);
|
||||
old.world.spawnEntity(newCoil);
|
||||
}
|
||||
} else if (stack.getCount()==1) {
|
||||
ItemIC2Coil.setLength(stack, lengthOnEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,9 +17,12 @@
|
|||
*/
|
||||
package malte0811.industrialWires;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface IIC2Connector {
|
||||
/**
|
||||
* @return leftover energy.
|
||||
*/
|
||||
double insertEnergy(double eu, boolean simulate);
|
||||
void addAvailableEnergy(double amount, Consumer<Double> consume);
|
||||
}
|
||||
|
|
|
@ -46,12 +46,12 @@ public class IWConfig {
|
|||
public static double ifMotorEfficiency = .9;
|
||||
|
||||
@Comment({"The maximum amount of IE rotational energy that can be converted into IC2 kinetic energy", "by one converter in one tick"})
|
||||
public static double maxRotToKin = 50;
|
||||
public static double maxRotToKin = 200;
|
||||
@Comment({"The efficiency of the conversion from IE rotational energy to IC2 kinetic energy"})
|
||||
public static double rotToKinEfficiency = .7;
|
||||
|
||||
@Comment({"The maximum amount of IC2 kinetic energy that can be converted into IE rotational energy", "by one converter in one tick"})
|
||||
public static int maxKinToRot = 2400;
|
||||
public static int maxKinToRot = 600;
|
||||
@Comment({"The efficiency of the conversion from IC2 kinetic energy to IE rotational energy"})
|
||||
public static double kinToRotEfficiency = .8;
|
||||
}
|
||||
|
@ -66,5 +66,7 @@ public class IWConfig {
|
|||
@Comment({"The effect of standing somewhat close to a Marx generator discharge.",
|
||||
"0: Tinnitus, 1: Nausea, 2: normal damage"})
|
||||
public static int marxSoundDamage = 0;
|
||||
@Comment({"Set to false to disable shaders. They are used for rendering the Marx generator and the Jacob's ladder."})
|
||||
public static boolean enableShaders = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,16 +17,17 @@
|
|||
*/
|
||||
package malte0811.industrialWires;
|
||||
|
||||
import blusunrize.immersiveengineering.ImmersiveEngineering;
|
||||
import blusunrize.immersiveengineering.api.MultiblockHandler;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireApi;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import malte0811.industrialWires.blocks.BlockIWBase;
|
||||
import malte0811.industrialWires.blocks.controlpanel.*;
|
||||
import malte0811.industrialWires.blocks.converter.*;
|
||||
import malte0811.industrialWires.blocks.hv.BlockHVMultiblocks;
|
||||
import malte0811.industrialWires.blocks.hv.BlockJacobsLadder;
|
||||
import malte0811.industrialWires.blocks.hv.TileEntityJacobsLadder;
|
||||
import malte0811.industrialWires.blocks.hv.TileEntityMarx;
|
||||
import malte0811.industrialWires.blocks.hv.*;
|
||||
import malte0811.industrialWires.blocks.wire.*;
|
||||
import malte0811.industrialWires.compat.Compat;
|
||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.controlpanel.PanelUtils;
|
||||
import malte0811.industrialWires.converter.MechMBPart;
|
||||
import malte0811.industrialWires.converter.MultiblockConverter;
|
||||
|
@ -46,6 +47,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
@ -64,7 +66,10 @@ import org.apache.logging.log4j.Logger;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
//TODO require IE 0.12-72
|
||||
|
||||
import static malte0811.industrialWires.blocks.wire.BlockTypes_IC2_Connector.*;
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.*;
|
||||
|
||||
@Mod(modid = IndustrialWires.MODID, version = IndustrialWires.VERSION, dependencies = "required-after:immersiveengineering@[0.12-72,);after:ic2",
|
||||
certificateFingerprint = "7e11c175d1e24007afec7498a1616bef0000027d")
|
||||
@Mod.EventBusSubscriber
|
||||
|
@ -88,6 +93,8 @@ public class IndustrialWires {
|
|||
public static BlockHVMultiblocks hvMultiblocks = null;
|
||||
@GameRegistry.ObjectHolder(MODID+":"+BlockMechanicalMB.NAME)
|
||||
public static BlockMechanicalMB mechanicalMB = null;
|
||||
@GameRegistry.ObjectHolder(MODID+":"+ BlockGeneralHV.NAME)
|
||||
public static BlockGeneralHV generalHV = null;
|
||||
|
||||
@GameRegistry.ObjectHolder(MODID+":"+ItemIC2Coil.NAME)
|
||||
public static ItemIC2Coil coil = null;
|
||||
|
@ -115,11 +122,23 @@ public class IndustrialWires {
|
|||
public static CommonProxy proxy;
|
||||
public static boolean hasIC2;
|
||||
public static boolean hasTechReborn;
|
||||
public static boolean isOldIE;
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent e) {
|
||||
hasIC2 = Loader.isModLoaded("ic2");
|
||||
hasTechReborn = Loader.isModLoaded("techreborn");
|
||||
{
|
||||
double ieThreshold = 12.74275;
|
||||
String ieVer = Loader.instance().getIndexedModList().get(ImmersiveEngineering.MODID).getDisplayVersion();
|
||||
int firstDash = ieVer.indexOf('-');
|
||||
String end = ieVer.substring(firstDash+1);
|
||||
String start = ieVer.substring(0, firstDash);
|
||||
end = end.replaceAll("[^0-9]", "");
|
||||
start = start.replaceAll("[^0-9]", "");
|
||||
double ieVerDouble = Double.parseDouble(start+"."+end);
|
||||
isOldIE = ieVerDouble<ieThreshold;
|
||||
}
|
||||
logger = e.getModLog();
|
||||
new IWConfig();
|
||||
if (hasIC2) {
|
||||
|
@ -149,6 +168,7 @@ public class IndustrialWires {
|
|||
GameRegistry.registerTileEntity(TileEntityPanelCreator.class, MODID + ":panel_creator");
|
||||
GameRegistry.registerTileEntity(TileEntityUnfinishedPanel.class, MODID + ":unfinished_panel");
|
||||
GameRegistry.registerTileEntity(TileEntityComponentPanel.class, MODID + ":single_component_panel");
|
||||
GameRegistry.registerTileEntity(TileEntityDischargeMeter.class, MODID + ":discharge_meter");
|
||||
|
||||
proxy.preInit();
|
||||
Compat.preInit();
|
||||
|
@ -168,6 +188,7 @@ public class IndustrialWires {
|
|||
event.getRegistry().register(new BlockPanel());
|
||||
event.getRegistry().register(new BlockHVMultiblocks());
|
||||
event.getRegistry().register(new BlockMechanicalMB());
|
||||
event.getRegistry().register(new BlockGeneralHV());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -200,11 +221,40 @@ public class IndustrialWires {
|
|||
packetHandler.registerMessage(MessageGUIInteract.HandlerServer.class, MessageGUIInteract.class, 2, Side.SERVER);
|
||||
packetHandler.registerMessage(MessageItemSync.HandlerServer.class, MessageItemSync.class, 3, Side.SERVER);
|
||||
|
||||
if (hasIC2) {
|
||||
ResourceLocation tex = new ResourceLocation(MODID, "blocks/ic2_conn_tin");
|
||||
float[] uvs = {3, 4, 11, 12};
|
||||
WireApi.registerFeedthroughForWiretype(TIN, new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"),
|
||||
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_conn_tin"), tex, uvs, .5, .5,
|
||||
(state) -> state.getBlock() == ic2conn && state.getValue(BlockIC2Connector.TYPE) == TIN_CONN);
|
||||
|
||||
WireApi.registerFeedthroughForWiretype(COPPER_IC2, new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"),
|
||||
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_conn_copper"), tex, uvs, .5, .5,
|
||||
(state) -> state.getBlock() == ic2conn && state.getValue(BlockIC2Connector.TYPE) == COPPER_CONN);
|
||||
|
||||
WireApi.registerFeedthroughForWiretype(GOLD, new ResourceLocation("immersiveengineering:block/connector/connector_mv.obj"),
|
||||
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_mv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_conn_gold"), tex, uvs, .5625, .5625,
|
||||
(state) -> state.getBlock() == ic2conn && state.getValue(BlockIC2Connector.TYPE) == GOLD_CONN);
|
||||
|
||||
WireApi.registerFeedthroughForWiretype(HV, new ResourceLocation("immersiveengineering:block/connector/connector_hv.obj"),
|
||||
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_hv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_conn_hv"), tex, uvs, .75, .75,
|
||||
(state) -> state.getBlock() == ic2conn && state.getValue(BlockIC2Connector.TYPE) == HV_CONN);
|
||||
|
||||
WireApi.registerFeedthroughForWiretype(GLASS, new ResourceLocation("immersiveengineering:block/connector/connector_hv.obj"),
|
||||
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_hv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_conn_glass"), tex, uvs, .75, .75,
|
||||
(state) -> state.getBlock() == ic2conn && state.getValue(BlockIC2Connector.TYPE) == GLASS_CONN);
|
||||
}
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
|
||||
IWPotions.init();
|
||||
Compat.init();
|
||||
MarxOreHandler.init();
|
||||
MechMBPart.init();
|
||||
PanelComponent.init();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
package malte0811.industrialWires.blocks;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
|
@ -59,6 +60,12 @@ public abstract class TileEntityIWBase extends TileEntity {
|
|||
readNBT(pkt.getNbtCompound(), true);
|
||||
}
|
||||
|
||||
public void triggerRenderUpdate() {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
world.addBlockEvent(pos, state.getBlock(), 255, 0);
|
||||
}
|
||||
|
||||
public abstract void writeNBT(NBTTagCompound out, boolean updatePacket);
|
||||
|
||||
public abstract void readNBT(NBTTagCompound in, boolean updatePacket);
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package malte0811.industrialWires.blocks.controlpanel;
|
||||
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.controlpanel.PropertyComponents;
|
||||
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||
|
@ -34,6 +33,8 @@ import net.minecraft.util.math.BlockPos;
|
|||
import javax.annotation.Nonnull;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static malte0811.industrialWires.util.MiscUtils.apply;
|
||||
|
||||
public class TileEntityComponentPanel extends TileEntityPanel {
|
||||
private int rsOut = 0;
|
||||
private Consumer<byte[]> rsIn;
|
||||
|
@ -51,8 +52,10 @@ public class TileEntityComponentPanel extends TileEntityPanel {
|
|||
PanelComponent pc = components.get(0);
|
||||
pc.registerRSOutput(-1, (channel, value, pcTmp)->{
|
||||
rsOut = value;
|
||||
markBlockForUpdate(pos);
|
||||
markBlockForUpdate(pos.offset(components.getTop(), -1));
|
||||
if (!isInvalid()) {
|
||||
markBlockForUpdate(pos);
|
||||
markBlockForUpdate(pos.offset(components.getTop(), -1));
|
||||
}
|
||||
});
|
||||
rsIn = pc.getRSInputHandler(-1, this);
|
||||
updateRS();
|
||||
|
|
|
@ -31,7 +31,6 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
@ -222,46 +221,50 @@ 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) {
|
||||
//TODO prevent clicking through the back of the panel
|
||||
public Pair<PanelComponent, RayTraceResult> getSelectedComponent(EntityPlayer player, Vec3d hitVec, boolean hitAbs) {
|
||||
Matrix4 mat = components.getPanelTopTransformInverse();
|
||||
PanelComponent retPc = null;
|
||||
RayTraceResult retRay = null;
|
||||
Vec3d playerPosRelative = player.getPositionVector().addVector(-pos.getX(), player.getEyeHeight() - pos.getY(), -pos.getZ());
|
||||
Vec3d playerPosTransformed = mat.apply(playerPosRelative);
|
||||
Vec3d hitRel = hitAbs ? hitVec.addVector(-pos.getX(), -pos.getY(), -pos.getZ()) : hitVec;
|
||||
RayTraceResult r = getBoundingBox().calculateIntercept(playerPosRelative, playerPosRelative.add(player.getLookVec().scale(200)));
|
||||
if (r != null && r.hitVec != null) {
|
||||
hitRel = r.hitVec;
|
||||
}
|
||||
Vec3d ray = hitRel.subtract(playerPosRelative.subtract(hitRel).scale(10));
|
||||
Vec3d rayTransformed = mat.apply(ray);
|
||||
{
|
||||
//Check whether the player is clicking on the back of the panel
|
||||
Vec3d hitTransformed = mat.apply(new Vec3d(hitRel.x, hitRel.y, hitRel.z));
|
||||
if (hitTransformed.y < 0) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
for (PanelComponent pc : components) {
|
||||
AxisAlignedBB box = pc.getBlockRelativeAABB();
|
||||
if (box.maxY > box.minY) {
|
||||
box = box.grow(.002);
|
||||
Vec3d hitVec = hitAbs ? hit.addVector(-pos.getX(), -pos.getY(), -pos.getZ()) : hit;
|
||||
hitVec = hitVec.subtract(playerPosRelative.subtract(hitVec).scale(10));
|
||||
RayTraceResult ray = box.calculateIntercept(playerPosTransformed, mat.apply(hitVec));
|
||||
if (ray != null) {
|
||||
RayTraceResult hit = box.calculateIntercept(playerPosTransformed, rayTransformed);
|
||||
if (hit != null) {
|
||||
if (retPc == null) {
|
||||
ray.hitVec = ray.hitVec.subtract(pc.getX(), 0, pc.getY());
|
||||
retPc = pc;
|
||||
retRay = ray;
|
||||
retRay = hit;
|
||||
} else {
|
||||
double oldDist = retRay.hitVec.subtract(playerPosRelative).lengthSquared();
|
||||
double newDist = ray.hitVec.subtract(playerPosRelative).lengthSquared();
|
||||
double newDist = hit.hitVec.subtract(playerPosRelative).lengthSquared();
|
||||
if (newDist < oldDist) {
|
||||
ray.hitVec = ray.hitVec.subtract(pc.getX(), 0, pc.getY());
|
||||
retPc = pc;
|
||||
retRay = ray;
|
||||
retRay = hit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (retRay != null) {
|
||||
retRay.hitVec = retRay.hitVec.subtract(retPc.getX(), 0, retPc.getY());
|
||||
}
|
||||
return retPc != null ? new ImmutablePair<>(retPc, retRay) : null;
|
||||
}
|
||||
|
||||
|
@ -282,12 +285,6 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
|
|||
}
|
||||
}
|
||||
|
||||
public void triggerRenderUpdate() {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
world.addBlockEvent(pos, state.getBlock(), 255, 0);
|
||||
}
|
||||
|
||||
public void registerRS(TileEntityRSPanelConn te) {
|
||||
rsPorts.add(te);
|
||||
}
|
||||
|
|
|
@ -50,6 +50,8 @@ import java.lang.ref.WeakReference;
|
|||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static blusunrize.immersiveengineering.api.energy.wires.WireType.REDSTONE_CATEGORY;
|
||||
|
||||
public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implements IRedstoneConnector, ITickable, INetGUI, IEBlockInterfaces.IDirectionalTile, IBlockBoundsIW {
|
||||
private byte[] out = new byte[16];
|
||||
private boolean dirty = true;
|
||||
|
@ -237,7 +239,7 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
|
|||
|
||||
@Override
|
||||
public boolean canConnectCable(WireType wire, TargetingInfo targetingInfo) {
|
||||
return wire == WireType.REDSTONE && !hasConn;
|
||||
return REDSTONE_CATEGORY.equals(wire.getCategory()) && !hasConn;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -82,7 +82,8 @@ public class TileEntityMechIEtoIC extends TileEntityIWBase implements IDirection
|
|||
@Override
|
||||
public int maxrequestkineticenergyTick(EnumFacing f) {
|
||||
if (f == dir) {
|
||||
return maxOutput;
|
||||
int stored = (int) (ConversionUtil.kinPerRot() * rotBuffer);
|
||||
return Math.min(maxOutput, stored);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* 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.hv;
|
||||
|
||||
import blusunrize.immersiveengineering.api.IEProperties;
|
||||
import malte0811.industrialWires.blocks.BlockIWBase;
|
||||
import malte0811.industrialWires.blocks.IMetaEnum;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockGeneralHV extends BlockIWBase implements IMetaEnum {
|
||||
public static final PropertyEnum<BlockTypes_GeneralHV> PROPERTY = PropertyEnum.create("type",
|
||||
BlockTypes_GeneralHV.class);
|
||||
public static final String NAME = "general_hv";
|
||||
|
||||
public BlockGeneralHV() {
|
||||
super(Material.IRON, NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IProperty[] getProperties() {
|
||||
return new IProperty[] {
|
||||
IEProperties.BOOLEANS[0], PROPERTY, IEProperties.FACING_HORIZONTAL
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTopSolid(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullBlock(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess worldIn, BlockPos pos) {
|
||||
state = super.getActualState(state, worldIn, pos);
|
||||
TileEntity te = worldIn.getTileEntity(pos);
|
||||
if (te instanceof TileEntityDischargeMeter)
|
||||
state = state.withProperty(IEProperties.BOOLEANS[0], ((TileEntityDischargeMeter) te).hasWire);
|
||||
return state;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(@Nonnull World world, @Nonnull IBlockState state) {
|
||||
switch (state.getValue(PROPERTY)) {
|
||||
case DISCHARGE_METER:
|
||||
return new TileEntityDischargeMeter();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockTypes_GeneralHV[] getValues() {
|
||||
return BlockTypes_GeneralHV.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(PROPERTY).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(PROPERTY, getValues()[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -155,15 +155,6 @@ public class BlockJacobsLadder extends BlockIWBase implements IMetaEnum, IPlacem
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
TileEntity te = worldIn.getTileEntity(pos);
|
||||
if (te instanceof TileEntityJacobsLadder) {
|
||||
return ((TileEntityJacobsLadder) te).onActivated(playerIn, hand);
|
||||
}
|
||||
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt(World w, BlockPos pos, ItemStack stack) {
|
||||
int dummyCount = LadderSize.values()[stack.getMetadata()].dummyCount;
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* 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.hv;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public enum BlockTypes_GeneralHV implements IStringSerializable{
|
||||
DISCHARGE_METER;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
* 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.hv;
|
||||
|
||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IPlayerInteraction;
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.IBlockBoundsIW;
|
||||
import malte0811.industrialWires.blocks.TileEntityIWBase;
|
||||
import malte0811.industrialWires.hv.IMarxTarget;
|
||||
import malte0811.industrialWires.util.MiscUtils;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
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 net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileEntityDischargeMeter extends TileEntityIWBase implements IPlayerInteraction, IMarxTarget,
|
||||
IBlockBoundsIW, IDirectionalTile {
|
||||
private static final String HAS_WIRE = "hasWire";
|
||||
private static final String FACING = "facing";
|
||||
private static final String LAST_DISCHARGE = "last";
|
||||
boolean hasWire;
|
||||
EnumFacing facing = EnumFacing.NORTH;
|
||||
double lastDischarge = -1;
|
||||
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound out, boolean updatePacket) {
|
||||
out.setByte(FACING, (byte) facing.getHorizontalIndex());
|
||||
out.setBoolean(HAS_WIRE, hasWire);
|
||||
out.setDouble(LAST_DISCHARGE, lastDischarge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound in, boolean updatePacket) {
|
||||
hasWire = in.getBoolean(HAS_WIRE);
|
||||
facing = EnumFacing.getHorizontal(in.getByte(FACING));
|
||||
lastDischarge = in.getDouble(LAST_DISCHARGE);
|
||||
aabb = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean interact(@Nonnull EnumFacing side, @Nonnull EntityPlayer player, @Nonnull EnumHand hand,
|
||||
@Nonnull ItemStack heldItem, float hitX, float hitY, float hitZ) {
|
||||
if (!world.isRemote) {
|
||||
if (hasWire)
|
||||
return false;
|
||||
if (ApiUtils.compareToOreName(heldItem, "wireAluminum")) {
|
||||
hasWire = true;
|
||||
heldItem.shrink(1);
|
||||
triggerRenderUpdate();
|
||||
} else if (lastDischarge > 0) {
|
||||
player.sendMessage(new TextComponentTranslation(IndustrialWires.MODID + ".chat.marxEnergy",
|
||||
String.format("%.1f", lastDischarge/1e3)));
|
||||
lastDischarge = -1;
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onHit(double energy, TileEntityMarx master) {
|
||||
if (hasWire) {
|
||||
hasWire = false;
|
||||
lastDischarge = energy;
|
||||
triggerRenderUpdate();
|
||||
markDirty();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
AxisAlignedBB aabb = null;
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox() {
|
||||
//if (aabb==null)
|
||||
{
|
||||
Matrix4 mat = new Matrix4();
|
||||
mat.translate(.5, 0, .5);
|
||||
mat.rotate((-facing.getHorizontalAngle()+180)*Math.PI/180, 0, 1, 0);
|
||||
mat.translate(-.5, 0, -.5);
|
||||
aabb = MiscUtils.apply(mat, new AxisAlignedBB(1F/16, 0, 5F/16,
|
||||
10F/16, (hasWire?15F:14F)/16, 11F/16));
|
||||
}
|
||||
return aabb;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumFacing getFacing() {
|
||||
return facing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacing(@Nonnull EnumFacing facing) {
|
||||
this.facing = facing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFacingLimitation() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mirrorFacingOnPlacement(@Nonnull EntityLivingBase placer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHammerRotate(@Nonnull EnumFacing side, float hitX, float hitY, float hitZ, @Nonnull EntityLivingBase entity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRotate(@Nonnull EnumFacing axis) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@
|
|||
package malte0811.industrialWires.blocks.hv;
|
||||
|
||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
|
||||
import blusunrize.immersiveengineering.common.blocks.TileEntityIEBase;
|
||||
import com.elytradev.mirage.lighting.IColoredLight;
|
||||
|
@ -73,18 +74,18 @@ import static malte0811.industrialWires.util.MiscUtils.interpolate;
|
|||
@Optional.Interface(modid = "mirage", iface = "com.elytradev.mirage.lighting.IColoredLight")
|
||||
})
|
||||
public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickable, IHasDummyBlocksIW, ISyncReceiver,
|
||||
IEnergySink, IBlockBoundsIW, IDirectionalTile, IColoredLight {
|
||||
IEnergySink, IBlockBoundsIW, IDirectionalTile, IColoredLight, IEBlockInterfaces.IPlayerInteraction {
|
||||
public EnumFacing facing = EnumFacing.NORTH;
|
||||
private DualEnergyStorage energy;
|
||||
public LadderSize size;
|
||||
|
||||
public Vec3d[] controls;
|
||||
//first and last move along the "rails", only the middle points move in bezier curves
|
||||
public Vec3d[][] controlControls;
|
||||
private Vec3d[][] controlControls;
|
||||
// movement of the controls in blocks/tick
|
||||
public Vec3d[] controlMovement;
|
||||
private double t = 0;
|
||||
public int dummy = 0;
|
||||
private int dummy = 0;
|
||||
public int timeTillActive = -1;
|
||||
private double tStep = 0;
|
||||
private double consumtionEU;
|
||||
|
@ -93,7 +94,7 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
private Vec3d soundPos;
|
||||
public double salt;
|
||||
|
||||
public TileEntityJacobsLadder(LadderSize s) {
|
||||
TileEntityJacobsLadder(LadderSize s) {
|
||||
size = s;
|
||||
initControl();
|
||||
}
|
||||
|
@ -334,7 +335,7 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
private boolean isActive() {
|
||||
if (isDummy()) {
|
||||
TileEntity master = world.getTileEntity(pos.down(dummy));
|
||||
return master instanceof TileEntityJacobsLadder && ((TileEntityJacobsLadder) master).isActive();
|
||||
|
@ -355,8 +356,9 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
e.attackEntityFrom(IWDamageSources.dmg_jacobs, IWConfig.HVStuff.jacobsBaseDmg * (size.ordinal() + 1));
|
||||
}
|
||||
|
||||
public boolean onActivated(EntityPlayer player, EnumHand hand) {
|
||||
ItemStack heldItem = player.getHeldItem(hand);
|
||||
@Override
|
||||
public boolean interact(@Nonnull EnumFacing side, @Nonnull EntityPlayer player,@Nonnull EnumHand hand,
|
||||
@Nonnull ItemStack heldItem, float hitX, float hitY, float hitZ) {
|
||||
TileEntity masterTE = dummy == 0 ? this : world.getTileEntity(pos.down(dummy));
|
||||
if (masterTE instanceof TileEntityJacobsLadder) {
|
||||
TileEntityJacobsLadder master = (TileEntityJacobsLadder) masterTE;
|
||||
|
@ -545,15 +547,15 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
return false;
|
||||
}
|
||||
|
||||
public static final float[] saltColor = {1, 190 / 255F, 50 / 255F};
|
||||
public static final float[] airColor = {1, .85F, 1};
|
||||
private static final float[] saltColor = {1, 190 / 255F, 50 / 255F};
|
||||
private static final float[] airColor = {1, .85F, 1};
|
||||
|
||||
private static final int factor = 20;
|
||||
private static final double smallMin = Math.exp(-.5);
|
||||
private static final double normalMin = Math.exp(-.25 * factor);
|
||||
private static final double hugeMin = Math.exp(-.75 * factor);
|
||||
public static float[] getColor(double t, double salt, LadderSize size) {
|
||||
salt = Math.min(salt, 1);
|
||||
int factor = 20;
|
||||
double smallMin = Math.exp(-.5);
|
||||
double normalMin = Math.exp(-.25 * factor);
|
||||
double hugeMin = Math.exp(-.75 * factor);
|
||||
double saltyness = 0;
|
||||
double t2 = t - .5;
|
||||
switch (size) {
|
||||
|
|
|
@ -28,9 +28,7 @@ import blusunrize.immersiveengineering.api.energy.wires.redstone.IRedstoneConnec
|
|||
import blusunrize.immersiveengineering.api.energy.wires.redstone.RedstoneWireNetwork;
|
||||
import blusunrize.immersiveengineering.common.IEContent;
|
||||
import blusunrize.immersiveengineering.common.blocks.BlockTypes_MetalsIE;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
|
||||
import blusunrize.immersiveengineering.common.blocks.metal.*;
|
||||
import blusunrize.immersiveengineering.common.blocks.wooden.TileEntityWallmount;
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import com.elytradev.mirage.event.GatherLightsEvent;
|
||||
|
@ -40,6 +38,7 @@ import malte0811.industrialWires.blocks.IBlockBoundsIW;
|
|||
import malte0811.industrialWires.blocks.ISyncReceiver;
|
||||
import malte0811.industrialWires.blocks.IWProperties;
|
||||
import malte0811.industrialWires.blocks.TileEntityIWMultiblock;
|
||||
import malte0811.industrialWires.hv.IMarxTarget;
|
||||
import malte0811.industrialWires.hv.MarxOreHandler;
|
||||
import malte0811.industrialWires.network.MessageTileSyncIW;
|
||||
import malte0811.industrialWires.util.DualEnergyStorage;
|
||||
|
@ -50,6 +49,7 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagDouble;
|
||||
|
@ -71,12 +71,14 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static blusunrize.immersiveengineering.api.energy.wires.WireType.REDSTONE_CATEGORY;
|
||||
import static malte0811.industrialWires.blocks.hv.TileEntityMarx.FiringState.FIRE;
|
||||
import static malte0811.industrialWires.util.MiscUtils.getOffset;
|
||||
import static malte0811.industrialWires.util.MiscUtils.offset;
|
||||
import static malte0811.industrialWires.util.NBTKeys.*;
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.IC2_HV_CAT;
|
||||
import static net.minecraft.item.EnumDyeColor.*;
|
||||
|
||||
/**
|
||||
|
@ -98,8 +100,8 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
private double rcTimeConst;
|
||||
private double timeFactor;
|
||||
private double timeFactorBottom;
|
||||
private final static double CAPACITANCE = 0.000_001_6;
|
||||
private final static double MAX_VOLTAGE = 250_000;
|
||||
private final static double CAPACITANCE = 1.6e-6;
|
||||
private final static double MAX_VOLTAGE = 250e3;
|
||||
|
||||
public IWProperties.MarxType type = IWProperties.MarxType.NO_MODEL;
|
||||
private int stageCount = 0;
|
||||
|
@ -124,6 +126,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
@Override
|
||||
public void writeNBT(NBTTagCompound out, boolean updatePacket) {
|
||||
super.writeNBT(out, updatePacket);
|
||||
MiscUtils.writeConnsToNBT(out, this);
|
||||
out.setInteger(TYPE, type.ordinal());
|
||||
out.setInteger(STAGES, stageCount);
|
||||
out.setBoolean(HAS_CONN, hasConnection);
|
||||
|
@ -140,6 +143,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
@Override
|
||||
public void readNBT(NBTTagCompound in, boolean updatePacket) {
|
||||
super.readNBT(in, updatePacket);
|
||||
MiscUtils.loadConnsFromNBT(in, this);
|
||||
type = IWProperties.MarxType.values()[in.getInteger(TYPE)];
|
||||
setStageCount(in.getInteger(STAGES));
|
||||
NBTTagList voltages = in.getTagList(CAP_VOLTAGES, 6);//DOUBLE
|
||||
|
@ -191,38 +195,19 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiConsumer<World, BlockPos> getOriginalBlockPlacer() {
|
||||
IBlockState original = getOriginalBlock();
|
||||
if (original!=null) {
|
||||
return (w, p) -> {
|
||||
w.setBlockState(p, original);
|
||||
TileEntity te = w.getTileEntity(p);
|
||||
if (te instanceof IDirectionalTile&&original.getProperties().containsKey(IEProperties.FACING_ALL)) {
|
||||
((IDirectionalTile) te).setFacing(original.getValue(IEProperties.FACING_ALL));
|
||||
te.markDirty();
|
||||
}
|
||||
if (te instanceof TileEntityWallmount) {
|
||||
((TileEntityWallmount) te).orientation = original.getValue(IEProperties.INT_4);
|
||||
}
|
||||
};
|
||||
}
|
||||
return (a, b)->IndustrialWires.logger.warn(a+", "+b+" wasn't found");//NOP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
ApiUtils.checkForNeedlessTicking(this);
|
||||
FIRING_GENERATORS.remove(this);
|
||||
switch (state) {
|
||||
case NEXT_TICK:
|
||||
state = FIRE;
|
||||
if (world.isRemote) {
|
||||
FIRING_GENERATORS.add(this);
|
||||
IndustrialWires.proxy.playMarxBang(this, getMiddle(), (float) getNormedEnergy(dischargeData.energy));
|
||||
} else {
|
||||
fire();
|
||||
}
|
||||
state = FIRE;
|
||||
break;
|
||||
case FIRE:
|
||||
state = FiringState.CHARGING;
|
||||
|
@ -291,7 +276,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
energyStored = -energyStored;
|
||||
} else {
|
||||
int seed = Utils.RAND.nextInt();
|
||||
genDischarge((float) energyStored, seed);//TODO test on a dedicated server
|
||||
genDischarge((float) energyStored, seed);
|
||||
data.setInteger("randSeed", seed);
|
||||
handleEntities(energyStored);
|
||||
handleOreProcessing(energyStored);//After entities to prevent killing the newly dropped items
|
||||
|
@ -303,12 +288,10 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
|
||||
private void handleOreProcessing(double energyStored) {
|
||||
BlockPos bottom = getBottomElectrode();
|
||||
Vec3d origin = new Vec3d(bottom).addVector(.5, 1, .5);
|
||||
Set<BlockPos> toBreak = new HashSet<>(dischargeData.vertices.length);
|
||||
Set<BlockPos> toBreak = new HashSet<>(stageCount-2);
|
||||
int ores = 0;
|
||||
for (int i = 1;i<dischargeData.vertices.length;i++) {
|
||||
Vec3d vecHere = origin.add(dischargeData.vertices[i]);
|
||||
BlockPos blockHere = new BlockPos(vecHere);
|
||||
for (int i = 1;i<stageCount-1;i++) {
|
||||
BlockPos blockHere = bottom.up(i);
|
||||
if (!world.isAirBlock(blockHere) && canBreak(blockHere)) {
|
||||
toBreak.add(blockHere);
|
||||
ores++;
|
||||
|
@ -322,6 +305,12 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
continue;
|
||||
}
|
||||
if (!world.isAirBlock(here)) {
|
||||
TileEntity te = world.getTileEntity(here);
|
||||
if (te instanceof IMarxTarget) {
|
||||
if (((IMarxTarget) te).onHit(energyPerOre, this)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
ItemStack[] out = MarxOreHandler.getYield(world, here, energyPerOre);
|
||||
for (ItemStack stack : out) {
|
||||
EntityItem item = new EntityItem(world, here.getX() + .5, here.getY() + .5, here.getZ() + .5, stack);
|
||||
|
@ -338,15 +327,13 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
}
|
||||
|
||||
private void handleEntities(double energyStored) {
|
||||
double damageDistSqu = Math.sqrt(energyStored/50e3);
|
||||
double tinnitusDistSqu = Math.sqrt(energyStored)/50;
|
||||
Vec3d v0 = getMiddle();
|
||||
AxisAlignedBB aabb = new AxisAlignedBB(v0.x, v0.y, v0.z, v0.x, v0.y, v0.z);
|
||||
aabb = aabb.grow(0, stageCount/2-1,0);
|
||||
final double sqrtStages = Math.sqrt(stageCount);
|
||||
aabb = aabb.grow(5*sqrtStages);
|
||||
aabb = aabb.grow(tinnitusDistSqu);
|
||||
List<Entity> fools = world.getEntitiesWithinAABB(Entity.class, aabb);
|
||||
double energyNormed = getNormedEnergy(energyStored);
|
||||
double damageDistSqu = energyNormed * stageCount;
|
||||
double tinnitusDistSqu = 5 * energyNormed * stageCount;
|
||||
damageDistSqu *= damageDistSqu;
|
||||
tinnitusDistSqu *= tinnitusDistSqu;
|
||||
if (IWConfig.HVStuff.marxSoundDamage == 2) {
|
||||
|
@ -407,7 +394,6 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
|
||||
@Override
|
||||
public void onSync(NBTTagCompound nbt) {
|
||||
state = FiringState.NEXT_TICK;
|
||||
float energy = nbt.getFloat("energy");
|
||||
if (energy>0) {
|
||||
genDischarge(energy, nbt.getInteger("randSeed"));
|
||||
|
@ -417,6 +403,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
}
|
||||
dischargeData.energy = energy;
|
||||
}
|
||||
state = FiringState.NEXT_TICK;
|
||||
}
|
||||
|
||||
private void genDischarge(float energy, int seed) {
|
||||
|
@ -552,13 +539,18 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
public double insertEnergy(double eu, boolean simulate) {
|
||||
TileEntityMarx master = master(this);
|
||||
if (master!=null) {
|
||||
double ret = master.storage.insertEU(eu, leftover, !simulate);
|
||||
leftover -= ret;
|
||||
double ret = master.storage.insertEU(eu, master.leftover, !simulate);
|
||||
master.leftover -= ret;
|
||||
return eu-ret;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//TODO
|
||||
@Override
|
||||
public void addAvailableEnergy(double amount, Consumer<Double> consume) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getConnectionMaster(@Nullable WireType cableType, TargetingInfo target) {
|
||||
|
@ -571,9 +563,9 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
return false;
|
||||
}
|
||||
if (getRight()==0) {
|
||||
return cableType==WireType.REDSTONE;
|
||||
return REDSTONE_CATEGORY.equals(cableType.getCategory());
|
||||
} else {
|
||||
return cableType==WireType.STEEL||cableType== IC2Wiretype.IC2_TYPES[3];
|
||||
return WireType.HV_CATEGORY.equals(cableType.getCategory())|| IC2_HV_CAT.equals(cableType.getCategory());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -584,7 +576,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
|
||||
@Override
|
||||
public WireType getCableLimiter(TargetingInfo target) {
|
||||
return getRight()==0?WireType.REDSTONE:IC2Wiretype.IC2_TYPES[3];
|
||||
return getRight()==0?WireType.REDSTONE:IC2Wiretype.HV;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -600,6 +592,11 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
@Override
|
||||
public void removeCable(ImmersiveNetHandler.Connection connection) {
|
||||
hasConnection = false;
|
||||
if(world != null)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
world.notifyBlockUpdate(pos, state,state, 3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -617,6 +614,28 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
return getRaytraceOffset(null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void validate()
|
||||
{
|
||||
super.validate();
|
||||
ImmersiveNetHandler.INSTANCE.resetCachedIndirectConnections();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
super.invalidate();
|
||||
if (world.isRemote)
|
||||
ImmersiveNetHandler.INSTANCE.clearConnectionsOriginatingFrom(pos, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean receiveClientEvent(int id, int type) {
|
||||
return MiscUtils.handleUpdate(id, pos, world)||super.receiveClientEvent(id, type);
|
||||
}
|
||||
|
||||
// Redstone wire stuff
|
||||
private RedstoneWireNetwork net = new RedstoneWireNetwork();
|
||||
@Override
|
||||
public void setNetwork(RedstoneWireNetwork net) {
|
||||
|
@ -657,15 +676,15 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
if (master.capVoltages!=null&&master.capVoltages.length==stageCount) {
|
||||
int signalTop = getRSSignalFromVoltage(master.capVoltages[stageCount-1]);
|
||||
int signalBottom = getRSSignalFromVoltage(master.capVoltages[0]);
|
||||
setSignal(ORANGE.getMetadata(), (signalBottom>>4)&0xf, signals);
|
||||
setSignal(MAGENTA.getMetadata(), (signalTop>>4)&0xf, signals);
|
||||
setSignal(LIME.getMetadata(), signalBottom&0xf, signals);
|
||||
setSignal(PINK.getMetadata(), signalTop&0xf, signals);
|
||||
setSignal(ORANGE, (signalBottom>>4)&0xf, signals);
|
||||
setSignal(MAGENTA, (signalTop>>4)&0xf, signals);
|
||||
setSignal(LIME, signalBottom&0xf, signals);
|
||||
setSignal(PINK, signalTop&0xf, signals);
|
||||
}
|
||||
}
|
||||
|
||||
private void setSignal(int channel, int value, byte[] signals) {
|
||||
signals[channel] = (byte) Math.max(value, signals[channel]);
|
||||
private void setSignal(EnumDyeColor channel, int value, byte[] signals) {
|
||||
signals[channel.getMetadata()] = (byte) Math.max(value, signals[channel.getMetadata()]);
|
||||
}
|
||||
|
||||
public void setStageCount(int stageCount) {
|
||||
|
@ -729,11 +748,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
final int stageCount;
|
||||
Discharge(int stages) {
|
||||
stageCount = stages;
|
||||
int count = 1;
|
||||
while (count<stageCount) {
|
||||
count <<= 1;
|
||||
}
|
||||
count = 8;
|
||||
int count = stages/5+1;
|
||||
vertices = new Vec3d[2*count];
|
||||
vertices[0] = new Vec3d(0, -.5F, 0);
|
||||
for (int i = 1;i<vertices.length;i++) {
|
||||
|
@ -745,10 +760,6 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
|
||||
// Meant to be const
|
||||
private final Vec3d side = new Vec3d(0, 0, 1);
|
||||
//used for calculation buffering
|
||||
private Vec3d diff;
|
||||
private Vec3d center;
|
||||
private Vec3d v0;
|
||||
private Matrix4 transform = new Matrix4();
|
||||
|
||||
void genMarxPoint(int randSeed) {
|
||||
|
@ -760,8 +771,8 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
*/
|
||||
void genMarxPoint(int min, int max, Random rand) {
|
||||
int toGenerate = (min+max)/2;
|
||||
diff = vertices[max].subtract(vertices[min]);
|
||||
v0 = diff.crossProduct(side);
|
||||
Vec3d diff = vertices[max].subtract(vertices[min]);
|
||||
Vec3d v0 = diff.crossProduct(side);
|
||||
transform.setIdentity();
|
||||
double diffLength = diff.lengthVector();
|
||||
double noise = Math.sqrt(diffLength)*rand.nextDouble()*1/(1+Math.abs(stageCount/2.0-toGenerate))*.75;
|
||||
|
@ -771,7 +782,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
v0 = v0.scale((float) (noise/v0.lengthVector()));
|
||||
diff = diff.scale(1/diffLength);
|
||||
transform.rotate(Math.PI*2*rand.nextDouble(), diff.x, diff.y, diff.z);
|
||||
center = vertices[max].add(vertices[min]).scale(.5);
|
||||
Vec3d center = vertices[max].add(vertices[min]).scale(.5);
|
||||
vertices[toGenerate] = transform.apply(v0);
|
||||
vertices[toGenerate] = center.add(vertices[toGenerate]);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
||||
private static final PropertyEnum<BlockTypes_IC2_Connector> type = PropertyEnum.create("type", BlockTypes_IC2_Connector.class);
|
||||
public static final PropertyEnum<BlockTypes_IC2_Connector> TYPE = PropertyEnum.create("type", BlockTypes_IC2_Connector.class);
|
||||
public static final String NAME = "ic2_connector";
|
||||
|
||||
public BlockIC2Connector() {
|
||||
|
@ -71,7 +71,7 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
|
||||
@Override
|
||||
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
|
||||
for (int i = 0; i < type.getAllowedValues().size(); i++) {
|
||||
for (int i = 0; i < TYPE.getAllowedValues().size(); i++) {
|
||||
list.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
|
||||
@Override
|
||||
protected IProperty<?>[] getProperties() {
|
||||
return new IProperty[]{type, IEProperties.FACING_ALL};
|
||||
return new IProperty[]{TYPE, IEProperties.FACING_ALL};
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -105,7 +105,7 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
@Nonnull
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return super.getStateFromMeta(meta).withProperty(type, BlockTypes_IC2_Connector.values()[meta]);
|
||||
return super.getStateFromMeta(meta).withProperty(TYPE, BlockTypes_IC2_Connector.values()[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -120,7 +120,7 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
|
||||
@Override
|
||||
public TileEntity createTileEntity(@Nonnull World world, @Nonnull IBlockState state) {
|
||||
switch (state.getValue(type)) {
|
||||
switch (state.getValue(TYPE)) {
|
||||
case TIN_CONN:
|
||||
return new TileEntityIC2ConnectorTin(false);
|
||||
case TIN_RELAY:
|
||||
|
@ -150,8 +150,10 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
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));
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.eu_per_tick", IC2Wiretype.IC2_TYPES[type].getTransferRate() / 8));
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.power_tier", (type%5) + 1));
|
||||
IC2Wiretype wire = IC2Wiretype.ALL[type];
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.eu_per_tick",
|
||||
wire.getTransferRate() / wire.getFactor()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,6 +193,6 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(type).ordinal();
|
||||
return state.getValue(TYPE).ordinal();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
package malte0811.industrialWires.blocks.wire;
|
||||
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.COPPER_IC2;
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.IC2_COPPER_CAT;
|
||||
|
||||
public class TileEntityIC2ConnectorCopper extends TileEntityIC2ConnectorTin {
|
||||
|
||||
|
@ -31,12 +33,12 @@ public class TileEntityIC2ConnectorCopper extends TileEntityIC2ConnectorTin {
|
|||
|
||||
{
|
||||
tier = 2;
|
||||
maxStored = IC2Wiretype.IC2_TYPES[1].getTransferRate() / 8;
|
||||
maxStored = COPPER_IC2.getTransferRate() / COPPER_IC2.getFactor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(WireType t) {
|
||||
return t == IC2Wiretype.IC2_TYPES[1];
|
||||
return IC2_COPPER_CAT.equals(t.getCategory());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
package malte0811.industrialWires.blocks.wire;
|
||||
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.GLASS;
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.IC2_GLASS_CAT;
|
||||
|
||||
public class TileEntityIC2ConnectorGlass extends TileEntityIC2ConnectorHV {
|
||||
public TileEntityIC2ConnectorGlass(boolean rel) {
|
||||
|
@ -30,11 +32,11 @@ public class TileEntityIC2ConnectorGlass extends TileEntityIC2ConnectorHV {
|
|||
|
||||
{
|
||||
tier = 5;
|
||||
maxStored = IC2Wiretype.IC2_TYPES[4].getTransferRate() / 8;
|
||||
maxStored = GLASS.getTransferRate() / GLASS.getFactor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(WireType t) {
|
||||
return t == IC2Wiretype.IC2_TYPES[4];
|
||||
return IC2_GLASS_CAT.equals(t.getCategory());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,12 @@ package malte0811.industrialWires.blocks.wire;
|
|||
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.GOLD;
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.IC2_GOLD_CAT;
|
||||
|
||||
public class TileEntityIC2ConnectorGold extends TileEntityIC2ConnectorTin {
|
||||
|
||||
public TileEntityIC2ConnectorGold(boolean rel) {
|
||||
|
@ -35,12 +37,12 @@ public class TileEntityIC2ConnectorGold extends TileEntityIC2ConnectorTin {
|
|||
|
||||
{
|
||||
tier = 3;
|
||||
maxStored = IC2Wiretype.IC2_TYPES[2].getTransferRate() / 8;
|
||||
maxStored = GOLD.getTransferRate() / GOLD.getFactor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(WireType t) {
|
||||
return t == IC2Wiretype.IC2_TYPES[2];
|
||||
return IC2_GOLD_CAT.equals(t.getCategory());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,10 +20,12 @@ package malte0811.industrialWires.blocks.wire;
|
|||
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.HV;
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.IC2_HV_CAT;
|
||||
|
||||
public class TileEntityIC2ConnectorHV extends TileEntityIC2ConnectorTin {
|
||||
|
||||
public TileEntityIC2ConnectorHV(boolean rel) {
|
||||
|
@ -35,12 +37,12 @@ public class TileEntityIC2ConnectorHV extends TileEntityIC2ConnectorTin {
|
|||
|
||||
{
|
||||
tier = 4;
|
||||
maxStored = IC2Wiretype.IC2_TYPES[3].getTransferRate() / 8;
|
||||
maxStored = HV.getTransferRate() / HV.getFactor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(WireType t) {
|
||||
return t == IC2Wiretype.IC2_TYPES[3];
|
||||
return IC2_HV_CAT.equals(t.getCategory());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,14 +19,10 @@ package malte0811.industrialWires.blocks.wire;
|
|||
|
||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||
import blusunrize.immersiveengineering.api.TargetingInfo;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.*;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.AbstractConnection;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConnectable;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import ic2.api.energy.event.EnergyTileLoadEvent;
|
||||
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||
import ic2.api.energy.tile.IEnergyAcceptor;
|
||||
|
@ -36,25 +32,26 @@ import ic2.api.energy.tile.IEnergySource;
|
|||
import malte0811.industrialWires.IIC2Connector;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.IBlockBoundsIW;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import reborncore.api.power.IEnergyInterfaceTile;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.IC2_TIN_CAT;
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.TIN;
|
||||
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = "ic2"),
|
||||
|
@ -71,7 +68,7 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
//IE net to IC2 net buffer
|
||||
double outBuffer = 0;
|
||||
double maxToMachine = 0;
|
||||
double maxStored = IC2Wiretype.IC2_TYPES[0].getTransferRate() / 8;
|
||||
double maxStored = TIN.getTransferRate() / TIN.getFactor();
|
||||
int tier = 1;
|
||||
|
||||
TileEntityIC2ConnectorTin(boolean rel) {
|
||||
|
@ -86,32 +83,24 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
if (first) {
|
||||
if (!world.isRemote&& IndustrialWires.hasIC2)
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
|
||||
ImmersiveNetHandler.INSTANCE.onTEValidated(this);
|
||||
first = false;
|
||||
}
|
||||
if (!world.isRemote) {
|
||||
if (inBuffer > .1) {
|
||||
transferPower();
|
||||
}
|
||||
if (outBuffer>.1&&IndustrialWires.hasTechReborn) {
|
||||
TileEntity output = Utils.getExistingTileEntity(world, pos.offset(facing));
|
||||
if (output instanceof IEnergyInterfaceTile) {
|
||||
IEnergyInterfaceTile out = (IEnergyInterfaceTile) output;
|
||||
if (out.canAcceptEnergy(facing.getOpposite())) {
|
||||
outBuffer -= out.addEnergy(Math.min(outBuffer, maxToMachine));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void transferPower() {
|
||||
Set<AbstractConnection> conns = new HashSet<>(ImmersiveNetHandler.INSTANCE.getIndirectEnergyConnections(pos, world));
|
||||
Set<AbstractConnection> conns = ImmersiveNetHandler.INSTANCE.getIndirectEnergyConnections(pos, world, true);
|
||||
Map<AbstractConnection, Pair<IIC2Connector, Double>> maxOutputs = new HashMap<>();
|
||||
double outputMax = Math.min(inBuffer, maxToNet);
|
||||
double sum = 0;
|
||||
for (AbstractConnection c : conns) {
|
||||
IImmersiveConnectable iic = ApiUtils.toIIC(c.end, world);
|
||||
if (iic instanceof IIC2Connector) {
|
||||
if (iic instanceof IIC2Connector&&iic.isEnergyOutput()) {
|
||||
double tmp = outputMax - ((IIC2Connector) iic).insertEnergy(outputMax, true);
|
||||
if (tmp > .00000001) {
|
||||
maxOutputs.put(c, new ImmutablePair<>((IIC2Connector) iic, tmp));
|
||||
|
@ -119,32 +108,40 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
}
|
||||
}
|
||||
}
|
||||
if (sum < .0001) {
|
||||
return;
|
||||
}
|
||||
final double oldInBuf = outputMax;
|
||||
HashMap<Connection, Integer> transferedPerConn = ImmersiveNetHandler.INSTANCE.getTransferedRates(world.provider.getDimension());
|
||||
for (AbstractConnection c : maxOutputs.keySet()) {
|
||||
Pair<IIC2Connector, Double> p = maxOutputs.get(c);
|
||||
double out = oldInBuf * p.getRight() / sum;
|
||||
double loss = getAverageLossRate(c);
|
||||
double inserted = out - p.getLeft().insertEnergy(out - loss, false);
|
||||
inBuffer -= inserted;
|
||||
float intermediaryLoss = 0;
|
||||
HashSet<IImmersiveConnectable> passedConnectors = new HashSet<>();
|
||||
double energyAtConn = inserted + loss;
|
||||
for (Connection sub : c.subConnections) {
|
||||
int transferredPerCon = transferedPerConn.getOrDefault(sub, 0);
|
||||
energyAtConn -= sub.cableType.getLossRatio() * sub.length;
|
||||
ImmersiveNetHandler.INSTANCE.getTransferedRates(world.provider.getDimension()).put(sub, (int) (transferredPerCon + energyAtConn));
|
||||
IImmersiveConnectable subStart = ApiUtils.toIIC(sub.start, world);
|
||||
IImmersiveConnectable subEnd = ApiUtils.toIIC(sub.end, world);
|
||||
if (subStart != null && passedConnectors.add(subStart))
|
||||
subStart.onEnergyPassthrough((int) (inserted - inserted * intermediaryLoss));
|
||||
if (subEnd != null && passedConnectors.add(subEnd))
|
||||
subEnd.onEnergyPassthrough((int) (inserted - inserted * intermediaryLoss));
|
||||
if (sum > .0001) {
|
||||
final double oldInBuf = outputMax;
|
||||
HashMap<Connection, Integer> transferedPerConn = ImmersiveNetHandler.INSTANCE.getTransferedRates(world.provider.getDimension());
|
||||
for (Map.Entry<AbstractConnection, Pair<IIC2Connector, Double>> entry : maxOutputs.entrySet()) {
|
||||
Pair<IIC2Connector, Double> p = entry.getValue();
|
||||
AbstractConnection c = entry.getKey();
|
||||
double out = oldInBuf * p.getRight() / sum;
|
||||
double loss = getAverageLossRate(c);
|
||||
double inserted = out - p.getLeft().insertEnergy(out - loss, false);
|
||||
inBuffer -= inserted;
|
||||
float intermediaryLoss = 0;
|
||||
HashSet<IImmersiveConnectable> passedConnectors = new HashSet<>();
|
||||
double energyAtConn = inserted + loss;
|
||||
for (Connection sub : c.subConnections) {
|
||||
int transferredPerCon = transferedPerConn.getOrDefault(sub, 0);
|
||||
energyAtConn -= sub.cableType.getLossRatio() * sub.length;
|
||||
ImmersiveNetHandler.INSTANCE.getTransferedRates(world.provider.getDimension()).put(sub, (int) (transferredPerCon + energyAtConn));
|
||||
IImmersiveConnectable subStart = ApiUtils.toIIC(sub.start, world);
|
||||
IImmersiveConnectable subEnd = ApiUtils.toIIC(sub.end, world);
|
||||
if (subStart != null && passedConnectors.add(subStart))
|
||||
subStart.onEnergyPassthrough((int) (inserted - inserted * intermediaryLoss));
|
||||
if (subEnd != null && passedConnectors.add(subEnd))
|
||||
subEnd.onEnergyPassthrough((int) (inserted - inserted * intermediaryLoss));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (inBuffer>0) {
|
||||
conns.stream().map((ac)->ApiUtils.toIIC(ac.end, world)).forEach((iic)-> {
|
||||
if (iic instanceof IIC2Connector) {
|
||||
((IIC2Connector) iic).addAvailableEnergy(inBuffer, (d)->inBuffer-=d);
|
||||
}
|
||||
});
|
||||
addAvailableEnergy(0D, null);
|
||||
}
|
||||
}
|
||||
|
||||
private double getAverageLossRate(AbstractConnection conn) {
|
||||
|
@ -189,12 +186,6 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
first = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getRaytraceOffset(IImmersiveConnectable link) {
|
||||
EnumFacing side = facing.getOpposite();
|
||||
return new Vec3d(.5 + side.getFrontOffsetX() * .0625, .5 + side.getFrontOffsetY() * .0625, .5 + side.getFrontOffsetZ() * .0625);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getConnectionOffset(Connection con) {
|
||||
EnumFacing side = facing.getOpposite();
|
||||
|
@ -213,12 +204,12 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectCable(WireType cableType, TargetingInfo target) {
|
||||
return (limitType == null || (this.isRelay() && limitType == cableType)) && canConnect(cableType);
|
||||
public boolean canConnectCable(WireType cableType, TargetingInfo target, Vec3i offset) {
|
||||
return (limitType == null || (this.isRelay() && WireApi.canMix(cableType, limitType))) && canConnect(cableType);
|
||||
}
|
||||
|
||||
public boolean canConnect(WireType t) {
|
||||
return t == IC2Wiretype.IC2_TYPES[0];
|
||||
return IC2_TIN_CAT.equals(t.getCategory());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -277,6 +268,50 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
markDirty();
|
||||
}
|
||||
|
||||
|
||||
private List<Pair<Double, Consumer<Double>>> sources = new ArrayList<>();
|
||||
private long lastSourceUpdate = 0;
|
||||
@Override
|
||||
public void addAvailableEnergy(double amount, Consumer<Double> consume) {
|
||||
long currentTime = world.getTotalWorldTime();
|
||||
if (lastSourceUpdate!=currentTime)
|
||||
{
|
||||
sources.clear();
|
||||
Pair<Double, Consumer<Double>> own = getOwnEnergyIC2();
|
||||
if (own!=null)
|
||||
sources.add(own);
|
||||
lastSourceUpdate = currentTime;
|
||||
}
|
||||
if (amount>0&&consume!=null)
|
||||
sources.add(new ImmutablePair<>(amount, consume));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Pair<Double,Consumer<Double>> getOwnEnergyIC2()
|
||||
{
|
||||
if (isRelay())
|
||||
return null;
|
||||
return new ImmutablePair<>(inBuffer, (d)->inBuffer -= d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDamageAmount(Entity e, Connection c)
|
||||
{
|
||||
float max = getMaxDamage(c);
|
||||
if (max==0||world.getTotalWorldTime()-lastSourceUpdate>1)
|
||||
return 0;
|
||||
float energy = 0;
|
||||
for (int i = 0;i<sources.size()&&energy<max;i++) {
|
||||
energy += Math.min(sources.get(i).getLeft(), max-energy);
|
||||
}
|
||||
return (float) Math.ceil(energy/64);//Same as IC2 uses
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getMaxDamage(Connection c) {
|
||||
return c.cableType.getTransferRate()/8;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid="ic2")
|
||||
public int getSourceTier() {
|
||||
|
|
|
@ -45,14 +45,14 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.ScreenShotHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
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.event.*;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
@ -64,6 +64,7 @@ import java.util.Map;
|
|||
|
||||
@Mod.EventBusSubscriber(modid = IndustrialWires.MODID, value = Side.CLIENT)
|
||||
public class ClientEventHandler {
|
||||
public static boolean shouldScreenshot = false;
|
||||
@SubscribeEvent
|
||||
public static void renderOverlayPost(RenderGameOverlayEvent.Post e) {
|
||||
if (ClientUtils.mc().player != null && e.getType() == RenderGameOverlayEvent.ElementType.TEXT) {
|
||||
|
@ -73,7 +74,7 @@ public class ClientEventHandler {
|
|||
if (!player.getHeldItem(hand).isEmpty()) {
|
||||
ItemStack equipped = player.getHeldItem(hand);
|
||||
if (OreDictionary.itemMatches(new ItemStack(IndustrialWires.coil, 1, OreDictionary.WILDCARD_VALUE), equipped, false)) {
|
||||
IC2Wiretype type = IC2Wiretype.IC2_TYPES[equipped.getItemDamage()];
|
||||
IC2Wiretype type = IC2Wiretype.ALL[equipped.getItemDamage()];
|
||||
int color = type.getColour(null);
|
||||
String s = I18n.format(IndustrialWires.MODID + ".desc.wireLength", ItemIC2Coil.getLength(equipped));
|
||||
ClientUtils.font().drawString(s, e.getResolution().getScaledWidth() / 2 - ClientUtils.font().getStringWidth(s) / 2, e.getResolution().getScaledHeight() - GuiIngameForge.left_height - 40, color, true);
|
||||
|
@ -171,4 +172,14 @@ public class ClientEventHandler {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public static void renderWorldLastLow(RenderWorldLastEvent ev) {
|
||||
if (shouldScreenshot) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
ITextComponent comp = ScreenShotHelper.saveScreenshot(mc.mcDataDir, mc.displayWidth, mc.displayHeight, mc.getFramebuffer());//TODO
|
||||
mc.player.sendMessage(comp);
|
||||
shouldScreenshot = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ package malte0811.industrialWires.client;
|
|||
|
||||
import blusunrize.immersiveengineering.api.ManualHelper;
|
||||
import blusunrize.immersiveengineering.api.ManualPageMultiblock;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireApi;
|
||||
import blusunrize.immersiveengineering.client.ClientUtils;
|
||||
import blusunrize.immersiveengineering.client.models.smart.ConnLoader;
|
||||
import blusunrize.immersiveengineering.common.Config;
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import blusunrize.lib.manual.ManualInstance;
|
||||
|
@ -41,7 +41,9 @@ import malte0811.industrialWires.client.gui.GuiPanelComponent;
|
|||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialWires.client.gui.GuiRSPanelConn;
|
||||
import malte0811.industrialWires.client.gui.GuiRenameKey;
|
||||
import malte0811.industrialWires.client.manual.TextSplitter;
|
||||
import malte0811.industrialWires.client.panelmodel.PanelModelLoader;
|
||||
import malte0811.industrialWires.client.render.Shaders;
|
||||
import malte0811.industrialWires.client.render.TileRenderJacobsLadder;
|
||||
import malte0811.industrialWires.client.render.TileRenderMBConverter;
|
||||
import malte0811.industrialWires.client.render.TileRenderMarx;
|
||||
|
@ -51,6 +53,7 @@ import malte0811.industrialWires.hv.MarxOreHandler;
|
|||
import malte0811.industrialWires.hv.MultiblockMarx;
|
||||
import malte0811.industrialWires.items.ItemIC2Coil;
|
||||
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||
import malte0811.industrialWires.util.CommandIWClient;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.MovingSound;
|
||||
|
@ -69,53 +72,57 @@ import net.minecraft.util.SoundEvent;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.ClientCommandHandler;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.obj.OBJLoader;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
@Override
|
||||
public void preInit() {
|
||||
super.preInit();
|
||||
if (IndustrialWires.hasIC2) {
|
||||
ConnLoader.baseModels.put("ic2_conn_tin", new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_conn_tin", ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv",
|
||||
WireApi.registerConnectorForRender("ic2_conn_tin", new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"),
|
||||
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_conn_tin"));
|
||||
ConnLoader.baseModels.put("ic2_relay_tin", new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_relay_tin", ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv",
|
||||
WireApi.registerConnectorForRender("ic2_relay_tin", new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"),
|
||||
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_relay_tin"));
|
||||
|
||||
ConnLoader.baseModels.put("ic2_conn_copper", new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_conn_copper", ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv",
|
||||
WireApi.registerConnectorForRender("ic2_conn_copper", new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"),
|
||||
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_conn_copper"));
|
||||
ConnLoader.baseModels.put("ic2_relay_copper", new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_relay_copper", ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv",
|
||||
WireApi.registerConnectorForRender("ic2_relay_copper", new ResourceLocation("immersiveengineering:block/connector/connector_lv.obj"),
|
||||
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_lv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_relay_copper"));
|
||||
|
||||
ConnLoader.baseModels.put("ic2_conn_gold", new ResourceLocation("immersiveengineering:block/connector/connector_mv.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_conn_gold", ImmutableMap.of("#immersiveengineering:blocks/connector_connector_mv",
|
||||
WireApi.registerConnectorForRender("ic2_conn_gold", new ResourceLocation("immersiveengineering:block/connector/connector_mv.obj"),
|
||||
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_mv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_conn_gold"));
|
||||
ConnLoader.baseModels.put("ic2_relay_gold", new ResourceLocation("immersiveengineering:block/connector/connector_mv.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_relay_gold", ImmutableMap.of("#immersiveengineering:blocks/connector_connector_mv",
|
||||
WireApi.registerConnectorForRender("ic2_relay_gold", new ResourceLocation("immersiveengineering:block/connector/connector_mv.obj"),
|
||||
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_mv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_relay_gold"));
|
||||
|
||||
ConnLoader.baseModels.put("ic2_conn_hv", new ResourceLocation("immersiveengineering:block/connector/connector_hv.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_conn_hv", ImmutableMap.of("#immersiveengineering:blocks/connector_connector_hv",
|
||||
WireApi.registerConnectorForRender("ic2_conn_hv", new ResourceLocation("immersiveengineering:block/connector/connector_hv.obj"),
|
||||
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_hv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_conn_hv"));
|
||||
ConnLoader.baseModels.put("ic2_relay_hv", new ResourceLocation("immersiveengineering:block/connector/relay_hv.obj"));
|
||||
WireApi.registerConnectorForRender("ic2_relay_hv", new ResourceLocation("immersiveengineering:block/connector/relay_hv.obj"), null);
|
||||
|
||||
ConnLoader.baseModels.put("ic2_conn_glass", new ResourceLocation("immersiveengineering:block/connector/connector_hv.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_conn_glass", ImmutableMap.of("#immersiveengineering:blocks/connector_connector_hv",
|
||||
WireApi.registerConnectorForRender("ic2_conn_glass", new ResourceLocation("immersiveengineering:block/connector/connector_hv.obj"),
|
||||
ImmutableMap.of("#immersiveengineering:blocks/connector_connector_hv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_conn_glass"));
|
||||
ConnLoader.baseModels.put("ic2_relay_glass", new ResourceLocation("immersiveengineering:block/connector/relay_hv.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_relay_glass", ImmutableMap.of("#immersiveengineering:blocks/connector_relay_hv",
|
||||
WireApi.registerConnectorForRender("ic2_relay_glass", new ResourceLocation("immersiveengineering:block/connector/relay_hv.obj"),
|
||||
ImmutableMap.of("#immersiveengineering:blocks/connector_relay_hv",
|
||||
IndustrialWires.MODID + ":blocks/ic2_relay_glass"));
|
||||
}
|
||||
ConnLoader.baseModels.put("rs_panel_conn", new ResourceLocation("industrialwires:block/rs_panel_conn.obj"));
|
||||
WireApi.registerConnectorForRender("rs_panel_conn", new ResourceLocation("industrialwires:block/rs_panel_conn.obj"), null);
|
||||
|
||||
ConnLoader.baseModels.put("empty", new ResourceLocation("builtin/generated"));
|
||||
WireApi.registerConnectorForRender("empty", new ResourceLocation("builtin/generated"), null);
|
||||
|
||||
OBJLoader.INSTANCE.addDomain(IndustrialWires.MODID);
|
||||
ModelLoaderRegistry.registerLoader(new PanelModelLoader());
|
||||
|
@ -124,22 +131,20 @@ public class ClientProxy extends CommonProxy {
|
|||
TileRenderMBConverter tesr = new TileRenderMBConverter();
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMultiblockConverter.class, tesr);
|
||||
((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(tesr);
|
||||
Shaders.initShaders(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
super.postInit();
|
||||
ManualInstance m = ManualHelper.getManual();
|
||||
if (IndustrialWires.hasIC2)
|
||||
{
|
||||
if (IndustrialWires.hasIC2) {
|
||||
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());
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
wireRecipes[0][3 * i + j] = new PositionedItemStack(tinCableList, 18 * i + xBase, 18 * j);
|
||||
}
|
||||
}
|
||||
|
@ -147,20 +152,15 @@ public class ClientProxy extends CommonProxy {
|
|||
ItemIC2Coil.setLength(tmp, 9);
|
||||
wireRecipes[0][9] = new PositionedItemStack(tmp, 18 * 4 + xBase, 18);
|
||||
Random r = new Random();
|
||||
for (int i = 1; i < 3; i++)
|
||||
{
|
||||
for (int i = 1; i < 3; i++) {
|
||||
int lengthSum = 0;
|
||||
for (int j1 = 0; j1 < 3; j1++)
|
||||
{
|
||||
for (int j2 = 0; j2 < 3; j2++)
|
||||
{
|
||||
if (r.nextBoolean())
|
||||
{
|
||||
for (int j1 = 0; j1 < 3; j1++) {
|
||||
for (int j2 = 0; j2 < 3; j2++) {
|
||||
if (r.nextBoolean()) {
|
||||
// cable
|
||||
lengthSum++;
|
||||
wireRecipes[i][3 * j1 + j2] = new PositionedItemStack(tinCableList, 18 * j1 + xBase, 18 * j2);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
// wire coil
|
||||
int length = r.nextInt(99) + 1;
|
||||
tmp = new ItemStack(IndustrialWires.coil);
|
||||
|
@ -181,8 +181,7 @@ public class ClientProxy extends CommonProxy {
|
|||
new ManualPages.Text(m, "industrialwires.wires1"),
|
||||
new ManualPages.CraftingMulti(m, "industrialwires.wires2", (Object[]) wireRecipes)
|
||||
);
|
||||
if (IndustrialWires.mechConv != null)
|
||||
{
|
||||
if (IndustrialWires.mechConv != null) {
|
||||
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)),
|
||||
|
@ -190,12 +189,12 @@ public class ClientProxy extends CommonProxy {
|
|||
);
|
||||
}
|
||||
}
|
||||
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();
|
||||
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();
|
||||
|
||||
ClientUtils.mc().getItemColors().registerItemColorHandler((stack, pass) -> {
|
||||
ClientUtils.mc().getItemColors().registerItemColorHandler((stack, pass) -> {
|
||||
if (pass == 1) {
|
||||
PanelComponent pc = ItemPanelComponent.componentFromStack(stack);
|
||||
if (pc != null) {
|
||||
|
@ -205,13 +204,6 @@ public class ClientProxy extends CommonProxy {
|
|||
return ~0;
|
||||
}, IndustrialWires.panelComponent);
|
||||
|
||||
if (IndustrialWires.mechConv != null) {
|
||||
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))
|
||||
);
|
||||
}
|
||||
Config.manual_doubleA.put("iwJacobsUsage", IWConfig.HVStuff.jacobsUsageEU);
|
||||
Config.manual_int.put("iwKeysOnRing", IWConfig.maxKeysOnRing);
|
||||
m.addEntry("industrialwires.jacobs", IndustrialWires.MODID,
|
||||
|
@ -247,38 +239,36 @@ public class ClientProxy extends CommonProxy {
|
|||
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))
|
||||
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))
|
||||
);
|
||||
List<MarxOreHandler.OreInfo> ores = MarxOreHandler.getRecipes();
|
||||
List<ManualPages> marxEntry = new ArrayList<>();
|
||||
marxEntry.add(new ManualPages.Text(m, IndustrialWires.MODID + ".marx0"));
|
||||
marxEntry.add(new ManualPageMultiblock(m, IndustrialWires.MODID + ".marx1", MultiblockMarx.INSTANCE));
|
||||
marxEntry.add(new ManualPages.Text(m, IndustrialWires.MODID + ".marx2"));
|
||||
marxEntry.add(new ManualPages.Text(m, IndustrialWires.MODID + ".marx3"));
|
||||
marxEntry.add(new ManualPages.Text(m, IndustrialWires.MODID + ".marx4"));
|
||||
marxEntry.add(new ManualPages.Text(m, IndustrialWires.MODID + ".marx5"));
|
||||
marxEntry.add(new ManualPages.Text(m, IndustrialWires.MODID + ".marx6"));
|
||||
String text = I18n.format("ie.manual.entry.industrialwires.marx7")+"\n";
|
||||
for (int i = 0; i < ores.size(); ) {
|
||||
for (int j = 0; j < 12 && i < ores.size(); j+=4, 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\n";
|
||||
text += I18n.format(IndustrialWires.MODID + ".desc.output") + ": " + Utils.formatDouble(curr.maxYield, "0.#") + "x" + curr.output.get().getDisplayName() + "\n";
|
||||
if (curr.outputSmall != null && !curr.outputSmall.get().isEmpty())
|
||||
{
|
||||
text += I18n.format(IndustrialWires.MODID + ".desc.alt") + ": " + curr.smallMax + "x" + curr.outputSmall.get().getDisplayName() + "\n";
|
||||
j++;
|
||||
}
|
||||
text += I18n.format(IndustrialWires.MODID + ".desc.ideal_e") + ": " + Utils.formatDouble(curr.avgEnergy * MarxOreHandler.defaultEnergy / 1000, "0.#") + " kJ\n\n";
|
||||
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>";
|
||||
}
|
||||
text += I18n.format(IndustrialWires.MODID + ".desc.ideal_e") + ": " + Utils.formatDouble(curr.avgEnergy * MarxOreHandler.defaultEnergy / 1000, "0.#") + " kJ<br><br>";
|
||||
}
|
||||
marxEntry.add(new ManualPages.Text(m, text));
|
||||
text = "";
|
||||
}
|
||||
boolean uni = m.fontRenderer.getUnicodeFlag();
|
||||
m.fontRenderer.setUnicodeFlag(true);
|
||||
m.entryRenderPre();
|
||||
TextSplitter splitter = new TextSplitter(m.fontRenderer::getStringWidth, 16, 120,
|
||||
(s) -> new ManualPages.Text(m, s));
|
||||
splitter.addSpecialPage(0, 0, 6,
|
||||
(s) -> new ManualPageMultiblock(m, s,
|
||||
MultiblockMarx.INSTANCE));
|
||||
splitter.split(text);
|
||||
m.entryRenderPost();
|
||||
m.fontRenderer.setUnicodeFlag(uni);
|
||||
List<ManualPages> marxEntry = splitter.toManualEntry();
|
||||
m.addEntry("industrialwires.marx", IndustrialWires.MODID, marxEntry.toArray(new ManualPages[marxEntry.size()]));
|
||||
|
||||
ClientCommandHandler.instance.registerCommand(new CommandIWClient());
|
||||
}
|
||||
|
||||
private static final ResourceLocation TINNITUS_LOC = new ResourceLocation(IndustrialWires.MODID, "tinnitus");
|
||||
|
|
|
@ -12,6 +12,7 @@ import malte0811.industrialWires.containers.ContainerPanelComponent;
|
|||
import malte0811.industrialWires.controlpanel.IConfigurableComponent;
|
||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.network.MessageItemSync;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
|
@ -207,8 +208,13 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
for (GuiIntChooser choose : intChoosers) {
|
||||
choose.drawChooser();
|
||||
}
|
||||
for (GuiSliderIE choose : floatSliders) {
|
||||
choose.drawButton(mc, mouseX, mouseY, partialTicks);
|
||||
for (int i = 0; i < floatSliders.size(); i++) {
|
||||
GuiSliderIE slider = floatSliders.get(i);
|
||||
double oldV = slider.getValue();
|
||||
slider.drawButton(mc, mouseX, mouseY, partialTicks);
|
||||
if (oldV != slider.getValue()) {
|
||||
sync(i, (float) slider.getValue());
|
||||
}
|
||||
}
|
||||
GuiChannelPickerSmall openPicker = null;
|
||||
for (GuiChannelPicker pick : rsChannelChoosers) {
|
||||
|
@ -355,5 +361,6 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setTag("data", list);
|
||||
IndustrialWires.packetHandler.sendToServer(new MessageItemSync(container.hand, nbt));
|
||||
IndustrialWires.panelComponent.onChange(nbt, Minecraft.getMinecraft().player, container.hand);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,212 @@
|
|||
/*
|
||||
* 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.client.manual;
|
||||
|
||||
import blusunrize.lib.manual.ManualPages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TextSplitter {
|
||||
private final Function<String, Integer> width;
|
||||
private final int lineWidth;
|
||||
private Map<Integer, Map<Integer, Page>> linesOnSpecialPages = new HashMap<>();
|
||||
private Map<Integer, Page> pageToSpecial = new HashMap<>();
|
||||
private List<List<String>> entry = new ArrayList<>();
|
||||
private Page defPage;
|
||||
public TextSplitter(Function<String, Integer> w, int lP, int lW, Function<String, ManualPages> defaultPage) {
|
||||
width = w;
|
||||
lineWidth = lW;
|
||||
defPage = new Page(lP, defaultPage);
|
||||
}
|
||||
|
||||
public void clearSpecial() {
|
||||
linesOnSpecialPages.clear();
|
||||
}
|
||||
|
||||
public void addSpecialPage(int ref, int offset, int linesOnPage, Function<String, ManualPages> factory) {
|
||||
if (offset<0||(ref!=-1&&ref<0)) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (!linesOnSpecialPages.containsKey(ref)) {
|
||||
linesOnSpecialPages.put(ref, new HashMap<>());
|
||||
}
|
||||
linesOnSpecialPages.get(ref).put(offset, new Page(linesOnPage, factory));
|
||||
}
|
||||
|
||||
// I added labels to all break statements to make it more readable
|
||||
@SuppressWarnings({"UnnecessaryLabelOnBreakStatement", "UnusedLabel"})
|
||||
public void split(String in) {
|
||||
String[] wordsAndSpaces = splitWhitespace(in);
|
||||
int pos = 0;
|
||||
List<String> overflow = new ArrayList<>();
|
||||
updateSpecials(-1, 0);
|
||||
entry:while (pos<wordsAndSpaces.length) {
|
||||
List<String> page = new ArrayList<>();
|
||||
page.addAll(overflow);
|
||||
overflow.clear();
|
||||
page:while (page.size()<getLinesOnPage(entry.size())&&pos<wordsAndSpaces.length) {
|
||||
String line = "";
|
||||
int currWidth = 0;
|
||||
line:while (pos<wordsAndSpaces.length&&currWidth<lineWidth) {
|
||||
String text = wordsAndSpaces[pos];
|
||||
if (pos<wordsAndSpaces.length) {
|
||||
int textWidth = getWidth(text);
|
||||
if (currWidth + textWidth < lineWidth||line.length()==0) {
|
||||
pos++;
|
||||
if (text.equals("<np>")) {
|
||||
page.add(line);
|
||||
break page;
|
||||
} else if (text.equals("<br>")) {
|
||||
break line;
|
||||
} else if (text.startsWith("<&")&&text.endsWith(">")) {
|
||||
int id = Integer.parseInt(text.substring(2, text.length()-1));
|
||||
int pageForId = entry.size();
|
||||
Map<Integer, Page> specialForId = linesOnSpecialPages.get(id);
|
||||
if (specialForId!=null&&specialForId.containsKey(0)) {
|
||||
if (page.size()>getLinesOnPage(pageForId)) {
|
||||
pageForId++;
|
||||
}
|
||||
}
|
||||
updateSpecials(id, pageForId);
|
||||
} else if (!Character.isWhitespace(text.charAt(0))||line.length()!=0) {//Don't add whitespace at the start of a line
|
||||
line += text;
|
||||
currWidth += textWidth;
|
||||
}
|
||||
} else {
|
||||
break line;
|
||||
}
|
||||
}
|
||||
}
|
||||
page.add(line);
|
||||
}
|
||||
if (!page.stream().allMatch(String::isEmpty)) {
|
||||
int linesMax = getLinesOnPage(entry.size());
|
||||
if (page.size()>linesMax) {
|
||||
overflow.addAll(page.subList(linesMax, page.size()));
|
||||
page = page.subList(0, linesMax-1);
|
||||
}
|
||||
entry.add(page);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<ManualPages> toManualEntry() {
|
||||
List<ManualPages> ret = new ArrayList<>(entry.size());
|
||||
for (int i = 0; i < entry.size(); i++) {
|
||||
String s = entry.get(i).stream().collect(Collectors.joining("\n"));
|
||||
ret.add(pageToSpecial.getOrDefault(i, defPage).factory.apply(s));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private int getWidth(String text) {
|
||||
switch (text) {
|
||||
case "<br>":
|
||||
case "<np>":
|
||||
return 0;
|
||||
default:
|
||||
if (text.startsWith("<link;")) {
|
||||
text = text.substring(text.indexOf(';') + 1);
|
||||
text = text.substring(text.indexOf(';') + 1, text.lastIndexOf(';'));
|
||||
}
|
||||
return width.apply(text);
|
||||
}
|
||||
}
|
||||
|
||||
private int getLinesOnPage(int id) {
|
||||
if (pageToSpecial.containsKey(id)) {
|
||||
return pageToSpecial.get(id).lines;
|
||||
}
|
||||
return defPage.lines;
|
||||
}
|
||||
|
||||
private void updateSpecials(int ref, int page) {
|
||||
if (linesOnSpecialPages.containsKey(ref)) {
|
||||
for (Map.Entry<Integer, Page> entry :linesOnSpecialPages.get(ref).entrySet()) {
|
||||
int specialPage = page+entry.getKey();
|
||||
if (pageToSpecial.containsKey(specialPage)) {
|
||||
throw new IllegalStateException("Page "+specialPage+" was registered already");
|
||||
}
|
||||
pageToSpecial.put(specialPage, entry.getValue());
|
||||
}
|
||||
} else if (ref!=-1) {//Default reference for page 0
|
||||
System.out.println("WARNING: Reference "+ref+" was found, but no special pages were registered for it");
|
||||
}
|
||||
}
|
||||
|
||||
private String[] splitWhitespace(String in) {
|
||||
List<String> parts = new ArrayList<>();
|
||||
for (int i = 0;i<in.length();) {
|
||||
StringBuilder here = new StringBuilder();
|
||||
char first = in.charAt(i);
|
||||
here.append(first);
|
||||
i++;
|
||||
for (;i<in.length();) {
|
||||
char hereC = in.charAt(i);
|
||||
byte action = shouldSplit(first, hereC);
|
||||
if ((action&1)!=0) {
|
||||
here.append(in.charAt(i));
|
||||
i++;
|
||||
}
|
||||
if ((action&2)!=0||(action&1)==0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
parts.add(here.toString());
|
||||
}
|
||||
return parts.toArray(new String[parts.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* &1: add
|
||||
* &2: end here
|
||||
*/
|
||||
private byte shouldSplit(char start, char here) {
|
||||
byte ret = 0b01;
|
||||
if (Character.isWhitespace(start)^Character.isWhitespace(here)) {
|
||||
ret = 0b10;
|
||||
}
|
||||
if (here=='<') {
|
||||
ret = 0b10;
|
||||
}
|
||||
if (start=='<') {
|
||||
ret = 0b01;
|
||||
if (here=='>') {
|
||||
ret |= 0b10;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<List<String>> getEntry() {
|
||||
return entry;
|
||||
}
|
||||
|
||||
private class Page {
|
||||
final int lines;
|
||||
final Function<String, ManualPages> factory;
|
||||
public Page(int l, Function<String, ManualPages> f) {
|
||||
factory = f;
|
||||
lines = l;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,7 +22,6 @@ 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.TileEntityPanel;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityUnfinishedPanel;
|
||||
|
|
|
@ -32,22 +32,38 @@ import net.minecraft.util.ResourceLocation;
|
|||
import org.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
public class RawModelFontRenderer extends FontRenderer {
|
||||
public static final ResourceLocation FONT = new ResourceLocation("minecraft", "textures/font/ascii.png");
|
||||
private static final Map<Thread, RawModelFontRenderer> instances = new WeakHashMap<>();
|
||||
float[] colorA = new float[4];
|
||||
private ImmutableList.Builder<RawQuad> builder = ImmutableList.builder();
|
||||
private final Vector3f normal = new Vector3f(0, 1, 0);
|
||||
public final float scale;
|
||||
private float scale;
|
||||
public Matrix4 transform = null;
|
||||
|
||||
private TextureAtlasSprite sprite;
|
||||
private static TextureAtlasSprite sprite = null;
|
||||
|
||||
public RawModelFontRenderer(GameSettings settings, ResourceLocation font, TextureManager manager, boolean isUnicode, float scale) {
|
||||
public static RawModelFontRenderer get() {
|
||||
Thread current = Thread.currentThread();
|
||||
if (!instances.containsKey(current)) {
|
||||
instances.put(current, new RawModelFontRenderer(Minecraft.getMinecraft().gameSettings, FONT, Minecraft.getMinecraft().getTextureManager(),
|
||||
false, 1));
|
||||
}
|
||||
return instances.get(current);
|
||||
}
|
||||
private RawModelFontRenderer(GameSettings settings, ResourceLocation font, TextureManager manager, boolean isUnicode, float scale) {
|
||||
super(settings, font, manager, isUnicode);
|
||||
this.scale = scale / (9 * 16);
|
||||
onResourceManagerReload(null);
|
||||
}
|
||||
|
||||
public void setScale(float scale) {
|
||||
this.scale = scale / (9 * 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float renderDefaultChar(int pos, boolean italic) {
|
||||
float x = (pos % 16);
|
||||
|
@ -112,4 +128,8 @@ public class RawModelFontRenderer extends FontRenderer {
|
|||
protected void bindTexture(@Nonnull ResourceLocation location) {
|
||||
//NO-OP
|
||||
}
|
||||
}
|
||||
|
||||
public float getScale() {
|
||||
return scale;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,176 @@
|
|||
/*
|
||||
* 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.client.render;
|
||||
|
||||
import blusunrize.immersiveengineering.api.IEApi;
|
||||
import malte0811.industrialWires.IWConfig;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import org.lwjgl.opengl.ARBFragmentShader;
|
||||
import org.lwjgl.opengl.ARBShaderObjects;
|
||||
import org.lwjgl.opengl.ARBVertexShader;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
public class Shaders
|
||||
{
|
||||
public static int JACOBS_ARC;
|
||||
public static int MARX;
|
||||
private static String PREFIX = "/assets/"+ IndustrialWires.MODID+"/shaders/";
|
||||
public static void initShaders(boolean setupReload) {
|
||||
if (areShadersEnabled()) {
|
||||
JACOBS_ARC = createProgram(null, PREFIX + "jacobs.frag");
|
||||
MARX = createProgram(null, PREFIX + "marx.frag");
|
||||
|
||||
if (setupReload) {
|
||||
IEApi.renderCacheClearers.add(() -> {
|
||||
if (JACOBS_ARC != 0) {
|
||||
deleteShader(JACOBS_ARC);
|
||||
JACOBS_ARC = 0;
|
||||
}
|
||||
if (MARX != 0) {
|
||||
deleteShader(MARX);
|
||||
MARX = 0;
|
||||
}
|
||||
|
||||
initShaders(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
//All stolen from Botania...
|
||||
private static final int VERT = ARBVertexShader.GL_VERTEX_SHADER_ARB;
|
||||
private static final int FRAG = ARBFragmentShader.GL_FRAGMENT_SHADER_ARB;
|
||||
|
||||
|
||||
private static void deleteShader(int id) {
|
||||
if (id != 0) {
|
||||
ARBShaderObjects.glDeleteObjectARB(id);
|
||||
}
|
||||
}
|
||||
|
||||
public static void useShader(int shader) {
|
||||
if (areShadersEnabled()) {
|
||||
ARBShaderObjects.glUseProgramObjectARB(shader);
|
||||
|
||||
if (shader != 0) {
|
||||
int time = ARBShaderObjects.glGetUniformLocationARB(shader, "time");
|
||||
ARBShaderObjects.glUniform1fARB(time, Minecraft.getMinecraft().world.getTotalWorldTime() + Minecraft.getMinecraft().getRenderPartialTicks());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void stopUsingShaders() {
|
||||
useShader(0);
|
||||
}
|
||||
private static int createProgram(String vert, String frag) {
|
||||
int vertId = 0, fragId = 0, program;
|
||||
if(vert != null)
|
||||
vertId = createShader(vert, VERT);
|
||||
if(frag != null)
|
||||
fragId = createShader(frag, FRAG);
|
||||
|
||||
program = ARBShaderObjects.glCreateProgramObjectARB();
|
||||
if(program == 0)
|
||||
return 0;
|
||||
|
||||
if(vert != null)
|
||||
ARBShaderObjects.glAttachObjectARB(program, vertId);
|
||||
if(frag != null)
|
||||
ARBShaderObjects.glAttachObjectARB(program, fragId);
|
||||
|
||||
ARBShaderObjects.glLinkProgramARB(program);
|
||||
if(ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE) {
|
||||
IndustrialWires.logger.error(getLogInfo(program));
|
||||
return 0;
|
||||
}
|
||||
|
||||
ARBShaderObjects.glValidateProgramARB(program);
|
||||
if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE) {
|
||||
IndustrialWires.logger.error(getLogInfo(program));
|
||||
return 0;
|
||||
}
|
||||
|
||||
return program;
|
||||
}
|
||||
|
||||
private static int createShader(String filename, int shaderType){
|
||||
int shader = 0;
|
||||
try {
|
||||
shader = ARBShaderObjects.glCreateShaderObjectARB(shaderType);
|
||||
|
||||
if(shader == 0)
|
||||
return 0;
|
||||
|
||||
ARBShaderObjects.glShaderSourceARB(shader, readFileAsString(filename));
|
||||
ARBShaderObjects.glCompileShaderARB(shader);
|
||||
|
||||
if (ARBShaderObjects.glGetObjectParameteriARB(shader, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE)
|
||||
throw new RuntimeException("Error creating shader: " + getLogInfo(shader));
|
||||
|
||||
return shader;
|
||||
}
|
||||
catch(Exception e) {
|
||||
ARBShaderObjects.glDeleteObjectARB(shader);
|
||||
e.printStackTrace();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getLogInfo(int obj) {
|
||||
return ARBShaderObjects.glGetInfoLogARB(obj, ARBShaderObjects.glGetObjectParameteriARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB));
|
||||
}
|
||||
|
||||
private static String readFileAsString(String filename) throws Exception {
|
||||
InputStream in = Shaders.class.getResourceAsStream(filename);
|
||||
|
||||
if(in == null)
|
||||
return "";
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"))) {
|
||||
return preProcess(reader.lines());
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean areShadersEnabled() {
|
||||
return IWConfig.HVStuff.enableShaders && OpenGlHelper.shadersSupported;
|
||||
}
|
||||
/*
|
||||
* Custom PreProcessor, I need random a lot and wanted #include
|
||||
*/
|
||||
private static String preProcess(Stream<String> lines) {
|
||||
lines = lines.map((s)->{
|
||||
if (s.startsWith("#include ")) {
|
||||
s = s.substring("#include ".length());
|
||||
String fileName = PREFIX +s;
|
||||
try {
|
||||
return readFileAsString(fileName);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(fileName+" not readable", e);
|
||||
}
|
||||
}
|
||||
return s;
|
||||
});
|
||||
return lines.collect(Collectors.joining("\n"));
|
||||
}
|
||||
}
|
|
@ -41,17 +41,20 @@ public class TileRenderJacobsLadder extends TileEntitySpecialRenderer<TileEntity
|
|||
GlStateManager.translate(x + .5, y + tile.size.heightOffset, z + .5);
|
||||
GlStateManager.rotate(tile.facing.getHorizontalAngle(), 0, 1, 0);
|
||||
GlStateManager.translate(-tile.size.bottomDistance / 2, 0, 0);
|
||||
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.shadeModel(GL11.GL_SMOOTH);
|
||||
if (Shaders.areShadersEnabled()) {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
setLightmapDisabled(true);
|
||||
GlStateManager.color(1, .85F, 1, 1);
|
||||
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.x * partialTicks, speed.y * partialTicks, speed.z * partialTicks);
|
||||
Vec3d speed = tile.controlMovement[i].scale(partialTicks);
|
||||
controls[i] = tile.controls[i].add(speed);
|
||||
}
|
||||
drawBezier(controls, tile.salt, tile.size);
|
||||
//DEBUG CODE
|
||||
|
@ -74,12 +77,14 @@ public class TileRenderJacobsLadder extends TileEntitySpecialRenderer<TileEntity
|
|||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.shadeModel(GL11.GL_FLAT);
|
||||
GlStateManager.disableBlend();
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
private void drawBezier(Vec3d[] controls, double salt, LadderSize size) {
|
||||
Shaders.useShader(Shaders.JACOBS_ARC);
|
||||
int steps = size.renderPoints;
|
||||
double diameter = size.renderDiameter;
|
||||
Vec3d radY = new Vec3d(0, diameter / 2, 0);
|
||||
|
@ -90,31 +95,41 @@ public class TileRenderJacobsLadder extends TileEntitySpecialRenderer<TileEntity
|
|||
vertBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
|
||||
Vec3d last = Beziers.getPoint(0, controls);
|
||||
colors[0] = getColor(0, salt, size);
|
||||
if (Shaders.areShadersEnabled()) {
|
||||
colors[0][0] = 0;
|
||||
}
|
||||
for (int i = 1; i <= steps; i++) {
|
||||
double d = i / (double) steps;
|
||||
colors[i] = getColor(d, salt, size);
|
||||
Vec3d pos = Beziers.getPoint(d, controls);
|
||||
drawQuad(last, pos, radY, colors[i - 1], colors[i], vertBuffer);
|
||||
drawQuad(last, pos, radZ, colors[i - 1], colors[i], vertBuffer);
|
||||
if (Shaders.areShadersEnabled()) {
|
||||
colors[i][0] = (float) d;
|
||||
}
|
||||
drawQuad(last, pos, radY, colors[i - 1], colors[i], vertBuffer, false);
|
||||
drawQuad(last, pos, radZ, colors[i - 1], colors[i], vertBuffer, false);
|
||||
last = pos;
|
||||
}
|
||||
tes.draw();
|
||||
Shaders.stopUsingShaders();
|
||||
}
|
||||
|
||||
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();
|
||||
private void drawQuad(Vec3d v0, Vec3d v1, Vec3d rad, float[] color0, float[] color1, BufferBuilder vertexBuffer,
|
||||
boolean horizontal) {
|
||||
float alpha0 = horizontal?.5F:0;
|
||||
float alpha1 = horizontal?.5F:1;
|
||||
color(color1, alpha0, vertexBuffer.pos(v1.x - rad.x, v1.y - rad.y, v1.z - rad.z)).endVertex();
|
||||
color(color0, alpha0, vertexBuffer.pos(v0.x - rad.x, v0.y - rad.y, v0.z - rad.z)).endVertex();
|
||||
color(color0, alpha1, vertexBuffer.pos(v0.x + rad.x, v0.y + rad.y, v0.z + rad.z)).endVertex();
|
||||
color(color1, alpha1, vertexBuffer.pos(v1.x + rad.x, v1.y + rad.y, v1.z + rad.z)).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();
|
||||
color(color1, alpha1, vertexBuffer.pos(v1.x + rad.x, v1.y + rad.y, v1.z + rad.z)).endVertex();
|
||||
color(color0, alpha1, vertexBuffer.pos(v0.x + rad.x, v0.y + rad.y, v0.z + rad.z)).endVertex();
|
||||
color(color0, alpha0, vertexBuffer.pos(v0.x - rad.x, v0.y - rad.y, v0.z - rad.z)).endVertex();
|
||||
color(color1, alpha0, vertexBuffer.pos(v1.x - rad.x, v1.y - rad.y, v1.z - rad.z)).endVertex();
|
||||
}
|
||||
|
||||
private BufferBuilder color(float[] color, BufferBuilder vb) {
|
||||
vb.color(color[0], color[1], color[2], 1);
|
||||
private BufferBuilder color(float[] color, float alpha, BufferBuilder vb) {
|
||||
vb.color(color[0], color[1], color[2], alpha);
|
||||
return vb;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
|||
import malte0811.industrialWires.blocks.IWProperties;
|
||||
import malte0811.industrialWires.blocks.hv.TileEntityMarx;
|
||||
import malte0811.industrialWires.blocks.hv.TileEntityMarx.Discharge;
|
||||
import malte0811.industrialWires.client.ClientEventHandler;
|
||||
import malte0811.industrialWires.util.MiscUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
|
@ -37,6 +38,7 @@ import org.lwjgl.opengl.GL11;
|
|||
import static malte0811.industrialWires.blocks.hv.TileEntityMarx.FiringState.FIRE;
|
||||
|
||||
public class TileRenderMarx extends TileEntitySpecialRenderer<TileEntityMarx> {
|
||||
public static boolean screenShot = false;
|
||||
@Override
|
||||
public void render(TileEntityMarx te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
|
||||
final boolean debug = false;
|
||||
|
@ -66,6 +68,10 @@ public class TileRenderMarx extends TileEntitySpecialRenderer<TileEntityMarx> {
|
|||
}
|
||||
cleanUp();
|
||||
te.state = TileEntityMarx.FiringState.CHARGING;
|
||||
if (screenShot) {
|
||||
ClientEventHandler.shouldScreenshot = true;
|
||||
screenShot = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +100,8 @@ public class TileRenderMarx extends TileEntitySpecialRenderer<TileEntityMarx> {
|
|||
}
|
||||
GlStateManager.rotate(angle, 0, 1, 0);
|
||||
vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
|
||||
drawDischargeSection(new Vec3d(0, -.2F, 0), new Vec3d(0, .2F, 0), .25F, vb);
|
||||
drawDischargeSection(new Vec3d(0, -.2F, 0), new Vec3d(0, .2F, 0), .25F,
|
||||
.4F, .45F, vb);
|
||||
tes.draw();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
@ -116,6 +123,7 @@ public class TileRenderMarx extends TileEntitySpecialRenderer<TileEntityMarx> {
|
|||
Matrix4 ret = new Matrix4();
|
||||
ret.rotate(-angle, 0, 1, 0);
|
||||
GlStateManager.rotate((float) Math.toDegrees(angle), 0, 1, 0);
|
||||
Shaders.useShader(Shaders.MARX);
|
||||
return ret;
|
||||
}
|
||||
private void cleanUp() {
|
||||
|
@ -125,29 +133,35 @@ public class TileRenderMarx extends TileEntitySpecialRenderer<TileEntityMarx> {
|
|||
GlStateManager.enableLighting();
|
||||
GlStateManager.shadeModel(GL11.GL_FLAT);
|
||||
GlStateManager.disableBlend();
|
||||
Shaders.stopUsingShaders();
|
||||
}
|
||||
private static final float[] WHITE = {1, 1, 1, 1};
|
||||
private static final float[] WHITE_TRANSPARENT = {1, 1, 1, 0};
|
||||
private void drawDischarge(Discharge d, BufferBuilder vb, Tessellator tes, Matrix4 mat) {
|
||||
if (d!=null&&d.vertices!=null) {
|
||||
vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
|
||||
for (int i = 0;i<d.vertices.length-1;i++) {
|
||||
drawDischargeSection(mat.apply(d.vertices[i]), mat.apply(d.vertices[i+1]), d.diameter, vb);
|
||||
drawDischargeSection(mat.apply(d.vertices[i]), mat.apply(d.vertices[i+1]), d.diameter,
|
||||
i/(float)(d.vertices.length-1), (i+1)/(float)(d.vertices.length-1), vb);
|
||||
}
|
||||
tes.draw();
|
||||
}
|
||||
}
|
||||
private void drawDischargeSection(Vec3d start, Vec3d end, float diameter, BufferBuilder vb) {
|
||||
drawPart(start, end, diameter/3, diameter/3, WHITE_TRANSPARENT, WHITE, vb);
|
||||
drawPart(start, end, 0, diameter/3, WHITE, WHITE, vb);
|
||||
drawPart(start, end, -diameter/3, diameter/3, WHITE, WHITE_TRANSPARENT, vb);
|
||||
private void drawDischargeSection(Vec3d start, Vec3d end, float diameter, float aMin, float aMax, BufferBuilder vb) {
|
||||
if (Shaders.areShadersEnabled()) {
|
||||
drawPart(0, diameter, start, end, aMin, aMax, vb);
|
||||
} else {
|
||||
drawPart(-diameter/3, diameter/3, start, end, 0, 1, vb);
|
||||
drawPart(0, diameter/3, start, end, 1, 1, vb);
|
||||
drawPart(diameter/3, diameter/3, start, end, 1, 0, vb);
|
||||
}
|
||||
}
|
||||
private void drawPart(Vec3d start, Vec3d end, float offset, float width, float[] color1, float[] color2, BufferBuilder vb) {
|
||||
vb.setTranslation(-offset-width/2, 0, 0);
|
||||
vb.pos(start.x, start.y, start.z).color(color1[0], color1[1], color1[2], color1[3]).endVertex();
|
||||
vb.pos(start.x+width, start.y, start.z).color(color2[0], color2[1], color2[2], color2[3]).endVertex();
|
||||
vb.pos(end.x+width, end.y, end.z).color(color2[0], color2[1], color2[2], color2[3]).endVertex();
|
||||
vb.pos(end.x, end.y, end.z).color(color1[0], color1[1], color1[2], color1[3]).endVertex();
|
||||
private void drawPart(double offset, double diameter, Vec3d start, Vec3d end, float aMin, float aMax, BufferBuilder vb) {
|
||||
boolean shaders = Shaders.areShadersEnabled();
|
||||
float red1 = shaders?0:1;
|
||||
vb.setTranslation(offset-diameter/2, 0, 0);
|
||||
vb.pos(start.x, start.y, start.z).color(red1, 1, 1, aMin).endVertex();
|
||||
vb.pos(start.x+diameter, start.y, start.z).color(1, 1, 1, shaders?aMin:aMax).endVertex();
|
||||
vb.pos(end.x+diameter, end.y, end.z).color(1, 1, 1, aMax).endVertex();
|
||||
vb.pos(end.x, end.y, end.z).color(red1, 1, 1, shaders?aMax:aMin).endVertex();
|
||||
vb.setTranslation(0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
|||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -45,6 +47,7 @@ public class CoveredToggleSwitch extends ToggleSwitch {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public List<RawQuad> getQuads() {
|
||||
float[] color = PanelUtils.getFloatColor(true, this.color);
|
||||
active = state.active;
|
||||
|
@ -74,6 +77,7 @@ public class CoveredToggleSwitch extends ToggleSwitch {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInGUI(GuiPanelCreator gui) {
|
||||
super.renderInGUIDefault(gui, 0xff000000 | this.color);
|
||||
super.renderInGUI(gui);
|
||||
|
|
|
@ -31,6 +31,8 @@ import net.minecraft.nbt.NBTTagInt;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
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.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -79,6 +81,7 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
|
|||
private static final float size = .0625F;
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public List<RawQuad> getQuads() {
|
||||
float[] color = new float[4];
|
||||
color[3] = 1;
|
||||
|
@ -167,6 +170,7 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInGUI(GuiPanelCreator gui) {
|
||||
renderInGUIDefault(gui, colorA);
|
||||
}
|
||||
|
|
|
@ -23,18 +23,17 @@ import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
|||
import malte0811.industrialWires.client.RawQuad;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialWires.client.panelmodel.RawModelFontRenderer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
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 net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -44,9 +43,7 @@ import static malte0811.industrialWires.util.NBTKeys.COLOR;
|
|||
import static malte0811.industrialWires.util.NBTKeys.TEXT;
|
||||
|
||||
public class Label extends PanelComponent implements IConfigurableComponent {
|
||||
public static final ResourceLocation FONT = new ResourceLocation("minecraft", "textures/font/ascii.png");
|
||||
private String text = "Test";
|
||||
private RawModelFontRenderer renderer;
|
||||
private int color = 0x808080;
|
||||
|
||||
public Label(String text, int color) {
|
||||
|
@ -72,8 +69,10 @@ public class Label extends PanelComponent implements IConfigurableComponent {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public List<RawQuad> getQuads() {
|
||||
RawModelFontRenderer render = fontRenderer();
|
||||
RawModelFontRenderer render = RawModelFontRenderer.get();
|
||||
render.setScale(1);
|
||||
render.drawString(text, 0, 0, 0xff000000 | color);
|
||||
return render.build();
|
||||
}
|
||||
|
@ -93,9 +92,9 @@ public class Label extends PanelComponent implements IConfigurableComponent {
|
|||
public AxisAlignedBB getBlockRelativeAABB() {
|
||||
if (aabb == null) {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
|
||||
RawModelFontRenderer fr = fontRenderer();
|
||||
float width = fr.getStringWidth(text) * fr.scale;
|
||||
float height = fr.FONT_HEIGHT * fr.scale;
|
||||
RawModelFontRenderer fr = RawModelFontRenderer.get();
|
||||
float width = fr.getStringWidth(text) * fr.getScale();
|
||||
float height = fr.FONT_HEIGHT * fr.getScale();
|
||||
aabb = new AxisAlignedBB(getX(), 0, getY(), getX() + width, 0, getY() + height);
|
||||
} else {
|
||||
aabb = new AxisAlignedBB(getX(), 0, getY(), getX() + .001, 0, getY() + .001);
|
||||
|
@ -123,15 +122,8 @@ public class Label extends PanelComponent implements IConfigurableComponent {
|
|||
return 0;
|
||||
}
|
||||
|
||||
private RawModelFontRenderer fontRenderer() {
|
||||
if (renderer == null) {
|
||||
renderer = new RawModelFontRenderer(Minecraft.getMinecraft().gameSettings, FONT, Minecraft.getMinecraft().getTextureManager(),
|
||||
false, 1);
|
||||
}
|
||||
return renderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInGUI(GuiPanelCreator gui) {
|
||||
int left = (int) (gui.getX0() + getX() * gui.panelSize);
|
||||
int top = (int) (gui.getY0() + getY() * gui.panelSize);
|
||||
|
|
|
@ -31,6 +31,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.nbt.NBTTagInt;
|
||||
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.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -85,6 +87,7 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
|
|||
private final static float size = .0625F;
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public List<RawQuad> getQuads() {
|
||||
float[] color = PanelUtils.getFloatColor(active, this.color);
|
||||
List<RawQuad> ret = new ArrayList<>(5);
|
||||
|
@ -154,13 +157,14 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInGUI(GuiPanelCreator gui) {
|
||||
renderInGUIDefault(gui, 0xff000000 | color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate(TileEntityPanel te) {
|
||||
setOut(false, te);
|
||||
setOut(rsOutputChannel, 0);
|
||||
}
|
||||
|
||||
private void setOut(boolean on, TileEntityPanel tile) {
|
||||
|
|
|
@ -38,6 +38,8 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraft.util.EnumHand;
|
||||
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.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -107,7 +109,7 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
|
|||
|
||||
private final static float size = .0625F;
|
||||
private final static float keyWidth = .125F * size;
|
||||
private final static float yOffset = size / 2 + .0001F;
|
||||
private final static float yOffset = size / 2 + Y_DELTA;
|
||||
private final static float xOffset = (size - keyWidth) / 2;
|
||||
private final static float[] DARK_GRAY = {.4F, .4F, .4F};
|
||||
private final static int DARK_GRAY_INT = 0xFF686868;
|
||||
|
@ -117,6 +119,7 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
|
|||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public List<RawQuad> getQuads() {
|
||||
List<RawQuad> ret = new ArrayList<>(5);
|
||||
PanelUtils.addColoredBox(GRAY, GRAY, null, new Vector3f(0, 0, 0), new Vector3f(size, size / 2, size), ret, false);
|
||||
|
@ -231,6 +234,7 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInGUI(GuiPanelCreator gui) {
|
||||
renderInGUIDefault(gui, GRAY_INT);
|
||||
AxisAlignedBB aabb = getBlockRelativeAABB();
|
||||
|
@ -243,7 +247,7 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
|
|||
|
||||
@Override
|
||||
public void invalidate(TileEntityPanel te) {
|
||||
setOut(te);
|
||||
setOut(rsOutputChannel, 0);
|
||||
}
|
||||
|
||||
private void setOut(TileEntityPanel tile) {
|
||||
|
|
|
@ -40,12 +40,15 @@ import java.util.function.Consumer;
|
|||
import java.util.function.Supplier;
|
||||
|
||||
public abstract class PanelComponent {
|
||||
public static final float Y_DELTA = .001F;
|
||||
protected float panelHeight;
|
||||
protected AxisAlignedBB aabb = null;
|
||||
protected float x, y;
|
||||
private final String type;
|
||||
protected final static float[] GRAY = {.8F, .8F, .8F};
|
||||
protected final static int GRAY_INT = 0xFFD0D0D0;
|
||||
protected static final float[] BLACK = {0, 0, 0, 1};
|
||||
|
||||
private Set<TriConsumer<Integer, Byte, PanelComponent>> outputs = new HashSet<>();
|
||||
|
||||
protected PanelComponent(String type) {
|
||||
|
@ -54,7 +57,7 @@ public abstract class PanelComponent {
|
|||
|
||||
public static final Map<String, Supplier<PanelComponent>> baseCreaters = new HashMap<>();
|
||||
|
||||
static {
|
||||
public static void init() {
|
||||
baseCreaters.put("lighted_button", LightedButton::new);
|
||||
baseCreaters.put("label", Label::new);
|
||||
baseCreaters.put("indicator_light", IndicatorLight::new);
|
||||
|
@ -64,6 +67,20 @@ public abstract class PanelComponent {
|
|||
baseCreaters.put("toggle_switch_covered", CoveredToggleSwitch::new);
|
||||
baseCreaters.put("lock", Lock::new);
|
||||
baseCreaters.put("panel_meter", PanelMeter::new);
|
||||
baseCreaters.put(SevenSegDisplay.NAME, SevenSegDisplay::new);
|
||||
//Check that all components implement equals+hashCode if in a dev env
|
||||
boolean isDevEnv = "NBTTagCompound".equals(NBTTagCompound.class.getSimpleName());
|
||||
if (isDevEnv) {
|
||||
for (Supplier<PanelComponent> sup:baseCreaters.values()) {
|
||||
PanelComponent comp = sup.get();
|
||||
try {
|
||||
comp.getClass().getDeclaredMethod("equals", Object.class);
|
||||
comp.getClass().getDeclaredMethod("hashCode");
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException(comp.getClass()+" lacks equals or hasCode! This will break the cache!", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void writeCustomNBT(NBTTagCompound nbt, boolean toItem);
|
||||
|
@ -71,6 +88,7 @@ public abstract class PanelComponent {
|
|||
protected abstract void readCustomNBT(NBTTagCompound nbt);
|
||||
|
||||
// DON'T OFFSET BY x, y IN THIS METHOD!
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract List<RawQuad> getQuads();
|
||||
|
||||
@Nonnull
|
||||
|
@ -177,8 +195,10 @@ public abstract class PanelComponent {
|
|||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract void renderInGUI(GuiPanelCreator gui);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInGUIDefault(GuiPanelCreator gui, int color) {
|
||||
color |= 0xff000000;
|
||||
AxisAlignedBB aabb = getBlockRelativeAABB();
|
||||
|
|
|
@ -24,7 +24,6 @@ import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
|||
import malte0811.industrialWires.client.RawQuad;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialWires.client.panelmodel.RawModelFontRenderer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
@ -36,6 +35,8 @@ import net.minecraft.nbt.NBTTagInt;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
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.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -72,11 +73,8 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
|
|||
protected void writeCustomNBT(NBTTagCompound nbt, boolean toItem) {
|
||||
nbt.setInteger(RS_ID, rsInputId);
|
||||
nbt.setByte(RS_CHANNEL, rsInputChannel);
|
||||
nbt.setBoolean(HAS_SECOND_CHANNEL, hasSecond);
|
||||
if (hasSecond) {
|
||||
nbt.setInteger(RS_ID2, rsInputId2);
|
||||
nbt.setByte(RS_CHANNEL2, rsInputChannel2);
|
||||
}
|
||||
nbt.setInteger(RS_ID2, rsInputId2);
|
||||
nbt.setByte(RS_CHANNEL2, rsInputChannel2);
|
||||
nbt.setBoolean(WIDE, wide);
|
||||
if (!toItem) {
|
||||
nbt.setInteger("rsInput", rsInput);
|
||||
|
@ -89,11 +87,14 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
|
|||
rsInputChannel = nbt.getByte(RS_CHANNEL);
|
||||
rsInput = nbt.getInteger("rsInput");
|
||||
wide = nbt.getBoolean(WIDE);
|
||||
hasSecond = nbt.getBoolean(HAS_SECOND_CHANNEL);
|
||||
if (hasSecond) {
|
||||
if (nbt.hasKey(RS_ID2)) {
|
||||
rsInputId2 = nbt.getInteger(RS_ID2);
|
||||
rsInputChannel2 = nbt.getByte(RS_CHANNEL2);
|
||||
hasSecond = rsInputId2>=0&&rsInputChannel2>=0;
|
||||
} else {
|
||||
hasSecond = false;
|
||||
}
|
||||
if (!hasSecond) {
|
||||
rsInputId2 = -1;
|
||||
rsInputChannel2 = -1;
|
||||
}
|
||||
|
@ -102,26 +103,27 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
|
|||
private static final float SIZE = .25F;
|
||||
private static final float WIDTH = 1.5F*SIZE;
|
||||
private static final float BORDER = SIZE /20;
|
||||
private static final float antiZOffset = .001F;
|
||||
private static final float[] BLACK = {0, 0, 0, 1};
|
||||
private static final float[] WHITE = {1, 1, 1, 1};
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public List<RawQuad> getQuads() {
|
||||
List<RawQuad> ret = new ArrayList<>();
|
||||
float width = wide?WIDTH:SIZE;
|
||||
//main panel
|
||||
PanelUtils.addColoredQuad(ret, new Vector3f(), new Vector3f(0, 0, SIZE), new Vector3f(width, 0, SIZE),
|
||||
new Vector3f(width, 0, 0), EnumFacing.UP, BLACK);
|
||||
PanelUtils.addColoredQuad(ret, new Vector3f(BORDER, antiZOffset, BORDER), new Vector3f(BORDER, antiZOffset, SIZE-BORDER),
|
||||
new Vector3f(width-BORDER, antiZOffset, SIZE-BORDER), new Vector3f(width-BORDER, antiZOffset, BORDER), EnumFacing.UP, WHITE);
|
||||
PanelUtils.addColoredQuad(ret, new Vector3f(BORDER, Y_DELTA, BORDER), new Vector3f(BORDER, Y_DELTA, SIZE-BORDER),
|
||||
new Vector3f(width-BORDER, Y_DELTA, SIZE-BORDER), new Vector3f(width-BORDER, Y_DELTA, BORDER), EnumFacing.UP, WHITE);
|
||||
|
||||
RawModelFontRenderer r = fontRenderer();
|
||||
RawModelFontRenderer r = RawModelFontRenderer.get();
|
||||
r.setScale(.5F);
|
||||
r.transform = new Matrix4();
|
||||
for (int i = 0;i<=3;i++) {
|
||||
transformNumber(r.transform, 5*17*i);
|
||||
String asString = Integer.toString(5*i);
|
||||
int lengthHalf = r.getStringWidth(asString)/2;
|
||||
r.transform.translate(-lengthHalf*r.scale, 0, -3.5*r.scale);
|
||||
r.transform.translate(-lengthHalf*r.getScale(), 0, -3.5*r.getScale());
|
||||
r.drawString(asString, 0, 0, 0xff000000);
|
||||
ret.addAll(r.build());
|
||||
}
|
||||
|
@ -135,22 +137,13 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
|
|||
return ret;
|
||||
}
|
||||
|
||||
private RawModelFontRenderer renderer;
|
||||
private RawModelFontRenderer fontRenderer() {
|
||||
if (renderer == null) {
|
||||
renderer = new RawModelFontRenderer(Minecraft.getMinecraft().gameSettings, Label.FONT, Minecraft.getMinecraft().getTextureManager(),
|
||||
false, .5F);
|
||||
}
|
||||
return renderer;
|
||||
}
|
||||
|
||||
private void transformNumber(Matrix4 mat, int value) {
|
||||
if (wide) {
|
||||
transformNeedle(mat, value);
|
||||
mat.translate(0, 0, getLength()+1.5*BORDER);
|
||||
mat.scale(-1, 1, -1);
|
||||
} else {
|
||||
mat.setIdentity().translate(0, antiZOffset, SIZE);
|
||||
mat.setIdentity().translate(0, Y_DELTA, SIZE);
|
||||
mat.translate(SIZE-3*BORDER, 0, -3*BORDER);
|
||||
float angle = 90*(1-value/255F);
|
||||
angle = (float) (angle*Math.PI/180);
|
||||
|
@ -160,7 +153,7 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
|
|||
}
|
||||
|
||||
private void transformNeedle(Matrix4 mat, int value) {
|
||||
mat.setIdentity().translate(0, 2*antiZOffset, SIZE);
|
||||
mat.setIdentity().translate(0, 2*Y_DELTA, SIZE);
|
||||
float angle;
|
||||
if (wide) {
|
||||
mat.translate(WIDTH/2, 0, -2*BORDER);
|
||||
|
@ -277,6 +270,7 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInGUI(GuiPanelCreator gui) {
|
||||
renderInGUIDefault(gui, 0);
|
||||
AxisAlignedBB aabb = getBlockRelativeAABB();
|
||||
|
|
|
@ -83,7 +83,7 @@ public final class PanelUtils {
|
|||
//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());
|
||||
Matrix4 m4Here = m4.copy().translate(pc.getX(), PanelComponent.Y_DELTA, pc.getY());
|
||||
List<RawQuad> compQuads = pc.getQuads();
|
||||
for (RawQuad bq : compQuads) {
|
||||
ret.add(bakeQuad(bq, m4Here, m4RotOnly));
|
||||
|
@ -277,52 +277,51 @@ public final class PanelUtils {
|
|||
|
||||
public static void addInfo(ItemStack stack, List<String> list, NBTTagCompound data) {
|
||||
switch (stack.getMetadata()) {
|
||||
case 0: //button
|
||||
addCommonInfo(data, list, true, true);
|
||||
if (data.hasKey(LATCHING)) {
|
||||
list.add(I18n.format(IndustrialWires.MODID + ".tooltip." + (data.getBoolean(LATCHING) ? "latching" : "instantaneous")));
|
||||
}
|
||||
break;
|
||||
case 1: //label
|
||||
if (data.hasKey(TEXT)) {
|
||||
list.add(I18n.format(IndustrialWires.MODID + ".tooltip.text", data.getString(TEXT)));
|
||||
}
|
||||
addCommonInfo(data, list, true, false);
|
||||
break;
|
||||
case 2: //indicator light
|
||||
addCommonInfo(data, list, true, true);
|
||||
break;
|
||||
case 3: //slider
|
||||
addCommonInfo(data, list, true, true);
|
||||
if (data.hasKey(HORIZONTAL)) {
|
||||
list.add(I18n.format(IndustrialWires.MODID + ".tooltip." + (data.getBoolean(HORIZONTAL) ? "horizontal" : "vertical")));
|
||||
}
|
||||
if (data.hasKey(LENGTH)) {
|
||||
list.add(I18n.format(IndustrialWires.MODID + ".tooltip.length", data.getFloat(LENGTH)));
|
||||
}
|
||||
|
||||
break;
|
||||
case 4://variac
|
||||
addCommonInfo(data, list, false, true);
|
||||
break;
|
||||
case 5://Toggle switch
|
||||
addCommonInfo(data, list, false, true);
|
||||
break;
|
||||
case 6://Covered toggle switch
|
||||
addCommonInfo(data, list, true, true);
|
||||
break;
|
||||
case 7://Lock
|
||||
addCommonInfo(data, list, false, true);
|
||||
if (data.hasKey(LATCHING)) {
|
||||
list.add(I18n.format(IndustrialWires.MODID + ".tooltip." + (data.getBoolean(LATCHING) ? "latching" : "instantaneous")));
|
||||
}
|
||||
break;
|
||||
case 8://Panel meter
|
||||
addCommonInfo(data, list, false, true);
|
||||
if (data.hasKey(WIDE)) {
|
||||
list.add(I18n.format(IndustrialWires.MODID + ".tooltip." + (data.getBoolean(WIDE) ? "wide" : "narrow")));
|
||||
}
|
||||
break;
|
||||
case 0: //button
|
||||
addCommonInfo(data, list, true, true);
|
||||
if (data.hasKey(LATCHING)) {
|
||||
list.add(I18n.format(IndustrialWires.MODID + ".tooltip." + (data.getBoolean(LATCHING) ? "latching" : "instantaneous")));
|
||||
}
|
||||
break;
|
||||
case 1: //label
|
||||
if (data.hasKey(TEXT)) {
|
||||
list.add(I18n.format(IndustrialWires.MODID + ".tooltip.text", data.getString(TEXT)));
|
||||
}
|
||||
addCommonInfo(data, list, true, false);
|
||||
break;
|
||||
case 2: //indicator light
|
||||
addCommonInfo(data, list, true, true);
|
||||
break;
|
||||
case 3: //slider
|
||||
addCommonInfo(data, list, true, true);
|
||||
if (data.hasKey(HORIZONTAL)) {
|
||||
list.add(I18n.format(IndustrialWires.MODID + ".tooltip." + (data.getBoolean(HORIZONTAL) ? "horizontal" : "vertical")));
|
||||
}
|
||||
if (data.hasKey(LENGTH)) {
|
||||
list.add(I18n.format(IndustrialWires.MODID + ".tooltip.length", data.getFloat(LENGTH)));
|
||||
}
|
||||
break;
|
||||
case 4://variac
|
||||
addCommonInfo(data, list, false, true);
|
||||
break;
|
||||
case 5://Toggle switch
|
||||
addCommonInfo(data, list, false, true);
|
||||
break;
|
||||
case 6://Covered toggle switch
|
||||
addCommonInfo(data, list, true, true);
|
||||
break;
|
||||
case 7://Lock
|
||||
addCommonInfo(data, list, false, true);
|
||||
if (data.hasKey(LATCHING)) {
|
||||
list.add(I18n.format(IndustrialWires.MODID + ".tooltip." + (data.getBoolean(LATCHING) ? "latching" : "instantaneous")));
|
||||
}
|
||||
break;
|
||||
case 8://Panel meter
|
||||
addCommonInfo(data, list, false, true);
|
||||
if (data.hasKey(WIDE)) {
|
||||
list.add(I18n.format(IndustrialWires.MODID + ".tooltip." + (data.getBoolean(WIDE) ? "wide" : "narrow")));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,333 @@
|
|||
/*
|
||||
* 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 malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
||||
import malte0811.industrialWires.client.RawQuad;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagByte;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static malte0811.industrialWires.util.MiscUtils.*;
|
||||
import static malte0811.industrialWires.util.NBTKeys.COLOR;
|
||||
import static malte0811.industrialWires.util.NBTKeys.RS_CHANNEL;
|
||||
import static malte0811.industrialWires.util.NBTKeys.RS_ID;
|
||||
|
||||
public class SevenSegDisplay extends PanelComponent implements IConfigurableComponent {
|
||||
public static final String NAME = "7seg";
|
||||
|
||||
private static final float sizeX = 1.5F/16;
|
||||
private static final float sizeY = 3.0F/16;
|
||||
/*
|
||||
0
|
||||
1 2
|
||||
3
|
||||
4 5
|
||||
6
|
||||
*/
|
||||
private static final boolean[][] numbers = {
|
||||
{true, true, true, false, true, true, true},//0
|
||||
{false, false, true, false, false, true, false},//1
|
||||
{true, false, true, true, true, false, true},//2
|
||||
{true, false, true, true, false, true, true},//3
|
||||
{false, true, true, true, false, true, false},//4
|
||||
{true, true, false, true, false, true, true},//5
|
||||
{true, true, false, true, true, true, true},//6
|
||||
{true, false, true, false, false, true, false},//7
|
||||
{true, true, true, true, true, true, true},//8
|
||||
{true, true, true, true, false, true, true},//9
|
||||
{true, true, true, true, true, true, false},//A
|
||||
{false, true, false, true, true, true, true},//b
|
||||
{true, true, false, false, true, false, true},//C
|
||||
{false, false, true, true, true, true, true},//d
|
||||
{true, true, false, true, true, false, true},//E
|
||||
{true, true, false, true, true, false, false}//F
|
||||
};
|
||||
/*
|
||||
0 1
|
||||
2 3
|
||||
4 5
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static Vec2f[][] positions;
|
||||
|
||||
|
||||
private int color = 0xff00;
|
||||
private byte input = 0;
|
||||
private int rsInputId;
|
||||
private byte rsInputChannel;
|
||||
|
||||
public SevenSegDisplay() {
|
||||
super(NAME);
|
||||
}
|
||||
|
||||
public SevenSegDisplay(int rsId, byte rsChannel, int color) {
|
||||
this();
|
||||
this.color = color;
|
||||
rsInputChannel = rsChannel;
|
||||
rsInputId = rsId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeCustomNBT(NBTTagCompound nbt, boolean toItem) {
|
||||
nbt.setInteger(RS_ID, rsInputId);
|
||||
nbt.setByte(RS_CHANNEL, rsInputChannel);
|
||||
nbt.setInteger(COLOR, color);
|
||||
if (!toItem) {
|
||||
nbt.setInteger("rsInput", input);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readCustomNBT(NBTTagCompound nbt) {
|
||||
rsInputId = nbt.getInteger(RS_ID);
|
||||
rsInputChannel = nbt.getByte(RS_CHANNEL);
|
||||
color = nbt.getInteger(COLOR);
|
||||
input = nbt.getByte("rsInput");
|
||||
}
|
||||
|
||||
private TileEntityPanel panel;
|
||||
private Consumer<byte[]> handler = (inputNew) -> {
|
||||
if (inputNew[rsInputChannel] != input) {
|
||||
input = inputNew[rsInputChannel];
|
||||
panel.markDirty();
|
||||
panel.triggerRenderUpdate();
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Consumer<byte[]> getRSInputHandler(int id, TileEntityPanel panel) {
|
||||
if (matchesId(rsInputId, id)) {
|
||||
this.panel = panel;
|
||||
return handler;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public List<RawQuad> getQuads() {
|
||||
if (positions==null) {
|
||||
positions = new Vec2f[7][6];
|
||||
Vec2f[][] startAndEnd = {
|
||||
{new Vec2f(1F/4*sizeX, 2F/8*sizeY), new Vec2f(3F/4*sizeX, 2F/8*sizeY)},
|
||||
{new Vec2f(1F/4*sizeX, 2F/8*sizeY), new Vec2f(1F/4*sizeX, 4F/8*sizeY)},
|
||||
{new Vec2f(3F/4*sizeX, 2F/8*sizeY), new Vec2f(3F/4*sizeX, 4F/8*sizeY)},
|
||||
{new Vec2f(1F/4*sizeX, 4F/8*sizeY), new Vec2f(3F/4*sizeX, 4F/8*sizeY)},
|
||||
{new Vec2f(1F/4*sizeX, 4F/8*sizeY), new Vec2f(1F/4*sizeX, 6F/8*sizeY)},
|
||||
{new Vec2f(3F/4*sizeX, 4F/8*sizeY), new Vec2f(3F/4*sizeX, 6F/8*sizeY)},
|
||||
{new Vec2f(1F/4*sizeX, 6F/8*sizeY), new Vec2f(3F/4*sizeX, 6F/8*sizeY)}
|
||||
};
|
||||
for (int i = 0;i<7;i++) {
|
||||
positions[i][2] = startAndEnd[i][0];
|
||||
positions[i][3] = startAndEnd[i][1];
|
||||
Vec2f dir = scale(subtract(startAndEnd[i][0], startAndEnd[i][1]), 1F/8);
|
||||
Vec2f perpend = rotate90(dir);
|
||||
positions[i][1] = add(add(startAndEnd[i][1], perpend), dir);
|
||||
positions[i][5] = add(subtract(startAndEnd[i][1], perpend), dir);
|
||||
positions[i][0] = subtract(add(startAndEnd[i][0], perpend), dir);
|
||||
positions[i][4] = subtract(subtract(startAndEnd[i][0], perpend), dir);
|
||||
}
|
||||
}
|
||||
List<RawQuad> ret = new ArrayList<>();
|
||||
PanelUtils.addColoredQuad(ret, new Vector3f(0, 0, 0), new Vector3f(0, 0, sizeY), new Vector3f(sizeX, 0, sizeY),
|
||||
new Vector3f(sizeX, 0, 0), EnumFacing.UP, BLACK);
|
||||
float[] colorOn = PanelUtils.getFloatColor(true, this.color);
|
||||
float[] colorOff = PanelUtils.getFloatColor(false, this.color);
|
||||
for (int i = 0;i<7;i++) {
|
||||
float[] colorToUse = numbers[input][i]?colorOn:colorOff;
|
||||
Vec2f[] pointsForSegment = positions[i];
|
||||
PanelUtils.addColoredQuad(ret,
|
||||
withNewY(pointsForSegment[1], Y_DELTA),
|
||||
withNewY(pointsForSegment[0], Y_DELTA),
|
||||
withNewY(pointsForSegment[2], Y_DELTA),
|
||||
withNewY(pointsForSegment[3], Y_DELTA),
|
||||
EnumFacing.UP, colorToUse);
|
||||
PanelUtils.addColoredQuad(ret,
|
||||
withNewY(pointsForSegment[3], Y_DELTA),
|
||||
withNewY(pointsForSegment[2], Y_DELTA),
|
||||
withNewY(pointsForSegment[4], Y_DELTA),
|
||||
withNewY(pointsForSegment[5], Y_DELTA),
|
||||
EnumFacing.UP, colorToUse);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public PanelComponent copyOf() {
|
||||
SevenSegDisplay ret = new SevenSegDisplay(rsInputId, rsInputChannel, color);
|
||||
ret.input = input;
|
||||
ret.setX(x);
|
||||
ret.setY(y);
|
||||
ret.panelHeight = panelHeight;
|
||||
return ret;
|
||||
}
|
||||
@Nonnull
|
||||
@Override
|
||||
public AxisAlignedBB getBlockRelativeAABB() {
|
||||
if (aabb == null) {
|
||||
aabb = new AxisAlignedBB(x, 0, y, x + sizeX, 0, y + sizeY);
|
||||
}
|
||||
return aabb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void interactWith(Vec3d hitRelative, TileEntityPanel tile, EntityPlayerMP player) {
|
||||
//NOP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(TileEntityPanel tile) {
|
||||
//NOP
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHeight() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInGUI(GuiPanelCreator gui) {
|
||||
color |= 0xff000000;
|
||||
renderInGUIDefault(gui, 0xff000000);
|
||||
AxisAlignedBB aabb = getBlockRelativeAABB();
|
||||
int left = (int) (gui.getX0() + (aabb.minX+sizeX/4) * gui.panelSize);
|
||||
int top = (int) (gui.getY0() + (aabb.minZ+sizeY/4) * gui.panelSize);
|
||||
int sizeX = (int) (SevenSegDisplay.sizeX/2 * gui.panelSize);
|
||||
int sizeY = (int) (SevenSegDisplay.sizeY/2 * gui.panelSize);
|
||||
Gui.drawRect(left, top, left+sizeX, top+sizeY, color);
|
||||
final int width = 1;
|
||||
Gui.drawRect(left+width, top+width, left+sizeX-width, top+sizeY/2-width, 0xff000000);
|
||||
Gui.drawRect(left+width, top+sizeY/2+width, left+sizeX-width, top+sizeY-width, 0xff000000);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void applyConfigOption(ConfigType type, int id, NBTBase value) {
|
||||
switch (type) {
|
||||
case RS_CHANNEL:
|
||||
rsInputChannel = ((NBTTagByte) value).getByte();
|
||||
break;
|
||||
case INT:
|
||||
rsInputId = ((NBTTagInt) value).getInt();
|
||||
break;
|
||||
case FLOAT:
|
||||
color = PanelUtils.setColor(color, id, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String fomatConfigName(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case FLOAT:
|
||||
return I18n.format(IndustrialWires.MODID + ".desc." + (id == 0 ? "red" : (id == 1 ? "green" : "blue")));
|
||||
case RS_CHANNEL:
|
||||
case INT:
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String fomatConfigDescription(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case FLOAT:
|
||||
return null;
|
||||
case RS_CHANNEL:
|
||||
return I18n.format(IndustrialWires.MODID + ".desc.rschannel_info");
|
||||
case INT:
|
||||
return I18n.format(IndustrialWires.MODID + ".desc.rsid_info");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RSChannelConfig[] getRSChannelOptions() {
|
||||
return new RSChannelConfig[]{
|
||||
new RSChannelConfig("channel", 0, 0, rsInputChannel)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntConfig[] getIntegerOptions() {
|
||||
return new IntConfig[]{
|
||||
new IntConfig("rsId", 0, 45, rsInputId, 2, false)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloatConfig[] getFloatOptions() {
|
||||
float[] color = PanelUtils.getFloatColor(true, this.color);
|
||||
int x = 70;
|
||||
int yOffset = 10;
|
||||
return new FloatConfig[]{
|
||||
new FloatConfig("red", x, yOffset, color[0], 60),
|
||||
new FloatConfig("green", x, yOffset + 20, color[1], 60),
|
||||
new FloatConfig("blue", x, yOffset + 40, 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;
|
||||
|
||||
SevenSegDisplay that = (SevenSegDisplay) o;
|
||||
|
||||
if (color != that.color) return false;
|
||||
return input == that.input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + color;
|
||||
result = 31 * result + (int) input;
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -30,6 +30,8 @@ import net.minecraft.nbt.*;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
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.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -80,7 +82,6 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
nbt.setInteger(RS_ID, rsId);
|
||||
nbt.setByte(RS_CHANNEL2, rsChannel2);
|
||||
nbt.setInteger(RS_ID2, rsId2);
|
||||
nbt.setBoolean(HAS_SECOND_CHANNEL, hasSecond);
|
||||
nbt.setBoolean(HORIZONTAL, horizontal);
|
||||
}
|
||||
|
||||
|
@ -88,23 +89,27 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
protected void readCustomNBT(NBTTagCompound nbt) {
|
||||
color = nbt.getInteger(COLOR);
|
||||
length = nbt.getFloat(LENGTH);
|
||||
horizontal = nbt.getBoolean(HORIZONTAL);
|
||||
out = nbt.getInteger("output");
|
||||
rsChannel = nbt.getByte(RS_CHANNEL);
|
||||
rsId = nbt.getInteger(RS_ID);
|
||||
rsChannel2 = nbt.getByte(RS_CHANNEL2);
|
||||
rsId2 = nbt.getInteger(RS_ID2);
|
||||
hasSecond = nbt.getBoolean(HAS_SECOND_CHANNEL);
|
||||
horizontal = nbt.getBoolean(HORIZONTAL);
|
||||
hasSecond = rsId2>=0&&rsChannel2>=0;
|
||||
if (!hasSecond) {
|
||||
rsChannel2 = -1;
|
||||
rsId2 = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public List<RawQuad> getQuads() {
|
||||
List<RawQuad> ret = new ArrayList<>();
|
||||
final float yOff = .001F;
|
||||
float xSize = horizontal ? length : WIDTH;
|
||||
float ySize = horizontal ? WIDTH : length;
|
||||
PanelUtils.addColoredQuad(ret, new Vector3f(0, yOff, 0), new Vector3f(0, yOff, ySize), new Vector3f(xSize, yOff, ySize), new Vector3f(xSize, yOff, 0),
|
||||
EnumFacing.UP, GRAY);
|
||||
PanelUtils.addColoredQuad(ret, new Vector3f(0, 0, 0), new Vector3f(0, 0, ySize), new Vector3f(xSize, 0, ySize),
|
||||
new Vector3f(xSize, 0, 0), EnumFacing.UP, GRAY);
|
||||
float[] color = new float[4];
|
||||
color[3] = 1;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
@ -185,6 +190,7 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInGUI(GuiPanelCreator gui) {
|
||||
renderInGUIDefault(gui, GRAY_INT);
|
||||
double middleX = (getX() + (horizontal ? length : .0625) / 2);
|
||||
|
|
|
@ -34,6 +34,8 @@ import net.minecraft.nbt.NBTTagInt;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
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.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -83,15 +85,15 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
|
|||
protected float sizeY = 1.5F * sizeX;
|
||||
protected float rodRadius = sizeX * .25F;
|
||||
protected float rodLength = 3 / 32F;
|
||||
protected float yOffset = .0001F;
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public List<RawQuad> getQuads() {
|
||||
List<RawQuad> ret = new ArrayList<>();
|
||||
PanelUtils.addColoredQuad(ret, new Vector3f(sizeX, yOffset, (sizeY - sizeX) / 2),
|
||||
new Vector3f(0, yOffset, (sizeY - sizeX) / 2),
|
||||
new Vector3f(0, yOffset, (sizeY + sizeX) / 2),
|
||||
new Vector3f(sizeX, yOffset, (sizeY + sizeX) / 2), EnumFacing.UP, GRAY);
|
||||
PanelUtils.addColoredQuad(ret, new Vector3f(sizeX, 0, (sizeY - sizeX) / 2),
|
||||
new Vector3f(0, 0, (sizeY - sizeX) / 2),
|
||||
new Vector3f(0, 0, (sizeY + sizeX) / 2),
|
||||
new Vector3f(sizeX, 0, (sizeY + sizeX) / 2), EnumFacing.UP, GRAY);
|
||||
Matrix4 rot = new Matrix4();
|
||||
rot.translate((sizeX) / 2, -.01F, sizeY / 2);
|
||||
rot.rotate(Math.PI * 1 / 16 * (active ? -1 : 1), 1, 0, 0);
|
||||
|
@ -145,6 +147,7 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInGUI(GuiPanelCreator gui) {
|
||||
AxisAlignedBB aabb = getBlockRelativeAABB();
|
||||
double zOffset = (aabb.maxZ - aabb.minZ - sizeX) / 2;
|
||||
|
@ -164,7 +167,7 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
|
|||
|
||||
@Override
|
||||
public void invalidate(TileEntityPanel te) {
|
||||
setOut(false, te);
|
||||
setOut(rsOutputChannel, 0);
|
||||
}
|
||||
|
||||
protected void setOut(boolean on, TileEntityPanel tile) {
|
||||
|
|
|
@ -35,6 +35,8 @@ import net.minecraft.nbt.NBTTagInt;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
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.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -85,7 +87,6 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
|
|||
nbt.setInteger(RS_ID, rsId);
|
||||
nbt.setByte(RS_CHANNEL2, rsChannel2);
|
||||
nbt.setInteger(RS_ID2, rsId2);
|
||||
nbt.setBoolean(HAS_SECOND_CHANNEL, hasSecond);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -95,10 +96,15 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
|
|||
rsId = nbt.getInteger(RS_ID);
|
||||
rsChannel2 = nbt.getByte(RS_CHANNEL2);
|
||||
rsId2 = nbt.getInteger(RS_ID2);
|
||||
hasSecond = nbt.getBoolean(HAS_SECOND_CHANNEL);
|
||||
hasSecond = rsChannel2>=0&&rsId2>=0;
|
||||
if (!hasSecond) {
|
||||
rsChannel2 = -1;
|
||||
rsId2 = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public List<RawQuad> getQuads() {
|
||||
List<RawQuad> ret = new ArrayList<>();
|
||||
float angle = -(float) (2 * Math.PI * (8.5 + out) / (17F*16F));
|
||||
|
@ -117,7 +123,7 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
|
|||
new Vector3f(innerSize, getHeight() / 2, innerSize), ret, false, mat);
|
||||
mat.translate(SIZE / 2, 0, SIZE / 2);
|
||||
mat.rotate(Math.PI / 2, 0, 1, 0);
|
||||
mat.translate(-SIZE / 2, .0001, -SIZE / 2);
|
||||
mat.translate(-SIZE / 2, Y_DELTA, -SIZE / 2);
|
||||
PanelUtils.addColoredQuad(ret, new Vector3f(offset, getHeight(), offset), new Vector3f(offset, getHeight(), offset),
|
||||
new Vector3f(offset + arrowSize / 2, getHeight(), offset + arrowSize),
|
||||
new Vector3f(offset + arrowSize, getHeight(), offset + arrowSize / 2), EnumFacing.UP, white, mat);
|
||||
|
@ -203,6 +209,7 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInGUI(GuiPanelCreator gui) {
|
||||
AxisAlignedBB aabb = getBlockRelativeAABB();
|
||||
int left = (int) Math.ceil(gui.getX0() + (offset + aabb.minX) * gui.panelSize);
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
*/
|
||||
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;
|
||||
|
@ -28,7 +27,6 @@ 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;
|
||||
|
||||
|
@ -48,8 +46,8 @@ public class RecipeCoilLength extends IForgeRegistryEntry.Impl<IRecipe> implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(@Nonnull InventoryCrafting inv, World worldIn) {
|
||||
int l = 0;//getLength(inv);
|
||||
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) {
|
||||
int l = getLength(inv);
|
||||
return l > 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -108,8 +108,9 @@ public class RecipeComponentCopy extends IForgeRegistryEntry.Impl<IRecipe> imple
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isHidden() {
|
||||
public boolean isDynamic() {
|
||||
return true;
|
||||
}
|
||||
}
|
26
src/main/java/malte0811/industrialWires/hv/IMarxTarget.java
Normal file
26
src/main/java/malte0811/industrialWires/hv/IMarxTarget.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* 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.hv;
|
||||
|
||||
import malte0811.industrialWires.blocks.hv.TileEntityMarx;
|
||||
|
||||
public interface IMarxTarget {
|
||||
/**
|
||||
* called when the block with this TE is hit by a Marx discharge.
|
||||
* Return true to prevent the block from being destroyed.
|
||||
*/
|
||||
boolean onHit(double energy, TileEntityMarx master);
|
||||
}
|
|
@ -27,7 +27,6 @@ import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Conn
|
|||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import blusunrize.immersiveengineering.common.IEContent;
|
||||
import blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_Connector;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.IWProperties;
|
||||
import malte0811.industrialWires.blocks.hv.BlockHVMultiblocks;
|
||||
|
@ -35,11 +34,10 @@ import malte0811.industrialWires.blocks.hv.TileEntityMarx;
|
|||
import malte0811.industrialWires.client.ClientUtilsIW;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
@ -48,18 +46,18 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static blusunrize.immersiveengineering.api.ApiUtils.getConnectionCatenary;
|
||||
import static blusunrize.immersiveengineering.api.IEProperties.*;
|
||||
import static blusunrize.immersiveengineering.common.IEContent.*;
|
||||
import static blusunrize.immersiveengineering.common.blocks.BlockTypes_MetalsIE.STEEL;
|
||||
|
@ -143,7 +141,7 @@ public class MultiblockMarx implements IMultiblock {
|
|||
new IngredientStack(new ItemStack(blockConnectors, 10, RELAY_HV.getMeta())),
|
||||
new IngredientStack(new ItemStack(itemWireCoil, 8, 2)),
|
||||
new IngredientStack(new ItemStack(blockMetalDecoration2, 8, STEEL_WALLMOUNT.getMeta())),
|
||||
new IngredientStack("fenceSteel", 7),
|
||||
new IngredientStack("fenceSteel", 8),
|
||||
new IngredientStack("blockSteel", 1)
|
||||
};
|
||||
}
|
||||
|
@ -390,15 +388,51 @@ public class MultiblockMarx implements IMultiblock {
|
|||
@Override
|
||||
public boolean overwriteBlockRender(ItemStack stack, int iterator) {
|
||||
IBlockState here = getBlockstateFromStack(-1, stack);
|
||||
if (here!=null) {
|
||||
if (stack == hvRel1Dummy) {
|
||||
//Based on ClientUtils.tessellateConnection
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder buffer = tessellator.getBuffer();
|
||||
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
double radius = WireType.STEEL.getRenderDiameter()/2;
|
||||
int c = WireType.STEEL.getColour(null);
|
||||
int[] rgba = {
|
||||
c&255,
|
||||
(c>>8)&255,
|
||||
(c>>16)&255,
|
||||
(c>>24)&255
|
||||
};
|
||||
TextureAtlasSprite tex = WireType.STEEL.getIcon(null);
|
||||
double uMin = tex.getMinU();
|
||||
double uMax = tex.getMaxU();
|
||||
double vMin = tex.getMinV();
|
||||
double vMax = tex.getMaxV();
|
||||
buffer.setTranslation(.125, .5, .5);
|
||||
buffer.pos(- radius, 0, 0).tex(uMin, vMin).color(rgba[0], rgba[1], rgba[2], 255).endVertex();
|
||||
buffer.pos(- radius, 1, 0).tex(uMax, vMin).color(rgba[0], rgba[1], rgba[2], 255).endVertex();
|
||||
buffer.pos(+ radius, 1, 0).tex(uMax, vMax).color(rgba[0], rgba[1], rgba[2], 255).endVertex();
|
||||
buffer.pos(+ radius, 0, 0).tex(uMin, vMax).color(rgba[0], rgba[1], rgba[2], 255).endVertex();
|
||||
|
||||
buffer.pos(- radius, 1, 0).tex(uMax, vMin).color(rgba[0], rgba[1], rgba[2], 255).endVertex();
|
||||
buffer.pos(- radius, 0, 0).tex(uMin, vMin).color(rgba[0], rgba[1], rgba[2], 255).endVertex();
|
||||
buffer.pos(+ radius, 0, 0).tex(uMin, vMax).color(rgba[0], rgba[1], rgba[2], 255).endVertex();
|
||||
buffer.pos(+ radius, 1, 0).tex(uMax, vMax).color(rgba[0], rgba[1], rgba[2], 255).endVertex();
|
||||
|
||||
|
||||
buffer.pos(0, 0, - radius).tex(uMin, vMin).color(rgba[0], rgba[1], rgba[2], 255).endVertex();
|
||||
buffer.pos(0, 1, - radius).tex(uMax, vMin).color(rgba[0], rgba[1], rgba[2], 255).endVertex();
|
||||
buffer.pos(0, 1, + radius).tex(uMax, vMax).color(rgba[0], rgba[1], rgba[2], 255).endVertex();
|
||||
buffer.pos(0, 0, + radius).tex(uMin, vMax).color(rgba[0], rgba[1], rgba[2], 255).endVertex();
|
||||
|
||||
buffer.pos(0, 1, - radius).tex(uMax, vMin).color(rgba[0], rgba[1], rgba[2], 255).endVertex();
|
||||
buffer.pos(0, 0, - radius).tex(uMin, vMin).color(rgba[0], rgba[1], rgba[2], 255).endVertex();
|
||||
buffer.pos(0, 0, + radius).tex(uMin, vMax).color(rgba[0], rgba[1], rgba[2], 255).endVertex();
|
||||
buffer.pos(0, 1, + radius).tex(uMax, vMax).color(rgba[0], rgba[1], rgba[2], 255).endVertex();
|
||||
buffer.setTranslation(0, 0, 0);
|
||||
tessellator.draw();
|
||||
}
|
||||
if (here!=null&&IndustrialWires.isOldIE) {
|
||||
BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
|
||||
IBakedModel model = dispatcher.getModelForState(here);
|
||||
if (stack == hvRel1Dummy && here instanceof IExtendedBlockState) {
|
||||
Connection up = new Connection(BlockPos.ORIGIN, BlockPos.ORIGIN.down(), WireType.STEEL, 1);
|
||||
up.catenaryVertices = getConnectionCatenary(up, new Vec3d(.125, .5, .5),
|
||||
new Vec3d(.125, 1.5, .5));
|
||||
here = ((IExtendedBlockState) here).withProperty(CONNECTIONS, ImmutableSet.of(up));
|
||||
}
|
||||
GlStateManager.disableBlend();
|
||||
ForgeHooksClient.setRenderLayer(BlockRenderLayer.SOLID);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
|
@ -419,12 +453,41 @@ public class MultiblockMarx implements IMultiblock {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean canRenderFormedStructure() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private List<BakedQuad> bottom = null;
|
||||
private List<BakedQuad> stage = null;
|
||||
private List<BakedQuad> top = null;
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderFormedStructure() {
|
||||
|
||||
BlockRendererDispatcher disp = Minecraft.getMinecraft().getBlockRendererDispatcher();
|
||||
if (bottom==null) {
|
||||
IBlockState base = IndustrialWires.hvMultiblocks.getStateFromMeta(0);
|
||||
BlockModelShapes shapes = disp.getBlockModelShapes();
|
||||
base = base.withProperty(IWProperties.MARX_TYPE, BOTTOM);
|
||||
bottom = shapes.getModelForState(base).getQuads(base, null, 0);
|
||||
base = base.withProperty(IWProperties.MARX_TYPE, STAGE);
|
||||
stage = shapes.getModelForState(base).getQuads(base, null, 0);
|
||||
base = base.withProperty(IWProperties.MARX_TYPE, TOP);
|
||||
top = shapes.getModelForState(base).getQuads(base, null, 0);
|
||||
}
|
||||
GlStateManager.translate(1.5, 1.5, 2.5);
|
||||
GlStateManager.rotate(-90, 0, 1, 0);
|
||||
Tessellator tes = Tessellator.getInstance();
|
||||
BufferBuilder buf = tes.getBuffer();
|
||||
buf.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
|
||||
ClientUtilsIW.renderModelTESRFast(bottom, buf);
|
||||
for (int i = 1;i<4;i++) {
|
||||
buf.setTranslation(0, i, 0);
|
||||
ClientUtilsIW.renderModelTESRFast(stage, buf);
|
||||
}
|
||||
buf.setTranslation(0, 4, 0);
|
||||
ClientUtilsIW.renderModelTESRFast(top, buf);
|
||||
buf.setTranslation(0, 0, 0);
|
||||
tes.draw();
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
package malte0811.industrialWires.items;
|
||||
|
||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||
import blusunrize.immersiveengineering.api.Lib;
|
||||
import blusunrize.immersiveengineering.api.TargetingInfo;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
|
||||
|
@ -27,7 +28,6 @@ import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
|||
import blusunrize.immersiveengineering.common.IESaveData;
|
||||
import blusunrize.immersiveengineering.common.util.ItemNBTHelper;
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import ic2.api.item.IC2Items;
|
||||
import malte0811.industrialWires.IWConfig;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
|
@ -38,11 +38,13 @@ import net.minecraft.creativetab.CreativeTabs;
|
|||
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.NBTTagInt;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@ -53,7 +55,9 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
public class ItemIC2Coil extends Item implements IWireCoil {
|
||||
public final static String[] subNames = {"tin", "copper", "gold", "hv", "glass"};
|
||||
public final static String[] subNames = {
|
||||
"tin", "copper", "gold", "hv", "glass", "tin_ins", "copper_ins", "gold_ins"
|
||||
};
|
||||
public final static String lengthKey = "wireLength";
|
||||
public final static String NAME = "ic2_wire_coil";
|
||||
|
||||
|
@ -61,7 +65,7 @@ public class ItemIC2Coil extends Item implements IWireCoil {
|
|||
setUnlocalizedName(IndustrialWires.MODID + "."+NAME);
|
||||
setHasSubtypes(true);
|
||||
this.setCreativeTab(IndustrialWires.creativeTab);
|
||||
setMaxStackSize(64);
|
||||
setMaxStackSize(1);
|
||||
setRegistryName(new ResourceLocation(IndustrialWires.MODID, NAME));
|
||||
IndustrialWires.items.add(this);
|
||||
}
|
||||
|
@ -86,16 +90,18 @@ public class ItemIC2Coil extends Item implements IWireCoil {
|
|||
|
||||
@Override
|
||||
public WireType getWireType(ItemStack stack) {
|
||||
return IC2Wiretype.IC2_TYPES[stack.getMetadata()];
|
||||
return IC2Wiretype.ALL[stack.getMetadata()];
|
||||
}
|
||||
|
||||
@Override
|
||||
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();
|
||||
IC2Wiretype wireType = IC2Wiretype.ALL[stack.getMetadata()];
|
||||
int transferRate = wireType.getTransferRate();
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.transfer_rate", transferRate));
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.input_rate", transferRate / 8));
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.input_rate",
|
||||
transferRate / wireType.getFactor()));
|
||||
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("linkingPos")) {
|
||||
int[] link = stack.getTagCompound().getIntArray("linkingPos");
|
||||
if (link.length > 3) {
|
||||
|
@ -110,7 +116,7 @@ public class ItemIC2Coil extends Item implements IWireCoil {
|
|||
@Override
|
||||
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (!world.isRemote && !stack.isEmpty()) {
|
||||
if (!stack.isEmpty()) {
|
||||
if (stack.getCount() > 1) {
|
||||
player.sendMessage(new TextComponentTranslation(IndustrialWires.MODID + ".chat.stackSize"));
|
||||
return EnumActionResult.FAIL;
|
||||
|
@ -120,97 +126,115 @@ public class ItemIC2Coil extends Item implements IWireCoil {
|
|||
TargetingInfo target = new TargetingInfo(side, hitX, hitY, hitZ);
|
||||
WireType wire = getWireType(stack);
|
||||
BlockPos masterPos = ((IImmersiveConnectable) tileEntity).getConnectionMaster(wire, target);
|
||||
Vec3i offset = pos.subtract(masterPos);
|
||||
tileEntity = world.getTileEntity(masterPos);
|
||||
if (!(tileEntity instanceof IImmersiveConnectable) || !((IImmersiveConnectable) tileEntity).canConnect()) {
|
||||
if (!(tileEntity instanceof IImmersiveConnectable) || !((IImmersiveConnectable) tileEntity).canConnect())
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
if (!((IImmersiveConnectable) tileEntity).canConnectCable(wire, target)) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "wrongCable"));
|
||||
if (!((IImmersiveConnectable) tileEntity).canConnectCable(wire, target, offset)) {
|
||||
if (!world.isRemote)
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "wrongCable"));
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
if (!ItemNBTHelper.hasKey(stack, "linkingPos")) {
|
||||
ItemNBTHelper.setIntArray(stack, "linkingPos", new int[]{world.provider.getDimension(), masterPos.getX(), masterPos.getY(), masterPos.getZ()});
|
||||
target.writeToNBT(stack.getTagCompound());
|
||||
} else {
|
||||
WireType type = getWireType(stack);
|
||||
int[] array = ItemNBTHelper.getIntArray(stack, "linkingPos");
|
||||
BlockPos linkPos = new BlockPos(array[1], array[2], array[3]);
|
||||
TileEntity tileEntityLinkingPos = world.getTileEntity(linkPos);
|
||||
int distanceSq = (int) Math.ceil(linkPos.distanceSq(masterPos));
|
||||
if (array[0] != world.provider.getDimension()) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "wrongDimension"));
|
||||
} else if (linkPos.equals(masterPos)) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "sameConnection"));
|
||||
} else if (distanceSq > (type.getMaxLength() * type.getMaxLength())) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "tooFar"));
|
||||
} else if (!(tileEntityLinkingPos instanceof IImmersiveConnectable) || !((IImmersiveConnectable) tileEntityLinkingPos).canConnectCable(type, TargetingInfo.readFromNBT(stack.getTagCompound()))) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "invalidPoint"));
|
||||
if (!world.isRemote)
|
||||
if (!ItemNBTHelper.hasKey(stack, "linkingPos")) {
|
||||
ItemNBTHelper.setIntArray(stack, "linkingPos", new int[]{world.provider.getDimension(), masterPos.getX(), masterPos.getY(), masterPos.getZ(),
|
||||
offset.getX(), offset.getY(), offset.getZ()});
|
||||
NBTTagCompound targetNbt = new NBTTagCompound();
|
||||
target.writeToNBT(targetNbt);
|
||||
ItemNBTHelper.setTagCompound(stack, "targettingInfo", targetNbt);
|
||||
} else {
|
||||
IImmersiveConnectable nodeHere = (IImmersiveConnectable) tileEntity;
|
||||
IImmersiveConnectable nodeLink = (IImmersiveConnectable) tileEntityLinkingPos;
|
||||
boolean connectionExists = false;
|
||||
Set<Connection> outputs = ImmersiveNetHandler.INSTANCE.getConnections(world, Utils.toCC(nodeHere));
|
||||
if (outputs != null) {
|
||||
for (Connection con : outputs) {
|
||||
if (con.end.equals(Utils.toCC(nodeLink))) {
|
||||
connectionExists = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (connectionExists) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "connectionExists"));
|
||||
int[] array = ItemNBTHelper.getIntArray(stack, "linkingPos");
|
||||
BlockPos linkPos = new BlockPos(array[1], array[2], array[3]);
|
||||
Vec3i offsetLink = BlockPos.NULL_VECTOR;
|
||||
if (array.length == 7)
|
||||
offsetLink = new Vec3i(array[4], array[5], array[6]);
|
||||
TileEntity tileEntityLinkingPos = world.getTileEntity(linkPos);
|
||||
int distanceSq = (int) Math.ceil(linkPos.distanceSq(masterPos));
|
||||
if (array[0] != world.provider.getDimension()) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "wrongDimension"));
|
||||
} else if (linkPos.equals(masterPos)) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "sameConnection"));
|
||||
} else if (distanceSq > (wire.getMaxLength() * wire.getMaxLength())) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "tooFar"));
|
||||
} else {
|
||||
Vec3d rtOff0 = nodeHere.getRaytraceOffset(nodeLink).addVector(masterPos.getX(), masterPos.getY(), masterPos.getZ());
|
||||
Vec3d rtOff1 = nodeLink.getRaytraceOffset(nodeHere).addVector(linkPos.getX(), linkPos.getY(), linkPos.getZ());
|
||||
Set<BlockPos> ignore = new HashSet<>();
|
||||
ignore.addAll(nodeHere.getIgnored(nodeLink));
|
||||
ignore.addAll(nodeLink.getIgnored(nodeHere));
|
||||
boolean canSee = Utils.rayTraceForFirst(rtOff0, rtOff1, world, ignore) == null;
|
||||
if (canSee) {
|
||||
int lengthOnStack = getLength(stack);
|
||||
int length = (int) Math.sqrt(distanceSq);
|
||||
if (length <= lengthOnStack) {
|
||||
TargetingInfo targetLink = TargetingInfo.readFromNBT(stack.getTagCompound());
|
||||
ImmersiveNetHandler.INSTANCE.addConnection(world, Utils.toCC(nodeHere), Utils.toCC(nodeLink), length, type);
|
||||
|
||||
nodeHere.connectCable(type, target, nodeLink);
|
||||
nodeLink.connectCable(type, targetLink, nodeHere);
|
||||
IESaveData.setDirty(world.provider.getDimension());
|
||||
Utils.unlockIEAdvancement(player, "main/connect_wire");
|
||||
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
if (length < lengthOnStack) {
|
||||
setLength(stack, lengthOnStack - length);
|
||||
} else {
|
||||
player.setHeldItem(hand, ItemStack.EMPTY);
|
||||
TargetingInfo targetLink = TargetingInfo.readFromNBT(ItemNBTHelper.getTagCompound(stack, "targettingInfo"));
|
||||
if (!(tileEntityLinkingPos instanceof IImmersiveConnectable) || !((IImmersiveConnectable) tileEntityLinkingPos).canConnectCable(wire, targetLink, offset)) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "invalidPoint"));
|
||||
} else {
|
||||
IImmersiveConnectable nodeHere = (IImmersiveConnectable) tileEntity;
|
||||
IImmersiveConnectable nodeLink = (IImmersiveConnectable) tileEntityLinkingPos;
|
||||
boolean connectionExists = false;
|
||||
Set<Connection> outputs = ImmersiveNetHandler.INSTANCE.getConnections(world, Utils.toCC(nodeHere));
|
||||
if (outputs != null) {
|
||||
for (Connection con : outputs) {
|
||||
if (con.end.equals(Utils.toCC(nodeLink))) {
|
||||
connectionExists = true;
|
||||
}
|
||||
}
|
||||
((TileEntity) nodeHere).markDirty();
|
||||
world.addBlockEvent(masterPos, ((TileEntity) nodeHere).getBlockType(), -1, 0);
|
||||
IBlockState state = world.getBlockState(masterPos);
|
||||
world.notifyBlockUpdate(masterPos, state, state, 3);
|
||||
((TileEntity) nodeLink).markDirty();
|
||||
world.addBlockEvent(linkPos, ((TileEntity) nodeLink).getBlockType(), -1, 0);
|
||||
state = world.getBlockState(linkPos);
|
||||
world.notifyBlockUpdate(linkPos, state, state, 3);
|
||||
} else {
|
||||
player.sendMessage(new TextComponentTranslation(IndustrialWires.MODID + ".chat.tooLong"));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "cantSee"));
|
||||
if (connectionExists) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "connectionExists"));
|
||||
} else {
|
||||
Set<BlockPos> ignore = new HashSet<>();
|
||||
ignore.addAll(nodeHere.getIgnored(nodeLink));
|
||||
ignore.addAll(nodeLink.getIgnored(nodeHere));
|
||||
Connection tmpConn = new Connection(Utils.toCC(nodeHere), Utils.toCC(nodeLink), wire,
|
||||
(int) Math.sqrt(distanceSq));
|
||||
Vec3d start = nodeHere.getConnectionOffset(tmpConn, target, pos.subtract(masterPos)).addVector(tileEntity.getPos().getX(),
|
||||
tileEntity.getPos().getY(), tileEntity.getPos().getZ());
|
||||
Vec3d end = nodeLink.getConnectionOffset(tmpConn, targetLink, offsetLink).addVector(tileEntityLinkingPos.getPos().getX(),
|
||||
tileEntityLinkingPos.getPos().getY(), tileEntityLinkingPos.getPos().getZ());
|
||||
boolean canSee = ApiUtils.raytraceAlongCatenary(tmpConn, (p) -> {
|
||||
if (ignore.contains(p.getLeft())) {
|
||||
return false;
|
||||
}
|
||||
IBlockState state = world.getBlockState(p.getLeft());
|
||||
return ApiUtils.preventsConnection(world, p.getLeft(), state, p.getMiddle(), p.getRight());
|
||||
}, (p) -> {
|
||||
}, start, end);
|
||||
if (canSee) {
|
||||
int lengthOnStack = getLength(stack);
|
||||
int length = (int) Math.sqrt(distanceSq);
|
||||
if (length <= lengthOnStack) {
|
||||
Connection conn = ImmersiveNetHandler.INSTANCE.addAndGetConnection(world, Utils.toCC(nodeHere), Utils.toCC(nodeLink),
|
||||
(int) Math.sqrt(distanceSq), wire);
|
||||
|
||||
|
||||
nodeHere.connectCable(wire, target, nodeLink, offset);
|
||||
nodeLink.connectCable(wire, targetLink, nodeHere, offsetLink);
|
||||
ImmersiveNetHandler.INSTANCE.addBlockData(world, conn);
|
||||
IESaveData.setDirty(world.provider.getDimension());
|
||||
Utils.unlockIEAdvancement(player, "main/connect_wire");
|
||||
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
if (length < lengthOnStack) {
|
||||
setLength(stack, lengthOnStack - length);
|
||||
} else {
|
||||
player.setHeldItem(hand, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
((TileEntity) nodeHere).markDirty();
|
||||
world.addBlockEvent(masterPos, ((TileEntity) nodeHere).getBlockType(), -1, 0);
|
||||
IBlockState state = world.getBlockState(masterPos);
|
||||
world.notifyBlockUpdate(masterPos, state, state, 3);
|
||||
((TileEntity) nodeLink).markDirty();
|
||||
world.addBlockEvent(linkPos, ((TileEntity) nodeLink).getBlockType(), -1, 0);
|
||||
state = world.getBlockState(linkPos);
|
||||
world.notifyBlockUpdate(linkPos, state, state, 3);
|
||||
} else
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "cantSee"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ItemNBTHelper.remove(stack, "linkingPos");
|
||||
ItemNBTHelper.remove(stack, "targettingInfo");
|
||||
}
|
||||
ItemNBTHelper.remove(stack, "linkingPos");
|
||||
ItemNBTHelper.remove(stack, "side");
|
||||
ItemNBTHelper.remove(stack, "hitX");
|
||||
ItemNBTHelper.remove(stack, "hitY");
|
||||
ItemNBTHelper.remove(stack, "hitZ");
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
@ -223,10 +247,10 @@ public class ItemIC2Coil extends Item implements IWireCoil {
|
|||
if (i.getTagCompound() == null) {
|
||||
setLength(i, 4);
|
||||
}
|
||||
return i.getTagCompound().getInteger(lengthKey);
|
||||
return ItemNBTHelper.getInt(i, lengthKey)*i.getCount();
|
||||
}
|
||||
|
||||
public static int getMaxWireLength(ItemStack i) {
|
||||
return IWConfig.maxLengthOnCoil[i.getItemDamage()];
|
||||
return IWConfig.maxLengthOnCoil[i.getItemDamage()%5];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
|||
import malte0811.industrialWires.controlpanel.IConfigurableComponent;
|
||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.controlpanel.PanelUtils;
|
||||
import malte0811.industrialWires.controlpanel.SevenSegDisplay;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -57,7 +58,7 @@ import static malte0811.industrialWires.util.NBTKeys.*;
|
|||
public class ItemPanelComponent extends Item implements INetGUIItem {
|
||||
public static final String[] types = {
|
||||
"lighted_button", "label", "indicator_light", "slider", "variac", "toggle_switch", "toggle_switch_covered",
|
||||
"lock", "panel_meter"
|
||||
"lock", "panel_meter", SevenSegDisplay.NAME
|
||||
};
|
||||
public static final String NAME = "panel_component";
|
||||
|
||||
|
@ -167,7 +168,7 @@ public class ItemPanelComponent extends Item implements INetGUIItem {
|
|||
@Override
|
||||
@Nonnull
|
||||
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, @Nonnull EnumHand hand) {
|
||||
if (!worldIn.isRemote) {
|
||||
if (!worldIn.isRemote&&!playerIn.isSneaking()) {
|
||||
playerIn.openGui(IndustrialWires.MODID, 1, worldIn, 0, 0, hand == EnumHand.MAIN_HAND ? 1 : 0);
|
||||
}
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand));
|
||||
|
@ -178,25 +179,26 @@ public class ItemPanelComponent extends Item implements INetGUIItem {
|
|||
*/
|
||||
@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 (player.isSneaking()) {
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
private void placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
|
@ -238,4 +240,9 @@ public class ItemPanelComponent extends Item implements INetGUIItem {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
||||
return !ItemStack.areItemsEqual(oldStack, newStack);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.util;
|
||||
|
||||
import malte0811.industrialWires.client.render.TileRenderMarx;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandIWClient extends CommandBase {
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "ciw";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUsage(@Nonnull ICommandSender sender) {
|
||||
return "/ciw <triggermarxscreenshot>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args) throws CommandException {
|
||||
if (args.length==0)
|
||||
throw new CommandException("1 parameter is required");
|
||||
switch (args[0].toLowerCase()) {
|
||||
//TODO more immersive way of doing this?
|
||||
case "triggermarxscreenshot":
|
||||
TileRenderMarx.screenShot = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos targetPos) {
|
||||
if (args.length==1) {
|
||||
return getListOfStringsMatchingLastWord(args, "triggermarxscreenshot");
|
||||
}
|
||||
return super.getTabCompletions(server, sender, args, targetPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -18,19 +18,31 @@
|
|||
|
||||
package malte0811.industrialWires.util;
|
||||
|
||||
import blusunrize.immersiveengineering.ImmersiveEngineering;
|
||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces;
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
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.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
|
@ -43,37 +55,6 @@ public final class MiscUtils {
|
|||
private MiscUtils() {
|
||||
}
|
||||
|
||||
public static Set<ImmersiveNetHandler.Connection> genConnBlockstate(Set<ImmersiveNetHandler.Connection> conns, World world) {
|
||||
if (conns == null)
|
||||
return ImmutableSet.of();
|
||||
Set<ImmersiveNetHandler.Connection> ret = new HashSet<ImmersiveNetHandler.Connection>() {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this)
|
||||
return true;
|
||||
if (!(o instanceof HashSet))
|
||||
return false;
|
||||
HashSet<ImmersiveNetHandler.Connection> other = (HashSet<ImmersiveNetHandler.Connection>) o;
|
||||
if (other.size() != this.size())
|
||||
return false;
|
||||
for (ImmersiveNetHandler.Connection c : this)
|
||||
if (!other.contains(c))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
for (ImmersiveNetHandler.Connection c : conns) {
|
||||
IImmersiveConnectable end = ApiUtils.toIIC(c.end, world, false);
|
||||
if (end == null)
|
||||
continue;
|
||||
// generate subvertices
|
||||
c.getSubVertices(world);
|
||||
ret.add(c);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static List<BlockPos> discoverLocal(World w, BlockPos here, BiPredicate<BlockPos, Integer> isValid) {
|
||||
List<BlockPos> ret = new ArrayList<>();
|
||||
List<BlockPos> open = new ArrayList<>();
|
||||
|
@ -107,14 +88,15 @@ public final class MiscUtils {
|
|||
|
||||
/**
|
||||
* Calculates the parameters for offset to generate here from origin
|
||||
*
|
||||
* @return right, forward, up
|
||||
*/
|
||||
public static BlockPos getOffset(BlockPos origin, EnumFacing f, boolean mirror, BlockPos here) {
|
||||
int dX = origin.getZ()-here.getZ();
|
||||
int dZ = origin.getX()-here.getX();
|
||||
int dX = origin.getZ() - here.getZ();
|
||||
int dZ = origin.getX() - here.getX();
|
||||
int forward = 0;
|
||||
int right = 0;
|
||||
int up = here.getY()-origin.getY();
|
||||
int up = here.getY() - origin.getY();
|
||||
switch (f) {
|
||||
case NORTH:
|
||||
forward = dZ;
|
||||
|
@ -138,6 +120,7 @@ public final class MiscUtils {
|
|||
}
|
||||
return new BlockPos(right, forward, up);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static AxisAlignedBB apply(@Nonnull Matrix4 mat, @Nonnull AxisAlignedBB in) {
|
||||
Vec3d min = new Vec3d(in.minX, in.minY, in.minZ);
|
||||
|
@ -162,4 +145,113 @@ public final class MiscUtils {
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
// Taken from TEImmersiveConnectable
|
||||
|
||||
|
||||
public static Set<ImmersiveNetHandler.Connection> genConnBlockstate(Set<ImmersiveNetHandler.Connection> conns, World world) {
|
||||
if (conns == null)
|
||||
return ImmutableSet.of();
|
||||
Set<ImmersiveNetHandler.Connection> ret = new HashSet<ImmersiveNetHandler.Connection>() {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this)
|
||||
return true;
|
||||
if (!(o instanceof HashSet))
|
||||
return false;
|
||||
HashSet<ImmersiveNetHandler.Connection> other = (HashSet<ImmersiveNetHandler.Connection>) o;
|
||||
if (other.size() != this.size())
|
||||
return false;
|
||||
for (ImmersiveNetHandler.Connection c : this)
|
||||
if (!other.contains(c))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
for (ImmersiveNetHandler.Connection c : conns) {
|
||||
IImmersiveConnectable end = ApiUtils.toIIC(c.end, world, false);
|
||||
if (end == null)
|
||||
continue;
|
||||
// generate subvertices
|
||||
c.getSubVertices(world);
|
||||
ret.add(c);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void writeConnsToNBT(NBTTagCompound nbt, TileEntity te) {
|
||||
World world = te.getWorld();
|
||||
if (world != null && !world.isRemote && nbt != null) {
|
||||
NBTTagList connectionList = new NBTTagList();
|
||||
Set<ImmersiveNetHandler.Connection> conL = ImmersiveNetHandler.INSTANCE.getConnections(world, Utils.toCC(te));
|
||||
if (conL != null)
|
||||
for (ImmersiveNetHandler.Connection con : conL)
|
||||
connectionList.appendTag(con.writeToNBT());
|
||||
nbt.setTag("connectionList", connectionList);
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadConnsFromNBT(NBTTagCompound nbt, TileEntity te) {
|
||||
World world = te.getWorld();
|
||||
if (world != null && world.isRemote && !Minecraft.getMinecraft().isSingleplayer() && nbt != null) {
|
||||
NBTTagList connectionList = nbt.getTagList("connectionList", 10);
|
||||
ImmersiveNetHandler.INSTANCE.clearConnectionsOriginatingFrom(Utils.toCC(te), world);
|
||||
for (int i = 0; i < connectionList.tagCount(); i++) {
|
||||
NBTTagCompound conTag = connectionList.getCompoundTagAt(i);
|
||||
ImmersiveNetHandler.Connection con = ImmersiveNetHandler.Connection.readFromNBT(conTag);
|
||||
if (con != null) {
|
||||
ImmersiveNetHandler.INSTANCE.addConnection(world, Utils.toCC(te), con);
|
||||
} else
|
||||
IndustrialWires.logger.error("CLIENT read connection as null");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean handleUpdate(int id, BlockPos pos, World world) {
|
||||
if (id == -1 || id == 255) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
return true;
|
||||
} else if (id == 254) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if (state instanceof IExtendedBlockState) {
|
||||
state = state.getActualState(world, pos);
|
||||
state = state.getBlock().getExtendedState(state, world, pos);
|
||||
ImmersiveEngineering.proxy.removeStateFromSmartModelCache((IExtendedBlockState) state);
|
||||
ImmersiveEngineering.proxy.removeStateFromConnectionModelCache((IExtendedBlockState) state);
|
||||
}
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//End of code from TEImmersiveConnectable
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static Vec2f rotate90(Vec2f in) {
|
||||
//Yes, when rotating by 90 degrees, x becomes y!
|
||||
//noinspection SuspiciousNameCombination
|
||||
return new Vec2f(-in.y, in.x);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static Vec2f subtract(Vec2f a, Vec2f b) {
|
||||
return new Vec2f(a.x-b.x, a.y-b.y);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static Vec2f add(Vec2f a, Vec2f b) {
|
||||
return new Vec2f(a.x+b.x, a.y+b.y);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static Vec2f scale(Vec2f a, float f) {
|
||||
return new Vec2f(a.x*f, a.y*f);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static Vector3f withNewY(Vec2f in, float y) {
|
||||
return new Vector3f(in.x, y, in.y);
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ package malte0811.industrialWires.wires;
|
|||
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireApi;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import malte0811.industrialWires.IWConfig;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
|
@ -28,18 +29,40 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class IC2Wiretype extends WireType {
|
||||
final int type;
|
||||
final int[] ic2Rates = {32 * 8, 128 * 8, 512 * 8, 2048 * 8, 8192 * 8};
|
||||
final int[] ic2Colors = {0xa5bcc7, 0xbc7945, 0xfeff73, 0xb9d6d9, 0xf1f1f1};
|
||||
final String[] ic2Names = {"ic2Tin", "ic2Copper", "ic2Gold", "ic2Hv", "ic2Glass"};
|
||||
final double[] lossPerBlock = {.2, .2, .4, .8, .025};
|
||||
final double[] ic2RenderDiameter = {.03125, .03125, .046875, .0625, .75 * .03125};
|
||||
public static final IC2Wiretype[] IC2_TYPES = {new IC2Wiretype(0), new IC2Wiretype(1), new IC2Wiretype(2), new IC2Wiretype(3), new IC2Wiretype(4)};
|
||||
public static final String IC2_TIN_CAT = "IC_TIN";
|
||||
public static final String IC2_COPPER_CAT = "IC_COPPER";
|
||||
public static final String IC2_GOLD_CAT = "IC_GOLD";
|
||||
public static final String IC2_HV_CAT = "IC_HV";
|
||||
public static final String IC2_GLASS_CAT = "IC_GLASS";
|
||||
private final int type;
|
||||
private final int[] ic2Rates = {32, 128, 512, 2048, 8192};
|
||||
private final int[] ic2Colors = {0xa5bcc7, 0xbc7945, 0xfeff73, 0xb9d6d9, 0xf1f1f1};
|
||||
private final String[] ic2Names = {"ic2Tin", "ic2Copper", "ic2Gold", "ic2Hv", "ic2Glass",
|
||||
"ic2TinIns", "ic2CopperIns", "ic2GoldIns"};
|
||||
private final double[] lossPerBlock = {.2, .2, .4, .8, .025};
|
||||
private final double[] ic2RenderDiameter = {
|
||||
.03125, .03125, .046875, .0625, .75 * .03125, .0625, .0625, 2*.046875
|
||||
};
|
||||
|
||||
public static final IC2Wiretype TIN = new IC2Wiretype(0);
|
||||
public static final IC2Wiretype COPPER_IC2 = new IC2Wiretype(1);
|
||||
public static final IC2Wiretype GOLD = new IC2Wiretype(2);
|
||||
public static final IC2Wiretype HV = new IC2Wiretype(3);
|
||||
public static final IC2Wiretype GLASS = new IC2Wiretype(4);
|
||||
public static final IC2Wiretype TIN_INSULATED = new IC2Wiretype(5);
|
||||
public static final IC2Wiretype COPPER_IC2_INSULATED = new IC2Wiretype(6);
|
||||
public static final IC2Wiretype GOLD_INSULATED = new IC2Wiretype(7);
|
||||
public static final IC2Wiretype[] ALL = {
|
||||
TIN, COPPER_IC2, GOLD, HV, GLASS, TIN_INSULATED, COPPER_IC2_INSULATED, GOLD_INSULATED
|
||||
};
|
||||
|
||||
public IC2Wiretype(int ordinal) {
|
||||
super();
|
||||
this.type = ordinal;
|
||||
WireApi.registerWireType(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -47,22 +70,22 @@ public class IC2Wiretype extends WireType {
|
|||
*/
|
||||
@Override
|
||||
public double getLossRatio() {
|
||||
return lossPerBlock[type];
|
||||
return lossPerBlock[type%5];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransferRate() {
|
||||
return ic2Rates[type];
|
||||
return ic2Rates[type%5]*getFactor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColour(Connection connection) {
|
||||
return ic2Colors[type];
|
||||
return type<5?ic2Colors[type]:0x2c2c2c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSlack() {
|
||||
return type == 2 ? 1.03 : 1.005;
|
||||
return type%5 == 2 ? 1.03 : 1.005;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,7 +96,7 @@ public class IC2Wiretype extends WireType {
|
|||
|
||||
@Override
|
||||
public int getMaxLength() {
|
||||
return IWConfig.maxLengthPerConn[type];
|
||||
return IWConfig.maxLengthPerConn[type%5];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -102,4 +125,40 @@ public class IC2Wiretype extends WireType {
|
|||
public boolean isEnergyWire() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCauseDamage() {
|
||||
return type<4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDamageRadius() {
|
||||
if (type>=4) {
|
||||
return 0;
|
||||
}
|
||||
return .3/4*(type+1);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getCategory() {
|
||||
switch (type%5) {
|
||||
case 0:
|
||||
return IC2_TIN_CAT;
|
||||
case 1:
|
||||
return IC2_COPPER_CAT;
|
||||
case 2:
|
||||
return IC2_GOLD_CAT;
|
||||
case 3:
|
||||
return IC2_HV_CAT;
|
||||
case 4:
|
||||
return IC2_GLASS_CAT;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//Factor between transfer- and input rate
|
||||
public int getFactor() {
|
||||
return type<5?8:4;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
"forge_marker": 1,
|
||||
"defaults": {
|
||||
"transform": "forge:default-block",
|
||||
"textures": {
|
||||
|
||||
},
|
||||
"custom": {
|
||||
"flip-v": true
|
||||
}
|
||||
},
|
||||
"variants": {
|
||||
"inventory,type=discharge_meter": [
|
||||
{
|
||||
"model": "industrialwires:discharge_meter.obj",
|
||||
"transform": {
|
||||
"scale": [ 0.5, 0.5, 0.5 ],
|
||||
"firstperson_righthand": { "translation": [ 0, 0.25, 0.125 ]},
|
||||
"firstperson_lefthand": { "translation": [ 0, 0.25, 0.125 ]},
|
||||
"thirdperson_righthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
|
||||
"thirdperson_lefthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
|
||||
"fixed": {"scale": [ 2,2,2 ], "translation": [ 0, 0, 0 ], "rotation": [{ "y": -90 }]},
|
||||
"gui": { "translation": [ 0, 0.125, 0 ], "rotation": [{ "x": 30 },{ "y": 135 },{ "z": 0 }], "scale": [ 1.5, 1.5, 1.5 ] }
|
||||
}
|
||||
}
|
||||
],
|
||||
"type": {
|
||||
"discharge_meter": {
|
||||
"model": "industrialwires:discharge_meter.obj"
|
||||
}
|
||||
},
|
||||
"boolean0":
|
||||
{
|
||||
"false":{},
|
||||
"true":{
|
||||
"model": "industrialwires:discharge_meter_wire.obj"
|
||||
}
|
||||
},
|
||||
"facing":
|
||||
{
|
||||
"north": { "transform": {
|
||||
"rotation": {"y": 0 }
|
||||
}},
|
||||
"south": { "transform": {
|
||||
"rotation": {"y": 180 }
|
||||
}},
|
||||
"west": { "transform": {
|
||||
"rotation": {"y": 90 }
|
||||
}},
|
||||
"east": { "transform": {
|
||||
"rotation": {"y": -90 }
|
||||
}}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,6 +9,8 @@ tile.industrialwires.ic2_connector.hv_relay.name=IC2 HV Wire Relay
|
|||
tile.industrialwires.ic2_connector.glass_conn.name=Glass Fiber Wire Connector
|
||||
tile.industrialwires.ic2_connector.glass_relay.name=Glass Fiber Wire Relay
|
||||
|
||||
tile.industrialwires.general_hv.discharge_meter.name=Discharge Energy Meter
|
||||
|
||||
tile.industrialwires.mechanical_converter.ie_motor.name=Rotational Motor
|
||||
tile.industrialwires.mechanical_converter.ie_to_ic2.name=Converter: Rotational To Kinetic
|
||||
tile.industrialwires.mechanical_converter.ic2_to_ie.name=Converter: Kinetic To Rotational
|
||||
|
@ -28,6 +30,9 @@ item.industrialwires.ic2_wire_coil.copper.name=Copper Wire Coil
|
|||
item.industrialwires.ic2_wire_coil.gold.name=Gold Wire Coil
|
||||
item.industrialwires.ic2_wire_coil.hv.name=IC2 HV Wire Coil
|
||||
item.industrialwires.ic2_wire_coil.glass.name=Glass Fiber Wire Coil
|
||||
item.industrialwires.ic2_wire_coil.tin_ins.name=Insulated Tin Wire Coil
|
||||
item.industrialwires.ic2_wire_coil.copper_ins.name=Insulated Copper Wire Coil
|
||||
item.industrialwires.ic2_wire_coil.gold_ins.name=Insulated Gold Wire Coil
|
||||
|
||||
item.industrialwires.panel_component.lighted_button.name=Lighted Button
|
||||
item.industrialwires.panel_component.label.name=Label
|
||||
|
@ -38,6 +43,7 @@ item.industrialwires.panel_component.toggle_switch.name=Toggle Switch
|
|||
item.industrialwires.panel_component.toggle_switch_covered.name=Covered Toggle Switch
|
||||
item.industrialwires.panel_component.lock.name=Lock Switch
|
||||
item.industrialwires.panel_component.panel_meter.name=Panel Meter
|
||||
item.industrialwires.panel_component.7seg.name=7-Segment Display
|
||||
item.industrialwires.key.key.name=Key
|
||||
item.industrialwires.key.key_named.name=Key for
|
||||
item.industrialwires.key.blank_key.name=Blank Key
|
||||
|
@ -100,6 +106,7 @@ industrialwires.tooltip.input_rate=%s EU/t per connector
|
|||
|
||||
industrialwires.chat.tooLong=This coil does not contain enough wire for this connection
|
||||
industrialwires.chat.stackSize=Linking is only possible with a stack of size 1
|
||||
industrialwires.chat.marxEnergy=Last discharge was %s kJ per block
|
||||
|
||||
death.attack.industrialwires.jacobs_ladder=%1$s was electrocuted by a Jacob's Ladder
|
||||
death.attack.industrialwires.marx=%1$s was struck by lightning produced by a Marx generator
|
||||
|
@ -131,14 +138,7 @@ ie.manual.entry.industrialwires.jacobs1=These are the required power values in E
|
|||
|
||||
ie.manual.entry.industrialwires.marx.name=Marx Generator
|
||||
ie.manual.entry.industrialwires.marx.subtext=I'm Erwin-Otto, not Karl!
|
||||
ie.manual.entry.industrialwires.marx0=A Marx Generator is a device use to produce high-voltage high-energy pulses. These pulses are visible as lightning between the output terminals and can be used to process ores. Each type of ore has an ideal amount of processing energy (see <link;industrialwires.marx;§oAppendix B§r;7>). The precise values are unknown, estimate values with 10%% accuracy can be found at the end of this entry. The factor between the actual value and the estimate is the same for all types of ore.
|
||||
ie.manual.entry.industrialwires.marx1=§lConstruction§r<br>The above plan shows a 5-stage generator capable of producing 3 block lightning. An arbitrary amount of stages can be added by increasing the number of
|
||||
ie.manual.entry.industrialwires.marx2="middle" layers. Power (either IF or EU) is connected to the HV connector, the redstone wire for the control signals is connected to the redstone connector<br>§lEnergy§r<br>Each stage of the Marx generator consists of a 1.6μF capacitor that is charged to up to 250kV (see <link;industrialwires.marx;§oAppendix A§r;6>). When the generator is fully charged the voltage of each capacitor is roughly equal to the charging voltage. The total energy is the sum of the energy stored in the individual
|
||||
ie.manual.entry.industrialwires.marx3=capacitors and is split equally between the ores to be processed.<br>§lControl signals§r<br>Voltages are represented by 2 signals: The first signal is simply proportional to the voltage to represent. The second signal is proportional to the voltage in the "gap" between 2 values of the first signal, thus allowing more precise control/measurements. Panel components capable of interacting with analog signals usually support this dual-channel setup.
|
||||
ie.manual.entry.industrialwires.marx4=The charging voltage is controlled by the white and yellow signals. The voltages of the top and bottom capacitor are output to the magenta and pink resp. the orange and lime signals. The light blue signal is a firing control. If it is high the generator will attempt to fire. If the voltage of the bottom capacitor is lower than 125 kV or the total voltage is lower than 30%% of the maximum output voltage the generator will misfire, discharging the capacitors without actually producing lightning.
|
||||
ie.manual.entry.industrialwires.marx5=§lSafety§r<br>Due to the high voltages and energies involved in firing a Marx generator a safe distance should be maintained to avoid injury or death. Even outside of this area hearing protection (As provided by Immersive Engineering) is obligatory. Formulas to calculate the safe distances can be found in <link;industrialwires.marx;§oAppendix A§r;6>.
|
||||
ie.manual.entry.industrialwires.marx6=§lAppendix A: Formulas§r<br>Energy stored in a capacitor:<br>E=0.5*C*U^2<br>E: Energy, C: Capacitance, U: Voltage<br>Voltage from redstone signals:<br>U=250/255*(16*a+b)<br>U: Voltage, a: First signal, b: Second signal<br>Safe distance (Physical damage):<br>r=sqrt(e/50,000)<br>r: Safe distance, e: Energy stored<br>Safe distance (Ear damage):<br>r=sqrt(e)/100<br>r: Safe distance, e: Energy stored
|
||||
ie.manual.entry.industrialwires.marx7=§lAppendix B: Ore Energy Values§r
|
||||
ie.manual.entry.industrialwires.marx=A Marx Generator is a device use to produce high-voltage high-energy pulses. These pulses are visible as lightning between the output terminals and can be used to process ores. Each type of ore has an ideal amount of processing energy (see <link;industrialwires.marx;§oAppendix B§r;7>). The precise values are unknown, estimate values with 10%% accuracy can be found at the end of this entry. The factor between the actual value and the estimate is the same for all types of ore.<br>§lConstruction§r<&0><br>The above plan shows a 5-stage generator capable of producing 3 block lightning. An arbitrary amount of stages can be added by increasing the number of "middle" layers. Power (either IF or EU) is connected to the HV connector, the redstone wire for the control signals is connected to the redstone connector<br>§lEnergy§r<br>Each stage of the Marx generator consists of a 1.6μF capacitor that is charged to up to 250kV (see <link;industrialwires.marx;§oAppendix A§r;6>). When the generator is fully charged the voltage of each capacitor is roughly equal to the charging voltage. The total energy is the sum of the energy stored in the individual capacitors and is split equally between the ores to be processed.<br>§lControl signals§r<br>Voltages are represented by 2 signals: The first signal is simply proportional to the voltage to represent. The second signal is proportional to the voltage in the "gap" between 2 values of the first signal, thus allowing more precise control/measurements. Panel components capable of interacting with analog signals usually support this dual-channel setup. The charging voltage is controlled by the white and yellow signals. The voltages of the top and bottom capacitor are output to the magenta and pink resp. the orange and lime signals. The light blue signal is a firing control. If it is high the generator will attempt to fire. If the voltage of the bottom capacitor is lower than 125 kV or the total voltage is lower than 30%% of the maximum output voltage the generator will misfire, discharging the capacitors without actually producing lightning.<br>§lSafety§r<br>Due to the high voltages and energies involved in firing a Marx generator a safe distance should be maintained to avoid injury or death. Even outside of this area hearing protection (As provided by Immersive Engineering) is obligatory. Formulas to calculate the safe distances can be found in <link;industrialwires.marx;§oAppendix A§r;6>.<np>§lAppendix A: Formulas§r<br>Energy stored in a capacitor:<br>E=0.5*C*U^2<br>E: Energy, C: Capacitance, U: Voltage<br><br>Voltage from redstone signals:<br>U=250/255*(16*a+b)<br>U: Voltage (kV), a: First signal, b: Second signal<br><br>Safe distance (Physical damage):<br>r=sqrt(e/50,000)<br>r: Safe distance, e: Energy stored<br><br>Safe distance (Ear damage):<br>r=sqrt(e)/50<br>r: Safe distance, e: Energy stored<np>§lAppendix B: Ore Energy Values§r<br>
|
||||
|
||||
ie.manual.entry.industrialwires.intro.name=Introduction
|
||||
ie.manual.entry.industrialwires.intro.subtext=
|
||||
|
@ -162,7 +162,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.<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.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 by shift-right-clicking 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 would.
|
||||
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.
|
||||
|
@ -172,4 +172,5 @@ ie.manual.entry.industrialwires.toggle_switch1=the switch. The color of the cove
|
|||
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.
|
||||
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 difference between the formats is purely visual.
|
||||
ie.manual.entry.industrialwires.7seg=Seven-Segment Displays are a way of displaying analog redstone signals precisely. Signal strengths 0-9 are displayed as one would expect, levels 10-15 are represented by the letters A-E. Some of the letters are lower-case to differentiate them from digits (e.g. 8 vs B).
|
|
@ -0,0 +1,2 @@
|
|||
newmtl discharge_meter
|
||||
map_Ka industrialwires:blocks/discharge_meter
|
|
@ -0,0 +1,268 @@
|
|||
mtllib discharge_meter.mtl
|
||||
o insulator
|
||||
v 0.375000 0.125000 0.562500
|
||||
v 0.375000 0.187500 0.562500
|
||||
v 0.375000 0.125000 0.437500
|
||||
v 0.375000 0.187500 0.437500
|
||||
v 0.625000 0.125000 0.562500
|
||||
v 0.625000 0.187500 0.562500
|
||||
v 0.625000 0.125000 0.437500
|
||||
v 0.625000 0.187500 0.437500
|
||||
v 0.125000 0.875000 0.625000
|
||||
v 0.125000 0.125000 0.625000
|
||||
v 0.375000 0.125000 0.625000
|
||||
v 0.375000 0.875000 0.625000
|
||||
v 0.375000 0.875000 0.375000
|
||||
v 0.375000 0.125000 0.375000
|
||||
v 0.125000 0.125000 0.375000
|
||||
v 0.125000 0.875000 0.375000
|
||||
v 0.062500 0.375000 0.687500
|
||||
v 0.062500 0.250000 0.687500
|
||||
v 0.437500 0.250000 0.687500
|
||||
v 0.437500 0.375000 0.687500
|
||||
v 0.437500 0.375000 0.312500
|
||||
v 0.437500 0.250000 0.312500
|
||||
v 0.062500 0.250000 0.312500
|
||||
v 0.062500 0.375000 0.312500
|
||||
v 0.062500 0.562500 0.687500
|
||||
v 0.062500 0.437500 0.687500
|
||||
v 0.437500 0.437500 0.687500
|
||||
v 0.437500 0.562500 0.687500
|
||||
v 0.437500 0.562500 0.312500
|
||||
v 0.437500 0.437500 0.312500
|
||||
v 0.062500 0.437500 0.312500
|
||||
v 0.062500 0.562500 0.312500
|
||||
v 0.062500 0.750000 0.687500
|
||||
v 0.062500 0.625000 0.687500
|
||||
v 0.437500 0.625000 0.687500
|
||||
v 0.437500 0.750000 0.687500
|
||||
v 0.437500 0.750000 0.312500
|
||||
v 0.437500 0.625000 0.312500
|
||||
v 0.062500 0.625000 0.312500
|
||||
v 0.062500 0.750000 0.312500
|
||||
v 0.062500 0.125000 0.687500
|
||||
v 0.062500 -0.000000 0.687500
|
||||
v 0.437500 -0.000000 0.687500
|
||||
v 0.437500 0.125000 0.687500
|
||||
v 0.437500 0.125000 0.312500
|
||||
v 0.437500 -0.000000 0.312500
|
||||
v 0.062500 -0.000000 0.312500
|
||||
v 0.062500 0.125000 0.312500
|
||||
v 0.375000 0.812500 0.562500
|
||||
v 0.375000 0.875000 0.562500
|
||||
v 0.375000 0.812500 0.437500
|
||||
v 0.375000 0.875000 0.437500
|
||||
v 0.625000 0.812500 0.562500
|
||||
v 0.625000 0.875000 0.562500
|
||||
v 0.625000 0.812500 0.437500
|
||||
v 0.625000 0.875000 0.437500
|
||||
vt 0.0000 0.0000
|
||||
vt 0.0000 0.0000
|
||||
vt 0.0000 0.0000
|
||||
vt 0.0000 0.0000
|
||||
vt 0.5000 0.8125
|
||||
vt 0.5000 0.7500
|
||||
vt 0.7500 0.7500
|
||||
vt 0.7500 0.8125
|
||||
vt 0.6875 0.8750
|
||||
vt 0.6875 0.8125
|
||||
vt 0.5625 0.8125
|
||||
vt 0.5625 0.8750
|
||||
vt 0.5000 0.8125
|
||||
vt 0.5000 0.7500
|
||||
vt 0.2500 0.7500
|
||||
vt 0.2500 0.8125
|
||||
vt 0.6875 1.0000
|
||||
vt 0.6875 0.7500
|
||||
vt 0.8125 0.7500
|
||||
vt 0.8125 1.0000
|
||||
vt 0.8125 1.0000
|
||||
vt 0.5625 1.0000
|
||||
vt 0.5625 0.8750
|
||||
vt 0.8125 0.8750
|
||||
vt -0.0000 1.0000
|
||||
vt 0.0000 0.1875
|
||||
vt 0.2500 0.1875
|
||||
vt 0.2500 1.0000
|
||||
vt 0.0000 0.9375
|
||||
vt -0.0000 0.0625
|
||||
vt 0.2500 0.0625
|
||||
vt 0.2500 0.9375
|
||||
vt 0.0000 1.0000
|
||||
vt 0.0000 0.7500
|
||||
vt 0.2500 0.7500
|
||||
vt 0.2500 1.0000
|
||||
vt 0.2500 0.7500
|
||||
vt 0.2500 1.0000
|
||||
vt 0.0000 1.0000
|
||||
vt 0.0000 0.7500
|
||||
vt 0.2500 0.9375
|
||||
vt -0.0000 0.9375
|
||||
vt -0.0000 0.0625
|
||||
vt 0.2500 0.0625
|
||||
vt 0.0000 0.1875
|
||||
vt 0.2500 0.1875
|
||||
vt 0.2500 1.0000
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.7500
|
||||
vt 1.0000 0.7500
|
||||
vt 1.0000 0.3750
|
||||
vt 1.0000 0.7500
|
||||
vt 0.6250 0.7500
|
||||
vt 0.6250 0.3750
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.7500
|
||||
vt 1.0000 0.7500
|
||||
vt 1.0000 0.3750
|
||||
vt 1.0000 0.7500
|
||||
vt 0.6250 0.7500
|
||||
vt 0.6250 0.3750
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.7500
|
||||
vt 1.0000 0.7500
|
||||
vt 1.0000 0.3750
|
||||
vt 1.0000 0.7500
|
||||
vt 0.6250 0.7500
|
||||
vt 0.6250 0.3750
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 1.0000 0.3750
|
||||
vt 0.4375 1.0000
|
||||
vt 0.4375 0.8750
|
||||
vt 0.6875 0.8750
|
||||
vt 0.6875 1.0000
|
||||
vt 0.4375 0.8750
|
||||
vt 0.4375 0.7500
|
||||
vt 0.8125 0.7500
|
||||
vt 0.8125 0.8750
|
||||
vt 0.2500 0.8125
|
||||
vt 0.2500 0.4375
|
||||
vt 0.6250 0.4375
|
||||
vt 0.6250 0.8125
|
||||
vt 0.6250 0.2500
|
||||
vt 0.6250 0.6250
|
||||
vt 0.2500 0.6250
|
||||
vt 0.2500 0.2500
|
||||
vt 0.8125 0.8750
|
||||
vt 0.4375 0.8750
|
||||
vt 0.4375 0.7500
|
||||
vt 0.8125 0.7500
|
||||
vt 0.4375 1.0000
|
||||
vt 0.4375 0.8750
|
||||
vt 0.8125 0.8750
|
||||
vt 0.8125 1.0000
|
||||
vt 0.0000 0.0000
|
||||
vt 0.0000 0.0000
|
||||
vt 0.0000 0.0000
|
||||
vt 0.0000 0.0000
|
||||
vt 0.6875 0.7500
|
||||
vt 0.6250 0.7500
|
||||
vt 0.6250 1.0000
|
||||
vt 0.6875 1.0000
|
||||
vt 0.2500 0.7500
|
||||
vt 0.2500 0.8125
|
||||
vt 0.3750 0.8125
|
||||
vt 0.3750 0.7500
|
||||
vt 1.0000 0.7500
|
||||
vt 0.7500 0.7500
|
||||
vt 0.7500 0.8125
|
||||
vt 1.0000 0.8125
|
||||
vt 0.5000 0.8125
|
||||
vt 0.7500 0.8125
|
||||
vt 0.7500 0.9375
|
||||
vt 0.5000 0.9375
|
||||
vt 0.4375 1.0000
|
||||
vt 0.4375 0.7500
|
||||
vt 0.5625 0.7500
|
||||
vt 0.5625 1.0000
|
||||
vn -1.0000 0.0000 0.0000
|
||||
vn 0.0000 0.0000 -1.0000
|
||||
vn 1.0000 0.0000 0.0000
|
||||
vn 0.0000 0.0000 1.0000
|
||||
vn 0.0000 -1.0000 0.0000
|
||||
vn 0.0000 1.0000 0.0000
|
||||
usemtl discharge_meter
|
||||
f 1/1/1 2/2/1 4/3/1 3/4/1
|
||||
f 3/5/2 4/6/2 8/7/2 7/8/2
|
||||
f 7/9/3 8/10/3 6/11/3 5/12/3
|
||||
f 5/13/4 6/14/4 2/15/4 1/16/4
|
||||
f 3/17/5 7/18/5 5/19/5 1/20/5
|
||||
f 8/21/6 4/22/6 2/23/6 6/24/6
|
||||
f 9/25/4 10/26/4 11/27/4 12/28/4
|
||||
f 13/29/2 14/30/2 15/31/2 16/32/2
|
||||
f 16/33/6 9/34/6 12/35/6 13/36/6
|
||||
f 10/37/5 15/38/5 14/39/5 11/40/5
|
||||
f 13/41/3 12/42/3 11/43/3 14/44/3
|
||||
f 16/33/1 15/45/1 10/46/1 9/47/1
|
||||
f 17/48/4 18/49/4 19/50/4 20/51/4
|
||||
f 21/52/2 22/53/2 23/54/2 24/55/2
|
||||
f 24/56/6 17/48/6 20/51/6 21/57/6
|
||||
f 18/58/5 23/59/5 22/60/5 19/61/5
|
||||
f 21/62/3 20/63/3 19/64/3 22/65/3
|
||||
f 24/66/1 23/67/1 18/68/1 17/69/1
|
||||
f 25/70/4 26/71/4 27/72/4 28/73/4
|
||||
f 29/74/2 30/75/2 31/76/2 32/77/2
|
||||
f 32/78/6 25/70/6 28/73/6 29/79/6
|
||||
f 26/80/5 31/81/5 30/82/5 27/83/5
|
||||
f 29/84/3 28/85/3 27/86/3 30/87/3
|
||||
f 32/88/1 31/89/1 26/90/1 25/91/1
|
||||
f 33/92/4 34/93/4 35/94/4 36/95/4
|
||||
f 37/96/2 38/97/2 39/98/2 40/99/2
|
||||
f 40/100/6 33/92/6 36/95/6 37/101/6
|
||||
f 34/102/5 39/103/5 38/104/5 35/105/5
|
||||
f 37/106/3 36/107/3 35/108/3 38/109/3
|
||||
f 40/110/1 39/111/1 34/112/1 33/113/1
|
||||
f 41/114/4 42/115/4 43/116/4 44/117/4
|
||||
f 45/118/2 46/119/2 47/120/2 48/121/2
|
||||
f 48/122/6 41/123/6 44/124/6 45/125/6
|
||||
f 42/126/5 47/127/5 46/128/5 43/129/5
|
||||
f 45/130/3 44/131/3 43/132/3 46/133/3
|
||||
f 48/134/1 47/135/1 42/136/1 41/137/1
|
||||
f 49/138/1 50/139/1 52/140/1 51/141/1
|
||||
f 51/142/2 52/143/2 56/144/2 55/145/2
|
||||
f 55/146/3 56/147/3 54/148/3 53/149/3
|
||||
f 53/150/4 54/151/4 50/152/4 49/153/4
|
||||
f 51/154/5 55/155/5 53/156/5 49/157/5
|
||||
f 56/158/6 52/159/6 50/160/6 54/161/6
|
|
@ -0,0 +1,2 @@
|
|||
newmtl discharge_meter
|
||||
map_Ka industrialwires:blocks/discharge_meter
|
|
@ -0,0 +1,316 @@
|
|||
# Blender v2.78 (sub 0) OBJ File: ''
|
||||
# www.blender.org
|
||||
mtllib discharge_meter_wire.mtl
|
||||
o Wire
|
||||
v 0.531250 0.062500 0.531250
|
||||
v 0.531250 0.937500 0.531250
|
||||
v 0.531250 0.937500 0.468750
|
||||
v 0.531250 0.062500 0.468750
|
||||
v 0.593750 0.937500 0.468750
|
||||
v 0.593750 0.062500 0.468750
|
||||
v 0.593750 0.937500 0.531250
|
||||
v 0.593750 0.062500 0.531250
|
||||
vt 0.0000 0.0000
|
||||
vt 1.0000 0.0000
|
||||
vt 1.0000 0.0625
|
||||
vt -0.0000 0.0625
|
||||
vt 1.0000 0.0625
|
||||
vt 0.0000 0.0625
|
||||
vt 0.0000 0.0000
|
||||
vt 1.0000 0.0000
|
||||
vt 0.0000 0.0000
|
||||
vt 1.0000 0.0000
|
||||
vt 1.0000 0.0625
|
||||
vt -0.0000 0.0625
|
||||
vt 1.0000 0.0625
|
||||
vt 0.0000 0.0625
|
||||
vt 0.0000 0.0000
|
||||
vt 1.0000 0.0000
|
||||
vt 0.7500 0.0000
|
||||
vt 0.8125 -0.0000
|
||||
vt 0.8125 0.0625
|
||||
vt 0.7500 0.0625
|
||||
vt 0.2500 0.0000
|
||||
vt 0.3125 0.0000
|
||||
vt 0.3125 0.0625
|
||||
vt 0.2500 0.0625
|
||||
vn -1.0000 0.0000 0.0000
|
||||
vn 0.0000 0.0000 -1.0000
|
||||
vn 1.0000 -0.0000 0.0000
|
||||
vn 0.0000 -0.0000 1.0000
|
||||
vn 0.0000 -1.0000 0.0000
|
||||
vn 0.0000 1.0000 0.0000
|
||||
usemtl discharge_meter
|
||||
f 1/1/1 2/2/1 3/3/1 4/4/1
|
||||
f 4/5/2 3/6/2 5/7/2 6/8/2
|
||||
f 6/9/3 5/10/3 7/11/3 8/12/3
|
||||
f 8/13/4 7/14/4 2/15/4 1/16/4
|
||||
f 4/17/5 6/18/5 8/19/5 1/20/5
|
||||
f 5/21/6 3/22/6 2/23/6 7/24/6
|
||||
o Insulator
|
||||
v 0.375000 0.125000 0.562500
|
||||
v 0.375000 0.187500 0.562500
|
||||
v 0.375000 0.187500 0.437500
|
||||
v 0.375000 0.125000 0.437500
|
||||
v 0.625000 0.187500 0.437500
|
||||
v 0.625000 0.125000 0.437500
|
||||
v 0.625000 0.187500 0.562500
|
||||
v 0.625000 0.125000 0.562500
|
||||
v 0.125000 0.875000 0.625000
|
||||
v 0.125000 0.125000 0.625000
|
||||
v 0.375000 0.125000 0.625000
|
||||
v 0.375000 0.875000 0.625000
|
||||
v 0.375000 0.875000 0.375000
|
||||
v 0.375000 0.125000 0.375000
|
||||
v 0.125000 0.125000 0.375000
|
||||
v 0.125000 0.875000 0.375000
|
||||
v 0.062500 0.375000 0.687500
|
||||
v 0.062500 0.250000 0.687500
|
||||
v 0.437500 0.250000 0.687500
|
||||
v 0.437500 0.375000 0.687500
|
||||
v 0.437500 0.375000 0.312500
|
||||
v 0.437500 0.250000 0.312500
|
||||
v 0.062500 0.250000 0.312500
|
||||
v 0.062500 0.375000 0.312500
|
||||
v 0.062500 0.562500 0.687500
|
||||
v 0.062500 0.437500 0.687500
|
||||
v 0.437500 0.437500 0.687500
|
||||
v 0.437500 0.562500 0.687500
|
||||
v 0.437500 0.562500 0.312500
|
||||
v 0.437500 0.437500 0.312500
|
||||
v 0.062500 0.437500 0.312500
|
||||
v 0.062500 0.562500 0.312500
|
||||
v 0.062500 0.750000 0.687500
|
||||
v 0.062500 0.625000 0.687500
|
||||
v 0.437500 0.625000 0.687500
|
||||
v 0.437500 0.750000 0.687500
|
||||
v 0.437500 0.750000 0.312500
|
||||
v 0.437500 0.625000 0.312500
|
||||
v 0.062500 0.625000 0.312500
|
||||
v 0.062500 0.750000 0.312500
|
||||
v 0.062500 0.125000 0.687500
|
||||
v 0.062500 -0.000000 0.687500
|
||||
v 0.437500 -0.000000 0.687500
|
||||
v 0.437500 0.125000 0.687500
|
||||
v 0.437500 0.125000 0.312500
|
||||
v 0.437500 -0.000000 0.312500
|
||||
v 0.062500 -0.000000 0.312500
|
||||
v 0.062500 0.125000 0.312500
|
||||
v 0.375000 0.812500 0.562500
|
||||
v 0.375000 0.875000 0.562500
|
||||
v 0.375000 0.875000 0.437500
|
||||
v 0.375000 0.812500 0.437500
|
||||
v 0.625000 0.875000 0.437500
|
||||
v 0.625000 0.812500 0.437500
|
||||
v 0.625000 0.875000 0.562500
|
||||
v 0.625000 0.812500 0.562500
|
||||
vt 0.0000 0.0000
|
||||
vt 0.0000 0.0000
|
||||
vt 0.0000 0.0000
|
||||
vt 0.0000 0.0000
|
||||
vt 0.5000 0.8125
|
||||
vt 0.5000 0.7500
|
||||
vt 0.7500 0.7500
|
||||
vt 0.7500 0.8125
|
||||
vt 0.6875 0.8750
|
||||
vt 0.6875 0.8125
|
||||
vt 0.5625 0.8125
|
||||
vt 0.5625 0.8750
|
||||
vt 0.5000 0.8125
|
||||
vt 0.5000 0.7500
|
||||
vt 0.2500 0.7500
|
||||
vt 0.2500 0.8125
|
||||
vt 0.6875 1.0000
|
||||
vt 0.6875 0.7500
|
||||
vt 0.8125 0.7500
|
||||
vt 0.8125 1.0000
|
||||
vt 0.8125 1.0000
|
||||
vt 0.5625 1.0000
|
||||
vt 0.5625 0.8750
|
||||
vt 0.8125 0.8750
|
||||
vt -0.0000 1.0000
|
||||
vt 0.0000 0.1875
|
||||
vt 0.2500 0.1875
|
||||
vt 0.2500 1.0000
|
||||
vt 0.0000 0.9375
|
||||
vt -0.0000 0.0625
|
||||
vt 0.2500 0.0625
|
||||
vt 0.2500 0.9375
|
||||
vt 0.0000 1.0000
|
||||
vt 0.0000 0.7500
|
||||
vt 0.2500 0.7500
|
||||
vt 0.2500 1.0000
|
||||
vt 0.2500 0.7500
|
||||
vt 0.2500 1.0000
|
||||
vt 0.0000 1.0000
|
||||
vt 0.0000 0.7500
|
||||
vt 0.2500 0.9375
|
||||
vt -0.0000 0.9375
|
||||
vt -0.0000 0.0625
|
||||
vt 0.2500 0.0625
|
||||
vt 0.0000 0.1875
|
||||
vt 0.2500 0.1875
|
||||
vt 0.2500 1.0000
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.7500
|
||||
vt 1.0000 0.7500
|
||||
vt 1.0000 0.3750
|
||||
vt 1.0000 0.7500
|
||||
vt 0.6250 0.7500
|
||||
vt 0.6250 0.3750
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.7500
|
||||
vt 1.0000 0.7500
|
||||
vt 1.0000 0.3750
|
||||
vt 1.0000 0.7500
|
||||
vt 0.6250 0.7500
|
||||
vt 0.6250 0.3750
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.7500
|
||||
vt 1.0000 0.7500
|
||||
vt 1.0000 0.3750
|
||||
vt 1.0000 0.7500
|
||||
vt 0.6250 0.7500
|
||||
vt 0.6250 0.3750
|
||||
vt 1.0000 0.3750
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 0.6250 0.3750
|
||||
vt 0.6250 0.2500
|
||||
vt 1.0000 0.2500
|
||||
vt 1.0000 0.3750
|
||||
vt 0.4375 1.0000
|
||||
vt 0.4375 0.8750
|
||||
vt 0.6875 0.8750
|
||||
vt 0.6875 1.0000
|
||||
vt 0.4375 0.8750
|
||||
vt 0.4375 0.7500
|
||||
vt 0.8125 0.7500
|
||||
vt 0.8125 0.8750
|
||||
vt 0.2500 0.8125
|
||||
vt 0.2500 0.4375
|
||||
vt 0.6250 0.4375
|
||||
vt 0.6250 0.8125
|
||||
vt 0.6250 0.2500
|
||||
vt 0.6250 0.6250
|
||||
vt 0.2500 0.6250
|
||||
vt 0.2500 0.2500
|
||||
vt 0.8125 0.8750
|
||||
vt 0.4375 0.8750
|
||||
vt 0.4375 0.7500
|
||||
vt 0.8125 0.7500
|
||||
vt 0.4375 1.0000
|
||||
vt 0.4375 0.8750
|
||||
vt 0.8125 0.8750
|
||||
vt 0.8125 1.0000
|
||||
vt 0.0000 0.0000
|
||||
vt 0.0000 0.0000
|
||||
vt 0.0000 0.0000
|
||||
vt 0.0000 0.0000
|
||||
vt 0.6875 0.7500
|
||||
vt 0.6250 0.7500
|
||||
vt 0.6250 1.0000
|
||||
vt 0.6875 1.0000
|
||||
vt 0.2500 0.7500
|
||||
vt 0.2500 0.8125
|
||||
vt 0.3750 0.8125
|
||||
vt 0.3750 0.7500
|
||||
vt 1.0000 0.7500
|
||||
vt 0.7500 0.7500
|
||||
vt 0.7500 0.8125
|
||||
vt 1.0000 0.8125
|
||||
vt 0.5000 0.8125
|
||||
vt 0.7500 0.8125
|
||||
vt 0.7500 0.9375
|
||||
vt 0.5000 0.9375
|
||||
vt 0.4375 1.0000
|
||||
vt 0.4375 0.7500
|
||||
vt 0.5625 0.7500
|
||||
vt 0.5625 1.0000
|
||||
vn -1.0000 0.0000 0.0000
|
||||
vn 0.0000 0.0000 -1.0000
|
||||
vn 1.0000 0.0000 0.0000
|
||||
vn 0.0000 0.0000 1.0000
|
||||
vn 0.0000 -1.0000 0.0000
|
||||
vn 0.0000 1.0000 0.0000
|
||||
usemtl discharge_meter
|
||||
f 9/25/7 10/26/7 11/27/7 12/28/7
|
||||
f 12/29/8 11/30/8 13/31/8 14/32/8
|
||||
f 14/33/9 13/34/9 15/35/9 16/36/9
|
||||
f 16/37/10 15/38/10 10/39/10 9/40/10
|
||||
f 12/41/11 14/42/11 16/43/11 9/44/11
|
||||
f 13/45/12 11/46/12 10/47/12 15/48/12
|
||||
f 17/49/10 18/50/10 19/51/10 20/52/10
|
||||
f 21/53/8 22/54/8 23/55/8 24/56/8
|
||||
f 24/57/12 17/58/12 20/59/12 21/60/12
|
||||
f 18/61/11 23/62/11 22/63/11 19/64/11
|
||||
f 21/65/9 20/66/9 19/67/9 22/68/9
|
||||
f 24/57/7 23/69/7 18/70/7 17/71/7
|
||||
f 25/72/10 26/73/10 27/74/10 28/75/10
|
||||
f 29/76/8 30/77/8 31/78/8 32/79/8
|
||||
f 32/80/12 25/72/12 28/75/12 29/81/12
|
||||
f 26/82/11 31/83/11 30/84/11 27/85/11
|
||||
f 29/86/9 28/87/9 27/88/9 30/89/9
|
||||
f 32/90/7 31/91/7 26/92/7 25/93/7
|
||||
f 33/94/10 34/95/10 35/96/10 36/97/10
|
||||
f 37/98/8 38/99/8 39/100/8 40/101/8
|
||||
f 40/102/12 33/94/12 36/97/12 37/103/12
|
||||
f 34/104/11 39/105/11 38/106/11 35/107/11
|
||||
f 37/108/9 36/109/9 35/110/9 38/111/9
|
||||
f 40/112/7 39/113/7 34/114/7 33/115/7
|
||||
f 41/116/10 42/117/10 43/118/10 44/119/10
|
||||
f 45/120/8 46/121/8 47/122/8 48/123/8
|
||||
f 48/124/12 41/116/12 44/119/12 45/125/12
|
||||
f 42/126/11 47/127/11 46/128/11 43/129/11
|
||||
f 45/130/9 44/131/9 43/132/9 46/133/9
|
||||
f 48/134/7 47/135/7 42/136/7 41/137/7
|
||||
f 49/138/10 50/139/10 51/140/10 52/141/10
|
||||
f 53/142/8 54/143/8 55/144/8 56/145/8
|
||||
f 56/146/12 49/147/12 52/148/12 53/149/12
|
||||
f 50/150/11 55/151/11 54/152/11 51/153/11
|
||||
f 53/154/9 52/155/9 51/156/9 54/157/9
|
||||
f 56/158/7 55/159/7 50/160/7 49/161/7
|
||||
f 57/162/7 58/163/7 59/164/7 60/165/7
|
||||
f 60/166/8 59/167/8 61/168/8 62/169/8
|
||||
f 62/170/9 61/171/9 63/172/9 64/173/9
|
||||
f 64/174/10 63/175/10 58/176/10 57/177/10
|
||||
f 60/178/11 62/179/11 64/180/11 57/181/11
|
||||
f 61/182/12 59/183/12 58/184/12 63/185/12
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"parent":"item/generated",
|
||||
"textures": {
|
||||
"layer0":"industrialwires:items/background_odd",
|
||||
"layer1":"industrialwires:items/7seg"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"result": {
|
||||
"item": "industrialwires:general_hv",
|
||||
"data": 0
|
||||
},
|
||||
"pattern": [
|
||||
"ss",
|
||||
"c ",
|
||||
"ss"
|
||||
],
|
||||
"type": "forge:ore_shaped",
|
||||
"key": {
|
||||
"c": {
|
||||
"item": "immersiveengineering:connector",
|
||||
"data": 4
|
||||
},
|
||||
"s": {
|
||||
"type": "forge:ore_dict", "ore": "stickSteel"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"result": {
|
||||
"item": "industrialwires:panel_component",
|
||||
"data": 9
|
||||
},
|
||||
"ingredients": [
|
||||
{
|
||||
"type": "forge:ore_dict",
|
||||
"ore": "dustRedstone"
|
||||
},
|
||||
{
|
||||
"type": "forge:ore_dict",
|
||||
"ore": "dustGlowstone"
|
||||
},
|
||||
{
|
||||
"type": "forge:ore_dict",
|
||||
"ore": "wireCopper"
|
||||
},
|
||||
{
|
||||
"type": "forge:ore_dict",
|
||||
"ore": "electronTube"
|
||||
}
|
||||
],
|
||||
"type": "forge:ore_shapeless"
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"type": "industrialwires:wire_coil",
|
||||
"cable": {
|
||||
"type": "industrialwires:ic2_item",
|
||||
"name": "cable",
|
||||
"variant": "type:copper,insulation:1"
|
||||
},
|
||||
"coil": {
|
||||
"item": "industrialwires:ic2_wire_coil",
|
||||
"data": 6
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"type": "forge:mod_loaded",
|
||||
"modid": "ic2"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"type": "industrialwires:wire_coil",
|
||||
"cable": {
|
||||
"type": "industrialwires:ic2_item",
|
||||
"name": "cable",
|
||||
"variant": "type:gold,insulation:2"
|
||||
},
|
||||
"coil": {
|
||||
"item": "industrialwires:ic2_wire_coil",
|
||||
"data": 7
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"type": "forge:mod_loaded",
|
||||
"modid": "ic2"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"type": "industrialwires:wire_coil",
|
||||
"cable": {
|
||||
"type": "industrialwires:ic2_item",
|
||||
"name": "cable",
|
||||
"variant": "type:tin,insulation:1"
|
||||
},
|
||||
"coil": {
|
||||
"item": "industrialwires:ic2_wire_coil",
|
||||
"data": 5
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"type": "forge:mod_loaded",
|
||||
"modid": "ic2"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
#version 120
|
||||
uniform float time;
|
||||
#include random.frag
|
||||
void main() {
|
||||
float height = 2*(gl_Color.a-.5);
|
||||
float x = gl_Color.r;
|
||||
height += .5*cnoise(vec2(x*10, time*.5));
|
||||
gl_FragColor = gl_Color;
|
||||
gl_FragColor.r = 1;
|
||||
gl_FragColor.a = 1-height*height;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#version 120
|
||||
uniform float time;
|
||||
#include random.frag
|
||||
void main() {
|
||||
float x = 2*(gl_Color.r-.5);
|
||||
float y = gl_Color.a;
|
||||
x -= .5*cnoise(vec2(10*y, time));
|
||||
gl_FragColor = vec4(1, 1, 1, 1-abs(x));
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
//Noise generation code taken from https://github.com/ashima/webgl-noise/blob/master/src/classicnoise2D.glsl
|
||||
|
||||
vec4 mod289(vec4 x)
|
||||
{
|
||||
return x - floor(x * (1.0 / 289.0)) * 289.0;
|
||||
}
|
||||
|
||||
vec4 permute(vec4 x)
|
||||
{
|
||||
return mod289(((x*34.0)+1.0)*x);
|
||||
}
|
||||
|
||||
vec4 taylorInvSqrt(vec4 r)
|
||||
{
|
||||
return 1.79284291400159 - 0.85373472095314 * r;
|
||||
}
|
||||
|
||||
vec2 fade(vec2 t) {
|
||||
return t*t*t*(t*(t*6.0-15.0)+10.0);
|
||||
}
|
||||
|
||||
// Classic Perlin noise
|
||||
float cnoise(vec2 P)
|
||||
{
|
||||
vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);
|
||||
vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);
|
||||
Pi = mod289(Pi); // To avoid truncation effects in permutation
|
||||
vec4 ix = Pi.xzxz;
|
||||
vec4 iy = Pi.yyww;
|
||||
vec4 fx = Pf.xzxz;
|
||||
vec4 fy = Pf.yyww;
|
||||
|
||||
vec4 i = permute(permute(ix) + iy);
|
||||
|
||||
vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0 ;
|
||||
vec4 gy = abs(gx) - 0.5 ;
|
||||
vec4 tx = floor(gx + 0.5);
|
||||
gx = gx - tx;
|
||||
|
||||
vec2 g00 = vec2(gx.x,gy.x);
|
||||
vec2 g10 = vec2(gx.y,gy.y);
|
||||
vec2 g01 = vec2(gx.z,gy.z);
|
||||
vec2 g11 = vec2(gx.w,gy.w);
|
||||
|
||||
vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));
|
||||
g00 *= norm.x;
|
||||
g01 *= norm.y;
|
||||
g10 *= norm.z;
|
||||
g11 *= norm.w;
|
||||
|
||||
float n00 = dot(g00, vec2(fx.x, fy.x));
|
||||
float n10 = dot(g10, vec2(fx.y, fy.y));
|
||||
float n01 = dot(g01, vec2(fx.z, fy.z));
|
||||
float n11 = dot(g11, vec2(fx.w, fy.w));
|
||||
|
||||
vec2 fade_xy = fade(Pf.xy);
|
||||
vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);
|
||||
float n_xy = mix(n_x.x, n_x.y, fade_xy.y);
|
||||
return 2.3 * n_xy;
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 555 B |
Binary file not shown.
After Width: | Height: | Size: 470 B |
Binary file not shown.
After Width: | Height: | Size: 480 B |
Loading…
Reference in a new issue