More work on the cables, and add items
This commit is contained in:
parent
1cd886e770
commit
e4b8918224
7 changed files with 98 additions and 26 deletions
|
@ -42,6 +42,7 @@ import techreborn.init.RecipeCompact;
|
||||||
import techreborn.lib.ModInfo;
|
import techreborn.lib.ModInfo;
|
||||||
import techreborn.packets.PacketAesu;
|
import techreborn.packets.PacketAesu;
|
||||||
import techreborn.packets.PacketIdsu;
|
import techreborn.packets.PacketIdsu;
|
||||||
|
import techreborn.powernet.PowerEvent;
|
||||||
import techreborn.proxies.CommonProxy;
|
import techreborn.proxies.CommonProxy;
|
||||||
import techreborn.tiles.idsu.IDSUManager;
|
import techreborn.tiles.idsu.IDSUManager;
|
||||||
import techreborn.world.TROreGen;
|
import techreborn.world.TROreGen;
|
||||||
|
@ -128,9 +129,10 @@ public class Core {
|
||||||
// IDSU manager
|
// IDSU manager
|
||||||
IDSUManager.INSTANCE = new IDSUManager();
|
IDSUManager.INSTANCE = new IDSUManager();
|
||||||
MinecraftForge.EVENT_BUS.register(IDSUManager.INSTANCE);
|
MinecraftForge.EVENT_BUS.register(IDSUManager.INSTANCE);
|
||||||
FMLCommonHandler.instance().bus().register(new MultiblockServerTickHandler());
|
MinecraftForge.EVENT_BUS.register(new MultiblockServerTickHandler());
|
||||||
FMLCommonHandler.instance().bus().register(new TRTickHandler());
|
MinecraftForge.EVENT_BUS.register(new TRTickHandler());
|
||||||
FMLCommonHandler.instance().bus().register(new OreUnifier());
|
MinecraftForge.EVENT_BUS.register(new OreUnifier());
|
||||||
|
MinecraftForge.EVENT_BUS.register(new PowerEvent());
|
||||||
logHelper.info("Initialization Complete");
|
logHelper.info("Initialization Complete");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,21 +12,7 @@ import reborncore.common.powerSystem.PoweredItem;
|
||||||
import reborncore.common.util.BucketHandler;
|
import reborncore.common.util.BucketHandler;
|
||||||
import techreborn.Core;
|
import techreborn.Core;
|
||||||
import techreborn.events.OreUnifier;
|
import techreborn.events.OreUnifier;
|
||||||
import techreborn.items.ItemCells;
|
import techreborn.items.*;
|
||||||
import techreborn.items.ItemCrushedOre;
|
|
||||||
import techreborn.items.ItemDusts;
|
|
||||||
import techreborn.items.ItemDustsSmall;
|
|
||||||
import techreborn.items.ItemGems;
|
|
||||||
import techreborn.items.ItemIngots;
|
|
||||||
import techreborn.items.ItemLapotronicOrb;
|
|
||||||
import techreborn.items.ItemLithiumBattery;
|
|
||||||
import techreborn.items.ItemMissingRecipe;
|
|
||||||
import techreborn.items.ItemNuggets;
|
|
||||||
import techreborn.items.ItemParts;
|
|
||||||
import techreborn.items.ItemPlates;
|
|
||||||
import techreborn.items.ItemPurifiedCrushedOre;
|
|
||||||
import techreborn.items.ItemReBattery;
|
|
||||||
import techreborn.items.ItemUUmatter;
|
|
||||||
import techreborn.items.armor.ItemLapotronPack;
|
import techreborn.items.armor.ItemLapotronPack;
|
||||||
import techreborn.items.armor.ItemLithiumBatpack;
|
import techreborn.items.armor.ItemLithiumBatpack;
|
||||||
import techreborn.items.tools.*;
|
import techreborn.items.tools.*;
|
||||||
|
@ -95,6 +81,7 @@ public class ModItems {
|
||||||
public static Item advancedChainsaw;
|
public static Item advancedChainsaw;
|
||||||
public static Item hammer;
|
public static Item hammer;
|
||||||
public static Item wrench;
|
public static Item wrench;
|
||||||
|
public static Item cables;
|
||||||
|
|
||||||
public static Item upgrades;
|
public static Item upgrades;
|
||||||
|
|
||||||
|
@ -317,6 +304,9 @@ public class ModItems {
|
||||||
missingRecipe = new ItemMissingRecipe().setUnlocalizedName("missingRecipe");
|
missingRecipe = new ItemMissingRecipe().setUnlocalizedName("missingRecipe");
|
||||||
GameRegistry.registerItem(missingRecipe, "mssingRecipe");
|
GameRegistry.registerItem(missingRecipe, "mssingRecipe");
|
||||||
|
|
||||||
|
cables = new ItemCables();
|
||||||
|
GameRegistry.registerItem(cables, "cables");
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE);
|
MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE);
|
||||||
|
|
||||||
|
|
||||||
|
|
69
src/main/java/techreborn/items/ItemCables.java
Normal file
69
src/main/java/techreborn/items/ItemCables.java
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
package techreborn.items;
|
||||||
|
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import techreborn.client.TechRebornCreativeTab;
|
||||||
|
import techreborn.init.ModItems;
|
||||||
|
import techreborn.lib.ModInfo;
|
||||||
|
|
||||||
|
import java.security.InvalidParameterException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Mark on 27/02/2016.
|
||||||
|
*/
|
||||||
|
public class ItemCables extends ItemTextureBase {
|
||||||
|
|
||||||
|
public static ItemStack getCableByName(String name, int count) {
|
||||||
|
for (int i = 0; i < types.length; i++) {
|
||||||
|
if (types[i].equalsIgnoreCase(name)) {
|
||||||
|
return new ItemStack(ModItems.cables, count, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new InvalidParameterException("The cabel " + name + " could not be found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStack getCableByName(String name) {
|
||||||
|
return getCableByName(name, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String[] types = new String[]
|
||||||
|
{"copper", "gold"};
|
||||||
|
|
||||||
|
|
||||||
|
public ItemCables() {
|
||||||
|
setCreativeTab(TechRebornCreativeTab.instance);
|
||||||
|
setHasSubtypes(true);
|
||||||
|
setUnlocalizedName("techreborn.cable");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
// gets Unlocalized Name depending on meta data
|
||||||
|
public String getUnlocalizedName(ItemStack itemStack) {
|
||||||
|
int meta = itemStack.getItemDamage();
|
||||||
|
if (meta < 0 || meta >= types.length) {
|
||||||
|
meta = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getUnlocalizedName() + "." + types[meta];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adds Dusts SubItems To Creative Tab
|
||||||
|
public void getSubItems(Item item, CreativeTabs creativeTabs, List list) {
|
||||||
|
for (int meta = 0; meta < types.length; ++meta) {
|
||||||
|
list.add(new ItemStack(item, 1, meta));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTextureName(int damage) {
|
||||||
|
return ModInfo.MOD_ID + ":items/cables/" + types[damage];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxMeta() {
|
||||||
|
return types.length;
|
||||||
|
}
|
||||||
|
}
|
|
@ -36,7 +36,7 @@ public class PowerCable {
|
||||||
if(network != null){
|
if(network != null){
|
||||||
if(tileEntity instanceof IPowerCableContainer){
|
if(tileEntity instanceof IPowerCableContainer){
|
||||||
IPowerCableContainer powerCableContainer = (IPowerCableContainer) tileEntity;
|
IPowerCableContainer powerCableContainer = (IPowerCableContainer) tileEntity;
|
||||||
if(powerCableContainer.getPowerCable().network != network){
|
if(powerCableContainer.getPowerCable() != null && powerCableContainer.getPowerCable().network != network){
|
||||||
network.merge(powerCableContainer.getPowerCable().network);
|
network.merge(powerCableContainer.getPowerCable().network);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,9 @@ package techreborn.powernet;
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
import reborncore.api.power.IEnergyInterfaceTile;
|
import reborncore.api.power.IEnergyInterfaceTile;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -13,7 +16,11 @@ public class PowerNetwork {
|
||||||
|
|
||||||
int networkPower;
|
int networkPower;
|
||||||
|
|
||||||
double maxTransfur;
|
double maxTransfer = 128;
|
||||||
|
|
||||||
|
public PowerNetwork() {
|
||||||
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
}
|
||||||
|
|
||||||
public PowerNetwork merge(PowerNetwork network){
|
public PowerNetwork merge(PowerNetwork network){
|
||||||
cables.addAll(network.cables);
|
cables.addAll(network.cables);
|
||||||
|
@ -34,7 +41,9 @@ public class PowerNetwork {
|
||||||
cable.setNetwork(null);
|
cable.setNetwork(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tick(World world){
|
@SubscribeEvent
|
||||||
|
public void tick(PowerEvent event){
|
||||||
|
World world = event.world;
|
||||||
for(PowerCable cable : cables){
|
for(PowerCable cable : cables){
|
||||||
if(cable.container.getWorld() == world){
|
if(cable.container.getWorld() == world){
|
||||||
for(PowerNode node : cable.nodes){
|
for(PowerNode node : cable.nodes){
|
||||||
|
@ -46,13 +55,13 @@ public class PowerNetwork {
|
||||||
switch (node.type){
|
switch (node.type){
|
||||||
case COLLECTOR:
|
case COLLECTOR:
|
||||||
if(iEnergyInterfaceTile.canProvideEnergy(node.facingFromCable)){
|
if(iEnergyInterfaceTile.canProvideEnergy(node.facingFromCable)){
|
||||||
double transfur = Math.min(maxTransfur, Math.min(iEnergyInterfaceTile.getMaxOutput(), iEnergyInterfaceTile.getEnergy()));
|
double transfur = Math.min(maxTransfer, Math.min(iEnergyInterfaceTile.getMaxOutput(), iEnergyInterfaceTile.getEnergy()));
|
||||||
networkPower += iEnergyInterfaceTile.useEnergy(transfur);
|
networkPower += iEnergyInterfaceTile.useEnergy(transfur);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RECEIVER:
|
case RECEIVER:
|
||||||
if(iEnergyInterfaceTile.canAcceptEnergy(node.facingFromCable)){
|
if(iEnergyInterfaceTile.canAcceptEnergy(node.facingFromCable)){
|
||||||
double transfur = Math.min(maxTransfur, Math.min(iEnergyInterfaceTile.getMaxOutput(), iEnergyInterfaceTile.getEnergy()));
|
double transfur = Math.min(maxTransfer, Math.min(iEnergyInterfaceTile.getMaxOutput(), iEnergyInterfaceTile.getEnergy()));
|
||||||
networkPower -= iEnergyInterfaceTile.addEnergy(transfur);
|
networkPower -= iEnergyInterfaceTile.addEnergy(transfur);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -60,6 +69,7 @@ public class PowerNetwork {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println(networkPower);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class TileCable extends TileEntity implements IPowerCableContainer, ITick
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
if(cable == null){
|
if(cable == null){
|
||||||
cable = new PowerCable(this);
|
createCable();
|
||||||
} else {
|
} else {
|
||||||
cable.checkNodes();
|
cable.checkNodes();
|
||||||
}
|
}
|
||||||
|
@ -43,5 +43,6 @@ public class TileCable extends TileEntity implements IPowerCableContainer, ITick
|
||||||
cable = new PowerCable(this);
|
cable = new PowerCable(this);
|
||||||
cable.setNetwork(network);
|
cable.setNetwork(network);
|
||||||
network.addCable(cable);
|
network.addCable(cable);
|
||||||
|
cable.checkNodes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ public class TileWindMill extends TilePowerAcceptor {
|
||||||
super(2);
|
super(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
int basePower = 10;
|
int basePower = 4;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
|
@ -22,7 +22,7 @@ public class TileWindMill extends TilePowerAcceptor {
|
||||||
if(worldObj.isThundering()){
|
if(worldObj.isThundering()){
|
||||||
actualPower *= 1.25;
|
actualPower *= 1.25;
|
||||||
}
|
}
|
||||||
addEnergy(actualPower * (pos.getY() - 64)); //Value taken from http://wiki.industrial-craft.net/?title=Wind_Mill Not worth making more complicated
|
addEnergy(actualPower); //Value taken from http://wiki.industrial-craft.net/?title=Wind_Mill Not worth making more complicated
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue