├── Textures
├── relay.png
├── fusetex.png
├── metertex.png
├── resistor.png
├── Items
│ └── items.png
├── elecmotortex.png
├── fusetex-burn.png
├── fusetex-hot.png
├── fusetex-hot2.png
├── fusetex-hot3.png
├── generatortex.png
├── GUI
│ ├── rfcablegui.png
│ └── transformergui.png
└── transformertex.png
├── Renders
├── RenderPreciseResistor.java
├── RenderRelay.java
├── RenderGenerator.java
├── RenderResistor.java
├── RenderMotor.java
├── ModelResistor.java
├── ModelMeter.java
├── RenderFuse.java
├── ModelPreciseResistor.java
├── RenderElectricMeter.java
├── RenderWire.java
├── RenderCable.java
├── ModelResistorBase.java
├── RenderTransformer.java
├── ModelTransformer.java
└── RenderModBattery.java
├── Auxiliary
├── Interfaces
│ ├── WireTerminus.java
│ ├── WireFuse.java
│ ├── CurrentThrottle.java
│ ├── ToggledConnection.java
│ ├── Overloadable.java
│ ├── WireReceiver.java
│ ├── ConversionTile.java
│ ├── WireEmitter.java
│ ├── BatteryTile.java
│ └── NetworkTile.java
├── ElectriBookTracker.java
├── ElectriTab.java
├── ElectriStacks.java
├── ElectriBookData.java
├── Lua
│ ├── LuaGetCurrent.java
│ ├── LuaGetVoltage.java
│ ├── LuaGetElectricPower.java
│ ├── LuaGetStoredEnergy.java
│ ├── LuaGetEUCapacity.java
│ ├── LuaGetStoredEU.java
│ ├── LuaGetLongRFCapacity.java
│ └── LuaGetLongStoredRF.java
├── ElectriNetworkEvent.java
├── BatteryTracker.java
├── ElectriRenderList.java
└── WrappedSource.java
├── .gitattributes
├── Base
├── ElectricalEmitter.java
├── ElectricalReceiver.java
├── NetworkBlock.java
├── BatteryTileBase.java
├── WiringTile.java
├── ElectriTERenderer.java
├── ElectriItemBase.java
├── TileEntityWireComponent.java
├── ElectriBlock.java
├── ElectriTileEntity.java
├── TileEntityResistorBase.java
└── NetworkTileEntity.java
├── NetworkObject.java
├── Resources
├── categories.xml
├── es_ES
│ ├── categories.xml
│ └── info.xml
└── info.xml
├── API
└── WrappableWireSource.java
├── Items
├── ItemEnergyCrystal.java
├── ItemElectriBook.java
├── ItemBlockElectriOre.java
├── ItemRFBatteryPlacer.java
└── ItemEUBatteryPlacer.java
├── ElectriCommon.java
├── Registry
├── ElectriPackets.java
├── ElectriCrafting.java
├── ElectriOptions.java
├── BatteryType.java
└── ElectriBlocks.java
├── Blocks
├── BlockEUBattery.java
├── BlockRFBattery.java
├── BlockEUCable.java
├── BlockRFCable.java
├── BlockElectriOre.java
├── BlockEUSplitter.java
└── BlockChargePad.java
├── ElectriConfig.java
├── TileEntities
├── TileEntityMeter.java
├── TileEntityResistor.java
├── TileEntityPreciseResistor.java
├── TileEntityRelay.java
├── ModInterface
│ ├── TileEntityEUCable.java
│ └── TileEntityRFBattery.java
└── TileEntityFuse.java
├── World
├── ElectriOreGenerator.java
└── BasicElectriOreGenerator.java
├── ElectriGuiHandler.java
├── Network
└── NetworkNode.java
├── ElectriNetworkManager.java
├── License.txt
├── ElectriItemRenderer.java
├── .gitignore
├── ElectriClient.java
└── GUIs
└── GuiRFCable.java
/Textures/relay.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ReikaKalseki/ElectriCraft/HEAD/Textures/relay.png
--------------------------------------------------------------------------------
/Textures/fusetex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ReikaKalseki/ElectriCraft/HEAD/Textures/fusetex.png
--------------------------------------------------------------------------------
/Textures/metertex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ReikaKalseki/ElectriCraft/HEAD/Textures/metertex.png
--------------------------------------------------------------------------------
/Textures/resistor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ReikaKalseki/ElectriCraft/HEAD/Textures/resistor.png
--------------------------------------------------------------------------------
/Textures/Items/items.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ReikaKalseki/ElectriCraft/HEAD/Textures/Items/items.png
--------------------------------------------------------------------------------
/Textures/elecmotortex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ReikaKalseki/ElectriCraft/HEAD/Textures/elecmotortex.png
--------------------------------------------------------------------------------
/Textures/fusetex-burn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ReikaKalseki/ElectriCraft/HEAD/Textures/fusetex-burn.png
--------------------------------------------------------------------------------
/Textures/fusetex-hot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ReikaKalseki/ElectriCraft/HEAD/Textures/fusetex-hot.png
--------------------------------------------------------------------------------
/Textures/fusetex-hot2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ReikaKalseki/ElectriCraft/HEAD/Textures/fusetex-hot2.png
--------------------------------------------------------------------------------
/Textures/fusetex-hot3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ReikaKalseki/ElectriCraft/HEAD/Textures/fusetex-hot3.png
--------------------------------------------------------------------------------
/Textures/generatortex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ReikaKalseki/ElectriCraft/HEAD/Textures/generatortex.png
--------------------------------------------------------------------------------
/Textures/GUI/rfcablegui.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ReikaKalseki/ElectriCraft/HEAD/Textures/GUI/rfcablegui.png
--------------------------------------------------------------------------------
/Textures/transformertex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ReikaKalseki/ElectriCraft/HEAD/Textures/transformertex.png
--------------------------------------------------------------------------------
/Textures/GUI/transformergui.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ReikaKalseki/ElectriCraft/HEAD/Textures/GUI/transformergui.png
--------------------------------------------------------------------------------
/Renders/RenderPreciseResistor.java:
--------------------------------------------------------------------------------
1 | package Reika.ElectriCraft.Renders;
2 |
3 |
4 | public class RenderPreciseResistor extends RenderResistor {
5 |
6 | public RenderPreciseResistor() {
7 | super();
8 | ResistorModel = new ModelPreciseResistor();
9 | }
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/Auxiliary/Interfaces/WireTerminus.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary.Interfaces;
11 |
12 |
13 | public interface WireTerminus extends NetworkTile {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/Auxiliary/Interfaces/WireFuse.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary.Interfaces;
11 |
12 |
13 | public interface WireFuse extends Overloadable, ToggledConnection {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/Auxiliary/Interfaces/CurrentThrottle.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary.Interfaces;
11 |
12 |
13 | public interface CurrentThrottle {
14 |
15 | public int getCurrentLimit();
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/Auxiliary/Interfaces/ToggledConnection.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2018
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary.Interfaces;
11 |
12 |
13 | public interface ToggledConnection {
14 |
15 | public boolean canConnect();
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/Auxiliary/Interfaces/Overloadable.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary.Interfaces;
11 |
12 |
13 | public interface Overloadable {
14 |
15 | public int getMaxCurrent();
16 |
17 | public void overload(int current);
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/Base/ElectricalEmitter.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Base;
11 |
12 | import Reika.ElectriCraft.Auxiliary.Interfaces.WireEmitter;
13 |
14 |
15 | public abstract class ElectricalEmitter extends NetworkTileEntity implements WireEmitter {
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/Base/ElectricalReceiver.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Base;
11 |
12 | import Reika.ElectriCraft.Auxiliary.Interfaces.WireReceiver;
13 |
14 | public abstract class ElectricalReceiver extends NetworkTileEntity implements WireReceiver {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/Auxiliary/Interfaces/WireReceiver.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary.Interfaces;
11 |
12 | import net.minecraftforge.common.util.ForgeDirection;
13 |
14 | public interface WireReceiver extends WireTerminus {
15 |
16 | public boolean canReceivePowerFromSide(ForgeDirection dir);
17 |
18 | public boolean canReceivePower();
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/Auxiliary/Interfaces/ConversionTile.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary.Interfaces;
11 |
12 | import net.minecraftforge.common.util.ForgeDirection;
13 |
14 | import Reika.RotaryCraft.API.Power.ShaftMachine;
15 |
16 | public interface ConversionTile extends ShaftMachine {
17 |
18 | public void setFacing(ForgeDirection dir);
19 |
20 | public ForgeDirection getFacing();
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/NetworkObject.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft;
11 |
12 | import Reika.ElectriCraft.Auxiliary.ElectriNetworkEvent.ElectriNetworkRepathEvent;
13 | import Reika.ElectriCraft.Auxiliary.ElectriNetworkEvent.ElectriNetworkTickEvent;
14 |
15 |
16 | public interface NetworkObject {
17 |
18 | public void tick(ElectriNetworkTickEvent evt);
19 |
20 | public void repath(ElectriNetworkRepathEvent evt);
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/Auxiliary/Interfaces/WireEmitter.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary.Interfaces;
11 |
12 | import net.minecraftforge.common.util.ForgeDirection;
13 |
14 | public interface WireEmitter extends WireTerminus {
15 |
16 | public abstract int getGenVoltage();
17 |
18 | public abstract int getGenCurrent();
19 |
20 | public boolean canEmitPowerToSide(ForgeDirection dir);
21 |
22 | public abstract boolean canEmitPower();
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/Resources/categories.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | These machines are used to convert to and from electrical power.
17 |
18 |
19 | These are used to transport and manipulate electrical power.
20 |
21 |
22 | These are the tools used to store electrical power.
23 |
24 |
25 | These are utility blocks used for specialized purposes.
26 |
27 |
28 | These devices interface with other mods.
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Resources/es_ES/categories.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | Estas maquinas son usadas para convertir en y de energia electrica.
17 |
18 |
19 | Estas son usadas para transportar y manipular la energia electrica.
20 |
21 |
22 | Estas son las herramientas usadas para almacenar energia electrica.
23 |
24 |
25 | Estos son bloques de utilidad usados para propositos especiales.
26 |
27 |
28 | Estos dispositivos interactuan con otros mods.
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Auxiliary/ElectriBookTracker.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary;
11 |
12 | import net.minecraft.item.ItemStack;
13 |
14 | import Reika.ElectriCraft.Registry.ElectriItems;
15 | import Reika.RotaryCraft.Auxiliary.HandbookTracker;
16 |
17 | public class ElectriBookTracker extends HandbookTracker {
18 |
19 | @Override
20 | public ItemStack getItem() {
21 | return ElectriItems.BOOK.getStackOf();
22 | }
23 |
24 | @Override
25 | public String getID() {
26 | return "ElectriCraft_Handbook";
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/API/WrappableWireSource.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2018
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.API;
11 |
12 | import net.minecraftforge.common.util.ForgeDirection;
13 |
14 | import Reika.RotaryCraft.API.Power.ShaftMachine;
15 | import Reika.RotaryCraft.Auxiliary.Interfaces.PowerSourceTracker;
16 |
17 | public interface WrappableWireSource extends ShaftMachine, PowerSourceTracker {
18 |
19 | public boolean canConnectToSide(ForgeDirection dir);
20 |
21 | public boolean isFunctional();
22 |
23 | public boolean hasPowerStatusChangedSinceLastTick();
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/Items/ItemEnergyCrystal.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Items;
11 |
12 | import net.minecraft.item.ItemStack;
13 |
14 | import Reika.ElectriCraft.Base.ElectriItemBase;
15 | import Reika.ElectriCraft.Registry.BatteryType;
16 |
17 |
18 | public class ItemEnergyCrystal extends ElectriItemBase {
19 |
20 | public ItemEnergyCrystal(int tex) {
21 | super(tex);
22 | }
23 |
24 | @Override
25 | public boolean hasEffect(ItemStack is) {
26 | return is.getItemDamage() >= BatteryType.batteryList.length-1;
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/Auxiliary/Interfaces/BatteryTile.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary.Interfaces;
11 |
12 | import net.minecraft.item.ItemStack;
13 |
14 | import Reika.ElectriCraft.Auxiliary.BatteryTracker;
15 |
16 | public interface BatteryTile {
17 |
18 | public String getDisplayEnergy();
19 | public long getStoredEnergy();
20 |
21 | public long getMaxEnergy();
22 | public String getFormattedCapacity();
23 |
24 | public void setEnergyFromNBT(ItemStack is);
25 |
26 | public int getEnergyColor();
27 | public String getUnitName();
28 | public boolean isDecimalSystem();
29 |
30 | public BatteryTracker getTracker();
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/Auxiliary/ElectriTab.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary;
11 |
12 | import net.minecraft.item.ItemStack;
13 |
14 | import Reika.DragonAPI.Instantiable.GUI.RegistryEnumCreativeTab;
15 | import Reika.ElectriCraft.Registry.ElectriTiles;
16 |
17 | import cpw.mods.fml.relauncher.Side;
18 | import cpw.mods.fml.relauncher.SideOnly;
19 |
20 | public class ElectriTab extends RegistryEnumCreativeTab {
21 |
22 | public ElectriTab(String tabID) {
23 | super(tabID);
24 | }
25 |
26 | @Override
27 | @SideOnly(Side.CLIENT)
28 | public ItemStack getIconItemStack() {
29 | return ElectriTiles.WIRE.getCraftedProduct();
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/Items/ItemElectriBook.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Items;
11 |
12 | import net.minecraft.entity.player.EntityPlayer;
13 | import net.minecraft.item.ItemStack;
14 | import net.minecraft.world.World;
15 |
16 | import Reika.ElectriCraft.ElectriCraft;
17 | import Reika.ElectriCraft.Base.ElectriItemBase;
18 |
19 | public class ItemElectriBook extends ElectriItemBase {
20 |
21 | public ItemElectriBook(int tex) {
22 | super(tex);
23 | maxStackSize = 1;
24 | }
25 |
26 | @Override
27 | public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer ep)
28 | {
29 | ep.openGui(ElectriCraft.instance, 10, world, 0, 0, 0);
30 | return itemstack;
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/ElectriCommon.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft;
11 |
12 | import net.minecraft.world.World;
13 |
14 | public class ElectriCommon
15 | {
16 | public static int wireRender;
17 | public static int cableRender;
18 | public static int batteryRender;
19 |
20 | /**
21 | * Client side only register stuff...
22 | */
23 | public void registerRenderers()
24 | {
25 | //unused server side. -- see ClientProxy for implementation
26 | }
27 |
28 | public void addArmorRenders() {}
29 |
30 | public World getClientWorld() {
31 | return null;
32 | }
33 |
34 | public void registerRenderInformation() {
35 |
36 | }
37 |
38 | public void registerSounds() {
39 |
40 | }
41 |
42 | }// End class CommonProxy
43 |
--------------------------------------------------------------------------------
/Auxiliary/ElectriStacks.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary;
11 |
12 | import net.minecraft.item.ItemStack;
13 |
14 | import Reika.ElectriCraft.Registry.ElectriOres;
15 |
16 | public class ElectriStacks {
17 |
18 | public static final ItemStack tinIngot = ElectriOres.TIN.getProduct();
19 | public static final ItemStack silverIngot = ElectriOres.SILVER.getProduct();
20 | public static final ItemStack nickelIngot = ElectriOres.NICKEL.getProduct();
21 | public static final ItemStack copperIngot = ElectriOres.COPPER.getProduct();
22 | public static final ItemStack platinumIngot = ElectriOres.PLATINUM.getProduct();
23 | public static final ItemStack aluminumIngot = ElectriOres.ALUMINUM.getProduct();
24 | }
25 |
--------------------------------------------------------------------------------
/Auxiliary/ElectriBookData.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary;
11 |
12 | import Reika.DragonAPI.Instantiable.Data.Maps.ArrayMap;
13 | import Reika.ElectriCraft.Registry.ElectriBook;
14 |
15 | public class ElectriBookData {
16 |
17 | private static final ArrayMap tabMappings = new ArrayMap(2);
18 |
19 | private static void mapHandbook() {
20 | for (int i = 0; i < ElectriBook.tabList.length; i++) {
21 | ElectriBook h = ElectriBook.tabList[i];
22 | tabMappings.putV(h, h.getScreen(), h.getPage());
23 | }
24 | }
25 |
26 | public static ElectriBook getMapping(int screen, int page) {
27 | return tabMappings.getV(screen, page);
28 | }
29 |
30 | static {
31 | mapHandbook();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Registry/ElectriPackets.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Registry;
11 |
12 | import Reika.DragonAPI.Auxiliary.PacketTypes;
13 |
14 | public enum ElectriPackets {
15 |
16 | RFCABLE(1),
17 | TRANSFORMER(2);
18 |
19 | public final int numInts;
20 | public final PacketTypes type;
21 |
22 | private ElectriPackets() {
23 | this(0);
24 | }
25 |
26 | private ElectriPackets(int size) {
27 | this(size, PacketTypes.DATA);
28 | }
29 |
30 | private ElectriPackets(int size, PacketTypes t) {
31 | numInts = size;
32 | type = t;
33 | }
34 |
35 | public static final ElectriPackets getEnum(int id) {
36 | ElectriPackets[] list = values();
37 | id = Math.max(0, Math.min(id, list.length-1));
38 | return list[id];
39 | }
40 |
41 | public boolean hasData() {
42 | return numInts > 0;
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/Auxiliary/Interfaces/NetworkTile.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary.Interfaces;
11 |
12 | import net.minecraft.world.World;
13 | import net.minecraftforge.common.util.ForgeDirection;
14 |
15 | import Reika.ElectriCraft.Network.WireNetwork;
16 |
17 | public interface NetworkTile {
18 |
19 | public void findAndJoinNetwork(World world, int x, int y, int z);
20 |
21 | public WireNetwork getNetwork();
22 |
23 | public void setNetwork(WireNetwork n);
24 |
25 | public void removeFromNetwork();
26 |
27 | public void resetNetwork();
28 |
29 | public boolean isConnectable();
30 |
31 | public void onNetworkChanged();
32 |
33 | public abstract boolean canNetworkOnSide(ForgeDirection dir);
34 |
35 | public World getWorld();
36 | public int getX();
37 | public int getY();
38 | public int getZ();
39 | }
40 |
--------------------------------------------------------------------------------
/Base/NetworkBlock.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Base;
11 |
12 | import net.minecraft.block.Block;
13 | import net.minecraft.block.material.Material;
14 | import net.minecraft.world.World;
15 |
16 | import Reika.DragonAPI.Base.BlockTileEnum;
17 | import Reika.ElectriCraft.Registry.ElectriTiles;
18 |
19 | public abstract class NetworkBlock extends BlockTileEnum {
20 |
21 | public NetworkBlock(Material par2Material) {
22 | super(par2Material);
23 | this.setHardness(2F);
24 | this.setResistance(10F);
25 | }
26 |
27 | @Override
28 | public void breakBlock(World world, int x, int y, int z, Block oldid, int oldmeta) {
29 | NetworkTileEntity te = (NetworkTileEntity)world.getTileEntity(x, y, z);
30 | if (!world.isRemote && te != null)
31 | te.removeFromNetwork();
32 | super.breakBlock(world, x, y, z, oldid, oldmeta);
33 | }
34 |
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/Auxiliary/Lua/LuaGetCurrent.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary.Lua;
11 |
12 | import net.minecraft.tileentity.TileEntity;
13 |
14 | import Reika.DragonAPI.ModInteract.Lua.LuaMethod;
15 | import Reika.ElectriCraft.Base.WiringTile;
16 |
17 | public class LuaGetCurrent extends LuaMethod {
18 |
19 | public LuaGetCurrent() {
20 | super("getCurrent", WiringTile.class);
21 | }
22 |
23 | @Override
24 | protected Object[] invoke(TileEntity te, Object[] args) throws LuaMethodException, InterruptedException {
25 | return new Object[]{((WiringTile)te).getWireCurrent()};
26 | }
27 |
28 | @Override
29 | public String getDocumentation() {
30 | return "Returns the wire current.";
31 | }
32 |
33 | @Override
34 | public String getArgsAsString() {
35 | return "";
36 | }
37 |
38 | @Override
39 | public ReturnType getReturnType() {
40 | return ReturnType.INTEGER;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/Auxiliary/Lua/LuaGetVoltage.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary.Lua;
11 |
12 | import net.minecraft.tileentity.TileEntity;
13 |
14 | import Reika.DragonAPI.ModInteract.Lua.LuaMethod;
15 | import Reika.ElectriCraft.Base.WiringTile;
16 |
17 | public class LuaGetVoltage extends LuaMethod {
18 |
19 | public LuaGetVoltage() {
20 | super("getVoltage", WiringTile.class);
21 | }
22 |
23 | @Override
24 | protected Object[] invoke(TileEntity te, Object[] args) throws LuaMethodException, InterruptedException {
25 | return new Object[]{((WiringTile)te).getWireVoltage()};
26 | }
27 |
28 | @Override
29 | public String getDocumentation() {
30 | return "Returns the wire voltage.";
31 | }
32 |
33 | @Override
34 | public String getArgsAsString() {
35 | return "";
36 | }
37 |
38 | @Override
39 | public ReturnType getReturnType() {
40 | return ReturnType.INTEGER;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/Auxiliary/Lua/LuaGetElectricPower.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary.Lua;
11 |
12 | import net.minecraft.tileentity.TileEntity;
13 |
14 | import Reika.DragonAPI.ModInteract.Lua.LuaMethod;
15 | import Reika.ElectriCraft.Base.WiringTile;
16 |
17 | public class LuaGetElectricPower extends LuaMethod {
18 |
19 | public LuaGetElectricPower() {
20 | super("getElectricPower", WiringTile.class);
21 | }
22 |
23 | @Override
24 | protected Object[] invoke(TileEntity te, Object[] args) throws LuaMethodException, InterruptedException {
25 | return new Object[]{((WiringTile)te).getWirePower()};
26 | }
27 |
28 | @Override
29 | public String getDocumentation() {
30 | return "Returns the wire power.";
31 | }
32 |
33 | @Override
34 | public String getArgsAsString() {
35 | return "";
36 | }
37 |
38 | @Override
39 | public ReturnType getReturnType() {
40 | return ReturnType.INTEGER;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/Auxiliary/ElectriNetworkEvent.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary;
11 |
12 | import net.minecraft.world.World;
13 |
14 | public class ElectriNetworkEvent {
15 |
16 | public final World networkWorld;
17 | public final long worldTime;
18 | public final long systemTime;
19 |
20 | public ElectriNetworkEvent(World world) {
21 | networkWorld = world;
22 | worldTime = world.getTotalWorldTime();
23 | systemTime = System.currentTimeMillis();
24 | }
25 |
26 | public static class ElectriNetworkTickEvent extends ElectriNetworkEvent {
27 |
28 | private static int currentIndex = 0;
29 | public final int tickIndex;
30 |
31 | public ElectriNetworkTickEvent(World world) {
32 | super(world);
33 | tickIndex = currentIndex;
34 | currentIndex++;
35 | }
36 |
37 | }
38 |
39 | public static class ElectriNetworkRepathEvent extends ElectriNetworkEvent {
40 |
41 | public ElectriNetworkRepathEvent(World world) {
42 | super(world);
43 | }
44 |
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Auxiliary/Lua/LuaGetStoredEnergy.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary.Lua;
11 |
12 | import net.minecraft.tileentity.TileEntity;
13 |
14 | import Reika.DragonAPI.ModInteract.Lua.LuaMethod;
15 | import Reika.ElectriCraft.TileEntities.TileEntityBattery;
16 |
17 | public class LuaGetStoredEnergy extends LuaMethod {
18 |
19 | public LuaGetStoredEnergy() {
20 | super("getStoredEnergy", TileEntityBattery.class);
21 | }
22 |
23 | @Override
24 | protected Object[] invoke(TileEntity te, Object[] args) throws LuaMethodException, InterruptedException {
25 | return new Object[]{((TileEntityBattery)te).getStoredEnergy(), ((TileEntityBattery)te).getMaxEnergy()};
26 | }
27 |
28 | @Override
29 | public String getDocumentation() {
30 | return "Returns the stored energy.";
31 | }
32 |
33 | @Override
34 | public String getArgsAsString() {
35 | return "";
36 | }
37 |
38 | @Override
39 | public ReturnType getReturnType() {
40 | return ReturnType.LONG;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/Blocks/BlockEUBattery.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Blocks;
11 |
12 | import net.minecraft.block.material.Material;
13 | import net.minecraft.world.IBlockAccess;
14 | import net.minecraft.world.World;
15 |
16 | import Reika.ElectriCraft.Base.BatteryBlock;
17 | import Reika.ElectriCraft.Base.ElectriTileEntity;
18 | import Reika.ElectriCraft.Registry.ElectriTiles;
19 | import Reika.ElectriCraft.TileEntities.ModInterface.TileEntityEUBattery;
20 |
21 | public class BlockEUBattery extends BatteryBlock {
22 |
23 | public BlockEUBattery(Material par2Material) {
24 | super(par2Material);
25 | }
26 |
27 | @Override
28 | public ElectriTileEntity createTileEntity(World world, int meta) {
29 | return new TileEntityEUBattery();
30 | }
31 |
32 | @Override
33 | protected String getTextureSubstring() {
34 | return "eu";
35 | }
36 |
37 | @Override
38 | public ElectriTiles getMapping(int meta) {
39 | return ElectriTiles.EUBATTERY;
40 | }
41 |
42 | @Override
43 | public ElectriTiles getMapping(IBlockAccess world, int x, int y, int z) {
44 | return ElectriTiles.EUBATTERY;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/Blocks/BlockRFBattery.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Blocks;
11 |
12 | import net.minecraft.block.material.Material;
13 | import net.minecraft.world.IBlockAccess;
14 | import net.minecraft.world.World;
15 |
16 | import Reika.ElectriCraft.Base.BatteryBlock;
17 | import Reika.ElectriCraft.Base.ElectriTileEntity;
18 | import Reika.ElectriCraft.Registry.ElectriTiles;
19 | import Reika.ElectriCraft.TileEntities.ModInterface.TileEntityRFBattery;
20 |
21 | public class BlockRFBattery extends BatteryBlock {
22 |
23 | public BlockRFBattery(Material par2Material) {
24 | super(par2Material);
25 | }
26 |
27 | @Override
28 | public ElectriTileEntity createTileEntity(World world, int meta) {
29 | return new TileEntityRFBattery();
30 | }
31 |
32 | @Override
33 | protected String getTextureSubstring() {
34 | return "rf";
35 | }
36 |
37 | @Override
38 | public ElectriTiles getMapping(int meta) {
39 | return ElectriTiles.RFBATTERY;
40 | }
41 |
42 | @Override
43 | public ElectriTiles getMapping(IBlockAccess world, int x, int y, int z) {
44 | return ElectriTiles.RFBATTERY;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/Auxiliary/Lua/LuaGetEUCapacity.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary.Lua;
11 |
12 | import net.minecraft.tileentity.TileEntity;
13 |
14 | import Reika.DragonAPI.ModInteract.Lua.LuaMethod;
15 | import Reika.DragonAPI.ModInteract.Lua.LuaMethod.ModTileDependent;
16 | import Reika.ElectriCraft.TileEntities.ModInterface.TileEntityEUBattery;
17 |
18 | @ModTileDependent(value = "ic2.api.energy.tile.IEnergyTile")
19 | public class LuaGetEUCapacity extends LuaMethod {
20 |
21 | public LuaGetEUCapacity() {
22 | super("getFullCapacity", TileEntityEUBattery.class);
23 | }
24 |
25 | @Override
26 | protected Object[] invoke(TileEntity te, Object[] args) throws LuaMethodException, InterruptedException {
27 | return new Object[]{((TileEntityEUBattery)te).getMaxEnergy()};
28 | }
29 |
30 | @Override
31 | public String getDocumentation() {
32 | return "Returns the EU capacity.\nArgs: None\nReturns: Capacity";
33 | }
34 |
35 | @Override
36 | public String getArgsAsString() {
37 | return "";
38 | }
39 |
40 | @Override
41 | public ReturnType getReturnType() {
42 | return ReturnType.LONG;
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/Auxiliary/Lua/LuaGetStoredEU.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary.Lua;
11 |
12 | import net.minecraft.tileentity.TileEntity;
13 |
14 | import Reika.DragonAPI.ModInteract.Lua.LuaMethod;
15 | import Reika.DragonAPI.ModInteract.Lua.LuaMethod.ModTileDependent;
16 | import Reika.ElectriCraft.TileEntities.ModInterface.TileEntityEUBattery;
17 |
18 | @ModTileDependent(value = "ic2.api.energy.tile.IEnergyTile")
19 | public class LuaGetStoredEU extends LuaMethod {
20 |
21 | public LuaGetStoredEU() {
22 | super("getFullStoredEnergy", TileEntityEUBattery.class);
23 | }
24 |
25 | @Override
26 | protected Object[] invoke(TileEntity te, Object[] args) throws LuaMethodException, InterruptedException {
27 | return new Object[]{((TileEntityEUBattery)te).getStoredEnergy()};
28 | }
29 |
30 | @Override
31 | public String getDocumentation() {
32 | return "Returns the stored EU value.\nArgs: None\nReturns: Energy";
33 | }
34 |
35 | @Override
36 | public String getArgsAsString() {
37 | return "";
38 | }
39 |
40 | @Override
41 | public ReturnType getReturnType() {
42 | return ReturnType.LONG;
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/ElectriConfig.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft;
11 |
12 | import java.util.ArrayList;
13 |
14 | import Reika.DragonAPI.Base.DragonAPIMod;
15 | import Reika.DragonAPI.Instantiable.IO.ControlledConfig;
16 | import Reika.DragonAPI.Interfaces.Configuration.ConfigList;
17 | import Reika.DragonAPI.Interfaces.Registry.IDRegistry;
18 | import Reika.DragonAPI.Libraries.Java.ReikaJavaLibrary;
19 | import Reika.ElectriCraft.Registry.ElectriOres;
20 |
21 | public class ElectriConfig extends ControlledConfig {
22 |
23 | private static final ArrayList entries = ReikaJavaLibrary.getEnumEntriesWithoutInitializing(ElectriOres.class);
24 | private DataElement[] ores = new DataElement[entries.size()];
25 |
26 | public ElectriConfig(DragonAPIMod mod, ConfigList[] option, IDRegistry[] id) {
27 | super(mod, option, id);
28 |
29 | for (int i = 0; i < entries.size(); i++) {
30 | String name = entries.get(i);
31 | ores[i] = this.registerAdditionalOption("Ore Control", name, true);
32 | }
33 | }
34 |
35 | public boolean isOreGenEnabled(ElectriOres ore) {
36 | return ores[ore.ordinal()].getData();
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/Auxiliary/Lua/LuaGetLongRFCapacity.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary.Lua;
11 |
12 | import net.minecraft.tileentity.TileEntity;
13 |
14 | import Reika.DragonAPI.ModInteract.Lua.LuaMethod;
15 | import Reika.DragonAPI.ModInteract.Lua.LuaMethod.ModTileDependent;
16 | import Reika.ElectriCraft.TileEntities.ModInterface.TileEntityRFBattery;
17 |
18 | @ModTileDependent(value = {"cofh.api.energy.IEnergyProvider", "cofh.api.energy.IEnergyReceiver"})
19 | public class LuaGetLongRFCapacity extends LuaMethod {
20 |
21 | public LuaGetLongRFCapacity() {
22 | super("getFullCapacity", TileEntityRFBattery.class);
23 | }
24 |
25 | @Override
26 | protected Object[] invoke(TileEntity te, Object[] args) throws LuaMethodException, InterruptedException {
27 | return new Object[]{((TileEntityRFBattery)te).getMaxEnergy()};
28 | }
29 |
30 | @Override
31 | public String getDocumentation() {
32 | return "Returns the real RF capacity.\nArgs: None\nReturns: Capacity";
33 | }
34 |
35 | @Override
36 | public String getArgsAsString() {
37 | return "";
38 | }
39 |
40 | @Override
41 | public ReturnType getReturnType() {
42 | return ReturnType.LONG;
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/Auxiliary/Lua/LuaGetLongStoredRF.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary.Lua;
11 |
12 | import net.minecraft.tileentity.TileEntity;
13 |
14 | import Reika.DragonAPI.ModInteract.Lua.LuaMethod;
15 | import Reika.DragonAPI.ModInteract.Lua.LuaMethod.ModTileDependent;
16 | import Reika.ElectriCraft.TileEntities.ModInterface.TileEntityRFBattery;
17 |
18 | @ModTileDependent(value = {"cofh.api.energy.IEnergyProvider", "cofh.api.energy.IEnergyReceiver"})
19 | public class LuaGetLongStoredRF extends LuaMethod {
20 |
21 | public LuaGetLongStoredRF() {
22 | super("getFullStoredEnergy", TileEntityRFBattery.class);
23 | }
24 |
25 | @Override
26 | protected Object[] invoke(TileEntity te, Object[] args) throws LuaMethodException, InterruptedException {
27 | return new Object[]{((TileEntityRFBattery)te).getStoredEnergy()};
28 | }
29 |
30 | @Override
31 | public String getDocumentation() {
32 | return "Returns the real stored RF value.\nArgs: None\nReturns: Energy";
33 | }
34 |
35 | @Override
36 | public String getArgsAsString() {
37 | return "";
38 | }
39 |
40 | @Override
41 | public ReturnType getReturnType() {
42 | return ReturnType.LONG;
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/Base/BatteryTileBase.java:
--------------------------------------------------------------------------------
1 | package Reika.ElectriCraft.Base;
2 |
3 | import net.minecraft.item.Item;
4 | import net.minecraft.item.ItemStack;
5 | import net.minecraft.world.World;
6 |
7 | import Reika.ElectriCraft.Auxiliary.BatteryTracker;
8 | import Reika.ElectriCraft.Auxiliary.Interfaces.BatteryTile;
9 |
10 | public abstract class BatteryTileBase extends ElectriTileEntity implements BatteryTile {
11 |
12 | private final BatteryTracker tracker = new BatteryTracker();
13 |
14 | @Override
15 | public void updateEntity(World world, int x, int y, int z, int meta) {
16 | tracker.update(this);
17 | }
18 |
19 | @Override
20 | protected void animateWithTick(World world, int x, int y, int z) {
21 |
22 | }
23 |
24 | @Override
25 | public final BatteryTracker getTracker() {
26 | return tracker;
27 | }
28 |
29 | @Override
30 | public final int getRedstoneOverride() {
31 | //return (int)Math.round(15D*ReikaMathLibrary.logbase(this.getStoredEnergy(), 2)/ReikaMathLibrary.logbase(this.getMaxEnergy(), 2));
32 | return (int)Math.round(15D*Math.pow(this.getStoredEnergy()/(double)this.getMaxEnergy(), 0.1));
33 | }
34 |
35 | public final void setEnergyFromNBT(ItemStack is) {
36 | if (is.getItem() == this.getPlacerItem()) {
37 | if (is.stackTagCompound != null)
38 | this.setEnergy(is.stackTagCompound.getLong("nrg"));
39 | else
40 | this.setEnergy(0);
41 | }
42 | else {
43 | this.setEnergy(0);
44 | }
45 | }
46 |
47 | protected abstract Item getPlacerItem();
48 |
49 | protected abstract void setEnergy(long val);
50 | }
51 |
--------------------------------------------------------------------------------
/Registry/ElectriCrafting.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Registry;
11 |
12 | import java.util.Locale;
13 |
14 | import net.minecraft.item.ItemStack;
15 | import net.minecraft.util.StatCollector;
16 |
17 | import Reika.DragonAPI.Libraries.Registry.ReikaItemHelper;
18 |
19 | public enum ElectriCrafting {
20 |
21 | BLUEDUST("dustLapis"),
22 | DIAMONDDUST("dustDiamond"),
23 | QUARTZDUST("dustNetherQuartz"),
24 | CRYSTALDUST();
25 |
26 | public static final ElectriCrafting[] craftingList = values();
27 |
28 | public final String oreDictName;
29 |
30 | private ElectriCrafting() {
31 | this(null);
32 | }
33 |
34 | private ElectriCrafting(String dict) {
35 | oreDictName = dict;
36 | }
37 |
38 | public ItemStack getItem() {
39 | return ElectriItems.CRAFTING.getStackOfMetadata(this.ordinal());
40 | }
41 |
42 | public boolean hasOreName() {
43 | return oreDictName != null && !oreDictName.isEmpty();
44 | }
45 |
46 | public String getName() {
47 | return StatCollector.translateToLocal("electricrafting."+this.name().toLowerCase(Locale.ENGLISH));
48 | }
49 |
50 | public ItemStack getItem(int amt) {
51 | return ReikaItemHelper.getSizedItemStack(this.getItem(), amt);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/TileEntities/TileEntityMeter.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.TileEntities;
11 |
12 | import net.minecraft.world.World;
13 | import net.minecraftforge.common.util.ForgeDirection;
14 |
15 | import Reika.DragonAPI.Libraries.World.ReikaWorldHelper;
16 | import Reika.ElectriCraft.Base.WiringTile;
17 | import Reika.ElectriCraft.Registry.ElectriTiles;
18 |
19 | public class TileEntityMeter extends WiringTile {
20 |
21 | @Override
22 | public int getResistance() {
23 | return 0;
24 | }
25 |
26 | @Override
27 | public void onNetworkChanged() {
28 | super.onNetworkChanged();
29 | worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
30 | ReikaWorldHelper.causeAdjacentUpdates(worldObj, xCoord, yCoord, zCoord);
31 | }
32 |
33 | @Override
34 | public ElectriTiles getTile() {
35 | return ElectriTiles.METER;
36 | }
37 |
38 | @Override
39 | protected void animateWithTick(World world, int x, int y, int z) {
40 |
41 | }
42 |
43 | @Override
44 | public boolean canNetworkOnSide(ForgeDirection dir) {
45 | return dir != ForgeDirection.UP;
46 | }
47 |
48 | @Override
49 | public int getRedstoneOverride() {
50 | long p = this.getWirePower();
51 | return p > 0 ? Math.max(1, Math.min(15, (int)(p/1048576))) : 0;
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/Base/WiringTile.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Base;
11 |
12 | import net.minecraft.nbt.NBTTagCompound;
13 |
14 | public abstract class WiringTile extends NetworkTileEntity {
15 |
16 | private int voltage;
17 | private int current;
18 |
19 | public abstract int getResistance();
20 |
21 | @Override
22 | public int getRedstoneOverride() {
23 | return 0;
24 | }
25 |
26 | @Override
27 | protected void onJoinNetwork() {
28 | current = network.getPointCurrent(this);
29 | voltage = network.getPointVoltage(this);
30 | }
31 |
32 | @Override
33 | public void onNetworkChanged() {
34 | current = network.getPointCurrent(this);
35 | voltage = network.getPointVoltage(this);
36 | }
37 |
38 | public final int getWireVoltage() {
39 | return voltage;
40 | }
41 |
42 | public final int getWireCurrent() {
43 | return current;
44 | }
45 |
46 | public final long getWirePower() {
47 | return (long)current*(long)voltage;
48 | }
49 |
50 | @Override
51 | protected void readSyncTag(NBTTagCompound NBT)
52 | {
53 | super.readSyncTag(NBT);
54 |
55 | voltage = NBT.getInteger("v");
56 | current = NBT.getInteger("a");
57 | }
58 |
59 | @Override
60 | protected void writeSyncTag(NBTTagCompound NBT)
61 | {
62 | super.writeSyncTag(NBT);
63 |
64 | NBT.setInteger("a", current);
65 | NBT.setInteger("v", voltage);
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/TileEntities/TileEntityResistor.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.TileEntities;
11 |
12 | import net.minecraft.nbt.NBTTagCompound;
13 |
14 | import Reika.DragonAPI.Libraries.MathSci.ReikaMathLibrary;
15 | import Reika.ElectriCraft.Base.TileEntityResistorBase;
16 | import Reika.ElectriCraft.Registry.ElectriTiles;
17 |
18 | public class TileEntityResistor extends TileEntityResistorBase {
19 |
20 | /** Use these to control current limits; change by right-clicking with dye */
21 | private ColorBand[] bands = {ColorBand.BLACK, ColorBand.BLACK, ColorBand.BLACK};
22 |
23 | @Override
24 | protected int calculateCurrentLimit() {
25 | int digit1 = bands[0].ordinal();
26 | int digit2 = bands[1].ordinal();
27 | int multiplier = bands[2].ordinal();
28 | int base = Integer.parseInt(String.format("%d%d", digit1, digit2));
29 | return base*ReikaMathLibrary.intpow2(10, multiplier);
30 | }
31 |
32 | @Override
33 | public ElectriTiles getTile() {
34 | return ElectriTiles.RESISTOR;
35 | }
36 |
37 | @Override
38 | public void readSyncTag(NBTTagCompound NBT) {
39 | super.readSyncTag(NBT);
40 | }
41 |
42 | @Override
43 | public void writeSyncTag(NBTTagCompound NBT) {
44 | super.writeSyncTag(NBT);
45 | }
46 |
47 | @Override
48 | public ColorBand[] getColorBands() {
49 | return bands;
50 | }
51 |
52 | @Override
53 | protected void setColorBands(ColorBand[] bands) {
54 | this.bands = bands;
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/World/ElectriOreGenerator.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.World;
11 |
12 | import java.util.ArrayList;
13 | import java.util.Random;
14 |
15 | import net.minecraft.world.World;
16 | import net.minecraft.world.chunk.IChunkProvider;
17 |
18 | import Reika.DragonAPI.Interfaces.OreGenerator;
19 | import Reika.DragonAPI.Interfaces.RetroactiveGenerator;
20 | import Reika.ElectriCraft.Registry.ElectriOres;
21 |
22 | public class ElectriOreGenerator implements RetroactiveGenerator {
23 |
24 | public static final ElectriOreGenerator instance = new ElectriOreGenerator();
25 |
26 | public final ArrayList generators = new ArrayList();
27 |
28 | private ElectriOreGenerator() {
29 | generators.add(new BasicElectriOreGenerator());
30 | }
31 |
32 | @Override
33 | public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkgen, IChunkProvider provider) {
34 | for (int i = 0; i < ElectriOres.oreList.length; i++) {
35 | ElectriOres ore = ElectriOres.oreList[i];
36 | if (ore.canGenerateInChunk(world, chunkX, chunkZ)) {
37 | for (OreGenerator gen : generators) {
38 | gen.generateOre(ore, random, world, chunkX, chunkZ);
39 | }
40 | }
41 | }
42 | }
43 |
44 | @Override
45 | public boolean canGenerateAt(World world, int chunkX, int chunkZ) {
46 | return true;
47 | }
48 |
49 | @Override
50 | public String getIDString() {
51 | return "ElectriCraft Ores";
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/Items/ItemBlockElectriOre.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Items;
11 |
12 | import java.util.List;
13 |
14 | import net.minecraft.block.Block;
15 | import net.minecraft.creativetab.CreativeTabs;
16 | import net.minecraft.item.Item;
17 | import net.minecraft.item.ItemBlock;
18 | import net.minecraft.item.ItemStack;
19 |
20 | import Reika.ElectriCraft.Registry.ElectriOres;
21 |
22 | import cpw.mods.fml.relauncher.Side;
23 | import cpw.mods.fml.relauncher.SideOnly;
24 |
25 | public class ItemBlockElectriOre extends ItemBlock {
26 |
27 | public ItemBlockElectriOre(Block b) {
28 | super(b);
29 | hasSubtypes = true;
30 | this.setMaxDamage(0);
31 | }
32 |
33 | @Override
34 | @SideOnly(Side.CLIENT)
35 | public void getSubItems(Item ID, CreativeTabs cr, List li)
36 | {
37 | for (int i = 0; i < this.getDataValues(); i++) {
38 | ItemStack item = new ItemStack(ID, 1, i);
39 | li.add(item);
40 | }
41 | }
42 |
43 | private int getDataValues() {
44 | return ElectriOres.oreList.length;
45 | }
46 |
47 | @Override
48 | public String getItemStackDisplayName(ItemStack is) {
49 | ElectriOres ore = ElectriOres.oreList[is.getItemDamage()];
50 | return ore.oreName;
51 | }
52 |
53 | @Override
54 | public String getUnlocalizedName(ItemStack is) {
55 | int d = is.getItemDamage();
56 | return super.getUnlocalizedName() + "." + d;
57 | }
58 |
59 | @Override
60 | public int getMetadata(int meta)
61 | {
62 | return meta;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/Resources/info.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 | Electrical power is measured with two parameters, voltage and current.
14 |
15 | The voltage is the "motive force" of the electricity. It is consumed to do work and varies along a circuit. In the traditional water analogy, it is analogous to water pressure.
16 |
17 | The current is the amount of electricity actually flowing. It is not consumed along a circuit, but the total current remains constant from output to input and can be split into multiple paths. In the water analogy, it corresponds to the actual mass flow rate.
18 |
19 |
20 | Terminus points to a wire path can be grouped into two categories. 'Sources' supply power to a wire, while 'Sinks' consume it. Power always flows from source to sink. Note that engines are one source each; generators preserve the source information sent into them.
21 |
22 |
23 | A wire network consists of a contiguous group of wire pieces, and can have one or many sources and/or sinks connected. Each source creates a path to each sink, and splits its current generation capacity among them, normally equally. Along a wire path, the current remains constant but voltage may change. Each sink may receive from one or more paths, and its voltage will be the lowest of them, and the current will be the sum of their individual currents.
24 |
25 |
26 | Most wires have resistances, and because that causes heat generation, current limits. These vary depending on the material from which the wire is constructed.
27 |
28 | %s
29 |
30 |
31 |
--------------------------------------------------------------------------------
/TileEntities/TileEntityPreciseResistor.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.TileEntities;
11 |
12 | import net.minecraft.nbt.NBTTagCompound;
13 |
14 | import Reika.DragonAPI.Libraries.MathSci.ReikaMathLibrary;
15 | import Reika.ElectriCraft.Base.TileEntityResistorBase;
16 | import Reika.ElectriCraft.Registry.ElectriTiles;
17 |
18 | public class TileEntityPreciseResistor extends TileEntityResistorBase {
19 |
20 | /** Use these to control current limits; change by right-clicking with dye */
21 | private ColorBand[] bands = {ColorBand.BLACK, ColorBand.BLACK, ColorBand.BLACK, ColorBand.BLACK};
22 |
23 | @Override
24 | protected int calculateCurrentLimit() {
25 | int digit1 = bands[0].ordinal();
26 | int digit2 = bands[1].ordinal();
27 | int digit3 = bands[2].ordinal();
28 | int multiplier = bands[3].ordinal();
29 | int base = Integer.parseInt(String.format("%d%d%d", digit1, digit2, digit3));
30 | return base*ReikaMathLibrary.intpow2(10, multiplier);
31 | }
32 |
33 | @Override
34 | public ElectriTiles getTile() {
35 | return ElectriTiles.PRECISERESISTOR;
36 | }
37 |
38 | @Override
39 | public void readSyncTag(NBTTagCompound NBT) {
40 | super.readSyncTag(NBT);
41 | }
42 |
43 | @Override
44 | public void writeSyncTag(NBTTagCompound NBT) {
45 | super.writeSyncTag(NBT);
46 | }
47 |
48 | @Override
49 | public ColorBand[] getColorBands() {
50 | return bands;
51 | }
52 |
53 | @Override
54 | protected void setColorBands(ColorBand[] bands) {
55 | this.bands = bands;
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/Resources/es_ES/info.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 | La potencia electrica se mide con dos parametros, tension e intensidad.
14 |
15 | El voltaje es la "fuerza motriz" de la electricidad. Es consumida para realizar trabajo, y varia de punto a punto a lo largo del circuito. En la analogia tradicional del agua, es similar a la presion del agua.
16 |
17 | La intensidad es la cantidad de electricidad fluyendo actualmente. No se consume a lo largo del circuito, ya que la intensidad total permanece constante de principio a fin y puede dividirse en multiples caminos. En la analogia del agua, corresponde al caudal.
18 |
19 |
20 | Los puntos terminales de un cable pueden ser agrupados en dos categorias. Las 'fuentes' proporcionan potencia al cable, mientras que los 'consumidores' la consumen. La potencia siempre fluye de las fuentes a los consumidores.
21 |
22 |
23 | Una red cableada consiste en un grupo contiguo de cables, y pueden tener una o mas fuentes y/o consumidores conectados. Cada fuente crea un camino para cada consumidor, y distribuye su capacidad de generacion de corriente entre ellos, normalmente de manera equilibrada. A lo largo del cable, la intensidad permanece constante, pero el voltaje puede variar. Cada consumidor puede recibir de uno o mas caminos, su voltaje sera el del mas bajo de ellos y la corriente sera la suma de las corrientes individuales.
24 |
25 |
26 | La mayoria de los cables tienen resistencias, y debido a que ello produce calor, tienen limitaciones de intensidad. Estos varian dependiendo del material del que este hecho el cable.
27 |
28 | %s
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Blocks/BlockEUCable.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Blocks;
11 |
12 | import net.minecraft.block.Block;
13 | import net.minecraft.block.material.Material;
14 | import net.minecraft.tileentity.TileEntity;
15 | import net.minecraft.world.World;
16 |
17 | import Reika.ElectriCraft.Base.BlockElectriCable;
18 | import Reika.ElectriCraft.Registry.ElectriTiles;
19 | import Reika.ElectriCraft.TileEntities.ModInterface.TileEntityEUCable;
20 |
21 | public class BlockEUCable extends BlockElectriCable {
22 |
23 | public BlockEUCable(Material par2Material) {
24 | super(par2Material);
25 | }
26 |
27 | @Override
28 | public TileEntity createTileEntity(World world, int meta) {
29 | return new TileEntityEUCable();
30 | }
31 | /*
32 | @Override
33 | public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer ep, int s, float a, float b, float c) {
34 | ItemStack is = ep.getCurrentEquippedItem();
35 | if (!ReikaItemHelper.matchStacks(is, ElectriTiles.CABLE.getCraftedProduct())) {
36 | ep.openGui(ElectriCraft.instance, 0, world, x, y, z);
37 | return true;
38 | }
39 | return false;
40 | }
41 | */
42 | @Override
43 | public void breakBlock(World world, int x, int y, int z, Block oldid, int oldmeta) {
44 | TileEntityEUCable te = (TileEntityEUCable)world.getTileEntity(x, y, z);
45 | super.breakBlock(world, x, y, z, oldid, oldmeta);
46 | }
47 |
48 | @Override
49 | protected String getTextureIcoName() {
50 | return "eu";
51 | }
52 |
53 | @Override
54 | public ElectriTiles getTile() {
55 | return ElectriTiles.EUCABLE;
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/TileEntities/TileEntityRelay.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.TileEntities;
11 |
12 | import net.minecraft.world.World;
13 |
14 | import Reika.ElectriCraft.Auxiliary.Interfaces.ToggledConnection;
15 | import Reika.ElectriCraft.Base.TileEntityWireComponent;
16 | import Reika.ElectriCraft.Registry.ElectriTiles;
17 |
18 | public class TileEntityRelay extends TileEntityWireComponent implements ToggledConnection {
19 |
20 | private boolean lastPower;
21 |
22 | @Override
23 | public void updateEntity(World world, int x, int y, int z, int meta) {
24 | super.updateEntity(world, x, y, z, meta);
25 |
26 | if (!world.isRemote)
27 | network.toString();
28 |
29 | boolean pwr = this.hasRedstoneSignal();
30 | if (!world.isRemote)
31 | if (pwr != lastPower)
32 | network.updateWires();
33 | lastPower = pwr;
34 | }
35 |
36 | @Override
37 | public int getResistance() {
38 | return this.isEnabled() ? 0 : Integer.MAX_VALUE;
39 | }
40 |
41 | @Override
42 | public void onNetworkChanged() {
43 |
44 | }
45 |
46 | @Override
47 | public ElectriTiles getTile() {
48 | return ElectriTiles.RELAY;
49 | }
50 |
51 | @Override
52 | protected void animateWithTick(World world, int x, int y, int z) {
53 |
54 | }
55 |
56 | public boolean isEnabled() {
57 | return this.hasRedstoneSignal();
58 | }
59 |
60 | @Override
61 | public float getHeight() {
62 | return 0.75F;
63 | }
64 |
65 | @Override
66 | public float getWidth() {
67 | return 0.75F;
68 | }
69 |
70 | @Override
71 | public boolean canConnect() {
72 | return this.isEnabled();
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/ElectriGuiHandler.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft;
11 |
12 | import net.minecraft.entity.player.EntityPlayer;
13 | import net.minecraft.tileentity.TileEntity;
14 | import net.minecraft.world.World;
15 |
16 | import Reika.DragonAPI.Base.CoreContainer;
17 | import Reika.ElectriCraft.GUIs.GuiElectriBook;
18 | import Reika.ElectriCraft.GUIs.GuiRFCable;
19 | import Reika.ElectriCraft.GUIs.GuiTransformer;
20 | import Reika.ElectriCraft.TileEntities.TileEntityTransformer;
21 | import Reika.ElectriCraft.TileEntities.ModInterface.TileEntityRFCable;
22 |
23 | import cpw.mods.fml.common.network.IGuiHandler;
24 |
25 | public class ElectriGuiHandler implements IGuiHandler {
26 |
27 | @Override
28 | public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
29 | TileEntity te = world.getTileEntity(x, y, z);
30 | if (ID == 10) {
31 | return null;
32 | }
33 | if (te instanceof TileEntityRFCable) {
34 | return new CoreContainer(player, te);
35 | }
36 | if (te instanceof TileEntityTransformer) {
37 | return new CoreContainer(player, te);
38 | }
39 | return null;
40 | }
41 |
42 | @Override
43 | public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
44 | if (ID == 10) {
45 | return new GuiElectriBook(player, world, 0, 0);
46 | }
47 | TileEntity te = world.getTileEntity(x, y, z);
48 | if (te instanceof TileEntityRFCable) {
49 | return new GuiRFCable(player, (TileEntityRFCable)te);
50 | }
51 | if (te instanceof TileEntityTransformer) {
52 | return new GuiTransformer(player, (TileEntityTransformer)te);
53 | }
54 | return null;
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/Network/NetworkNode.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Network;
11 |
12 | import java.util.ArrayList;
13 | import java.util.Collection;
14 | import java.util.Collections;
15 |
16 | import net.minecraftforge.common.util.ForgeDirection;
17 |
18 | import Reika.ElectriCraft.Base.WiringTile;
19 |
20 | public final class NetworkNode {
21 |
22 | public final int x;
23 | public final int y;
24 | public final int z;
25 |
26 | private final WiringTile wire;
27 |
28 | private final WireNetwork network;
29 |
30 | private final ArrayList connections = new ArrayList();
31 |
32 | private final ArrayList paths = new ArrayList();
33 |
34 | NetworkNode(WireNetwork w, WiringTile te, Collection sides) {
35 | network = w;
36 | x = te.xCoord;
37 | y = te.yCoord;
38 | z = te.zCoord;
39 |
40 | wire = te;
41 | connections.addAll(sides);
42 | }
43 |
44 | void addPath(WirePath p) {
45 | paths.add(p);
46 | }
47 |
48 | void removePath(WirePath p) {
49 | paths.remove(p);
50 | }
51 |
52 | public boolean connectsToSide(ForgeDirection dir) {
53 | return connections.contains(dir);
54 | }
55 |
56 | @Override
57 | public String toString() {
58 | return "<"+x+":"+y+":"+z+">";
59 | }
60 |
61 | @Override
62 | public boolean equals(Object o) {
63 | if (o instanceof NetworkNode) {
64 | NetworkNode n = (NetworkNode)o;
65 | return n.wire == wire && n.network == network && n.connections.equals(connections);
66 | }
67 | return false;
68 | }
69 |
70 | public Collection getDirections() {
71 | return Collections.unmodifiableCollection(connections);
72 | }
73 |
74 | public int getPaths() {
75 | return paths.size();
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/World/BasicElectriOreGenerator.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.World;
11 |
12 | import java.util.Random;
13 |
14 | import net.minecraft.block.Block;
15 | import net.minecraft.world.World;
16 | import net.minecraft.world.gen.feature.WorldGenMinable;
17 |
18 | import Reika.DragonAPI.Interfaces.OreGenerator;
19 | import Reika.DragonAPI.Interfaces.Registry.OreEnum;
20 | import Reika.ElectriCraft.Registry.ElectriOptions;
21 | import Reika.ElectriCraft.Registry.ElectriOres;
22 |
23 | public class BasicElectriOreGenerator implements OreGenerator {
24 |
25 | @Override
26 | public void generateOre(OreEnum ore, Random random, World world, int chunkX, int chunkZ) {
27 | ElectriOres e = (ElectriOres)ore;
28 | if (random.nextInt(ElectriOptions.DISCRETE.getValue()) == 0) {
29 | this.generate(e, world, random, chunkX*16, chunkZ*16);
30 | }
31 | }
32 |
33 | private void generate(ElectriOres ore, World world, Random random, int chunkX, int chunkZ) {
34 | //ReikaJavaLibrary.pConsole("Generating "+ore);
35 | //ReikaJavaLibrary.pConsole(chunkX+", "+chunkZ);
36 | Block id = ore.getBlock();
37 | int meta = ore.getBlockMetadata();
38 | int passes = ore.perChunk*ElectriOptions.DISCRETE.getValue();
39 | for (int i = 0; i < passes; i++) {
40 | int posX = chunkX+random.nextInt(16);
41 | int posZ = chunkZ+random.nextInt(16);
42 | int posY = ore.minY+random.nextInt(ore.maxY-ore.minY+1);
43 |
44 |
45 | if (ore.canGenAt(world, posX, posY, posZ)) {
46 | if ((new WorldGenMinable(id, meta, ore.veinSize, ore.getReplaceableBlock())).generate(world, random, posX, posY, posZ))
47 | ;//ReikaJavaLibrary.pConsole(ore+" @ "+posX+", "+posY+", "+posZ, ore == ElectriOres.MAGNETITE);
48 | }
49 | }
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/Blocks/BlockRFCable.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Blocks;
11 |
12 | import net.minecraft.block.Block;
13 | import net.minecraft.block.material.Material;
14 | import net.minecraft.entity.player.EntityPlayer;
15 | import net.minecraft.item.ItemStack;
16 | import net.minecraft.tileentity.TileEntity;
17 | import net.minecraft.world.World;
18 |
19 | import Reika.DragonAPI.Libraries.Registry.ReikaItemHelper;
20 | import Reika.ElectriCraft.ElectriCraft;
21 | import Reika.ElectriCraft.Base.BlockElectriCable;
22 | import Reika.ElectriCraft.Registry.ElectriTiles;
23 | import Reika.ElectriCraft.TileEntities.ModInterface.TileEntityRFCable;
24 |
25 | public class BlockRFCable extends BlockElectriCable {
26 |
27 | public BlockRFCable(Material par2Material) {
28 | super(par2Material);
29 | }
30 |
31 | @Override
32 | public TileEntity createTileEntity(World world, int meta) {
33 | return new TileEntityRFCable();
34 | }
35 |
36 | @Override
37 | public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer ep, int s, float a, float b, float c) {
38 | ItemStack is = ep.getCurrentEquippedItem();
39 | if (!ReikaItemHelper.matchStacks(is, ElectriTiles.CABLE.getCraftedProduct())) {
40 | ep.openGui(ElectriCraft.instance, 0, world, x, y, z);
41 | return true;
42 | }
43 | return false;
44 | }
45 |
46 | @Override
47 | public void breakBlock(World world, int x, int y, int z, Block oldid, int oldmeta) {
48 | TileEntityRFCable te = (TileEntityRFCable)world.getTileEntity(x, y, z);
49 | if (!world.isRemote)
50 | te.removeFromNetwork();
51 | super.breakBlock(world, x, y, z, oldid, oldmeta);
52 | }
53 |
54 | @Override
55 | protected String getTextureIcoName() {
56 | return "rf";
57 | }
58 |
59 | @Override
60 | public ElectriTiles getTile() {
61 | return ElectriTiles.CABLE;
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/Auxiliary/BatteryTracker.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary;
11 |
12 | import net.minecraft.util.EnumChatFormatting;
13 |
14 | import Reika.DragonAPI.Instantiable.Math.MovingAverage;
15 | import Reika.DragonAPI.Libraries.MathSci.ReikaDateHelper;
16 | import Reika.ElectriCraft.Auxiliary.Interfaces.BatteryTile;
17 |
18 |
19 | public class BatteryTracker {
20 |
21 | private final MovingAverage energyStored = new MovingAverage(10);
22 | private final MovingAverage energyFlow = new MovingAverage(10);
23 |
24 | private double lastEnergy = Double.NaN;
25 |
26 | public void update(BatteryTile t) {
27 | long energy = t.getStoredEnergy();
28 | energyStored.addValue(energy);
29 | if (lastEnergy != Double.NaN) {
30 | energyFlow.addValue(energy-lastEnergy);
31 | }
32 | lastEnergy = energy;
33 | }
34 |
35 | public String getAverageStorage(int decimals) {
36 | String format = "%."+decimals+"f";
37 | return String.format(format, energyStored.getAverage());
38 | }
39 |
40 | public String getAverageFlow(int decimals) {
41 | String format = "%s%."+decimals+"f";
42 | double avg = energyFlow.getAverage();
43 | return String.format(format, avg > 0 ? EnumChatFormatting.GREEN+"+" : avg < 0 ? EnumChatFormatting.RED.toString() : "", avg);
44 | }
45 |
46 | public String getTimeUntilFullOrEmpty(BatteryTile t) {
47 | double avg = energyFlow.getAverage();
48 | if (avg < 0) {
49 | double ticks = t.getStoredEnergy()/-avg;
50 | return ReikaDateHelper.getTickAsHMS(Math.round(ticks))+" until empty";
51 | }
52 | else if (avg > 0) {
53 | double limit = t.getMaxEnergy();
54 | double space = limit-t.getStoredEnergy();
55 | double ticks = space/avg;
56 | return ReikaDateHelper.getTickAsHMS(Math.round(ticks))+" until full";
57 | }
58 | else {
59 | return "No net flow";
60 | }
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/Items/ItemRFBatteryPlacer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Items;
11 |
12 | import java.util.List;
13 |
14 | import net.minecraft.block.Block;
15 | import net.minecraft.creativetab.CreativeTabs;
16 | import net.minecraft.entity.player.EntityPlayer;
17 | import net.minecraft.item.Item;
18 | import net.minecraft.item.ItemStack;
19 | import net.minecraft.nbt.NBTTagCompound;
20 |
21 | import Reika.DragonAPI.Libraries.MathSci.ReikaEngLibrary;
22 | import Reika.DragonAPI.Libraries.MathSci.ReikaMathLibrary;
23 | import Reika.ElectriCraft.Registry.ElectriBlocks;
24 | import Reika.ElectriCraft.TileEntities.ModInterface.TileEntityRFBattery;
25 |
26 | public class ItemRFBatteryPlacer extends ItemBatteryPlacer {
27 |
28 | public ItemRFBatteryPlacer(int tex) {
29 | super(tex);
30 | }
31 |
32 | @Override
33 | public void getSubItems(Item item, CreativeTabs tab, List li) {
34 | li.add(new ItemStack(item));
35 |
36 | ItemStack is = new ItemStack(item);
37 | is.stackTagCompound = new NBTTagCompound();
38 | is.stackTagCompound.setLong("nrg", TileEntityRFBattery.CAPACITY);
39 | li.add(is);
40 | }
41 |
42 | @Override
43 | protected Block getPlacingBlock() {
44 | return ElectriBlocks.RFBATTERY.getBlockInstance();
45 | }
46 |
47 | @Override
48 | protected int getPlacingMeta(ItemStack is) {
49 | return 0;
50 | }
51 |
52 | @Override
53 | public void addInformation(ItemStack is, EntityPlayer ep, List li, boolean vb) {
54 | long e = 0;
55 | if (is.stackTagCompound != null) {
56 | e = is.stackTagCompound.getLong("nrg");
57 | }
58 | long max = TileEntityRFBattery.CAPACITY;
59 | String sg = ReikaEngLibrary.getSIPrefix(e);
60 | String sg2 = ReikaEngLibrary.getSIPrefix(max);
61 | double b = ReikaMathLibrary.getThousandBase(e);
62 | double b2 = ReikaMathLibrary.getThousandBase(max);
63 | li.add(String.format("Stored Energy: %.2f %sRF/%.2f %sRF", b, sg, b2, sg2));
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/Items/ItemEUBatteryPlacer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Items;
11 |
12 | import java.util.List;
13 |
14 | import net.minecraft.block.Block;
15 | import net.minecraft.creativetab.CreativeTabs;
16 | import net.minecraft.entity.player.EntityPlayer;
17 | import net.minecraft.item.Item;
18 | import net.minecraft.item.ItemStack;
19 | import net.minecraft.nbt.NBTTagCompound;
20 |
21 | import Reika.DragonAPI.Libraries.MathSci.ReikaEngLibrary;
22 | import Reika.DragonAPI.Libraries.MathSci.ReikaMathLibrary;
23 | import Reika.ElectriCraft.Registry.ElectriBlocks;
24 | import Reika.ElectriCraft.TileEntities.ModInterface.TileEntityEUBattery;
25 |
26 | public class ItemEUBatteryPlacer extends ItemBatteryPlacer {
27 |
28 | public ItemEUBatteryPlacer(int tex) {
29 | super(tex);
30 | }
31 |
32 | @Override
33 | public void getSubItems(Item item, CreativeTabs tab, List li) {
34 | li.add(new ItemStack(item));
35 |
36 | ItemStack is = new ItemStack(item);
37 | is.stackTagCompound = new NBTTagCompound();
38 | is.stackTagCompound.setLong("nrg", (long)TileEntityEUBattery.CAPACITY);
39 | li.add(is);
40 | }
41 |
42 | @Override
43 | protected Block getPlacingBlock() {
44 | return ElectriBlocks.EUBATTERY.getBlockInstance();
45 | }
46 |
47 | @Override
48 | protected int getPlacingMeta(ItemStack is) {
49 | return 0;
50 | }
51 |
52 | @Override
53 | public void addInformation(ItemStack is, EntityPlayer ep, List li, boolean vb) {
54 | long e = 0;
55 | if (is.stackTagCompound != null) {
56 | e = is.stackTagCompound.getLong("nrg");
57 | }
58 | double max = TileEntityEUBattery.CAPACITY;
59 | String sg = ReikaEngLibrary.getSIPrefix(e);
60 | String sg2 = ReikaEngLibrary.getSIPrefix(max);
61 | double b = ReikaMathLibrary.getThousandBase(e);
62 | double b2 = ReikaMathLibrary.getThousandBase(max);
63 | li.add(String.format("Stored Energy: %.2f%s EU/%.2f%s EU", b, sg, b2, sg2));
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/Base/ElectriTERenderer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Base;
11 |
12 | import org.lwjgl.opengl.GL11;
13 | import org.lwjgl.opengl.GL12;
14 |
15 | import net.minecraftforge.client.MinecraftForgeClient;
16 |
17 | import Reika.DragonAPI.Base.DragonAPIMod;
18 | import Reika.DragonAPI.Base.TileEntityBase;
19 | import Reika.DragonAPI.Base.TileEntityRenderBase;
20 | import Reika.DragonAPI.Interfaces.TextureFetcher;
21 | import Reika.ElectriCraft.ElectriCraft;
22 |
23 | import cpw.mods.fml.relauncher.Side;
24 | import cpw.mods.fml.relauncher.SideOnly;
25 |
26 | @SideOnly(Side.CLIENT)
27 | public abstract class ElectriTERenderer extends TileEntityRenderBase implements TextureFetcher {
28 |
29 | @Override
30 | public final String getTextureFolder() {
31 | return "/Reika/ElectriCraft/Textures/TileEntityTex/";
32 | }
33 |
34 | @Override
35 | protected Class getModClass() {
36 | return ElectriCraft.class;
37 | }
38 |
39 | protected void setupGL(ElectriTileEntity tile, double par2, double par4, double par6) {
40 | GL11.glPushMatrix();
41 | GL11.glEnable(GL12.GL_RESCALE_NORMAL);
42 | GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
43 | GL11.glTranslated(par2, par4, par6);
44 | GL11.glScalef(1.0F, -1.0F, -1.0F);
45 | GL11.glTranslatef(0.5F, 0.5F, 0.5F);
46 | GL11.glTranslated(0, -2, -1);
47 |
48 | if (tile.isInWorld() && tile.isFlipped && MinecraftForgeClient.getRenderPass() == 0) {
49 | GL11.glRotated(180, 1, 0, 0);
50 | GL11.glTranslated(0, -2, 0);
51 | }
52 | }
53 |
54 | protected void closeGL(ElectriTileEntity tile) {
55 | if (tile.isInWorld())
56 | GL11.glDisable(GL12.GL_RESCALE_NORMAL);
57 | GL11.glPopMatrix();
58 | GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
59 | }
60 |
61 | @Override
62 | protected final boolean doRenderModel(TileEntityBase te) {
63 | return this.isValidMachineRenderPass(te);
64 | }
65 |
66 | @Override
67 | protected final DragonAPIMod getOwnerMod() {
68 | return ElectriCraft.instance;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/Renders/RenderRelay.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Renders;
11 |
12 | import org.lwjgl.opengl.GL11;
13 |
14 | import net.minecraft.tileentity.TileEntity;
15 | import net.minecraftforge.client.MinecraftForgeClient;
16 |
17 | import Reika.DragonAPI.Interfaces.TileEntity.RenderFetcher;
18 | import Reika.ElectriCraft.Base.ElectriTERenderer;
19 | import Reika.ElectriCraft.TileEntities.TileEntityRelay;
20 | import Reika.RotaryCraft.Auxiliary.IORenderer;
21 |
22 | public class RenderRelay extends ElectriTERenderer
23 | {
24 | private ModelRelay RelayModel = new ModelRelay();
25 |
26 | public void renderTileEntityRelayAt(TileEntityRelay tile, double par2, double par4, double par6, float par8)
27 | {
28 | int var9;
29 |
30 | if (!tile.isInWorld())
31 | var9 = 0;
32 | else
33 | var9 = tile.getBlockMetadata();
34 |
35 | ModelRelay var14;
36 | var14 = RelayModel;
37 |
38 | this.setupGL(tile, par2, par4, par6);
39 |
40 | this.bindTextureByName("/Reika/ElectriCraft/Textures/relay.png");
41 |
42 | int var11 = 0;
43 | float var13;
44 | switch(tile.getFacing()) {
45 | case EAST:
46 | var11 = 270;
47 | break;
48 | case WEST:
49 | var11 = 90;
50 | break;
51 | case NORTH:
52 | var11 = 180;
53 | break;
54 | case SOUTH:
55 | var11 = 0;
56 | break;
57 | default:
58 | break;
59 | }
60 |
61 | GL11.glRotatef(var11, 0.0F, 1.0F, 0.0F);
62 | var14.renderAll(tile, null, tile.phi);
63 |
64 | this.closeGL(tile);
65 | }
66 |
67 | @Override
68 | public void renderTileEntityAt(TileEntity tile, double par2, double par4, double par6, float par8)
69 | {
70 | if (this.doRenderModel((TileEntityRelay)tile))
71 | this.renderTileEntityRelayAt((TileEntityRelay)tile, par2, par4, par6, par8);
72 | if (((TileEntityRelay) tile).isInWorld() && MinecraftForgeClient.getRenderPass() == 1) {
73 | IORenderer.renderIO(tile, par2, par4, par6);
74 | }
75 | }
76 |
77 | @Override
78 | public String getImageFileName(RenderFetcher te) {
79 | return "relay.png";
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/Blocks/BlockElectriOre.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Blocks;
11 |
12 | import java.util.ArrayList;
13 |
14 | import net.minecraft.block.material.Material;
15 | import net.minecraft.client.renderer.texture.IIconRegister;
16 | import net.minecraft.item.ItemStack;
17 | import net.minecraft.util.IIcon;
18 | import net.minecraft.util.MovingObjectPosition;
19 | import net.minecraft.world.World;
20 |
21 | import Reika.DragonAPI.Base.EnumOreBlock;
22 | import Reika.DragonAPI.Interfaces.Registry.OreEnum;
23 | import Reika.ElectriCraft.ElectriCraft;
24 | import Reika.ElectriCraft.Registry.ElectriBlocks;
25 | import Reika.ElectriCraft.Registry.ElectriOres;
26 |
27 | public class BlockElectriOre extends EnumOreBlock {
28 |
29 | private IIcon[] icons = new IIcon[ElectriOres.oreList.length];
30 |
31 | public BlockElectriOre(Material par2Material) {
32 | super(par2Material);
33 | this.setResistance(5);
34 | this.setHardness(2);
35 | this.setCreativeTab(ElectriCraft.tabElectri);
36 | }
37 |
38 | @Override
39 | public int damageDropped(int meta) {
40 | return meta;
41 | }
42 |
43 | @Override
44 | public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune)
45 | {
46 | ArrayList li = new ArrayList();
47 | //ItemStack is = new ItemStack(ElectriBlocks.ORE.getBlock(), 1, metadata);
48 | ElectriOres ore = ElectriOres.getOre(this, metadata);
49 | li.addAll(ore.getOreDrop(metadata));
50 | return li;
51 | }
52 |
53 | @Override
54 | public ItemStack getPickBlock(MovingObjectPosition tgt, World world, int x, int y, int z)
55 | {
56 | ElectriOres ore = ElectriOres.getOre(world, x, y, z);
57 | return new ItemStack(ElectriBlocks.ORE.getBlockInstance(), 1, ore.getBlockMetadata());
58 | }
59 |
60 | @Override
61 | public void registerBlockIcons(IIconRegister ico) {
62 | for (int i = 0; i < ElectriOres.oreList.length; i++) {
63 | icons[i] = ico.registerIcon(ElectriOres.oreList[i].getTextureName());
64 | }
65 | }
66 |
67 | @Override
68 | public IIcon getIcon(int s, int meta) {
69 | return icons[meta];
70 | }
71 |
72 | @Override
73 | public OreEnum getOre(int meta) {
74 | return ElectriOres.getOre(this, meta);
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/Renders/RenderGenerator.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Renders;
11 |
12 | import org.lwjgl.opengl.GL11;
13 |
14 | import net.minecraft.tileentity.TileEntity;
15 | import net.minecraftforge.client.MinecraftForgeClient;
16 |
17 | import Reika.DragonAPI.Interfaces.TileEntity.RenderFetcher;
18 | import Reika.ElectriCraft.Base.ElectriTERenderer;
19 | import Reika.ElectriCraft.TileEntities.TileEntityGenerator;
20 | import Reika.RotaryCraft.Auxiliary.IORenderer;
21 | import Reika.RotaryCraft.ModInterface.ModelGenerator;
22 |
23 | public class RenderGenerator extends ElectriTERenderer
24 | {
25 |
26 | private ModelGenerator GeneratorModel = new ModelGenerator();
27 |
28 | public void renderTileEntityGeneratorAt(TileEntityGenerator tile, double par2, double par4, double par6, float par8)
29 | {
30 | int var9;
31 |
32 | if (!tile.isInWorld())
33 | var9 = 0;
34 | else
35 | var9 = tile.getBlockMetadata();
36 |
37 | ModelGenerator var14;
38 | var14 = GeneratorModel;
39 |
40 | this.bindTextureByName("/Reika/ElectriCraft/Textures/generatortex.png");
41 |
42 | this.setupGL(tile, par2, par4, par6);
43 |
44 | int var11 = 0;
45 | float var13;
46 | switch(tile.getFacing()) {
47 | case EAST:
48 | var11 = 270;
49 | break;
50 | case WEST:
51 | var11 = 90;
52 | break;
53 | case NORTH:
54 | var11 = 180;
55 | break;
56 | case SOUTH:
57 | var11 = 0;
58 | break;
59 | default:
60 | break;
61 | }
62 |
63 | GL11.glRotatef(var11+180, 0.0F, 1.0F, 0.0F);
64 | if (tile.isFlipped && tile.getFacing().offsetZ != 0) {
65 | GL11.glRotated(180, 0, 1, 0);
66 | }
67 | var14.renderAll(tile, null);
68 |
69 | this.closeGL(tile);
70 | }
71 |
72 | @Override
73 | public void renderTileEntityAt(TileEntity tile, double par2, double par4, double par6, float par8)
74 | {
75 | if (this.doRenderModel((TileEntityGenerator)tile))
76 | this.renderTileEntityGeneratorAt((TileEntityGenerator)tile, par2, par4, par6, par8);
77 | if (((TileEntityGenerator) tile).isInWorld() && MinecraftForgeClient.getRenderPass() == 1) {
78 | IORenderer.renderIO(tile, par2, par4, par6);
79 | }
80 | }
81 |
82 | @Override
83 | public String getImageFileName(RenderFetcher te) {
84 | return "generatortex.png";
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/Renders/RenderResistor.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Renders;
11 |
12 | import org.lwjgl.opengl.GL11;
13 |
14 | import net.minecraft.tileentity.TileEntity;
15 | import net.minecraftforge.client.MinecraftForgeClient;
16 |
17 | import Reika.DragonAPI.Interfaces.TileEntity.RenderFetcher;
18 | import Reika.DragonAPI.Libraries.Java.ReikaJavaLibrary;
19 | import Reika.ElectriCraft.Base.ElectriTERenderer;
20 | import Reika.ElectriCraft.Base.TileEntityResistorBase;
21 | import Reika.ElectriCraft.Base.TileEntityResistorBase.ColorBand;
22 | import Reika.RotaryCraft.Auxiliary.IORenderer;
23 |
24 | public class RenderResistor extends ElectriTERenderer
25 | {
26 | protected ModelResistorBase ResistorModel = new ModelResistor();
27 |
28 | public final void renderTileEntityResistorAt(TileEntityResistorBase tile, double par2, double par4, double par6, float par8) {
29 | int var9;
30 |
31 | if (!tile.isInWorld())
32 | var9 = 0;
33 | else
34 | var9 = tile.getBlockMetadata();
35 |
36 | ModelResistorBase var14;
37 | var14 = ResistorModel;
38 |
39 | this.setupGL(tile, par2, par4, par6);
40 |
41 | this.bindTextureByName("/Reika/ElectriCraft/Textures/resistor.png");
42 |
43 | int var11 = 0;
44 | float var13;
45 | switch(tile.getFacing()) {
46 | case EAST:
47 | var11 = 270;
48 | break;
49 | case WEST:
50 | var11 = 90;
51 | break;
52 | case NORTH:
53 | var11 = 180;
54 | break;
55 | case SOUTH:
56 | var11 = 0;
57 | break;
58 | default:
59 | break;
60 | }
61 |
62 | GL11.glRotatef(var11, 0.0F, 1.0F, 0.0F);
63 | ColorBand[] colors = tile.getColorBands();
64 | var14.renderAll(tile, ReikaJavaLibrary.makeListFrom(colors), tile.phi, 0);
65 |
66 | this.closeGL(tile);
67 | }
68 |
69 | @Override
70 | public final void renderTileEntityAt(TileEntity tile, double par2, double par4, double par6, float par8) {
71 | if (this.doRenderModel((TileEntityResistorBase)tile))
72 | this.renderTileEntityResistorAt((TileEntityResistorBase)tile, par2, par4, par6, par8);
73 | if (((TileEntityResistorBase) tile).isInWorld() && MinecraftForgeClient.getRenderPass() == 1) {
74 | IORenderer.renderIO(tile, par2, par4, par6);
75 | }
76 | }
77 |
78 | @Override
79 | public final String getImageFileName(RenderFetcher te) {
80 | return "resistor.png";
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ElectriNetworkManager.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft;
11 |
12 | import java.util.ArrayList;
13 | import java.util.Collection;
14 | import java.util.EnumSet;
15 |
16 | import net.minecraft.world.World;
17 | import net.minecraftforge.common.DimensionManager;
18 |
19 | import Reika.DragonAPI.Auxiliary.Trackers.TickRegistry.TickHandler;
20 | import Reika.DragonAPI.Auxiliary.Trackers.TickRegistry.TickType;
21 | import Reika.ElectriCraft.Auxiliary.ElectriNetworkEvent.ElectriNetworkRepathEvent;
22 | import Reika.ElectriCraft.Auxiliary.ElectriNetworkEvent.ElectriNetworkTickEvent;
23 |
24 | import cpw.mods.fml.common.gameevent.TickEvent.Phase;
25 |
26 | public class ElectriNetworkManager implements TickHandler {
27 |
28 | public static final ElectriNetworkManager instance = new ElectriNetworkManager();
29 |
30 | private final Collection networks = new ArrayList();
31 | private final Collection discard = new ArrayList();
32 |
33 | private ElectriNetworkManager() {
34 |
35 | }
36 |
37 | @Override
38 | public void tick(TickType type, Object... tickData) {
39 | Phase phase = (Phase)tickData[0];
40 | World world = DimensionManager.getWorld(0);
41 | //ReikaJavaLibrary.pConsole(networks.size()+":"+networks);
42 | if (phase == Phase.START) {
43 | if (!discard.isEmpty()) {
44 | networks.removeAll(discard);
45 | discard.clear();
46 | }
47 | if (world != null) {
48 | ElectriNetworkTickEvent evt = new ElectriNetworkTickEvent(world);
49 | for (NetworkObject net : networks) {
50 | net.tick(evt);
51 | }
52 | }
53 | }
54 | else if (phase == Phase.END) {
55 | if (world != null) {
56 | ElectriNetworkRepathEvent evt = new ElectriNetworkRepathEvent(world);
57 | for (NetworkObject net : networks) {
58 | net.repath(evt);
59 | }
60 | }
61 | }
62 | }
63 |
64 | @Override
65 | public EnumSet getType() {
66 | return EnumSet.of(TickType.SERVER);
67 | }
68 |
69 | @Override
70 | public boolean canFire(Phase p) {
71 | return p == Phase.START || p == Phase.END;
72 | }
73 |
74 | @Override
75 | public String getLabel() {
76 | return "Electri Network";
77 | }
78 |
79 | public void addNetwork(NetworkObject net) {
80 | networks.add(net);
81 | }
82 |
83 | public void scheduleNetworkDiscard(NetworkObject net) {
84 | discard.add(net);
85 | }
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/Auxiliary/ElectriRenderList.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary;
11 |
12 | import java.util.HashMap;
13 |
14 | import Reika.DragonAPI.Exception.RegistrationException;
15 | import Reika.DragonAPI.Interfaces.TileEntity.RenderFetcher;
16 | import Reika.DragonAPI.Libraries.Java.ReikaJavaLibrary;
17 | import Reika.ElectriCraft.ElectriCraft;
18 | import Reika.ElectriCraft.Base.ElectriTERenderer;
19 | import Reika.ElectriCraft.Registry.ElectriTiles;
20 |
21 | import cpw.mods.fml.relauncher.Side;
22 | import cpw.mods.fml.relauncher.SideOnly;
23 |
24 | @SideOnly(Side.CLIENT)
25 | public class ElectriRenderList {
26 |
27 | private static HashMap renders = new HashMap();
28 | private static HashMap overrides = new HashMap();
29 |
30 | public static boolean addRender(ElectriTiles m, ElectriTERenderer r) {
31 | if (!renders.containsValue(r)) {
32 | renders.put(m, r);
33 | return true;
34 | }
35 | else {
36 | ElectriTiles parent = ReikaJavaLibrary.getHashMapKeyByValue(renders, r);
37 | overrides.put(m, parent);
38 | return false;
39 | }
40 | }
41 |
42 | public static ElectriTERenderer getRenderForMachine(ElectriTiles m) {
43 | if (overrides.containsKey(m))
44 | return renders.get(overrides.get(m));
45 | return renders.get(m);
46 | }
47 |
48 | public static String getRenderTexture(ElectriTiles m, RenderFetcher te) {
49 | return getRenderForMachine(m).getImageFileName(te);
50 | }
51 |
52 | public static ElectriTERenderer instantiateRenderer(ElectriTiles m) {
53 | try {
54 | ElectriTERenderer r = (ElectriTERenderer)Class.forName(m.getRenderer()).newInstance();
55 | if (addRender(m, r))
56 | return r;
57 | else
58 | return renders.get(overrides.get(m));
59 | }
60 | catch (InstantiationException e) {
61 | e.printStackTrace();
62 | throw new RuntimeException("Tried to call nonexistent render "+m.getRenderer()+"!");
63 | }
64 | catch (IllegalAccessException e) {
65 | e.printStackTrace();
66 | throw new RuntimeException("Tried to call illegal render "+m.getRenderer()+"!");
67 | }
68 | catch (ClassNotFoundException e) {
69 | e.printStackTrace();
70 | throw new RegistrationException(ElectriCraft.instance, "No class found for Renderer "+m.getRenderer()+"!");
71 | }
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/Renders/RenderMotor.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Renders;
11 |
12 | import org.lwjgl.opengl.GL11;
13 |
14 | import net.minecraft.tileentity.TileEntity;
15 | import net.minecraftforge.client.MinecraftForgeClient;
16 |
17 | import Reika.DragonAPI.Interfaces.TileEntity.RenderFetcher;
18 | import Reika.DragonAPI.Libraries.Java.ReikaJavaLibrary;
19 | import Reika.ElectriCraft.Base.ElectriTERenderer;
20 | import Reika.ElectriCraft.TileEntities.TileEntityMotor;
21 | import Reika.RotaryCraft.Auxiliary.IORenderer;
22 | import Reika.RotaryCraft.ModInterface.Conversion.ModelElecMotor;
23 |
24 | public class RenderMotor extends ElectriTERenderer
25 | {
26 | private ModelElecMotor ElecMotorModel = new ModelElecMotor();
27 |
28 | public void renderTileEntityMotorAt(TileEntityMotor tile, double par2, double par4, double par6, float par8)
29 | {
30 | int var9;
31 |
32 | if (!tile.isInWorld())
33 | var9 = 0;
34 | else
35 | var9 = tile.getBlockMetadata();
36 |
37 | ModelElecMotor var14;
38 | var14 = ElecMotorModel;
39 |
40 | this.setupGL(tile, par2, par4, par6);
41 |
42 | this.bindTextureByName("/Reika/ElectriCraft/Textures/elecmotortex.png");
43 |
44 | int var11 = 0;
45 | float var13;
46 | switch(tile.getFacing()) {
47 | case EAST:
48 | var11 = 270;
49 | break;
50 | case WEST:
51 | var11 = 90;
52 | break;
53 | case NORTH:
54 | var11 = 180;
55 | break;
56 | case SOUTH:
57 | var11 = 0;
58 | break;
59 | default:
60 | break;
61 | }
62 |
63 | GL11.glRotatef(var11, 0.0F, 1.0F, 0.0F);
64 | if (tile.isFlipped && tile.getFacing().offsetZ != 0) {
65 | GL11.glRotated(180, 0, 1, 0);
66 | }
67 | int num = tile.isInWorld() ? 5 : 5;
68 | var14.renderAll(tile, ReikaJavaLibrary.makeListFrom(num, tile.getFinColor(), tile.getPower() > 0), tile.phi, 0);
69 |
70 | this.closeGL(tile);
71 | }
72 |
73 | @Override
74 | public void renderTileEntityAt(TileEntity tile, double par2, double par4, double par6, float par8)
75 | {
76 | if (this.doRenderModel((TileEntityMotor)tile))
77 | this.renderTileEntityMotorAt((TileEntityMotor)tile, par2, par4, par6, par8);
78 | if (((TileEntityMotor) tile).isInWorld() && MinecraftForgeClient.getRenderPass() == 1) {
79 | IORenderer.renderIO(tile, par2, par4, par6);
80 | }
81 | }
82 |
83 | @Override
84 | public String getImageFileName(RenderFetcher te) {
85 | return "elecmotortex.png";
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/Base/ElectriItemBase.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Base;
11 |
12 | import java.util.List;
13 |
14 | import net.minecraft.client.renderer.texture.IIconRegister;
15 | import net.minecraft.creativetab.CreativeTabs;
16 | import net.minecraft.item.Item;
17 | import net.minecraft.item.ItemStack;
18 |
19 | import Reika.DragonAPI.Interfaces.Item.IndexedItemSprites;
20 | import Reika.ElectriCraft.ElectriCraft;
21 | import Reika.ElectriCraft.Registry.ElectriItems;
22 |
23 | import cpw.mods.fml.relauncher.Side;
24 | import cpw.mods.fml.relauncher.SideOnly;
25 |
26 | public class ElectriItemBase extends Item implements IndexedItemSprites {
27 |
28 | private final int texture;
29 |
30 | public ElectriItemBase(int tex) {
31 | super();
32 | texture = tex;
33 | this.setCreativeTab(ElectriCraft.tabElectri);
34 | hasSubtypes = true;
35 | this.setMaxDamage(0);
36 | }
37 |
38 | @Override
39 | public int getItemSpriteIndex(ItemStack is) {
40 | return texture+this.getTextureOffset(is);
41 | }
42 |
43 | public int getTextureOffset(ItemStack is) {
44 | return is.getItemDamage();
45 | }
46 |
47 | @Override
48 | public final void registerIcons(IIconRegister ico) {}
49 |
50 | @Override
51 | @SideOnly(Side.CLIENT)
52 | public void getSubItems(Item ID, CreativeTabs cr, List li)
53 | {
54 | ElectriItems ri = ElectriItems.getEntryByID(ID);
55 | for (int i = 0; i < this.getDataValues(); i++) {
56 | ItemStack item = new ItemStack(ID, 1, i);
57 | if (ri.isAvailableInCreative(item))
58 | li.add(item);
59 | }
60 | }
61 |
62 | public final int getDataValues() {
63 | ElectriItems i = ElectriItems.getEntryByID(this);
64 | if (i == null)
65 | return 0;
66 | return i.getNumberMetadatas();
67 | }
68 |
69 | @Override
70 | public String getUnlocalizedName(ItemStack is) {
71 | if (this.getDataValues() <= 1)
72 | return super.getUnlocalizedName(is);
73 | int d = is.getItemDamage();
74 | return super.getUnlocalizedName() + "." + d;
75 | }
76 |
77 | public Class getTextureReferenceClass() {
78 | return ElectriCraft.class;
79 | }
80 |
81 | @Override
82 | public String getTexture(ItemStack is) {
83 | return "/Reika/ElectriCraft/Textures/Items/items1.png";
84 | }
85 |
86 | @Override
87 | public String getItemStackDisplayName(ItemStack is) {
88 | ElectriItems ir = ElectriItems.getEntry(is);
89 | return ir.hasMultiValuedName() ? ir.getMultiValuedName(is.getItemDamage()) : ir.getBasicName();
90 | }
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/Base/TileEntityWireComponent.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Base;
11 |
12 | import net.minecraft.nbt.NBTTagCompound;
13 | import net.minecraft.util.AxisAlignedBB;
14 | import net.minecraft.world.World;
15 | import net.minecraftforge.common.util.ForgeDirection;
16 |
17 | import Reika.RotaryCraft.API.Interfaces.Screwdriverable;
18 |
19 | public abstract class TileEntityWireComponent extends WiringTile implements Screwdriverable {
20 |
21 | private ForgeDirection facing;
22 |
23 | @Override
24 | public final boolean canNetworkOnSide(ForgeDirection dir) {
25 | return dir == this.getFacing() || dir == this.getFacing().getOpposite();
26 | }
27 |
28 | public final ForgeDirection getFacing() {
29 | return facing != null ? facing : ForgeDirection.EAST;
30 | }
31 |
32 | public final void setFacing(ForgeDirection dir) {
33 | facing = dir;
34 | }
35 |
36 | public abstract boolean canConnect();
37 |
38 | public final AxisAlignedBB getAABB() {
39 | float miny = 0;
40 | float maxy = this.getHeight();
41 | float w = this.getWidth()/2F;
42 | ForgeDirection dir = this.getFacing();
43 | float maxx = dir.offsetX != 0 ? 1 : 0.5F+w;
44 | float minx = dir.offsetX != 0 ? 0 : 0.5F-w;
45 | float maxz = dir.offsetZ != 0 ? 1 : 0.5F+w;
46 | float minz = dir.offsetZ != 0 ? 0 : 0.5F-w;
47 | if (isFlipped) {
48 | miny = 1-this.getHeight();
49 | maxy = 1;
50 | }
51 | return AxisAlignedBB.getBoundingBox(xCoord+minx, yCoord+miny, zCoord+minz, xCoord+maxx, yCoord+maxy, zCoord+maxz);
52 | }
53 |
54 | @Override
55 | protected void writeSyncTag(NBTTagCompound NBT)
56 | {
57 | super.writeSyncTag(NBT);
58 |
59 | NBT.setInteger("face", this.getFacing().ordinal());
60 | }
61 |
62 | @Override
63 | protected void readSyncTag(NBTTagCompound NBT)
64 | {
65 | super.readSyncTag(NBT);
66 |
67 | this.setFacing(dirs[NBT.getInteger("face")]);
68 | }
69 |
70 | @Override
71 | public boolean onShiftRightClick(World world, int x, int y, int z, ForgeDirection side) {
72 | return false;
73 | }
74 |
75 | @Override
76 | public boolean onRightClick(World world, int x, int y, int z, ForgeDirection side) {
77 | this.incrementFacing();
78 | return true;
79 | }
80 |
81 | protected void incrementFacing() {
82 | int o = this.getFacing().ordinal();
83 | if (o == 5)
84 | this.setFacing(dirs[2]);
85 | else
86 | this.setFacing(dirs[o+1]);
87 | this.rebuildNetwork();
88 | }
89 |
90 | public abstract float getHeight();
91 | public abstract float getWidth();
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/License.txt:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------------------------------------
2 | # @author Reika Kalseki
3 | #
4 | # Copyright 2013-2021
5 | #
6 | # All rights reserved.
7 | # Distribution of the software in any form is only allowed with
8 | # explicit, prior permission from the owner.
9 | #-------------------------------------------------------------------------------
10 | @author Reika
11 |
12 |
13 | This code is the property of and owned and copyrighted by Reika.
14 | This code is provided under a modified visible-source license that is as follows:
15 |
16 |
17 | API Code:
18 | ==============================
19 | API code is identifiable as being in an "API" package in the respective repository or mod, and is intended to allow some level of inter-mod interactions without creating hard dependencies on the mod proper. This code is exempt from the below restrictions for "Mod Code", as it by nature will require some level of copying and redistribution.
20 |
21 | The only restrictions imposed on API code are that it remain clearly marked with its original authorship and source, that it be used for the purpose described previously, and that it not be modified from the original without first contacting Reika.
22 |
23 |
24 | Mod Code:
25 | ==============================
26 | Any and all users are permitted to use the source for educational purposes, or to create derivative works
27 | for private use only. GitHub forks and direct downloads are considered derivative works.
28 |
29 | Unless given explicit written permission - electronic writing is acceptable - no user may redistribute this
30 | source code nor any derivative works. These pre-approved works must prominently contain this copyright notice.
31 |
32 | Derivative mods using any or all of the source code or assets are EXPRESSLY FORBIDDEN.
33 |
34 | Additionally, no attempt may be made to achieve monetary gain from this code by anyone except the original author.
35 | In the case of pre-approved derivative works, any monetary gains made will be shared between the original author
36 | and the other developer(s), proportional to the ratio of derived to original code.
37 |
38 | Finally, any and all displays, duplicates or derivatives of this code must be prominently marked as such, and must
39 | contain attribution to the original author, including a link to the original source. Any attempts to claim credit
40 | for this code will be treated as intentional theft.
41 |
42 | Due to the Mojang and Minecraft Mod Terms of Service and Licensing Restrictions, compiled versions of this code
43 | must be provided for free. However, with the exception of pre-approved derivative works, only the original authoror modpacks
44 | may distribute compiled binary versions of this code.
45 |
46 | ==============================
47 |
48 | Failure to comply with these restrictions is a violation of copyright law and will be dealt with accordingly.
49 |
--------------------------------------------------------------------------------
/Registry/ElectriOptions.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Registry;
11 |
12 | import Reika.DragonAPI.Interfaces.Configuration.BooleanConfig;
13 | import Reika.DragonAPI.Interfaces.Configuration.IntegerConfig;
14 | import Reika.DragonAPI.Interfaces.Configuration.UserSpecificConfig;
15 | import Reika.ElectriCraft.ElectriCraft;
16 |
17 | public enum ElectriOptions implements IntegerConfig, BooleanConfig, UserSpecificConfig {
18 |
19 | //RETROGEN("Retrogenerate Ores", false),
20 | DISCRETE("Ore Discretization", 1); //How much to "clump" the ore into larger but fewer veins. Largely useless now that CondensedOres exists.
21 |
22 | private String label;
23 | private boolean defaultState;
24 | private int defaultValue;
25 | private Class type;
26 | private boolean enforcing = false;
27 |
28 | public static final ElectriOptions[] optionList = ElectriOptions.values();
29 |
30 | private ElectriOptions(String l, boolean d) {
31 | label = l;
32 | defaultState = d;
33 | type = boolean.class;
34 | }
35 |
36 | private ElectriOptions(String l, boolean d, boolean tag) {
37 | label = l;
38 | defaultState = d;
39 | type = boolean.class;
40 | enforcing = true;
41 | }
42 |
43 | private ElectriOptions(String l, int d) {
44 | label = l;
45 | defaultValue = d;
46 | type = int.class;
47 | }
48 |
49 | public boolean isBoolean() {
50 | return type == boolean.class;
51 | }
52 |
53 | public boolean isNumeric() {
54 | return type == int.class;
55 | }
56 |
57 | public Class getPropertyType() {
58 | return type;
59 | }
60 |
61 | public String getLabel() {
62 | return label;
63 | }
64 |
65 | public boolean getState() {
66 | return (Boolean)ElectriCraft.config.getControl(this.ordinal());
67 | }
68 |
69 | public int getValue() {
70 | return (Integer)ElectriCraft.config.getControl(this.ordinal());
71 | }
72 |
73 | public boolean isDummiedOut() {
74 | return type == null;
75 | }
76 |
77 | @Override
78 | public boolean getDefaultState() {
79 | return defaultState;
80 | }
81 |
82 | @Override
83 | public int getDefaultValue() {
84 | return defaultValue;
85 | }
86 |
87 | @Override
88 | public boolean isEnforcingDefaults() {
89 | return enforcing;
90 | }
91 |
92 | @Override
93 | public boolean shouldLoad() {
94 | return true;
95 | }
96 |
97 | @Override
98 | public boolean isUserSpecific() {
99 | switch(this) {
100 | default:
101 | return false;
102 | }
103 | }
104 |
105 | }
106 |
--------------------------------------------------------------------------------
/ElectriItemRenderer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft;
11 |
12 | import org.lwjgl.opengl.GL11;
13 |
14 | import net.minecraft.client.renderer.RenderBlocks;
15 | import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
16 | import net.minecraft.item.ItemStack;
17 | import net.minecraft.tileentity.TileEntity;
18 | import net.minecraftforge.client.IItemRenderer;
19 |
20 | import Reika.DragonAPI.Libraries.IO.ReikaTextureHelper;
21 | import Reika.ElectriCraft.Auxiliary.Interfaces.BatteryTile;
22 | import Reika.ElectriCraft.Registry.ElectriTiles;
23 | import Reika.ElectriCraft.Registry.WireType;
24 | import Reika.ElectriCraft.TileEntities.TileEntityWire;
25 |
26 | public class ElectriItemRenderer implements IItemRenderer {
27 |
28 |
29 | public ElectriItemRenderer() {
30 |
31 | }
32 |
33 | @Override
34 | public boolean handleRenderType(ItemStack item, ItemRenderType type) {
35 | return true;
36 | }
37 |
38 | @Override
39 | public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
40 | return true;
41 | }
42 |
43 | @Override
44 | public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
45 | float a = 0; float b = 0;
46 |
47 | RenderBlocks rb = (RenderBlocks)data[0];
48 | if (type == type.ENTITY) {
49 | a = -0.5F;
50 | b = -0.5F;
51 | GL11.glScalef(0.5F, 0.5F, 0.5F);
52 | }
53 | ElectriTiles machine = ElectriTiles.getMachine(item);
54 | if (machine == ElectriTiles.WIRE) {
55 | TileEntityWire wire = (TileEntityWire)ElectriTiles.WIRE.createTEInstanceForRender();
56 | wire.insulated = item.getItemDamage() >= WireType.INS_OFFSET;
57 | wire.setBlockMetadata(item.getItemDamage()%WireType.INS_OFFSET);
58 | TileEntityRendererDispatcher.instance.renderTileEntityAt(wire, a, -0.1D, b, 0.0F);
59 | }
60 | else if (machine == ElectriTiles.RFBATTERY || machine == ElectriTiles.EUBATTERY) {
61 | BatteryTile te = (BatteryTile)machine.createTEInstanceForRender();
62 | ReikaTextureHelper.bindTerrainTexture();
63 | rb.renderBlockAsItem(machine.getBlockInstance(), item.getItemDamage(), 1);
64 | te.setEnergyFromNBT(item);
65 | TileEntityRendererDispatcher.instance.renderTileEntityAt((TileEntity)te, -0.5, -0.5, -0.5, 0.0F);
66 | }
67 | else if (machine.hasRender())
68 | TileEntityRendererDispatcher.instance.renderTileEntityAt(machine.createTEInstanceForRender(), a, -0.1D, b, 0.0F);
69 | else {
70 | ReikaTextureHelper.bindTerrainTexture();
71 | rb.renderBlockAsItem(machine.getBlockInstance(), item.getItemDamage(), 1);
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/Renders/ModelResistor.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | // Date: 13-03-2014 09:44:42
11 | // Template version 1.1
12 | // Java generated by Techne
13 | // Keep in mind that you still need to fill in some blanks
14 | // - ZeuX
15 |
16 | package Reika.ElectriCraft.Renders;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Collections;
20 | import java.util.List;
21 |
22 | import Reika.DragonAPI.Instantiable.Rendering.LODModelPart;
23 |
24 | public class ModelResistor extends ModelResistorBase {
25 |
26 | LODModelPart band3b;
27 | LODModelPart band2a;
28 | LODModelPart band3a;
29 | LODModelPart band1a;
30 | LODModelPart band1b;
31 | LODModelPart band2b;
32 |
33 | private ArrayList bands;
34 |
35 | @Override
36 | protected void addBands() {
37 | band3b = new LODModelPart(this, 22, 63);
38 | band3b.addBox(0F, 0F, 0F, 9, 6, 2);
39 | band3b.setRotationPoint(-4.5F, 13.5F, 0F);
40 | band3b.setTextureSize(128, 128);
41 | band3b.mirror = true;
42 | this.setRotation(band3b, 0F, 0F, 0F);
43 | band2a = new LODModelPart(this, 0, 63);
44 | band2a.addBox(0F, 0F, 0F, 7, 6, 2);
45 | band2a.setRotationPoint(-3.5F, 11.5F, -3F);
46 | band2a.setTextureSize(128, 128);
47 | band2a.mirror = true;
48 | this.setRotation(band2a, 0F, 0F, 0F);
49 | band3a = new LODModelPart(this, 0, 63);
50 | band3a.addBox(0F, 0F, 0F, 7, 6, 2);
51 | band3a.setRotationPoint(-3.5F, 11.5F, 0F);
52 | band3a.setTextureSize(128, 128);
53 | band3a.mirror = true;
54 | this.setRotation(band3a, 0F, 0F, 0F);
55 | band1a = new LODModelPart(this, 0, 63);
56 | band1a.addBox(0F, 0F, 0F, 7, 6, 2);
57 | band1a.setRotationPoint(-3.5F, 11.5F, -6F);
58 | band1a.setTextureSize(128, 128);
59 | band1a.mirror = true;
60 | this.setRotation(band1a, 0F, 0F, 0F);
61 | band1b = new LODModelPart(this, 22, 63);
62 | band1b.addBox(0F, 0F, 0F, 9, 6, 2);
63 | band1b.setRotationPoint(-4.5F, 13.5F, -6F);
64 | band1b.setTextureSize(128, 128);
65 | band1b.mirror = true;
66 | this.setRotation(band1b, 0F, 0F, 0F);
67 | band2b = new LODModelPart(this, 22, 63);
68 | band2b.addBox(0F, 0F, 0F, 9, 6, 2);
69 | band2b.setRotationPoint(-4.5F, 13.5F, -3F);
70 | band2b.setTextureSize(128, 128);
71 | band2b.mirror = true;
72 | this.setRotation(band2b, 0F, 0F, 0F);
73 |
74 | bands = new ArrayList();
75 | bands.add(new ResistorBand(1, band1a, band1b));
76 | bands.add(new ResistorBand(2, band2a, band2b));
77 | bands.add(new ResistorBand(3, band3a, band3b));
78 | }
79 |
80 | @Override
81 | protected List getBands() {
82 | return Collections.unmodifiableList(bands);
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/Base/ElectriBlock.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Base;
11 |
12 | import net.minecraft.block.material.Material;
13 | import net.minecraft.client.particle.EffectRenderer;
14 | import net.minecraft.client.renderer.texture.IIconRegister;
15 | import net.minecraft.util.AxisAlignedBB;
16 | import net.minecraft.util.MovingObjectPosition;
17 | import net.minecraft.world.World;
18 |
19 | import Reika.DragonAPI.Libraries.Java.ReikaJavaLibrary;
20 | import Reika.DragonAPI.Libraries.Rendering.ReikaRenderHelper;
21 | import Reika.ElectriCraft.ElectriCraft;
22 | import Reika.ElectriCraft.Registry.ElectriBlocks;
23 |
24 | import cpw.mods.fml.relauncher.Side;
25 | import cpw.mods.fml.relauncher.SideOnly;
26 |
27 | public abstract class ElectriBlock extends NetworkBlock {
28 |
29 | public ElectriBlock(Material par2Material) {
30 | super(par2Material);
31 | }
32 |
33 | @Override
34 | public boolean hasTileEntity(int meta) {
35 | return true;
36 | }
37 |
38 | @Override
39 | public final boolean isOpaqueCube() {
40 | return false;
41 | }
42 |
43 | @Override
44 | public final boolean renderAsNormalBlock()
45 | {
46 | return false;
47 | }
48 |
49 | @Override
50 | public int getRenderType() {
51 | return -1;
52 | }
53 |
54 | @Override
55 | public void registerBlockIcons(IIconRegister ico) {
56 | blockIcon = ico.registerIcon("rotarycraft:steel");
57 | }
58 |
59 | @Override
60 | public final AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z)
61 | {
62 | return this.getCollisionBoundingBoxFromPool(world, x, y, z);
63 | }
64 |
65 | @Override
66 | @SideOnly(Side.CLIENT)
67 | public final boolean addDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer eff)
68 | {
69 | if (this == ElectriBlocks.WIRE.getBlockInstance() || this == ElectriBlocks.CABLE.getBlockInstance())
70 | return super.addDestroyEffects(world, x, y, z, meta, eff);
71 | return ReikaRenderHelper.addModelledBlockParticles("/Reika/ElectriCraft/Textures/", world, x, y, z, this, eff, ReikaJavaLibrary.makeListFrom(new double[]{0,0,1,1}), ElectriCraft.class);
72 | }
73 |
74 | @Override
75 | @SideOnly(Side.CLIENT)
76 | public final boolean addHitEffects(World world, MovingObjectPosition tg, EffectRenderer eff)
77 | {
78 | if (this == ElectriBlocks.WIRE.getBlockInstance() || this == ElectriBlocks.CABLE.getBlockInstance())
79 | return super.addHitEffects(world, tg, eff);
80 | return ReikaRenderHelper.addModelledBlockParticles("/Reika/ElectriCraft/Textures/", world, tg, this, eff, ReikaJavaLibrary.makeListFrom(new double[]{0,0,1,1}), ElectriCraft.class);
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/Renders/ModelMeter.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | // Date: 02/09/2014 9:43:31 PM
11 | // Template version 1.1
12 | // Java generated by Techne
13 | // Keep in mind that you still need to fill in some blanks
14 | // - ZeuX
15 |
16 | package Reika.ElectriCraft.Renders;
17 |
18 | import java.util.ArrayList;
19 |
20 | import net.minecraft.tileentity.TileEntity;
21 |
22 | import Reika.DragonAPI.Instantiable.Rendering.LODModelPart;
23 | import Reika.RotaryCraft.Base.RotaryModelBase;
24 |
25 | public class ModelMeter extends RotaryModelBase
26 | {
27 | //fields
28 | LODModelPart Shape1;
29 | LODModelPart Shape2;
30 | LODModelPart Shape2a;
31 | LODModelPart Shape3;
32 | LODModelPart Shape3a;
33 | LODModelPart Shape4;
34 |
35 | public ModelMeter()
36 | {
37 | textureWidth = 128;
38 | textureHeight = 128;
39 |
40 | Shape1 = new LODModelPart(this, 0, 0);
41 | Shape1.addBox(0F, 0F, 0F, 16, 15, 16);
42 | Shape1.setRotationPoint(-8F, 9F, -8F);
43 | Shape1.setTextureSize(128, 128);
44 | Shape1.mirror = true;
45 | this.setRotation(Shape1, 0F, 0F, 0F);
46 | Shape2 = new LODModelPart(this, 0, 50);
47 | Shape2.addBox(0F, 0F, 0F, 2, 1, 16);
48 | Shape2.setRotationPoint(6F, 8F, -8F);
49 | Shape2.setTextureSize(128, 128);
50 | Shape2.mirror = true;
51 | this.setRotation(Shape2, 0F, 0F, 0F);
52 | Shape2a = new LODModelPart(this, 0, 32);
53 | Shape2a.addBox(0F, 0F, 0F, 2, 1, 16);
54 | Shape2a.setRotationPoint(-8F, 8F, -8F);
55 | Shape2a.setTextureSize(128, 128);
56 | Shape2a.mirror = true;
57 | this.setRotation(Shape2a, 0F, 0F, 0F);
58 | Shape3 = new LODModelPart(this, 0, 68);
59 | Shape3.addBox(0F, 0F, 0F, 12, 1, 2);
60 | Shape3.setRotationPoint(-6F, 8F, 6F);
61 | Shape3.setTextureSize(128, 128);
62 | Shape3.mirror = true;
63 | this.setRotation(Shape3, 0F, 0F, 0F);
64 | Shape3a = new LODModelPart(this, 0, 68);
65 | Shape3a.addBox(0F, 0F, 0F, 12, 1, 2);
66 | Shape3a.setRotationPoint(-6F, 8F, -8F);
67 | Shape3a.setTextureSize(128, 128);
68 | Shape3a.mirror = true;
69 | this.setRotation(Shape3a, 0F, 0F, 0F);
70 | Shape4 = new LODModelPart(this, 0, 72);
71 | Shape4.addBox(0F, 0F, 0F, 15, 1, 15);
72 | Shape4.setRotationPoint(-7.5F, 8.5F, -7.5F);
73 | Shape4.setTextureSize(128, 128);
74 | Shape4.mirror = true;
75 | this.setRotation(Shape4, 0F, 0F, 0F);
76 | }
77 |
78 | @Override
79 | public void renderAll(TileEntity te, ArrayList li, float phi, float theta)
80 | {
81 | Shape1.render(te, f5);
82 | Shape2.render(te, f5);
83 | Shape2a.render(te, f5);
84 | Shape3.render(te, f5);
85 | Shape3a.render(te, f5);
86 | Shape4.render(te, f5);
87 | }
88 |
89 | @Override
90 | public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
91 | {
92 | super.setRotationAngles(f, f1, f2, f3, f4, f5);
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/Renders/RenderFuse.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Renders;
11 |
12 | import org.lwjgl.opengl.GL11;
13 |
14 | import net.minecraft.tileentity.TileEntity;
15 | import net.minecraftforge.client.MinecraftForgeClient;
16 |
17 | import Reika.DragonAPI.Interfaces.TileEntity.RenderFetcher;
18 | import Reika.DragonAPI.Libraries.Java.ReikaGLHelper.BlendMode;
19 | import Reika.ElectriCraft.Base.ElectriTERenderer;
20 | import Reika.ElectriCraft.TileEntities.TileEntityFuse;
21 | import Reika.RotaryCraft.Auxiliary.IORenderer;
22 |
23 | public class RenderFuse extends ElectriTERenderer
24 | {
25 | private ModelFuse FuseModel = new ModelFuse();
26 |
27 | public void renderTileEntityFuseAt(TileEntityFuse tile, double par2, double par4, double par6, float par8)
28 | {
29 | int var9;
30 |
31 | if (!tile.isInWorld())
32 | var9 = 0;
33 | else
34 | var9 = tile.getBlockMetadata();
35 |
36 | ModelFuse var14;
37 | var14 = FuseModel;
38 |
39 | this.setupGL(tile, par2, par4, par6);
40 | GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
41 | GL11.glEnable(GL11.GL_BLEND);
42 | BlendMode.DEFAULT.apply();
43 |
44 | String s = "/Reika/ElectriCraft/Textures/fusetex.png";
45 | if (tile.isOverloaded()) {
46 | s = "/Reika/ElectriCraft/Textures/fusetex-burn.png";
47 | }
48 | else {
49 | float f = tile.getWireCurrent()/(float)tile.getMaxCurrent();
50 | if (f >= 0.75) {
51 | s = "/Reika/ElectriCraft/Textures/fusetex-hot3.png";
52 | }
53 | else if (f >= 0.5) {
54 | s = "/Reika/ElectriCraft/Textures/fusetex-hot2.png";
55 | }
56 | else if (f >= 0.25) {
57 | s = "/Reika/ElectriCraft/Textures/fusetex-hot.png";
58 | }
59 | }
60 | this.bindTextureByName(s);
61 |
62 | int var11 = 0;
63 | float var13;
64 | switch(tile.getFacing()) {
65 | case EAST:
66 | var11 = 270;
67 | break;
68 | case WEST:
69 | var11 = 90;
70 | break;
71 | case NORTH:
72 | var11 = 180;
73 | break;
74 | case SOUTH:
75 | var11 = 0;
76 | break;
77 | default:
78 | break;
79 | }
80 |
81 | GL11.glRotatef(var11, 0.0F, 1.0F, 0.0F);
82 | //GL11.glTranslated(0, -0.1875, 0);
83 | var14.renderAll(tile, null, tile.phi);
84 |
85 | GL11.glPopAttrib();
86 | this.closeGL(tile);
87 | }
88 |
89 | @Override
90 | public void renderTileEntityAt(TileEntity tile, double par2, double par4, double par6, float par8)
91 | {
92 | //if (this.doRenderModel((TileEntityFuse)tile))
93 | this.renderTileEntityFuseAt((TileEntityFuse)tile, par2, par4, par6, par8);
94 | if (((TileEntityFuse) tile).isInWorld() && MinecraftForgeClient.getRenderPass() == 1) {
95 | IORenderer.renderIO(tile, par2, par4, par6);
96 | }
97 | }
98 |
99 | @Override
100 | public String getImageFileName(RenderFetcher te) {
101 | return "fusetex.png";
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/Blocks/BlockEUSplitter.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Blocks;
11 |
12 | import java.util.Random;
13 |
14 | import net.minecraft.block.Block;
15 | import net.minecraft.block.material.Material;
16 | import net.minecraft.client.renderer.texture.IIconRegister;
17 | import net.minecraft.entity.player.EntityPlayer;
18 | import net.minecraft.item.Item;
19 | import net.minecraft.item.ItemStack;
20 | import net.minecraft.tileentity.TileEntity;
21 | import net.minecraft.util.IIcon;
22 | import net.minecraft.util.MovingObjectPosition;
23 | import net.minecraft.world.IBlockAccess;
24 | import net.minecraft.world.World;
25 |
26 | import Reika.ElectriCraft.Registry.ElectriTiles;
27 | import Reika.ElectriCraft.TileEntities.ModInterface.TileEntityEUSplitter;
28 |
29 | public class BlockEUSplitter extends Block {
30 |
31 | private IIcon outIcon;
32 | private IIcon inIcon;
33 |
34 | public BlockEUSplitter(Material m) {
35 | super(m);
36 | this.setHardness(2F);
37 | this.setResistance(10F);
38 | }
39 |
40 | @Override
41 | public boolean hasTileEntity(int meta) {
42 | return true;
43 | }
44 |
45 | @Override
46 | public TileEntity createTileEntity(World world, int meta) {
47 | return ElectriTiles.createTEFromIDAndMetadata(this, meta);
48 | }
49 |
50 | @Override
51 | public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
52 | {
53 | return ElectriTiles.getTE(world, x, y, z).getCraftedProduct();
54 | }
55 |
56 | @Override
57 | public Item getItemDropped(int id, Random r, int fortune) {
58 | return null;
59 | }
60 |
61 |
62 | @Override
63 | public int damageDropped(int par1)
64 | {
65 | return ElectriTiles.getMachineFromIDandMetadata(this, par1).ordinal();
66 | }
67 |
68 | @Override
69 | public int quantityDropped(Random par1Random)
70 | {
71 | return 1;
72 | }
73 |
74 | @Override
75 | public final boolean canSilkHarvest(World world, EntityPlayer player, int x, int y, int z, int metadata)
76 | {
77 | return false;
78 | }
79 |
80 | @Override
81 | public void registerBlockIcons(IIconRegister ico) {
82 | blockIcon = ico.registerIcon("electricraft:eusplit");
83 | inIcon = ico.registerIcon("electricraft:eusplit_in");
84 | outIcon = ico.registerIcon("electricraft:eusplit_out");
85 | }
86 |
87 | @Override
88 | public IIcon getIcon(int s, int meta) {
89 | switch(s) {
90 | case 4: //side when as item
91 | return inIcon;
92 | case 1:
93 | return outIcon;
94 | default:
95 | return blockIcon;
96 | }
97 | }
98 |
99 | @Override
100 | public IIcon getIcon(IBlockAccess iba, int x, int y, int z, int s) {
101 | TileEntityEUSplitter te = (TileEntityEUSplitter)iba.getTileEntity(x, y, z);
102 | boolean in = te.getFacing().ordinal() == s;
103 | boolean out = te.emitsTo(s);
104 | return in ? inIcon : out ? outIcon : blockIcon;
105 | }
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/Base/ElectriTileEntity.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Base;
11 |
12 | import java.util.ArrayList;
13 |
14 | import net.minecraft.nbt.NBTTagCompound;
15 | import net.minecraft.world.World;
16 | import net.minecraftforge.common.util.ForgeDirection;
17 |
18 | import Reika.DragonAPI.ModList;
19 | import Reika.DragonAPI.ASM.DependentMethodStripper.ModDependent;
20 | import Reika.DragonAPI.Base.TileEntityRegistryBase;
21 | import Reika.DragonAPI.Interfaces.TextureFetcher;
22 | import Reika.DragonAPI.Interfaces.TileEntity.RenderFetcher;
23 | import Reika.ElectriCraft.Auxiliary.ElectriRenderList;
24 | import Reika.ElectriCraft.Registry.ElectriTiles;
25 | import Reika.ElectriCraft.TileEntities.TileEntityBattery;
26 | import Reika.ElectriCraft.TileEntities.TileEntityWire;
27 | import Reika.RotaryCraft.API.Interfaces.Transducerable;
28 | import Reika.RotaryCraft.API.Power.ShaftMachine;
29 |
30 | import li.cil.oc.api.network.Visibility;
31 |
32 | public abstract class ElectriTileEntity extends TileEntityRegistryBase implements RenderFetcher, Transducerable {
33 |
34 | protected ForgeDirection[] dirs = ForgeDirection.values();
35 |
36 | public float phi;
37 |
38 | public boolean isFlipped = false;
39 |
40 | public final TextureFetcher getRenderer() {
41 | if (ElectriTiles.TEList[this.getIndex()].hasRender())
42 | return ElectriRenderList.getRenderForMachine(ElectriTiles.TEList[this.getIndex()]);
43 | else
44 | return null;
45 | }
46 |
47 | @Override
48 | public final boolean allowTickAcceleration() {
49 | return false;
50 | }
51 |
52 | public abstract ElectriTiles getTile();
53 |
54 | public int getTextureState(ForgeDirection side) {
55 | return 0;
56 | }
57 |
58 | @Override
59 | protected void writeSyncTag(NBTTagCompound NBT) {
60 | super.writeSyncTag(NBT);
61 | NBT.setBoolean("flip", isFlipped);
62 | }
63 |
64 | @Override
65 | protected void readSyncTag(NBTTagCompound NBT) {
66 | super.readSyncTag(NBT);
67 | isFlipped = NBT.getBoolean("flip");
68 | }
69 |
70 | @Override
71 | public boolean shouldRenderInPass(int pass) {
72 | ElectriTiles r = ElectriTiles.TEList[this.getIndex()];
73 | return pass == 0 || ((r.renderInPass1() || this instanceof ShaftMachine) && pass == 1);
74 | }
75 |
76 | public final ArrayList getMessages(World world, int x, int y, int z, int side) {
77 | ArrayList li = new ArrayList();
78 | if (this instanceof TileEntityWire) {
79 | TileEntityWire wire = (TileEntityWire)this;
80 | li.add(String.format("Point Voltage: %dV", wire.getWireVoltage()));
81 | li.add(String.format("Point Current: %dA", wire.getWireCurrent()));
82 | }
83 | if (this instanceof TileEntityBattery) {
84 | TileEntityBattery b = (TileEntityBattery)this;
85 | double max = b.getMaxEnergy();
86 | li.add(String.format("Stored Energy: %s/%s", b.getDisplayEnergy(), b.getBatteryType().getFormattedCapacity()));
87 | }
88 | return li;
89 | }
90 |
91 | @Override
92 | public int getRedstoneOverride() {
93 | return 0;
94 | }
95 |
96 | @Override
97 | @ModDependent(ModList.OPENCOMPUTERS)
98 | public final Visibility getOCNetworkVisibility() {
99 | return this.getTile().isWiring() ? Visibility.None : Visibility.Network;
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/Renders/ModelPreciseResistor.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | // Date: 13-03-2014 09:44:42
11 | // Template version 1.1
12 | // Java generated by Techne
13 | // Keep in mind that you still need to fill in some blanks
14 | // - ZeuX
15 |
16 | package Reika.ElectriCraft.Renders;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Collections;
20 | import java.util.List;
21 |
22 | import Reika.DragonAPI.Instantiable.Rendering.LODModelPart;
23 |
24 | public class ModelPreciseResistor extends ModelResistorBase {
25 |
26 | LODModelPart band4a;
27 | LODModelPart band4b;
28 | LODModelPart band3a;
29 | LODModelPart band3b;
30 | LODModelPart band2a;
31 | LODModelPart band2b;
32 | LODModelPart band1a;
33 | LODModelPart band1b;
34 |
35 | private ArrayList bands;
36 |
37 | @Override
38 | protected void addBands() {
39 | band4a = new LODModelPart(this, 0, 63);
40 | band4a.addBox(0F, 0F, 0F, 7, 6, 2);
41 | band4a.setRotationPoint(-3.5F, 11.5F, 3F);
42 | band4a.setTextureSize(128, 128);
43 | band4a.mirror = true;
44 | this.setRotation(band4a, 0F, 0F, 0F);
45 | band4b = new LODModelPart(this, 22, 63);
46 | band4b.addBox(0F, 0F, 0F, 9, 6, 2);
47 | band4b.setRotationPoint(-4.5F, 13.5F, 3F);
48 | band4b.setTextureSize(128, 128);
49 | band4b.mirror = true;
50 | this.setRotation(band4b, 0F, 0F, 0F);
51 |
52 | band3a = new LODModelPart(this, 0, 63);
53 | band3a.addBox(0F, 0F, 0F, 7, 6, 2);
54 | band3a.setRotationPoint(-3.5F, 11.5F, 0F);
55 | band3a.setTextureSize(128, 128);
56 | band3a.mirror = true;
57 | this.setRotation(band3a, 0F, 0F, 0F);
58 | band3b = new LODModelPart(this, 22, 63);
59 | band3b.addBox(0F, 0F, 0F, 9, 6, 2);
60 | band3b.setRotationPoint(-4.5F, 13.5F, 0F);
61 | band3b.setTextureSize(128, 128);
62 | band3b.mirror = true;
63 | this.setRotation(band3b, 0F, 0F, 0F);
64 |
65 | band2a = new LODModelPart(this, 0, 63);
66 | band2a.addBox(0F, 0F, 0F, 7, 6, 2);
67 | band2a.setRotationPoint(-3.5F, 11.5F, -3F);
68 | band2a.setTextureSize(128, 128);
69 | band2a.mirror = true;
70 | this.setRotation(band2a, 0F, 0F, 0F);
71 | band2b = new LODModelPart(this, 22, 63);
72 | band2b.addBox(0F, 0F, 0F, 9, 6, 2);
73 | band2b.setRotationPoint(-4.5F, 13.5F, -3F);
74 | band2b.setTextureSize(128, 128);
75 | band2b.mirror = true;
76 | this.setRotation(band2b, 0F, 0F, 0F);
77 |
78 | band1a = new LODModelPart(this, 0, 63);
79 | band1a.addBox(0F, 0F, 0F, 7, 6, 2);
80 | band1a.setRotationPoint(-3.5F, 11.5F, -6F);
81 | band1a.setTextureSize(128, 128);
82 | band1a.mirror = true;
83 | this.setRotation(band1a, 0F, 0F, 0F);
84 | band1b = new LODModelPart(this, 22, 63);
85 | band1b.addBox(0F, 0F, 0F, 9, 6, 2);
86 | band1b.setRotationPoint(-4.5F, 13.5F, -6F);
87 | band1b.setTextureSize(128, 128);
88 | band1b.mirror = true;
89 | this.setRotation(band1b, 0F, 0F, 0F);
90 |
91 | bands = new ArrayList();
92 | bands.add(new ResistorBand(1, band1a, band1b));
93 | bands.add(new ResistorBand(2, band2a, band2b));
94 | bands.add(new ResistorBand(3, band3a, band3b));
95 | bands.add(new ResistorBand(4, band4a, band4b));
96 | }
97 |
98 | @Override
99 | protected List getBands() {
100 | return Collections.unmodifiableList(bands);
101 | }
102 |
103 | }
104 |
--------------------------------------------------------------------------------
/Renders/RenderElectricMeter.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Renders;
11 |
12 | import org.lwjgl.opengl.GL11;
13 | import org.lwjgl.opengl.GL12;
14 |
15 | import net.minecraft.client.gui.FontRenderer;
16 | import net.minecraft.client.renderer.entity.RenderManager;
17 | import net.minecraft.tileentity.TileEntity;
18 | import net.minecraftforge.client.MinecraftForgeClient;
19 |
20 | import Reika.DragonAPI.Interfaces.TileEntity.RenderFetcher;
21 | import Reika.DragonAPI.Libraries.Rendering.ReikaRenderHelper;
22 | import Reika.ElectriCraft.Base.ElectriTERenderer;
23 | import Reika.ElectriCraft.TileEntities.TileEntityMeter;
24 | import Reika.RotaryCraft.Auxiliary.IORenderer;
25 |
26 | public class RenderElectricMeter extends ElectriTERenderer
27 | {
28 | private ModelMeter MeterModel = new ModelMeter();
29 |
30 | public void renderTileEntityMeterAt(TileEntityMeter tile, double par2, double par4, double par6, float par8)
31 | {
32 | int var9;
33 |
34 | ModelMeter var14;
35 | var14 = MeterModel;
36 |
37 | GL11.glEnable(GL12.GL_RESCALE_NORMAL);
38 | GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
39 | this.setupGL(tile, par2, par4, par6);
40 |
41 | this.bindTextureByName("/Reika/ElectriCraft/Textures/metertex.png");
42 |
43 | var14.renderAll(tile, null, tile.phi);
44 | if (tile.isInWorld())
45 | this.renderText(tile, par2, par4, par6);
46 |
47 | this.closeGL(tile);
48 | }
49 |
50 | private void renderText(TileEntityMeter tile, double par2, double par4, double par6) {
51 | FontRenderer f = this.getFontRenderer();
52 | String s1 = String.format("Voltage:");
53 | String s2 = String.format("Current:");
54 | String s1b = String.format("%dV", tile.getWireVoltage());
55 | String s2b = String.format("%dA", tile.getWireCurrent());
56 |
57 | String s3 = String.format("Resistance: %d Ohms", tile.getResistance());
58 |
59 | GL11.glPushMatrix();
60 | double s = 0.01;
61 | //ReikaRenderHelper.disableLighting();
62 | GL11.glDisable(GL11.GL_LIGHTING);
63 | ReikaRenderHelper.disableEntityLighting();
64 | GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
65 | GL11.glDepthMask(false);
66 | float ang = RenderManager.instance.playerViewY%360;
67 | if (ang < 0)
68 | ang += 360;
69 | int ra = 90*(int)((ang+180+45)/90F);
70 | GL11.glRotated(ra, 0, 1, 0);
71 | GL11.glTranslated(0, 0.515, 0);
72 | GL11.glScaled(s, s, s);
73 | GL11.glRotated(-90, 1, 0, 0);
74 |
75 | int dx = -30;
76 | int dy = -30;
77 |
78 | f.drawString(s1, dx, dy, 0xffffff);
79 | f.drawString(s1b, dx, dy+10, 0xffffff);
80 |
81 | f.drawString(s2, dx, dy+30, 0xffffff);
82 | f.drawString(s2b, dx, dy+40, 0xffffff);
83 |
84 | GL11.glPopMatrix();
85 | GL11.glDepthMask(true);
86 | ReikaRenderHelper.enableEntityLighting();
87 | GL11.glEnable(GL11.GL_LIGHTING);
88 | }
89 |
90 | @Override
91 | public void renderTileEntityAt(TileEntity tile, double par2, double par4, double par6, float par8)
92 | {
93 | if (this.doRenderModel((TileEntityMeter)tile))
94 | this.renderTileEntityMeterAt((TileEntityMeter)tile, par2, par4, par6, par8);
95 | if (((TileEntityMeter) tile).isInWorld() && MinecraftForgeClient.getRenderPass() == 1) {
96 | IORenderer.renderIO(tile, par2, par4, par6);
97 | }
98 | }
99 |
100 | @Override
101 | public String getImageFileName(RenderFetcher te) {
102 | return "metertex.png";
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #################
2 | ## Eclipse
3 | #################
4 |
5 | *.pydevproject
6 | .project
7 | .metadata
8 | bin/
9 | tmp/
10 | *.tmp
11 | *.bak
12 | *.swp
13 | *~.nib
14 | local.properties
15 | .classpath
16 | .settings/
17 | .loadpath
18 |
19 | # External tool builders
20 | .externalToolBuilders/
21 |
22 | # Locally stored "Eclipse launch configurations"
23 | *.launch
24 |
25 | # CDT-specific
26 | .cproject
27 |
28 | # PDT-specific
29 | .buildpath
30 |
31 |
32 | #################
33 | ## Visual Studio
34 | #################
35 |
36 | ## Ignore Visual Studio temporary files, build results, and
37 | ## files generated by popular Visual Studio add-ons.
38 |
39 | # User-specific files
40 | *.suo
41 | *.user
42 | *.sln.docstates
43 |
44 | # Build results
45 |
46 | [Dd]ebug/
47 | [Rr]elease/
48 | x64/
49 | build/
50 | [Bb]in/
51 | [Oo]bj/
52 |
53 | # MSTest test Results
54 | [Tt]est[Rr]esult*/
55 | [Bb]uild[Ll]og.*
56 |
57 | *_i.c
58 | *_p.c
59 | *.ilk
60 | *.meta
61 | *.obj
62 | *.pch
63 | *.pdb
64 | *.pgc
65 | *.pgd
66 | *.rsp
67 | *.sbr
68 | *.tlb
69 | *.tcn
70 | *.pdn
71 | *.rar
72 | *.tli
73 | *.tlh
74 | *.tmp
75 | *.tmp_proj
76 | *.log
77 | *.vspscc
78 | *.vssscc
79 | .builds
80 | *.pidb
81 | *.log
82 | *.scc
83 |
84 | # Visual C++ cache files
85 | ipch/
86 | *.aps
87 | *.ncb
88 | *.opensdf
89 | *.sdf
90 | *.cachefile
91 |
92 | # Visual Studio profiler
93 | *.psess
94 | *.vsp
95 | *.vspx
96 |
97 | # Guidance Automation Toolkit
98 | *.gpState
99 |
100 | # ReSharper is a .NET coding add-in
101 | _ReSharper*/
102 | *.[Rr]e[Ss]harper
103 |
104 | # TeamCity is a build add-in
105 | _TeamCity*
106 |
107 | # DotCover is a Code Coverage Tool
108 | *.dotCover
109 |
110 | # NCrunch
111 | *.ncrunch*
112 | .*crunch*.local.xml
113 |
114 | # Installshield output folder
115 | [Ee]xpress/
116 |
117 | # DocProject is a documentation generator add-in
118 | DocProject/buildhelp/
119 | DocProject/Help/*.HxT
120 | DocProject/Help/*.HxC
121 | DocProject/Help/*.hhc
122 | DocProject/Help/*.hhk
123 | DocProject/Help/*.hhp
124 | DocProject/Help/Html2
125 | DocProject/Help/html
126 |
127 | # Click-Once directory
128 | publish/
129 |
130 | # Publish Web Output
131 | *.Publish.xml
132 | *.pubxml
133 |
134 | # NuGet Packages Directory
135 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
136 | #packages/
137 |
138 | # Windows Azure Build Output
139 | csx
140 | *.build.csdef
141 |
142 | # Windows Store app package directory
143 | AppPackages/
144 |
145 | # Others
146 | sql/
147 | *.Cache
148 | ClientBin/
149 | [Ss]tyle[Cc]op.*
150 | ~$*
151 | *~
152 | *.dbmdl
153 | *.[Pp]ublish.xml
154 | *.pfx
155 | *.publishsettings
156 |
157 | # RIA/Silverlight projects
158 | Generated_Code/
159 |
160 | # Backup & report files from converting an old project file to a newer
161 | # Visual Studio version. Backup files are not needed, because we have git ;-)
162 | _UpgradeReport_Files/
163 | Backup*/
164 | UpgradeLog*.XML
165 | UpgradeLog*.htm
166 |
167 | # SQL Server files
168 | App_Data/*.mdf
169 | App_Data/*.ldf
170 |
171 | #############
172 | ## Windows detritus
173 | #############
174 |
175 | # Windows image file caches
176 | Thumbs.db
177 | ehthumbs.db
178 |
179 | # Folder config file
180 | Desktop.ini
181 |
182 | # Recycle Bin used on file shares
183 | $RECYCLE.BIN/
184 |
185 | # Mac crap
186 | .DS_Store
187 |
188 |
189 | #############
190 | ## Python
191 | #############
192 |
193 | *.py[co]
194 |
195 | # Packages
196 | *.egg
197 | *.egg-info
198 | dist/
199 | build/
200 | eggs/
201 | parts/
202 | var/
203 | sdist/
204 | develop-eggs/
205 | .installed.cfg
206 |
207 | # Installer logs
208 | pip-log.txt
209 |
210 | # Unit test / coverage reports
211 | .coverage
212 | .tox
213 |
214 | #Translations
215 | *.mo
216 |
217 | #Mr Developer
218 | .mr.developer.cfg
219 |
--------------------------------------------------------------------------------
/Renders/RenderWire.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Renders;
11 |
12 | import org.lwjgl.opengl.GL11;
13 |
14 | import net.minecraft.client.renderer.Tessellator;
15 | import net.minecraft.tileentity.TileEntity;
16 | import net.minecraft.util.IIcon;
17 |
18 | import Reika.DragonAPI.Interfaces.TileEntity.RenderFetcher;
19 | import Reika.DragonAPI.Libraries.IO.ReikaTextureHelper;
20 | import Reika.ElectriCraft.Base.ElectriTERenderer;
21 | import Reika.ElectriCraft.TileEntities.TileEntityWire;
22 |
23 | public class RenderWire extends ElectriTERenderer {
24 |
25 | @Override
26 | public String getImageFileName(RenderFetcher te) {
27 | return "";
28 | }
29 |
30 | @Override
31 | public void renderTileEntityAt(TileEntity tile, double par2, double par4, double par6, float f) {
32 | TileEntityWire te = (TileEntityWire)tile;
33 | if (tile.hasWorldObj()) {
34 |
35 | }
36 | else {
37 | ReikaTextureHelper.bindTerrainTexture();
38 | this.renderBlock(te, par2, par4-0.3, par6, te.insulated ? te.getInsulatedEndIcon() : te.getEndIcon());
39 | this.renderBlock(te, par2, par4+0.1, par6, te.insulated ? te.getInsulatedCenterIcon() : te.getCenterIcon());
40 | this.renderBlock(te, par2, par4+0.5, par6, te.insulated ? te.getInsulatedEndIcon() : te.getEndIcon());
41 | }
42 | }
43 |
44 | private void renderBlock(TileEntityWire te, double par2, double par4, double par6, IIcon ico) {
45 | float u = ico.getMinU();
46 | float v = ico.getMinV();
47 | float du = ico.getMaxU();
48 | float dv = ico.getMaxV();
49 | GL11.glPushMatrix();
50 | GL11.glTranslated(par2, par4, par6);
51 | Tessellator v5 = Tessellator.instance;
52 |
53 | float f = 0.5F;
54 | double s = 0.4;
55 | GL11.glColor4f(f, f, f, 1);
56 | GL11.glScaled(s, s, s);
57 | GL11.glTranslated(0.5, 0.375, 0.5);
58 | v5.startDrawingQuads();
59 | v5.setNormal(0, 1, 0);
60 | v5.addVertexWithUV(0, 0, 1, u, v);
61 | v5.addVertexWithUV(1, 0, 1, du, v);
62 | v5.addVertexWithUV(1, 1, 1, du, dv);
63 | v5.addVertexWithUV(0, 1, 1, u, dv);
64 | v5.draw();
65 |
66 | v5.startDrawingQuads();
67 | v5.setNormal(0, 1, 0);
68 | v5.addVertexWithUV(0, 1, 0, u, dv);
69 | v5.addVertexWithUV(1, 1, 0, du, dv);
70 | v5.addVertexWithUV(1, 0, 0, du, v);
71 | v5.addVertexWithUV(0, 0, 0, u, v);
72 | v5.draw();
73 |
74 | f = 0.33F;
75 | GL11.glColor4f(f, f, f, 1);
76 | v5.startDrawingQuads();
77 | v5.setNormal(0, 1, 0);
78 | v5.addVertexWithUV(1, 1, 0, u, dv);
79 | v5.addVertexWithUV(1, 1, 1, du, dv);
80 | v5.addVertexWithUV(1, 0, 1, du, v);
81 | v5.addVertexWithUV(1, 0, 0, u, v);
82 | v5.draw();
83 |
84 | v5.startDrawingQuads();
85 | v5.setNormal(0, 1, 0);
86 | v5.addVertexWithUV(0, 0, 0, u, v);
87 | v5.addVertexWithUV(0, 0, 1, du, v);
88 | v5.addVertexWithUV(0, 1, 1, du, dv);
89 | v5.addVertexWithUV(0, 1, 0, u, dv);
90 | v5.draw();
91 |
92 | f = 1F;
93 | GL11.glColor4f(f, f, f, 1);
94 | v5.startDrawingQuads();
95 | v5.setNormal(0, 1, 0);
96 | v5.addVertexWithUV(0, 1, 1, u, dv);
97 | v5.addVertexWithUV(1, 1, 1, du, dv);
98 | v5.addVertexWithUV(1, 1, 0, du, v);
99 | v5.addVertexWithUV(0, 1, 0, u, v);
100 | v5.draw();
101 |
102 | v5.startDrawingQuads();
103 | v5.setNormal(0, 1, 0);
104 | v5.addVertexWithUV(0, 0, 0, u, v);
105 | v5.addVertexWithUV(1, 0, 0, du, v);
106 | v5.addVertexWithUV(1, 0, 1, du, dv);
107 | v5.addVertexWithUV(0, 0, 1, u, dv);
108 | v5.draw();
109 | GL11.glPopMatrix();
110 | v5.setColorOpaque(255, 255, 255);
111 | }
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/Renders/RenderCable.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Renders;
11 |
12 | import org.lwjgl.opengl.GL11;
13 |
14 | import net.minecraft.client.renderer.Tessellator;
15 | import net.minecraft.tileentity.TileEntity;
16 | import net.minecraft.util.IIcon;
17 |
18 | import Reika.DragonAPI.Interfaces.TileEntity.RenderFetcher;
19 | import Reika.DragonAPI.Libraries.IO.ReikaTextureHelper;
20 | import Reika.ElectriCraft.Base.ElectriCable;
21 | import Reika.ElectriCraft.Base.ElectriTERenderer;
22 |
23 | public class RenderCable extends ElectriTERenderer {
24 |
25 | @Override
26 | public String getImageFileName(RenderFetcher te) {
27 | return "";
28 | }
29 |
30 | @Override
31 | public void renderTileEntityAt(TileEntity tile, double par2, double par4, double par6, float f) {
32 | ElectriCable te = (ElectriCable)tile;
33 | if (tile.hasWorldObj()) {
34 |
35 | }
36 | else {
37 | ReikaTextureHelper.bindTerrainTexture();
38 | this.renderBlock(te, par2, par4-0.3, par6, te.getEndIcon(), te.getCenterIcon());
39 | this.renderBlock(te, par2, par4+0.1, par6, te.getCenterIcon(), te.getCenterIcon());
40 | this.renderBlock(te, par2, par4+0.5, par6, te.getEndIcon(), te.getCenterIcon());
41 | }
42 | }
43 |
44 | private void renderBlock(ElectriCable te, double par2, double par4, double par6, IIcon ico, IIcon ico2) {
45 | float u = ico.getMinU();
46 | float v = ico.getMinV();
47 | float du = ico.getMaxU();
48 | float dv = ico.getMaxV();
49 |
50 | float u2 = ico2.getMinU();
51 | float v2 = ico2.getMinV();
52 | float du2 = ico2.getMaxU();
53 | float dv2 = ico2.getMaxV();
54 | GL11.glPushMatrix();
55 | GL11.glTranslated(par2, par4, par6);
56 | Tessellator v5 = Tessellator.instance;
57 |
58 | float f = 0.5F;
59 | double s = 0.4;
60 | GL11.glColor4f(f, f, f, 1);
61 | GL11.glScaled(s, s, s);
62 | GL11.glTranslated(0.5, 0.375, 0.5);
63 | v5.startDrawingQuads();
64 | v5.setNormal(0, 1, 0);
65 | v5.addVertexWithUV(0, 0, 1, u, v);
66 | v5.addVertexWithUV(1, 0, 1, du, v);
67 | v5.addVertexWithUV(1, 1, 1, du, dv);
68 | v5.addVertexWithUV(0, 1, 1, u, dv);
69 | v5.draw();
70 |
71 | v5.startDrawingQuads();
72 | v5.setNormal(0, 1, 0);
73 | v5.addVertexWithUV(0, 1, 0, u, dv);
74 | v5.addVertexWithUV(1, 1, 0, du, dv);
75 | v5.addVertexWithUV(1, 0, 0, du, v);
76 | v5.addVertexWithUV(0, 0, 0, u, v);
77 | v5.draw();
78 |
79 | f = 0.33F;
80 | GL11.glColor4f(f, f, f, 1);
81 | v5.startDrawingQuads();
82 | v5.setNormal(0, 1, 0);
83 | v5.addVertexWithUV(1, 1, 0, u, dv);
84 | v5.addVertexWithUV(1, 1, 1, du, dv);
85 | v5.addVertexWithUV(1, 0, 1, du, v);
86 | v5.addVertexWithUV(1, 0, 0, u, v);
87 | v5.draw();
88 |
89 | v5.startDrawingQuads();
90 | v5.setNormal(0, 1, 0);
91 | v5.addVertexWithUV(0, 0, 0, u, v);
92 | v5.addVertexWithUV(0, 0, 1, du, v);
93 | v5.addVertexWithUV(0, 1, 1, du, dv);
94 | v5.addVertexWithUV(0, 1, 0, u, dv);
95 | v5.draw();
96 |
97 | f = 1F;
98 | GL11.glColor4f(f, f, f, 1);
99 | v5.startDrawingQuads();
100 | v5.setNormal(0, 1, 0);
101 | v5.addVertexWithUV(0, 1, 1, u2, dv2);
102 | v5.addVertexWithUV(1, 1, 1, du2, dv2);
103 | v5.addVertexWithUV(1, 1, 0, du2, v2);
104 | v5.addVertexWithUV(0, 1, 0, u2, v2);
105 | v5.draw();
106 |
107 | v5.startDrawingQuads();
108 | v5.setNormal(0, 1, 0);
109 | v5.addVertexWithUV(0, 0, 0, u2, v2);
110 | v5.addVertexWithUV(1, 0, 0, du2, v2);
111 | v5.addVertexWithUV(1, 0, 1, du2, dv2);
112 | v5.addVertexWithUV(0, 0, 1, u2, dv2);
113 | v5.draw();
114 | GL11.glPopMatrix();
115 | v5.setColorOpaque(255, 255, 255);
116 | }
117 |
118 | }
119 |
--------------------------------------------------------------------------------
/TileEntities/ModInterface/TileEntityEUCable.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.TileEntities.ModInterface;
11 |
12 | import net.minecraft.tileentity.TileEntity;
13 | import net.minecraft.world.World;
14 | import net.minecraftforge.common.MinecraftForge;
15 | import net.minecraftforge.common.util.ForgeDirection;
16 |
17 | import Reika.ChromatiCraft.API.Interfaces.WorldRift;
18 | import Reika.DragonAPI.ModList;
19 | import Reika.DragonAPI.ASM.APIStripper.Strippable;
20 | import Reika.DragonAPI.ASM.DependentMethodStripper.ModDependent;
21 | import Reika.ElectriCraft.Base.ElectriCable;
22 | import Reika.ElectriCraft.Registry.ElectriTiles;
23 |
24 | import ic2.api.energy.event.EnergyTileLoadEvent;
25 | import ic2.api.energy.event.EnergyTileUnloadEvent;
26 | import ic2.api.energy.tile.IEnergyAcceptor;
27 | import ic2.api.energy.tile.IEnergyConductor;
28 | import ic2.api.energy.tile.IEnergyEmitter;
29 | import ic2.api.energy.tile.IEnergyTile;
30 |
31 | @Strippable(value="ic2.api.energy.tile.IEnergyConductor")
32 | public class TileEntityEUCable extends ElectriCable implements IEnergyConductor {
33 |
34 | public static final double CAPACITY = Double.MAX_VALUE;//10e9;//Double.POSITIVE_INFINITY;
35 |
36 | @Override
37 | public void onFirstTick(World world, int x, int y, int z) {
38 | if (!world.isRemote && ModList.IC2.isLoaded())
39 | this.addTileToNet();
40 | }
41 |
42 | @ModDependent(ModList.IC2)
43 | private void addTileToNet() {
44 | MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
45 | }
46 |
47 | @Override
48 | protected void onInvalidateOrUnload(World world, int x, int y, int z, boolean invalidate) {
49 | if (!world.isRemote && ModList.IC2.isLoaded())
50 | this.removeTileFromNet();
51 | }
52 |
53 | @ModDependent(ModList.IC2)
54 | private void removeTileFromNet() {
55 | MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
56 | }
57 |
58 | @Override
59 | public boolean acceptsEnergyFrom(TileEntity te, ForgeDirection dir) {
60 | if (!(te instanceof IEnergyTile))
61 | return false;
62 | return true;
63 | }
64 |
65 | @Override
66 | public boolean emitsEnergyTo(TileEntity te, ForgeDirection dir) {
67 | if (!(te instanceof IEnergyTile))
68 | return false;
69 | return true;
70 | }
71 |
72 | @Override
73 | public double getConductionLoss() {
74 | return 1e-12;
75 | }
76 |
77 | @Override
78 | public double getInsulationEnergyAbsorption() {
79 | return Double.POSITIVE_INFINITY;
80 | }
81 |
82 | @Override
83 | public double getInsulationBreakdownEnergy() {
84 | return CAPACITY;
85 | }
86 |
87 | @Override
88 | public double getConductorBreakdownEnergy() {
89 | return CAPACITY;
90 | }
91 |
92 | @Override
93 | public void removeInsulation() {
94 |
95 | }
96 |
97 | @Override
98 | public void removeConductor() {
99 | this.delete();
100 | }
101 |
102 | @Override
103 | public ElectriTiles getTile() {
104 | return ElectriTiles.EUCABLE;
105 | }
106 |
107 | @Override
108 | public void updateEntity(World world, int x, int y, int z, int meta) {
109 |
110 | }
111 |
112 | @Override
113 | protected void animateWithTick(World world, int x, int y, int z) {
114 |
115 | }
116 |
117 | @Override
118 | protected boolean connectsToTile(TileEntity te, ForgeDirection dir) {
119 | if (te instanceof IEnergyEmitter && ((IEnergyEmitter)te).emitsEnergyTo(this, dir.getOpposite()))
120 | return true;
121 | if (te instanceof IEnergyAcceptor && ((IEnergyAcceptor)te).acceptsEnergyFrom(this, dir.getOpposite()))
122 | return true;
123 | if (te instanceof WorldRift)
124 | return true;
125 | return false;
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/Auxiliary/WrappedSource.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2018
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Auxiliary;
11 |
12 | import java.util.Collection;
13 |
14 | import net.minecraft.tileentity.TileEntity;
15 | import net.minecraft.world.World;
16 | import net.minecraftforge.common.util.ForgeDirection;
17 |
18 | import Reika.ElectriCraft.API.WrappableWireSource;
19 | import Reika.ElectriCraft.Auxiliary.Interfaces.WireEmitter;
20 | import Reika.ElectriCraft.Network.WireNetwork;
21 | import Reika.RotaryCraft.API.Power.ShaftMerger;
22 | import Reika.RotaryCraft.Auxiliary.PowerSourceList;
23 | import Reika.RotaryCraft.Auxiliary.Interfaces.PowerSourceTracker;
24 |
25 |
26 | public final class WrappedSource implements WireEmitter, PowerSourceTracker {
27 |
28 | private final WrappableWireSource source;
29 |
30 | public WrappedSource(WrappableWireSource src) {
31 | source = src;
32 | if (!(src instanceof TileEntity)) {
33 | throw new IllegalArgumentException("You cannot wrap non-tile sources!");
34 | }
35 | if (!src.getClass().getName().startsWith("Reika"))
36 | throw new IllegalArgumentException("This class is for internal use only!");
37 | }
38 |
39 | @Override
40 | public void findAndJoinNetwork(World world, int x, int y, int z) {}
41 | @Override
42 | public WireNetwork getNetwork() {return null;}
43 | @Override
44 | public void setNetwork(WireNetwork n) {}
45 | @Override
46 | public void removeFromNetwork() {}
47 | @Override
48 | public void resetNetwork() {}
49 | @Override
50 | public void onNetworkChanged() {}
51 |
52 | @Override
53 | public boolean isConnectable() {
54 | return this.canEmitPower();
55 | }
56 |
57 | @Override
58 | public boolean canNetworkOnSide(ForgeDirection dir) {
59 | return this.canEmitPowerToSide(dir);
60 | }
61 |
62 | @Override
63 | public World getWorld() {
64 | return ((TileEntity)source).worldObj;
65 | }
66 |
67 | @Override
68 | public int getX() {
69 | return ((TileEntity)source).xCoord;
70 | }
71 |
72 | @Override
73 | public int getY() {
74 | return ((TileEntity)source).yCoord;
75 | }
76 |
77 | @Override
78 | public int getZ() {
79 | return ((TileEntity)source).zCoord;
80 | }
81 |
82 | @Override
83 | public int getGenVoltage() {
84 | return source.getOmega()*WireNetwork.TORQUE_PER_AMP;
85 | }
86 |
87 | @Override
88 | public int getGenCurrent() {
89 | return source.getTorque()/WireNetwork.TORQUE_PER_AMP;
90 | }
91 |
92 | @Override
93 | public boolean canEmitPowerToSide(ForgeDirection dir) {
94 | return source.canConnectToSide(dir);
95 | }
96 |
97 | @Override
98 | public boolean canEmitPower() {
99 | return source.isFunctional();
100 | }
101 |
102 | public boolean needsUpdate() {
103 | return source.hasPowerStatusChangedSinceLastTick();
104 | }
105 |
106 | @Override
107 | public boolean equals(Object o) {
108 | return o instanceof WrappedSource && ((WrappedSource)o).source.equals(source);
109 | }
110 |
111 | @Override
112 | public int hashCode() {
113 | return source.hashCode();
114 | }
115 |
116 | @Override
117 | public PowerSourceList getPowerSources(PowerSourceTracker io, ShaftMerger caller) {
118 | return source.getPowerSources(io, caller);
119 | }
120 |
121 | @Override
122 | public void getAllOutputs(Collection c, ForgeDirection dir) {
123 | source.getAllOutputs(c, dir);
124 | }
125 |
126 | @Override
127 | public int getIoOffsetX() {
128 | return source.getIoOffsetX();
129 | }
130 |
131 | @Override
132 | public int getIoOffsetY() {
133 | return source.getIoOffsetY();
134 | }
135 |
136 | @Override
137 | public int getIoOffsetZ() {
138 | return source.getIoOffsetZ();
139 | }
140 |
141 | }
142 |
--------------------------------------------------------------------------------
/ElectriClient.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft;
11 |
12 | import net.minecraft.world.World;
13 | import net.minecraftforge.client.MinecraftForgeClient;
14 |
15 | import Reika.DragonAPI.DragonOptions;
16 | import Reika.DragonAPI.Instantiable.Rendering.ItemSpriteSheetRenderer;
17 | import Reika.ElectriCraft.Auxiliary.ElectriRenderList;
18 | import Reika.ElectriCraft.Base.ElectriTERenderer;
19 | import Reika.ElectriCraft.Registry.ElectriItems;
20 | import Reika.ElectriCraft.Registry.ElectriTiles;
21 | import Reika.ElectriCraft.Renders.BatteryRenderer;
22 |
23 | import cpw.mods.fml.client.FMLClientHandler;
24 | import cpw.mods.fml.client.registry.ClientRegistry;
25 | import cpw.mods.fml.client.registry.RenderingRegistry;
26 | import cpw.mods.fml.relauncher.Side;
27 | import cpw.mods.fml.relauncher.SideOnly;
28 |
29 | @SideOnly(Side.CLIENT)
30 | public class ElectriClient extends ElectriCommon
31 | {
32 | private final ItemSpriteSheetRenderer items = new ItemSpriteSheetRenderer(ElectriCraft.instance, ElectriCraft.class, "Textures/Items/items.png");
33 |
34 | public static final ElectriItemRenderer machineItems = new ElectriItemRenderer();
35 |
36 | public static WireRenderer wire;
37 | public static CableRenderer cable;
38 | public static BatteryRenderer battery;
39 |
40 | @Override
41 | public void registerSounds() {
42 | //MinecraftForge.EVENT_BUS.register(new SoundLoader(RotaryCraft.instance, SoundRegistry.soundList, SoundRegistry.SOUND_FOLDER));
43 | }
44 |
45 | @Override
46 | public void registerRenderers() {
47 | wireRender = RenderingRegistry.getNextAvailableRenderId();
48 | wire = new WireRenderer(wireRender);
49 | RenderingRegistry.registerBlockHandler(wireRender, wire);
50 |
51 | cableRender = RenderingRegistry.getNextAvailableRenderId();
52 | cable = new CableRenderer(cableRender);
53 | RenderingRegistry.registerBlockHandler(cableRender, cable);
54 |
55 | batteryRender = RenderingRegistry.getNextAvailableRenderId();
56 | battery = new BatteryRenderer(batteryRender);
57 | RenderingRegistry.registerBlockHandler(batteryRender, battery);
58 |
59 | if (DragonOptions.NORENDERS.getState()) {
60 | ElectriCraft.logger.log("Disabling all machine renders for FPS and lag profiling.");
61 | }
62 | else {
63 | this.loadModels();
64 | }
65 |
66 | this.registerSpriteSheets();
67 | }
68 |
69 | @Override
70 | public void addArmorRenders() {
71 |
72 | }
73 |
74 | public void loadModels() {
75 | for (int i = 0; i < ElectriTiles.TEList.length; i++) {
76 | ElectriTiles m = ElectriTiles.TEList[i];
77 | if (m.hasRender()) {
78 | ElectriTERenderer render = ElectriRenderList.instantiateRenderer(m);
79 | ClientRegistry.bindTileEntitySpecialRenderer(m.getTEClass(), render);
80 | }
81 | }
82 |
83 | MinecraftForgeClient.registerItemRenderer(ElectriItems.PLACER.getItemInstance(), machineItems);
84 | MinecraftForgeClient.registerItemRenderer(ElectriItems.WIRE.getItemInstance(), machineItems);
85 | MinecraftForgeClient.registerItemRenderer(ElectriItems.BATTERY.getItemInstance(), machineItems);
86 | MinecraftForgeClient.registerItemRenderer(ElectriItems.RFBATTERY.getItemInstance(), machineItems);
87 | MinecraftForgeClient.registerItemRenderer(ElectriItems.EUBATTERY.getItemInstance(), machineItems);
88 | }
89 |
90 | private void registerSpriteSheets() {
91 | for (int i = 0; i < ElectriItems.itemList.length; i++) {
92 | ElectriItems ii = ElectriItems.itemList[i];
93 | if (!ii.isPlacerItem())
94 | MinecraftForgeClient.registerItemRenderer(ElectriItems.itemList[i].getItemInstance(), items);
95 | }
96 | }
97 |
98 | @Override
99 | public World getClientWorld()
100 | {
101 | return FMLClientHandler.instance().getClient().theWorld;
102 | }
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/Base/TileEntityResistorBase.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Base;
11 |
12 | import net.minecraft.nbt.NBTTagCompound;
13 | import net.minecraft.world.World;
14 |
15 | import Reika.DragonAPI.Libraries.Registry.ReikaDyeHelper;
16 | import Reika.ElectriCraft.Auxiliary.Interfaces.CurrentThrottle;
17 |
18 | import cpw.mods.fml.relauncher.Side;
19 | import cpw.mods.fml.relauncher.SideOnly;
20 |
21 | public abstract class TileEntityResistorBase extends TileEntityWireComponent implements CurrentThrottle {
22 |
23 | private int selectedCurrent;
24 |
25 | public static enum ColorBand {
26 | BLACK(ReikaDyeHelper.BLACK),
27 | BROWN(ReikaDyeHelper.BROWN),
28 | RED(ReikaDyeHelper.RED),
29 | ORANGE(ReikaDyeHelper.ORANGE),
30 | YELLOW(ReikaDyeHelper.YELLOW),
31 | GREEN(ReikaDyeHelper.LIME),
32 | BLUE(ReikaDyeHelper.BLUE),
33 | PURPLE(ReikaDyeHelper.PURPLE),
34 | GRAY(ReikaDyeHelper.GRAY),
35 | WHITE(ReikaDyeHelper.WHITE);
36 |
37 | public final ReikaDyeHelper renderColor;
38 |
39 | public static final ColorBand[] bandList = values();
40 |
41 | private ColorBand(ReikaDyeHelper color) {
42 | renderColor = color;
43 | }
44 |
45 | public static ColorBand getBandFromColor(ReikaDyeHelper color) {
46 | for (int i = 0; i < bandList.length; i++) {
47 | ColorBand b = bandList[i];
48 | if (b.renderColor == color)
49 | return b;
50 | }
51 | return null;
52 | }
53 | }
54 |
55 | public abstract ColorBand[] getColorBands();
56 | protected abstract void setColorBands(ColorBand[] bands);
57 |
58 | @Override
59 | public final int getResistance() {
60 | return 0;
61 | }
62 |
63 | @Override
64 | public final int getCurrentLimit() {
65 | return selectedCurrent;
66 | }
67 |
68 | public final boolean setColor(ReikaDyeHelper color, int digit) {
69 | ColorBand band = color != null ? ColorBand.getBandFromColor(color) : null;
70 | if (band == null)
71 | return false;
72 | //ReikaJavaLibrary.pConsole(band);
73 | ColorBand[] bands = this.getColorBands();
74 | if (band.ordinal() > 7 && digit == bands.length)
75 | return false;
76 | this.assignBand(band, digit);
77 | selectedCurrent = this.calculateCurrentLimit();
78 | if (!worldObj.isRemote && network != null)
79 | network.updateWires();
80 | return true;
81 | }
82 |
83 | protected abstract int calculateCurrentLimit();
84 |
85 | @Override
86 | protected void animateWithTick(World world, int x, int y, int z) {
87 |
88 | }
89 |
90 | @Override
91 | public void onNetworkChanged() {
92 |
93 | }
94 |
95 | @Override
96 | public void readSyncTag(NBTTagCompound NBT) {
97 | super.readSyncTag(NBT);
98 |
99 | ColorBand[] bands = this.getColorBands();
100 | for (int i = 0; i < bands.length; i++) {
101 | int tag = i+1;
102 | int idx = NBT.getInteger("band"+tag);
103 | bands[i] = ColorBand.bandList[idx];
104 | }
105 | this.setColorBands(bands);
106 |
107 | selectedCurrent = NBT.getInteger("sel");
108 | }
109 |
110 | @Override
111 | public void writeSyncTag(NBTTagCompound NBT) {
112 | super.writeSyncTag(NBT);
113 |
114 | ColorBand[] bands = this.getColorBands();
115 | for (int i = 0; i < bands.length; i++) {
116 | int tag = i+1;
117 | NBT.setInteger("band"+tag, bands[i].ordinal());
118 | }
119 |
120 | NBT.setInteger("sel", selectedCurrent);
121 | }
122 |
123 | @Override
124 | public final float getHeight() {
125 | return 0.75F;
126 | }
127 |
128 | @Override
129 | public final float getWidth() {
130 | return 0.5F;
131 | }
132 |
133 | @Override
134 | public final boolean canConnect() {
135 | return selectedCurrent > 0;
136 | }
137 |
138 | private void assignBand(ColorBand band, int digit) {
139 | ColorBand[] bands = this.getColorBands();
140 | bands[digit-1] = band;
141 | this.setColorBands(bands);
142 | }
143 |
144 | @SideOnly(Side.CLIENT)
145 | public final void setColor(ColorBand band, int digit) {
146 | this.assignBand(band, digit);
147 | }
148 |
149 | }
150 |
--------------------------------------------------------------------------------
/Registry/BatteryType.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Registry;
11 |
12 | import java.util.Locale;
13 |
14 | import net.minecraft.client.renderer.texture.IIconRegister;
15 | import net.minecraft.init.Blocks;
16 | import net.minecraft.item.ItemStack;
17 | import net.minecraft.util.IIcon;
18 | import net.minecraft.util.StatCollector;
19 | import net.minecraftforge.oredict.ShapedOreRecipe;
20 |
21 | import Reika.DragonAPI.Libraries.MathSci.ReikaEngLibrary;
22 | import Reika.DragonAPI.Libraries.MathSci.ReikaMathLibrary;
23 | import Reika.RotaryCraft.Auxiliary.ItemStacks;
24 | import Reika.RotaryCraft.Auxiliary.RecipeManagers.RecipeHandler.RecipeLevel;
25 | import Reika.RotaryCraft.Auxiliary.RecipeManagers.WorktableRecipes;
26 | import Reika.RotaryCraft.Registry.ConfigRegistry;
27 |
28 | import cpw.mods.fml.common.registry.GameRegistry;
29 | import cpw.mods.fml.relauncher.Side;
30 | import cpw.mods.fml.relauncher.SideOnly;
31 |
32 | public enum BatteryType {
33 |
34 | REDSTONE( 20, 256, 32),
35 | GLOWSTONE( 24, 512, 64),
36 | LAPIS( 28, 2048, 128),
37 | ENDER( 33, 4096, 256),
38 | DIAMOND( 40, 16384, 1024),
39 | STAR( 48, 65536, 4096);
40 |
41 | public final long maxCapacity;
42 | public final int outputVoltage;
43 | public final int outputCurrent;
44 |
45 | private IIcon icon;
46 |
47 | private BatteryType(int cap, int v, int a) {
48 | maxCapacity = ReikaMathLibrary.longpow(2, cap);
49 | outputCurrent = a;
50 | outputVoltage = v;
51 | }
52 |
53 | public static final BatteryType[] batteryList = values();
54 |
55 | public String getName() {
56 | return StatCollector.translateToLocal("battery."+this.name().toLowerCase(Locale.ENGLISH));
57 | }
58 |
59 | public String getFormattedCapacity() {
60 | double base = ReikaMathLibrary.getThousandBase(maxCapacity);
61 | String exp = ReikaEngLibrary.getSIPrefix(maxCapacity);
62 | return String.format("%.3f%sJ", base, exp);
63 | }
64 |
65 | public void addCrafting() {
66 | ItemStack is = this.getCraftedProduct();
67 | ItemStack in = ElectriItems.CRYSTAL.getStackOfMetadata(this.ordinal());
68 | Object[] obj = {"ScS", "WCW", "SPS", 'W', Blocks.wool, 'c', this.getTopMaterial(), 'C', in, 'P', this.getBottomMaterial(), 'S', ItemStacks.steelingot};
69 | ShapedOreRecipe ir = new ShapedOreRecipe(is, obj);
70 | WorktableRecipes.getInstance().addRecipe(ir, RecipeLevel.CORE);
71 | if (ConfigRegistry.TABLEMACHINES.getState()) {
72 | GameRegistry.addRecipe(ir);
73 | }
74 | }
75 |
76 | private Object getBottomMaterial() {
77 | switch(this) {
78 | case STAR:
79 | return ItemStacks.bedingot;
80 | case DIAMOND:
81 | return ItemStacks.tungsteningot;
82 | case LAPIS:
83 | return ItemStacks.silumin;
84 | default:
85 | return ItemStacks.basepanel;
86 | }
87 | }
88 |
89 | private Object getTopMaterial() {
90 | switch(this) {
91 | case GLOWSTONE:
92 | case LAPIS:
93 | return "ingotSilver";
94 | case ENDER:
95 | case STAR:
96 | case DIAMOND:
97 | return ItemStacks.redgoldingot;
98 | default:
99 | return "ingotCopper";
100 | }
101 | }
102 |
103 | public ItemStack getCraftedProduct() {
104 | return ElectriItems.BATTERY.getStackOfMetadata(this.ordinal());
105 | }
106 |
107 | @SideOnly(Side.CLIENT)
108 | public void loadIcon(IIconRegister ico) {
109 | icon = ico.registerIcon("electricraft:battery/"+this.name().toLowerCase(Locale.ENGLISH)+"_glow");
110 | }
111 |
112 | @SideOnly(Side.CLIENT)
113 | public IIcon getGlowingIcon() {
114 | return icon;
115 | }
116 |
117 | public static String getDataForDisplay() {
118 | StringBuilder sb = new StringBuilder();
119 | for (int i = 0; i < batteryList.length; i++) {
120 | BatteryType type = batteryList[i];
121 | sb.append(type.getName()+" - Capacity: "+type.getFormattedCapacity()+"; Output: "+type.outputCurrent+"A @ "+type.outputVoltage+"V");
122 | sb.append("\n");
123 | }
124 | return sb.toString();
125 | }
126 |
127 | }
128 |
--------------------------------------------------------------------------------
/Base/NetworkTileEntity.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Base;
11 |
12 | import net.minecraft.tileentity.TileEntity;
13 | import net.minecraft.world.World;
14 | import net.minecraftforge.common.util.ForgeDirection;
15 |
16 | import Reika.ChromatiCraft.API.Interfaces.WorldRift;
17 | import Reika.DragonAPI.Instantiable.Data.Immutable.WorldLocation;
18 | import Reika.ElectriCraft.ElectriCraft;
19 | import Reika.ElectriCraft.Auxiliary.Interfaces.NetworkTile;
20 | import Reika.ElectriCraft.Network.WireNetwork;
21 |
22 | public abstract class NetworkTileEntity extends ElectriTileEntity implements NetworkTile {
23 |
24 | protected WireNetwork network;
25 | private boolean isConnectable = true;
26 |
27 | @Override
28 | public void updateEntity(World world, int x, int y, int z, int meta) {
29 | if ((this.getTicksExisted() == 0 || network == null) && !world.isRemote) {
30 | this.findAndJoinNetwork(world, x, y, z);
31 | //ReikaJavaLibrary.pConsole(network, Side.SERVER);
32 | }
33 | }
34 |
35 | @Override
36 | public final void onInvalidateOrUnload(World world, int x, int y, int z, boolean invalid) {
37 | isConnectable = false;
38 | if (network != null)
39 | network.removeElement(this);
40 | }
41 |
42 | public final boolean isConnectable() {
43 | return isConnectable && !worldObj.isRemote && worldObj.checkChunksExist(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
44 | }
45 |
46 | public void onNetworkChanged() {
47 |
48 | }
49 |
50 | public final void findAndJoinNetwork(World world, int x, int y, int z) {
51 | network = null;
52 | if (!isConnectable)
53 | return;
54 | network = new WireNetwork();
55 | network.addElement(this);
56 | for (int i = 0; i < 6; i++) {
57 | ForgeDirection dir = dirs[i];
58 | if (this.canNetworkOnSide(dir) && this.isChunkLoadedOnSide(dir)) {
59 | TileEntity te = this.getAdjacentTileEntity(dir);
60 | this.linkTile(te, dir);
61 | }
62 | }
63 | this.onJoinNetwork();
64 | }
65 |
66 | private void linkTile(TileEntity te, ForgeDirection dir) {
67 | if (te instanceof NetworkTileEntity) {
68 | //ReikaJavaLibrary.pConsole(te, Side.SERVER);
69 | NetworkTileEntity n = (NetworkTileEntity)te;
70 | if (n.canNetworkOnSide(dir.getOpposite())) {
71 | WireNetwork w = n.network;
72 | if (w != null) {
73 | //ReikaJavaLibrary.pConsole(dir+":"+te, Side.SERVER);
74 | w.merge(network);
75 | }
76 | }
77 | }
78 | else if (te instanceof WorldRift) {
79 | WorldRift sr = (WorldRift)te;
80 | WorldLocation loc = sr.getLinkTarget();
81 | if (loc != null) {
82 | this.linkTile(sr.getTileEntityFrom(dir), dir);
83 | }
84 | }
85 | }
86 |
87 | protected void onJoinNetwork() {}
88 |
89 | public abstract boolean canNetworkOnSide(ForgeDirection dir);
90 |
91 | public final WireNetwork getNetwork() {
92 | return network;
93 | }
94 |
95 | public final void setNetwork(WireNetwork n) {
96 | if (n == null) {
97 | ElectriCraft.logger.logError(this+" was told to join a null network!");
98 | }
99 | else {
100 | network = n;
101 | network.addElement(this);
102 | }
103 | }
104 |
105 | public final void removeFromNetwork() {
106 | if (network == null)
107 | ElectriCraft.logger.logError(this+" was removed from a null network!");
108 | else
109 | network.removeElement(this);
110 | }
111 |
112 | public final void rebuildNetwork() {
113 | this.removeFromNetwork();
114 | this.resetNetwork();
115 | this.findAndJoinNetwork(worldObj, xCoord, yCoord, zCoord);
116 | }
117 |
118 | public final void resetNetwork() {
119 | network = null;
120 | }
121 |
122 | @Override
123 | public final World getWorld() {
124 | return worldObj;
125 | }
126 |
127 | @Override
128 | public final int getX() {
129 | return xCoord;
130 | }
131 |
132 | @Override
133 | public final int getY() {
134 | return yCoord;
135 | }
136 |
137 | @Override
138 | public final int getZ() {
139 | return zCoord;
140 | }
141 |
142 | }
143 |
--------------------------------------------------------------------------------
/Renders/ModelResistorBase.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | // Date: 13-03-2014 09:44:42
11 | // Template version 1.1
12 | // Java generated by Techne
13 | // Keep in mind that you still need to fill in some blanks
14 | // - ZeuX
15 |
16 | package Reika.ElectriCraft.Renders;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 |
21 | import org.lwjgl.opengl.GL11;
22 |
23 | import net.minecraft.tileentity.TileEntity;
24 |
25 | import Reika.DragonAPI.Instantiable.Rendering.LODModelPart;
26 | import Reika.ElectriCraft.Base.TileEntityResistorBase.ColorBand;
27 | import Reika.RotaryCraft.Base.RotaryModelBase;
28 |
29 | public abstract class ModelResistorBase extends RotaryModelBase
30 | {
31 | //fields
32 | LODModelPart Shape1;
33 | LODModelPart Shape2a;
34 | LODModelPart Shape2;
35 | LODModelPart Shape3a;
36 | LODModelPart Shape3;
37 | LODModelPart Shape3b;
38 | LODModelPart Shape3c;
39 |
40 | public ModelResistorBase()
41 | {
42 | textureWidth = 128;
43 | textureHeight = 128;
44 |
45 | Shape1 = new LODModelPart(this, 63, 0);
46 | Shape1.addBox(0F, 0F, 0F, 12, 5, 16);
47 | Shape1.setRotationPoint(-6F, 19F, -8F);
48 | Shape1.setTextureSize(128, 128);
49 | Shape1.mirror = true;
50 | this.setRotation(Shape1, 0F, 0F, 0F);
51 | Shape2a = new LODModelPart(this, 63, 23);
52 | Shape2a.addBox(0F, 0F, 0F, 6, 2, 16);
53 | Shape2a.setRotationPoint(-3F, 12F, -8F);
54 | Shape2a.setTextureSize(128, 128);
55 | Shape2a.mirror = true;
56 | this.setRotation(Shape2a, 0F, 0F, 0F);
57 | Shape2 = new LODModelPart(this, 0, 18);
58 | Shape2.addBox(0F, 0F, 0F, 8, 5, 16);
59 | Shape2.setRotationPoint(-4F, 14F, -8F);
60 | Shape2.setTextureSize(128, 128);
61 | Shape2.mirror = true;
62 | this.setRotation(Shape2, 0F, 0F, 0F);
63 | Shape3a = new LODModelPart(this, 0, 41);
64 | Shape3a.addBox(0F, 0F, 0F, 8, 1, 15);
65 | Shape3a.setRotationPoint(-4F, 12.5F, -7.5F);
66 | Shape3a.setTextureSize(128, 128);
67 | Shape3a.mirror = true;
68 | this.setRotation(Shape3a, 0F, 0F, 0F);
69 | Shape3 = new LODModelPart(this, 0, 0);
70 | Shape3.addBox(0F, 0F, 0F, 10, 1, 15);
71 | Shape3.setRotationPoint(-5F, 16F, -7.5F);
72 | Shape3.setTextureSize(128, 128);
73 | Shape3.mirror = true;
74 | this.setRotation(Shape3, 0F, 0F, 0F);
75 | Shape3b = new LODModelPart(this, 0, 0);
76 | Shape3b.addBox(0F, 0F, 0F, 10, 1, 15);
77 | Shape3b.setRotationPoint(-5F, 14.5F, -7.5F);
78 | Shape3b.setTextureSize(128, 128);
79 | Shape3b.mirror = true;
80 | this.setRotation(Shape3b, 0F, 0F, 0F);
81 | Shape3c = new LODModelPart(this, 0, 0);
82 | Shape3c.addBox(0F, 0F, 0F, 10, 1, 15);
83 | Shape3c.setRotationPoint(-5F, 17.5F, -7.5F);
84 | Shape3c.setTextureSize(128, 128);
85 | Shape3c.mirror = true;
86 | this.setRotation(Shape3c, 0F, 0F, 0F);
87 |
88 | this.addBands();
89 | }
90 |
91 | protected abstract void addBands();
92 |
93 | protected abstract List getBands();
94 |
95 | @Override
96 | public final void renderAll(TileEntity te, ArrayList li, float phi, float theta) {
97 | Shape1.render(te, f5);
98 | Shape2a.render(te, f5);
99 | Shape2.render(te, f5);
100 | Shape3a.render(te, f5);
101 | Shape3.render(te, f5);
102 | Shape3b.render(te, f5);
103 | Shape3c.render(te, f5);
104 |
105 | List bands = this.getBands();
106 | for (int i = 0; i < bands.size(); i++) {
107 | ResistorBand rb = bands.get(i);
108 | rb.color = (ColorBand) li.get(i);
109 | rb.color.renderColor.setGLColorBlend();
110 | rb.partA.render(te, f5);
111 | rb.partB.render(te, f5);
112 | }
113 |
114 | GL11.glColor3f(1, 1, 1);
115 | }
116 |
117 | protected static class ResistorBand {
118 |
119 | private final int index;
120 |
121 | private ColorBand color;
122 |
123 | private final LODModelPart partA;
124 | private final LODModelPart partB;
125 |
126 | protected ResistorBand(int i, LODModelPart p1, LODModelPart p2) {
127 | index = i;
128 | partA = p1;
129 | partB = p2;
130 | }
131 |
132 | }
133 |
134 | }
135 |
--------------------------------------------------------------------------------
/Renders/RenderTransformer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Renders;
11 |
12 | import org.lwjgl.opengl.GL11;
13 |
14 | import net.minecraft.client.renderer.Tessellator;
15 | import net.minecraft.tileentity.TileEntity;
16 | import net.minecraftforge.client.MinecraftForgeClient;
17 |
18 | import Reika.DragonAPI.Interfaces.TileEntity.RenderFetcher;
19 | import Reika.DragonAPI.Libraries.Java.ReikaGLHelper.BlendMode;
20 | import Reika.DragonAPI.Libraries.Rendering.ReikaRenderHelper;
21 | import Reika.DragonAPI.Libraries.Java.ReikaJavaLibrary;
22 | import Reika.ElectriCraft.Base.ElectriTERenderer;
23 | import Reika.ElectriCraft.TileEntities.TileEntityTransformer;
24 | import Reika.RotaryCraft.Auxiliary.IORenderer;
25 |
26 | public class RenderTransformer extends ElectriTERenderer
27 | {
28 | private ModelTransformer TransformerModel = new ModelTransformer();
29 |
30 | public void renderTileEntityTransformerAt(TileEntityTransformer tile, double par2, double par4, double par6, float par8)
31 | {
32 | int var9;
33 |
34 | if (!tile.isInWorld())
35 | var9 = 0;
36 | else
37 | var9 = tile.getBlockMetadata();
38 |
39 | ModelTransformer var14;
40 | var14 = TransformerModel;
41 |
42 | this.setupGL(tile, par2, par4, par6);
43 |
44 | this.bindTextureByName("/Reika/ElectriCraft/Textures/transformertex.png");
45 |
46 | int var11 = 0;
47 | float var13;
48 | switch(tile.getFacing()) {
49 | case EAST:
50 | var11 = 180;
51 | break;
52 | case WEST:
53 | var11 = 0;
54 | break;
55 | case NORTH:
56 | var11 = 90;
57 | break;
58 | case SOUTH:
59 | var11 = 270;
60 | break;
61 | default:
62 | break;
63 | }
64 |
65 | GL11.glRotatef(var11, 0.0F, 1.0F, 0.0F);
66 | var14.renderAll(tile, ReikaJavaLibrary.makeListFrom(tile.getN1(), tile.getN2()), tile.phi, 0);
67 |
68 | this.closeGL(tile);
69 | }
70 |
71 | @Override
72 | public void renderTileEntityAt(TileEntity tile, double par2, double par4, double par6, float par8)
73 | {
74 | TileEntityTransformer te = (TileEntityTransformer)tile;
75 | if (this.doRenderModel(te))
76 | this.renderTileEntityTransformerAt(te, par2, par4, par6, par8);
77 | if (te.isInWorld() && MinecraftForgeClient.getRenderPass() == 1) {
78 | IORenderer.renderIO(tile, par2, par4, par6);
79 |
80 | this.renderArrow(te, par2, par4, par6);
81 | }
82 | }
83 |
84 | private void renderArrow(TileEntityTransformer te, double par2, double par4, double par6) {
85 | int a = Math.max(0, 512-te.getTicksExisted()*8);
86 | if (a > 0) {
87 | GL11.glPushMatrix();
88 | GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
89 |
90 | GL11.glTranslated(par2, par4, par6);
91 | GL11.glDisable(GL11.GL_LIGHTING);
92 | GL11.glEnable(GL11.GL_BLEND);
93 | BlendMode.DEFAULT.apply();
94 | GL11.glDisable(GL11.GL_TEXTURE_2D);
95 | ReikaRenderHelper.disableEntityLighting();
96 | float lw = GL11.glGetFloat(GL11.GL_LINE_WIDTH);
97 | GL11.glLineWidth(5);
98 |
99 | Tessellator v5 = Tessellator.instance;
100 | v5.setBrightness(240);
101 | v5.startDrawing(GL11.GL_LINES);
102 | v5.setColorRGBA_I(0xffffff, a);
103 |
104 | double h = 1.1;
105 | v5.addVertex(0.5, h, 0.5);
106 | double dr = 0.125;
107 | double r = 0.375;
108 | double w = 0.08;
109 | double dx = 0.5+te.getFacing().offsetX*r;
110 | double dz = 0.5+te.getFacing().offsetZ*r;
111 | v5.addVertex(dx, h, dz);
112 |
113 | v5.addVertex(dx, h, dz);
114 | v5.addVertex(dx-te.getFacing().offsetX*dr+te.getFacing().offsetZ*w, h, dz-te.getFacing().offsetZ*dr+te.getFacing().offsetX*w);
115 |
116 | v5.addVertex(dx, h, dz);
117 | v5.addVertex(dx-te.getFacing().offsetX*dr-te.getFacing().offsetZ*w, h, dz-te.getFacing().offsetZ*dr-te.getFacing().offsetX*w);
118 |
119 | v5.draw();
120 |
121 | GL11.glLineWidth(lw);
122 |
123 | GL11.glPopMatrix();
124 | GL11.glPopAttrib();
125 | }
126 | }
127 |
128 | @Override
129 | public String getImageFileName(RenderFetcher te) {
130 | return "transformertex.png";
131 | }
132 | }
133 |
--------------------------------------------------------------------------------
/TileEntities/TileEntityFuse.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.TileEntities;
11 |
12 | import java.util.ArrayList;
13 |
14 | import net.minecraft.init.Blocks;
15 | import net.minecraft.nbt.NBTTagCompound;
16 | import net.minecraft.world.World;
17 |
18 | import Reika.DragonAPI.APIPacketHandler.PacketIDs;
19 | import Reika.DragonAPI.DragonAPIInit;
20 | import Reika.DragonAPI.Libraries.IO.ReikaPacketHelper;
21 | import Reika.DragonAPI.Libraries.IO.ReikaSoundHelper;
22 | import Reika.ElectriCraft.Auxiliary.Interfaces.WireFuse;
23 | import Reika.ElectriCraft.Base.TileEntityWireComponent;
24 | import Reika.ElectriCraft.Registry.ElectriTiles;
25 | import Reika.RotaryCraft.Auxiliary.Interfaces.NBTMachine;
26 |
27 | public class TileEntityFuse extends TileEntityWireComponent implements WireFuse, NBTMachine {
28 |
29 | private boolean overloaded;
30 |
31 | private int currentLimit;
32 |
33 | public static final int[] TIERS = {
34 | 32,
35 | 128,
36 | 1024,
37 | 8192
38 | };
39 |
40 | public TileEntityFuse() {
41 |
42 | }
43 |
44 | public TileEntityFuse(int limit) {
45 | currentLimit = limit;
46 | }
47 |
48 | @Override
49 | public void updateEntity(World world, int x, int y, int z, int meta) {
50 | super.updateEntity(world, x, y, z, meta);
51 | }
52 |
53 | @Override
54 | public int getResistance() {
55 | return !this.isOverloaded() ? 0 : Integer.MAX_VALUE;
56 | }
57 |
58 | @Override
59 | public int getMaxCurrent() {
60 | return currentLimit;
61 | }
62 |
63 | @Override
64 | public ElectriTiles getTile() {
65 | return ElectriTiles.FUSE;
66 | }
67 |
68 | @Override
69 | protected void animateWithTick(World world, int x, int y, int z) {
70 |
71 | }
72 |
73 | public boolean isOverloaded() {
74 | return overloaded;
75 | }
76 |
77 | @Override
78 | public float getHeight() {
79 | return 0.625F;
80 | }
81 |
82 | @Override
83 | public float getWidth() {
84 | return 0.75F;
85 | }
86 |
87 | @Override
88 | public boolean canConnect() {
89 | return !this.isOverloaded();
90 | }
91 |
92 | @Override
93 | public void overload(int current) {
94 | overloaded = true;
95 | ReikaSoundHelper.playBreakSound(worldObj, xCoord, yCoord, zCoord, Blocks.glass);
96 | ReikaSoundHelper.playSoundAtBlock(worldObj, xCoord, yCoord, zCoord, "random.fizz", 2, 1);
97 | ReikaPacketHelper.sendDataPacketWithRadius(DragonAPIInit.packetChannel, PacketIDs.COLOREDPARTICLE.ordinal(), this, 24, 1, 1, 1, 32, 0);
98 | }
99 |
100 | @Override
101 | public void readSyncTag(NBTTagCompound NBT) {
102 | super.readSyncTag(NBT);
103 |
104 | overloaded = NBT.getBoolean("overload");
105 | currentLimit = NBT.getInteger("limit");
106 | }
107 |
108 | @Override
109 | public void writeSyncTag(NBTTagCompound NBT) {
110 | super.writeSyncTag(NBT);
111 |
112 |
113 | NBT.setBoolean("overload", overloaded);
114 | NBT.setInteger("limit", currentLimit);
115 | }
116 |
117 | @Override
118 | public boolean shouldRenderInPass(int pass) {
119 | return pass <= 1;
120 | }
121 |
122 | @Override
123 | public NBTTagCompound getTagsToWriteToStack() {
124 | NBTTagCompound tag = new NBTTagCompound();
125 | tag.setInteger("currentlim", currentLimit);
126 | return tag;
127 | }
128 |
129 | @Override
130 | public void setDataFromItemStackTag(NBTTagCompound NBT) {
131 | if (NBT != null) {
132 | currentLimit = NBT.getInteger("currentlim");
133 | }
134 | }
135 |
136 | @Override
137 | public ArrayList getCreativeModeVariants() {
138 | ArrayList li = new ArrayList();
139 | for (int i = 0; i < TIERS.length; i++) {
140 | NBTTagCompound tag = new NBTTagCompound();
141 | tag.setInteger("currentlim", TIERS[i]);
142 | li.add(tag);
143 | }
144 | return li;
145 | }
146 |
147 | @Override
148 | public ArrayList getDisplayTags(NBTTagCompound NBT) {
149 | ArrayList li = new ArrayList();
150 | if (NBT != null) {
151 | li.add("Current Limit: "+NBT.getInteger("currentlim")+"A");
152 | }
153 | return li;
154 | }
155 |
156 | }
157 |
--------------------------------------------------------------------------------
/Renders/ModelTransformer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | // Date: 21/09/2014 11:26:11 AM
11 | // Template version 1.1
12 | // Java generated by Techne
13 | // Keep in mind that you still need to fill in some blanks
14 | // - ZeuX
15 |
16 | package Reika.ElectriCraft.Renders;
17 |
18 | import java.util.ArrayList;
19 |
20 | import org.lwjgl.opengl.GL11;
21 |
22 | import net.minecraft.tileentity.TileEntity;
23 |
24 | import Reika.DragonAPI.Instantiable.Rendering.LODModelPart;
25 | import Reika.RotaryCraft.Base.RotaryModelBase;
26 |
27 | public class ModelTransformer extends RotaryModelBase
28 | {
29 | //fields
30 | LODModelPart Shape1;
31 | LODModelPart Shape1a;
32 | LODModelPart Shape2;
33 | LODModelPart Shape2a;
34 | LODModelPart Shape3;
35 | LODModelPart Shape3a;
36 |
37 | public ModelTransformer()
38 | {
39 | textureWidth = 64;
40 | textureHeight = 32;
41 |
42 | Shape1 = new LODModelPart(this, 0, 0);
43 | Shape1.addBox(0F, 0F, 0F, 4, 16, 4);
44 | Shape1.setRotationPoint(2F, 8F, -2F);
45 | Shape1.setTextureSize(64, 32);
46 | Shape1.mirror = true;
47 | this.setRotation(Shape1, 0F, 0F, 0F);
48 | Shape1a = new LODModelPart(this, 17, 0);
49 | Shape1a.addBox(0F, 0F, 0F, 4, 16, 4);
50 | Shape1a.setRotationPoint(-6F, 8F, -2F);
51 | Shape1a.setTextureSize(64, 32);
52 | Shape1a.mirror = true;
53 | this.setRotation(Shape1a, 0F, 0F, 0F);
54 | Shape2 = new LODModelPart(this, 17, 21);
55 | Shape2.addBox(0F, 0F, 0F, 4, 4, 4);
56 | Shape2.setRotationPoint(-2F, 20F, -2F);
57 | Shape2.setTextureSize(64, 32);
58 | Shape2.mirror = true;
59 | this.setRotation(Shape2, 0F, 0F, 0F);
60 | Shape2a = new LODModelPart(this, 0, 21);
61 | Shape2a.addBox(0F, 0F, 0F, 4, 4, 4);
62 | Shape2a.setRotationPoint(-2F, 8F, -2F);
63 | Shape2a.setTextureSize(64, 32);
64 | Shape2a.mirror = true;
65 | this.setRotation(Shape2a, 0F, 0F, 0F);
66 | Shape3 = new LODModelPart(this, 34, 8);
67 | Shape3.addBox(0F, 0F, 0F, 6, 1, 6);
68 | Shape3.setRotationPoint(1F, 12.5F, -3F);
69 | Shape3.setTextureSize(64, 32);
70 | Shape3.mirror = true;
71 | this.setRotation(Shape3, 0F, 0F, 0F);
72 | Shape3a = new LODModelPart(this, 34, 0);
73 | Shape3a.addBox(0F, 0F, 0F, 6, 1, 6);
74 | Shape3a.setRotationPoint(-7F, 12.5F, -3F);
75 | Shape3a.setTextureSize(64, 32);
76 | Shape3a.mirror = true;
77 | this.setRotation(Shape3a, 0F, 0F, 0F);
78 | }
79 |
80 | @Override
81 | public void renderAll(TileEntity te, ArrayList li, float phi, float theta)
82 | {
83 | Shape1.render(te, f5);
84 | Shape1a.render(te, f5);
85 | Shape2.render(te, f5);
86 | Shape2a.render(te, f5);
87 |
88 | this.renderCoils(te, li);
89 | }
90 |
91 | private void renderCoils(TileEntity te, ArrayList li) {
92 |
93 | LODModelPart[] s = {Shape3, Shape3a};
94 | for (int c = 0; c <= 1; c++) {
95 | int n1 = (Integer)li.get(c);
96 | GL11.glPushMatrix();
97 | int n;
98 | double ty;
99 | double dy;
100 | double sc;
101 | if (n1 == 1) {
102 | n = 0;
103 | dy = sc = ty = 0;
104 | for (int i = 0; i < 4; i++) {
105 | GL11.glPushMatrix();
106 | GL11.glTranslated(0, i/8D, 0);
107 | s[c].render(te, f5);
108 | GL11.glPopMatrix();
109 | }
110 | }
111 | else if (n1 < 16) {
112 | n = 6;
113 | sc = 0.75;
114 | dy = 0.25;
115 | ty = 12;
116 | }
117 | else if (n1 < 128) {
118 | n = 8;
119 | sc = 0.5;
120 | dy = 0.75;
121 | ty = 16;
122 | }
123 | else {
124 | n = 16;
125 | sc = 0.25;
126 | dy = 2.25;
127 | ty = 32;
128 | }
129 |
130 | for (int i = 0; i < n; i++) {
131 | GL11.glPushMatrix();
132 | GL11.glTranslated(0, i/ty, 0);
133 | GL11.glScaled(1, sc, 1);
134 | GL11.glTranslated(0, dy, 0);
135 | s[c].render(te, f5);
136 | GL11.glPopMatrix();
137 | }
138 |
139 | GL11.glPopMatrix();
140 | }
141 | }
142 |
143 | @Override
144 | public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
145 | {
146 | super.setRotationAngles(f, f1, f2, f3, f4, f5);
147 | }
148 |
149 | }
150 |
--------------------------------------------------------------------------------
/Renders/RenderModBattery.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Renders;
11 |
12 | import org.lwjgl.opengl.GL11;
13 |
14 | import net.minecraft.client.renderer.Tessellator;
15 | import net.minecraft.tileentity.TileEntity;
16 |
17 | import Reika.DragonAPI.Base.TileEntityBase;
18 | import Reika.DragonAPI.Interfaces.TileEntity.RenderFetcher;
19 | import Reika.DragonAPI.Libraries.MathSci.ReikaMathLibrary;
20 | import Reika.DragonAPI.Libraries.Rendering.ReikaColorAPI;
21 | import Reika.DragonAPI.Libraries.Rendering.ReikaRenderHelper;
22 | import Reika.ElectriCraft.Auxiliary.Interfaces.BatteryTile;
23 | import Reika.ElectriCraft.Base.ElectriTERenderer;
24 |
25 | public class RenderModBattery extends ElectriTERenderer {
26 |
27 | @Override
28 | public String getImageFileName(RenderFetcher te) {
29 | return "";
30 | }
31 |
32 | @Override
33 | public void renderTileEntityAt(TileEntity tile, double par2, double par4, double par6, float par8) {
34 | BatteryTile te = (BatteryTile)tile;
35 | //if (te.isInWorld()) {
36 | GL11.glPushMatrix();
37 | GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
38 | GL11.glTranslated(par2, par4, par6);
39 | Tessellator v5 = Tessellator.instance;
40 | if (((TileEntityBase)te).isInWorld())
41 | ReikaRenderHelper.prepareGeoDraw(true);
42 | else {
43 | GL11.glDisable(GL11.GL_TEXTURE_2D);
44 | GL11.glDisable(GL11.GL_LIGHTING);
45 | }
46 |
47 | double o = 0.0025;
48 | double w = 0.1875;
49 | double h = 0.0625;
50 |
51 | //double[] l = ReikaMathLibrary.splitNumberByDigits(te.getStoredEnergy(), 10);
52 | //for (int k = 0; k < l.length; k++) {
53 | int v = 4;
54 | int n = 16*v;
55 | int c = (int)(64*ReikaMathLibrary.logbase(te.getStoredEnergy(), 10)/ReikaMathLibrary.logbase(te.getMaxEnergy(), 10));//(int)Math.min(n, 0.5+(double)te.getStoredEnergy()*n/te.CAPACITY);//(int)(n*l[k]);//;
56 | double d = (1-h*2)/n;
57 | //double r = 0.0625/3;
58 | int c1 = te.getEnergyColor();
59 | int c2 = ReikaColorAPI.getColorWithBrightnessMultiplier(c1, 0.05F);
60 | for (int i = 0; i < c; i++) {
61 | v5.startDrawingQuads();
62 | int color = ReikaColorAPI.mixColors(c1, c2, (float)i/n);
63 | v5.setColorOpaque_I(color);
64 | v5.addVertex(0.5-w, h+d*(i+1), 0-o);
65 | v5.addVertex(0.5+w, h+d*(i+1), 0-o);
66 | v5.addVertex(0.5+w, h+d*i, 0-o);
67 | v5.addVertex(0.5-w, h+d*i, 0-o);
68 | v5.draw();
69 | }
70 |
71 | for (int i = 0; i < c; i++) {
72 | v5.startDrawingQuads();
73 | int color = ReikaColorAPI.mixColors(c1, c2, (float)i/n);
74 | v5.setColorOpaque_I(color);
75 | v5.addVertex(0.5-w, h+d*i, 1+o);
76 | v5.addVertex(0.5+w, h+d*i, 1+o);
77 | v5.addVertex(0.5+w, h+d*(i+1), 1+o);
78 | v5.addVertex(0.5-w, h+d*(i+1), 1+o);
79 | v5.draw();
80 | }
81 |
82 | for (int i = 0; i < c; i++) {
83 | v5.startDrawingQuads();
84 | int color = ReikaColorAPI.mixColors(c1, c2, (float)i/n);
85 | v5.setColorOpaque_I(color);
86 | v5.addVertex(1+o, h+d*(i+1), 0.5-w);
87 | v5.addVertex(1+o, h+d*(i+1), 0.5+w);
88 | v5.addVertex(1+o, h+d*i, 0.5+w);
89 | v5.addVertex(1+o, h+d*i, 0.5-w);
90 | v5.draw();
91 | }
92 |
93 | for (int i = 0; i < c; i++) {
94 | v5.startDrawingQuads();
95 | int color = ReikaColorAPI.mixColors(c1, c2, (float)i/n);
96 | v5.setColorOpaque_I(color);
97 | v5.addVertex(0-o, h+d*i, 0.5-w);
98 | v5.addVertex(0-o, h+d*i, 0.5+w);
99 | v5.addVertex(0-o, h+d*(i+1), 0.5+w);
100 | v5.addVertex(0-o, h+d*(i+1), 0.5-w);
101 | v5.draw();
102 | }
103 |
104 | // }
105 |
106 | GL11.glPopAttrib();
107 |
108 | /*
109 | ReikaRenderHelper.disableEntityLighting();
110 | GL11.glDisable(GL11.GL_LIGHTING);
111 | GL11.glPushMatrix();
112 | double s = 0.125;
113 | double da = 0;
114 | double db = 5;
115 | double dc = 0;
116 | GL11.glTranslated(da, db, dc);
117 | GL11.glScaled(s, -s, s);
118 | this.getFontRenderer().drawString(String.format("%.5f", ReikaMathLibrary.logbase(te.getStoredEnergy(), 10)), 0, 0, 0xffffff);
119 | GL11.glPopMatrix();
120 |
121 | ReikaRenderHelper.enableEntityLighting();
122 | GL11.glEnable(GL11.GL_LIGHTING);*/
123 |
124 | GL11.glPopMatrix();
125 | //}
126 | }
127 |
128 | }
129 |
--------------------------------------------------------------------------------
/Registry/ElectriBlocks.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Registry;
11 |
12 | import net.minecraft.block.Block;
13 | import net.minecraft.block.material.Material;
14 | import net.minecraft.item.Item;
15 | import net.minecraft.item.ItemBlock;
16 | import net.minecraft.item.ItemStack;
17 |
18 | import Reika.DragonAPI.Interfaces.Registry.BlockEnum;
19 | import Reika.DragonAPI.Libraries.Java.ReikaStringParser;
20 | import Reika.ElectriCraft.ElectriCraft;
21 | import Reika.ElectriCraft.Blocks.BlockChargePad;
22 | import Reika.ElectriCraft.Blocks.BlockEUBattery;
23 | import Reika.ElectriCraft.Blocks.BlockEUCable;
24 | import Reika.ElectriCraft.Blocks.BlockEUSplitter;
25 | import Reika.ElectriCraft.Blocks.BlockElectriOre;
26 | import Reika.ElectriCraft.Blocks.BlockElectricBattery;
27 | import Reika.ElectriCraft.Blocks.BlockElectricMachine;
28 | import Reika.ElectriCraft.Blocks.BlockRFBattery;
29 | import Reika.ElectriCraft.Blocks.BlockRFCable;
30 | import Reika.ElectriCraft.Blocks.BlockWire;
31 | import Reika.ElectriCraft.Items.ItemBlockElectriOre;
32 | import Reika.ElectriCraft.TileEntities.TileEntityWirelessCharger;
33 |
34 | public enum ElectriBlocks implements BlockEnum {
35 | WIRE(BlockWire.class, "Wire", false),
36 | MACHINE(BlockElectricMachine.class, "Converter", false),
37 | ORE(BlockElectriOre.class, ItemBlockElectriOre.class, "ElectriOre", true),
38 | BATTERY(BlockElectricBattery.class, "ElectriBattery", true),
39 | CABLE(BlockRFCable.class, "RFCable", false),
40 | RFBATTERY(BlockRFBattery.class, "ElectriRFBattery", true),
41 | EUSPLIT(BlockEUSplitter.class, "EUSplitter", false),
42 | EUCABLE(BlockEUCable.class, "EUCable", false),
43 | EUBATTERY(BlockEUBattery.class, "ElectriEUBattery", true),
44 | CHARGEPAD(BlockChargePad.class, "ElectriChargePad", false);
45 |
46 | private Class blockClass;
47 | private String blockName;
48 | private Class itemBlock;
49 | private boolean model;
50 |
51 | public static final ElectriBlocks[] blockList = values();
52 |
53 | private ElectriBlocks(Class extends Block> cl, Class extends ItemBlock> ib, String n, boolean m) {
54 | blockClass = cl;
55 | blockName = n;
56 | itemBlock = ib;
57 | model = m;
58 | }
59 |
60 | private ElectriBlocks(Class extends Block> cl, String n) {
61 | this(cl, null, n, false);
62 | }
63 |
64 | private ElectriBlocks(Class extends Block> cl, String n, boolean m) {
65 | this(cl, null, n, m);
66 | }
67 |
68 | public Block getBlockInstance() {
69 | return ElectriCraft.blocks[this.ordinal()];
70 | }
71 |
72 | public Material getBlockMaterial() {
73 | return this == ORE ? Material.rock : Material.iron;
74 | }
75 |
76 | @Override
77 | public Class[] getConstructorParamTypes() {
78 | return new Class[]{Material.class};
79 | }
80 |
81 | @Override
82 | public Object[] getConstructorParams() {
83 | return new Object[]{this.getBlockMaterial()};
84 | }
85 |
86 | @Override
87 | public String getUnlocalizedName() {
88 | return ReikaStringParser.stripSpaces(blockName);
89 | }
90 |
91 | @Override
92 | public Class getObjectClass() {
93 | return blockClass;
94 | }
95 |
96 | @Override
97 | public String getBasicName() {
98 | return blockName;
99 | }
100 |
101 | @Override
102 | public String getMultiValuedName(int meta) {
103 | switch(this) {
104 | case CHARGEPAD:
105 | return TileEntityWirelessCharger.ChargerTiers.tierList[meta].getLocalizedName()+" "+ElectriTiles.WIRELESSPAD.getName();
106 | default:
107 | return "";
108 | }
109 | }
110 |
111 | @Override
112 | public boolean hasMultiValuedName() {
113 | return true;
114 | }
115 |
116 | @Override
117 | public int getNumberMetadatas() {
118 | switch(this) {
119 | default:
120 | return 1;
121 | }
122 | }
123 |
124 | @Override
125 | public Class extends ItemBlock> getItemBlock() {
126 | return itemBlock;
127 | }
128 |
129 | @Override
130 | public boolean hasItemBlock() {
131 | return itemBlock != null;
132 | }
133 |
134 | public boolean isDummiedOut() {
135 | return blockClass == null;
136 | }
137 |
138 | public boolean isModelled() {
139 | return model;
140 | }
141 |
142 | public Item getItem() {
143 | return Item.getItemFromBlock(this.getBlockInstance());
144 | }
145 |
146 | public ItemStack getStackOfMetadata(int meta) {
147 | return new ItemStack(this.getBlockInstance(), 1, meta);
148 | }
149 |
150 | }
151 |
--------------------------------------------------------------------------------
/GUIs/GuiRFCable.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.GUIs;
11 |
12 | import org.lwjgl.input.Keyboard;
13 | import org.lwjgl.opengl.GL11;
14 |
15 | import net.minecraft.client.gui.GuiButton;
16 | import net.minecraft.client.gui.inventory.GuiContainer;
17 | import net.minecraft.entity.player.EntityPlayer;
18 |
19 | import Reika.DragonAPI.Base.CoreContainer;
20 | import Reika.DragonAPI.Instantiable.GUI.ImagedGuiButton;
21 | import Reika.DragonAPI.Libraries.IO.ReikaPacketHelper;
22 | import Reika.DragonAPI.Libraries.IO.ReikaTextureHelper;
23 | import Reika.DragonAPI.Libraries.MathSci.ReikaEngLibrary;
24 | import Reika.DragonAPI.Libraries.MathSci.ReikaMathLibrary;
25 | import Reika.DragonAPI.Libraries.Rendering.ReikaGuiAPI;
26 | import Reika.ElectriCraft.ElectriCraft;
27 | import Reika.ElectriCraft.Registry.ElectriPackets;
28 | import Reika.ElectriCraft.TileEntities.ModInterface.TileEntityRFCable;
29 | import Reika.RotaryCraft.RotaryCraft;
30 |
31 | public class GuiRFCable extends GuiContainer {
32 |
33 | private final TileEntityRFCable cable;
34 | private int limit;
35 |
36 | public GuiRFCable(EntityPlayer ep, TileEntityRFCable te) {
37 | super(new CoreContainer(ep, te));
38 | cable = te;
39 | limit = te.getRFLimit();
40 | xSize = 197;
41 | ySize = 103;
42 | }
43 |
44 | @Override
45 | public void initGui() {
46 | super.initGui();
47 | buttonList.clear();
48 |
49 | int j = (width - xSize) / 2;
50 | int k = (height - ySize) / 2;
51 |
52 | String tex = "/Reika/RotaryCraft/Textures/GUI/buttons.png";
53 | for (int i = 0; i < 6; i++) {
54 | int dx = xSize/2-12;
55 | int dy = 20+i*12;
56 | int w = 50;
57 | int nve = i != 0 ? -i : -40;
58 | buttonList.add(new ImagedGuiButton(i, j+dx-w, k+dy, 24, 12, 18, 54, tex, RotaryCraft.class));
59 | buttonList.add(new ImagedGuiButton(nve, j+dx+w, k+dy, 24, 12, 42, 54, tex, RotaryCraft.class));
60 | }
61 | buttonList.add(new GuiButton(100, j+xSize/2-20, k+72, 40, 20, "Reset"));
62 | }
63 |
64 | @Override
65 | protected void actionPerformed(GuiButton b) {
66 | super.actionPerformed(b);
67 |
68 | if (b.id == 100) {
69 | limit = 0;
70 | }
71 | else {
72 | int amt = b.id == -40 ? 1 : ReikaMathLibrary.intpow2(10, this.getPower(b.id));
73 | if (b.id < 0)
74 | amt = -amt;
75 | limit += amt;
76 | limit = Math.max(limit, 0);
77 | }
78 |
79 | cable.setRFLimit(limit);
80 | ReikaPacketHelper.sendPacketToServer(ElectriCraft.packetChannel, ElectriPackets.RFCABLE.ordinal(), cable, limit);
81 | this.initGui();
82 | }
83 |
84 | private int getPower(int base) {
85 | return Math.abs(base)+(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ? 3 : 0);
86 | }
87 |
88 | @Override
89 | protected void drawGuiContainerForegroundLayer(int par1, int par2) {
90 | super.drawGuiContainerForegroundLayer(par1, par2);
91 | int j = (width - xSize) / 2;
92 | int k = (height - ySize) / 2;
93 | String s = String.format("Network Limit:");
94 | String s2 = String.format("%.3f %sRF/t", ReikaMathLibrary.getThousandBase(limit), ReikaEngLibrary.getSIPrefix(limit));
95 | int dx = xSize/2;
96 | int dy = ySize/2-4;
97 | ReikaGuiAPI.instance.drawCenteredStringNoShadow(fontRendererObj, s, dx, dy-6, 4210752);
98 | ReikaGuiAPI.instance.drawCenteredStringNoShadow(fontRendererObj, s2, dx, dy+6, 4210752);
99 |
100 | for (int i = 0; i < 6; i++) {
101 | int dx2 = xSize/2-12;
102 | int dy2 = 20+i*12+3;
103 | int w = 53;
104 | int n = ReikaMathLibrary.intpow2(10, this.getPower(i));
105 | String sl = String.format("+%d%s", (int)ReikaMathLibrary.getThousandBase(n), ReikaEngLibrary.getSIPrefix(n));
106 | String sr = String.format("-%d%s", (int)ReikaMathLibrary.getThousandBase(n), ReikaEngLibrary.getSIPrefix(n));
107 | fontRendererObj.drawString(sl, dx2-w-fontRendererObj.getStringWidth(sl), dy2, 0);
108 | fontRendererObj.drawString(sr, dx2+w+24, dy2, 0);
109 | }
110 |
111 |
112 | ReikaGuiAPI.instance.drawCenteredStringNoShadow(fontRendererObj, "RF Cable Network", dx, 6, 4210752);
113 | }
114 |
115 | @Override
116 | protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
117 | int j = (width - xSize) / 2;
118 | int k = (height - ySize) / 2;
119 | String i = "/Reika/ElectriCraft/Textures/GUI/rfcablegui.png";
120 | GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
121 | ReikaTextureHelper.bindTexture(RotaryCraft.class, i);
122 | this.drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
123 | }
124 |
125 | }
126 |
--------------------------------------------------------------------------------
/Blocks/BlockChargePad.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.Blocks;
11 |
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | import net.minecraft.block.BlockContainer;
16 | import net.minecraft.block.material.Material;
17 | import net.minecraft.client.renderer.texture.IIconRegister;
18 | import net.minecraft.creativetab.CreativeTabs;
19 | import net.minecraft.entity.player.EntityPlayer;
20 | import net.minecraft.item.Item;
21 | import net.minecraft.item.ItemStack;
22 | import net.minecraft.nbt.NBTTagCompound;
23 | import net.minecraft.tileentity.TileEntity;
24 | import net.minecraft.util.IIcon;
25 | import net.minecraft.util.MovingObjectPosition;
26 | import net.minecraft.world.IBlockAccess;
27 | import net.minecraft.world.World;
28 |
29 | import Reika.DragonAPI.Libraries.Registry.ReikaItemHelper;
30 | import Reika.ElectriCraft.Registry.ElectriTiles;
31 | import Reika.ElectriCraft.TileEntities.TileEntityWirelessCharger;
32 | import Reika.ElectriCraft.TileEntities.TileEntityWirelessCharger.ChargerTiers;
33 |
34 |
35 | public class BlockChargePad extends BlockContainer {
36 |
37 | private IIcon frontIcon;
38 | private IIcon backIcon;
39 | private IIcon[] sideIcons;
40 |
41 | public static ChargerTiers itemRender;
42 |
43 | public BlockChargePad(Material mat) {
44 | super(mat);
45 | this.setHardness(2);
46 | this.setResistance(10);
47 | }
48 |
49 | @Override
50 | public TileEntity createNewTileEntity(World world, int meta) {
51 | return new TileEntityWirelessCharger();
52 | }
53 |
54 | @Override
55 | public IIcon getIcon(int s, int meta) {
56 | return s == 0 ? backIcon : s == 1 ? frontIcon : sideIcons[itemRender != null ? itemRender.ordinal() : 0];
57 | }
58 |
59 | @Override
60 | public IIcon getIcon(IBlockAccess iba, int x, int y, int z, int s) {
61 | int meta = iba.getBlockMetadata(x, y, z);
62 | TileEntityWirelessCharger te = (TileEntityWirelessCharger)iba.getTileEntity(x, y, z);
63 | int back = te.getFacing().getOpposite().ordinal();
64 | int front = te.getFacing().ordinal();
65 | return s == back ? backIcon : s == front ? frontIcon : sideIcons[meta];
66 | }
67 |
68 | @Override
69 | public void registerBlockIcons(IIconRegister ico) {
70 | frontIcon = ico.registerIcon("electricraft:wireless/front");
71 | backIcon = ico.registerIcon("electricraft:wireless/back");
72 | sideIcons = new IIcon[TileEntityWirelessCharger.ChargerTiers.tierList.length];
73 | for (int i = 0; i < sideIcons.length; i++) {
74 | sideIcons[i] = ico.registerIcon("electricraft:wireless/side_"+i);
75 | }
76 | }
77 |
78 | @Override
79 | public void getSubBlocks(Item item, CreativeTabs cr, List li) {
80 | for (int i = 0; i < TileEntityWirelessCharger.ChargerTiers.tierList.length; i++) {
81 | li.add(new ItemStack(this, 1, i));
82 | }
83 | }
84 |
85 | @Override
86 | public int damageDropped(int meta) {
87 | return meta;
88 | }
89 |
90 | @Override
91 | public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean harv) {
92 | if (!player.capabilities.isCreativeMode && this.canHarvest(world, player, x, y, z))
93 | this.harvestBlock(world, player, x, y, z, world.getBlockMetadata(x, y, z));
94 | return world.setBlockToAir(x, y, z);
95 | }
96 |
97 | @Override
98 | public void harvestBlock(World world, EntityPlayer ep, int x, int y, int z, int meta) {
99 | if (!this.canHarvest(world, ep, x, y, z))
100 | return;
101 | if (world.getBlock(x, y, z) == this)
102 | ReikaItemHelper.dropItems(world, x+0.5, y+0.5, z+0.5, this.getDrops(world, x, y, z, meta, 0));
103 | }
104 |
105 | private boolean canHarvest(World world, EntityPlayer ep, int x, int y, int z) {
106 | return true;
107 | }
108 |
109 | @Override
110 | public ArrayList getDrops(World world, int x, int y, int z, int meta, int fortune) {
111 | ArrayList li = new ArrayList();
112 | ItemStack is = ElectriTiles.WIRELESSPAD.getCraftedProduct();
113 | is.stackTagCompound = new NBTTagCompound();
114 | is.stackTagCompound.setInteger("tier", meta);
115 | li.add(is);
116 | return li;
117 | }
118 |
119 | @Override
120 | public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
121 | int meta = world.getBlockMetadata(x, y, z);
122 | ItemStack is = ElectriTiles.WIRELESSPAD.getCraftedProduct();
123 | is.stackTagCompound = new NBTTagCompound();
124 | is.stackTagCompound.setInteger("tier", meta);
125 | return is;
126 | }
127 |
128 | }
129 |
--------------------------------------------------------------------------------
/TileEntities/ModInterface/TileEntityRFBattery.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * @author Reika Kalseki
3 | *
4 | * Copyright 2017
5 | *
6 | * All rights reserved.
7 | * Distribution of the software in any form is only allowed with
8 | * explicit, prior permission from the owner.
9 | ******************************************************************************/
10 | package Reika.ElectriCraft.TileEntities.ModInterface;
11 |
12 | import net.minecraft.item.Item;
13 | import net.minecraft.nbt.NBTTagCompound;
14 | import net.minecraft.tileentity.TileEntity;
15 | import net.minecraft.world.World;
16 | import net.minecraftforge.common.util.ForgeDirection;
17 |
18 | import Reika.DragonAPI.Libraries.MathSci.ReikaEngLibrary;
19 | import Reika.DragonAPI.Libraries.MathSci.ReikaMathLibrary;
20 | import Reika.ElectriCraft.Base.BatteryTileBase;
21 | import Reika.ElectriCraft.Registry.ElectriItems;
22 | import Reika.ElectriCraft.Registry.ElectriTiles;
23 |
24 | import cofh.api.energy.IEnergyConnection;
25 | import cofh.api.energy.IEnergyHandler;
26 | import cofh.api.energy.IEnergyReceiver;
27 |
28 | public class TileEntityRFBattery extends BatteryTileBase implements IEnergyHandler {
29 |
30 | private long energy;
31 | public static final long CAPACITY = 60000000000000L;//1099511627775L;//;
32 |
33 | @Override
34 | public String getDisplayEnergy() {
35 | return formatNumber(energy);
36 | }
37 |
38 | @Override
39 | public long getStoredEnergy() {
40 | return energy;
41 | }
42 |
43 | @Override
44 | public long getMaxEnergy() {
45 | return CAPACITY;
46 | }
47 |
48 | @Override
49 | public String getFormattedCapacity() {
50 | return formatNumber(CAPACITY);
51 | }
52 |
53 | private static String formatNumber(long num) {
54 | return String.format("%.3f %sRF", ReikaMathLibrary.getThousandBase(num), ReikaEngLibrary.getSIPrefix(num));
55 | }
56 |
57 | @Override
58 | public ElectriTiles getTile() {
59 | return ElectriTiles.RFBATTERY;
60 | }
61 |
62 | @Override
63 | public void updateEntity(World world, int x, int y, int z, int meta) {
64 | super.updateEntity(world, x, y, z, meta);
65 |
66 | if (world.getTotalWorldTime()%64 == 0) {
67 | world.markBlockForUpdate(x, y, z);
68 | }
69 |
70 | if (!world.isRemote && this.hasRedstoneSignal()) {
71 | int exp = (int)Math.min(energy, Integer.MAX_VALUE);
72 | if (exp > 0) {
73 | TileEntity te = this.getAdjacentTileEntity(ForgeDirection.UP);
74 | if (te instanceof IEnergyConnection) {
75 | if (((IEnergyConnection)te).canConnectEnergy(ForgeDirection.DOWN)) {
76 | if (te instanceof IEnergyReceiver) {
77 | IEnergyReceiver ier = (IEnergyReceiver)te;
78 | int added = ier.receiveEnergy(ForgeDirection.DOWN, exp, false);
79 | energy -= added;
80 | }
81 | else if (te instanceof IEnergyHandler) {
82 | IEnergyHandler ieh = (IEnergyHandler)te;
83 | int added = ieh.receiveEnergy(ForgeDirection.DOWN, exp, false);
84 | energy -= added;
85 | }
86 | }
87 | }
88 | }
89 | }
90 | }
91 |
92 | @Override
93 | public boolean canConnectEnergy(ForgeDirection dir) {
94 | return true;
95 | }
96 |
97 | @Override
98 | public int receiveEnergy(ForgeDirection dir, int amt, boolean simulate) {
99 | long ret = dir != ForgeDirection.UP ? Math.min(amt, CAPACITY-energy) : 0;
100 | if (ret > 0 && !simulate) {
101 | energy += ret;
102 | }
103 | return (int)ret;
104 | }
105 |
106 | @Override
107 | public int extractEnergy(ForgeDirection dir, int amt, boolean simulate) {
108 | long ret = dir == ForgeDirection.UP ? Math.min(amt, energy) : 0;
109 | if (ret > 0 && !simulate) {
110 | energy -= ret;
111 | }
112 | return (int)ret;
113 | }
114 |
115 | @Override
116 | public int getEnergyStored(ForgeDirection dir) {
117 | return energy == this.getMaxEnergy() ? Integer.MAX_VALUE : (int)Math.min(energy, Integer.MAX_VALUE-1);
118 | }
119 |
120 | @Override
121 | public int getMaxEnergyStored(ForgeDirection dir) {
122 | return Integer.MAX_VALUE;
123 | }
124 |
125 | @Override
126 | protected void writeSyncTag(NBTTagCompound NBT) {
127 | super.writeSyncTag(NBT);
128 |
129 | NBT.setLong("e", energy);
130 | }
131 |
132 | @Override
133 | protected void readSyncTag(NBTTagCompound NBT) {
134 | super.readSyncTag(NBT);
135 |
136 | energy = NBT.getLong("e");
137 | }
138 |
139 | @Override
140 | public int getEnergyColor() {
141 | return 0xff1111;
142 | }
143 |
144 | @Override
145 | public String getUnitName() {
146 | return "RF";
147 | }
148 |
149 | @Override
150 | public boolean isDecimalSystem() {
151 | return false;
152 | }
153 |
154 | @Override
155 | protected Item getPlacerItem() {
156 | return ElectriItems.RFBATTERY.getItemInstance();
157 | }
158 |
159 | @Override
160 | protected void setEnergy(long val) {
161 | energy = val;
162 | }
163 |
164 | }
165 |
--------------------------------------------------------------------------------