Merge pull request #1 from Universal-Electricity/development

Development
This commit is contained in:
Robert WC Seifert 2014-05-14 05:42:22 -04:00
commit a3bf294ab5
260 changed files with 9113 additions and 6904 deletions

9
.gitignore vendored
View file

@ -36,4 +36,11 @@
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
Thumbs.db
/bin
.classpath
.gradle/
.settings/
build/
eclipse/
.project

3
.gitmodules vendored
View file

@ -1,3 +0,0 @@
[submodule "src/main/resources/assets/resonantinduction/languages"]
path = src/main/resources/assets/resonantinduction/languages
url = https://github.com/calclavia/Resonant-Induction-Localization

View file

@ -0,0 +1,34 @@
package mcp.mobius.waila.api;
import java.util.List;
import net.minecraft.item.ItemStack;
@Deprecated
public interface IWailaBlock {
/*
* Use this method to return an item stack in case the default lookup system fails.
* Return null if you want to use the default lookup system.
* You get the world, the player and the location of the block. With that, it is easy to gather information & tile entities
*/
ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config);
/* Waila HUD is divided into 3 zones. The head corresponds to the item name,
* body to where you mostly want to put informations, and I reserve the tail for modname display
*/
/* Those 2 methods works exactly the same way, except they are related to a different zone in Waila HUD.
* You get in input world, player and the block location. You also get the itemstack as returned by the default lookup system or getWailaStack().
* ConfigHandler provides the current Waila config state so you can show/hide elements depending on the configuration. Refer the ConfigHandler class for more info.
* currenttip represents the current list of text lines in the tooltip zone.
* For example, getWailaHead() will have the current item name as currenttip.
* You can modify the tips, add more, remove some, etc.
* When you are done, just returns the currenttip and it will display in Waila.
*
* Always return the currenttip is you don't want to modify the current zone.
*/
List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
}

View file

@ -0,0 +1,9 @@
package mcp.mobius.waila.api;
import net.minecraft.item.ItemStack;
public interface IWailaBlockDecorator {
void decorateBlock(ItemStack itemStack, IWailaDataAccessor accessor, IWailaConfigHandler config);
}

View file

@ -0,0 +1,28 @@
package mcp.mobius.waila.api;
import java.util.HashMap;
import java.util.Set;
public interface IWailaConfigHandler {
/* Returns a set of all the currently loaded modules in the config handler */
public Set<String> getModuleNames();
/* Returns all the currently available options for a given module */
public HashMap<String, String> getConfigKeys(String modName);
/* Add a new option to a given module
*
* modName is the name of the module to add the option to (ie : Buildcraft, IndustrialCraft2, etc)
* key is the config key (ie : bc.tankcontent, ic2.inputvalue)
* name is the human readable name of the option (ie : "Tank content", "Max EU Input")
* */
//public void addConfig(String modName, String key, String name);
/* Returns the current value of an option (true/false) with a default value defvalue if not set*/
public boolean getConfig(String key, boolean defvalue);
/* Returns the current value of an option (true/false) with a default value true if not set*/
public boolean getConfig(String key);
//public void setConfig(String key, boolean value);
}

View file

@ -0,0 +1,33 @@
package mcp.mobius.waila.api;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
/* The Accessor is used to get some basic data out of the game without having to request
* direct access to the game engine.
* It will also return things that are unmodified by the overriding systems (like getWailaStack).
*/
public interface IWailaDataAccessor {
World getWorld();
EntityPlayer getPlayer();
Block getBlock();
int getBlockID();
int getMetadata();
TileEntity getTileEntity();
MovingObjectPosition getPosition();
Vec3 getRenderingPosition();
NBTTagCompound getNBTData();
int getNBTInteger(NBTTagCompound tag, String keyname);
double getPartialFrame();
ForgeDirection getSide();
ItemStack getStack();
}

View file

@ -0,0 +1,33 @@
package mcp.mobius.waila.api;
import java.util.List;
import net.minecraft.item.ItemStack;
public interface IWailaDataProvider{
/*
* Use this method to return an item stack in case the default lookup system fails.
* Return null if you want to use the default lookup system.
* You get the world, the player and the location of the block. With that, it is easy to gather information & tile entities
*/
ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config);
/* Waila HUD is divided into 3 zones. The head corresponds to the item name,
* body to where you mostly want to put informations, and I reserve the tail for modname display
*/
/* Those 2 methods works exactly the same way, except they are related to a different zone in Waila HUD.
* You get in input world, player and the block location. You also get the itemstack as returned by the default lookup system or getWailaStack().
* ConfigHandler provides the current Waila config state so you can show/hide elements depending on the configuration. Refer the ConfigHandler class for more info.
* currenttip represents the current list of text lines in the tooltip zone.
* For example, getWailaHead() will have the current item name as currenttip.
* You can modify the tips, add more, remove some, etc.
* When you are done, just returns the currenttip and it will display in Waila.
*
* Always return the currenttip is you don't want to modify the current zone.
*/
List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
}

View file

@ -0,0 +1,24 @@
package mcp.mobius.waila.api;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
/* The Accessor is used to get some basic data out of the game without having to request
* direct access to the game engine.
* It will also return things that are unmodified by the overriding systems (like getWailaStack).
*/
public interface IWailaEntityAccessor {
World getWorld();
EntityPlayer getPlayer();
Entity getEntity();
MovingObjectPosition getPosition();
Vec3 getRenderingPosition();
NBTTagCompound getNBTData();
int getNBTInteger(NBTTagCompound tag, String keyname);
double getPartialFrame();
}

View file

@ -0,0 +1,16 @@
package mcp.mobius.waila.api;
import java.util.List;
import net.minecraft.entity.Entity;
public interface IWailaEntityProvider {
/* A way to get an override on the entity returned by the raytracing */
Entity getWailaOverride(IWailaEntityAccessor accessor, IWailaConfigHandler config);
/* The classical HEAD/BODY/TAIL text getters */
List<String> getWailaHead(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config);
List<String> getWailaBody(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config);
List<String> getWailaTail(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config);
}

View file

@ -0,0 +1,28 @@
package mcp.mobius.waila.api;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
/* The Accessor is used to get some basic data out of the game without having to request
* direct access to the game engine.
* It will also return things that are unmodified by the overriding systems (like getWailaStack).
*/
public interface IWailaFMPAccessor {
World getWorld();
EntityPlayer getPlayer();
TileEntity getTileEntity();
MovingObjectPosition getPosition();
NBTTagCompound getNBTData();
NBTTagCompound getFullNBTData();
int getNBTInteger(NBTTagCompound tag, String keyname);
double getPartialFrame();
Vec3 getRenderingPosition();
String getID();
}

View file

@ -0,0 +1,7 @@
package mcp.mobius.waila.api;
import net.minecraft.item.ItemStack;
public interface IWailaFMPDecorator {
void decorateBlock(ItemStack itemStack, IWailaFMPAccessor accessor, IWailaConfigHandler config);
}

View file

@ -0,0 +1,12 @@
package mcp.mobius.waila.api;
import java.util.List;
import net.minecraft.item.ItemStack;
public interface IWailaFMPProvider {
/* The classical HEAD/BODY/TAIL text getters */
List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config);
List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config);
List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config);
}

View file

@ -0,0 +1,56 @@
package mcp.mobius.waila.api;
public interface IWailaRegistrar {
/* Add a config option in the section modname with displayed text configtext and access key keyname */
public void addConfig(String modname, String keyname, String configtext);
public void addConfigRemote(String modname, String keyname, String configtext);
public void addConfig(String modname, String keyname);
public void addConfigRemote(String modname, String keyname);
/* Register a IWailaDataProvider for the given blockID, either for the Head section or the Body section */
@Deprecated
public void registerHeadProvider (IWailaDataProvider dataProvider, int blockID);
@Deprecated
public void registerBodyProvider (IWailaDataProvider dataProvider, int blockID);
@Deprecated
public void registerTailProvider (IWailaDataProvider dataProvider, int blockID);
/* Register a stack overrider for the given blockID */
@Deprecated
public void registerStackProvider(IWailaDataProvider dataProvider, int blockID);
public void registerStackProvider(IWailaDataProvider dataProvider, Class block);
/* Same thing, but works on a class hierarchy instead */
public void registerHeadProvider (IWailaDataProvider dataProvider, Class block);
public void registerBodyProvider (IWailaDataProvider dataProvider, Class block);
public void registerTailProvider (IWailaDataProvider dataProvider, Class block);
/* Entity text registration methods */
public void registerHeadProvider (IWailaEntityProvider dataProvider, Class entity);
public void registerBodyProvider (IWailaEntityProvider dataProvider, Class entity);
public void registerTailProvider (IWailaEntityProvider dataProvider, Class entity);
public void registerOverrideEntityProvider (IWailaEntityProvider dataProvider, Class entity);
/* FMP Providers */
public void registerHeadProvider(IWailaFMPProvider dataProvider, String name);
public void registerBodyProvider(IWailaFMPProvider dataProvider, String name);
public void registerTailProvider(IWailaFMPProvider dataProvider, String name);
/* The block decorators */
@Deprecated
public void registerDecorator (IWailaBlockDecorator decorator, int blockID);
public void registerDecorator (IWailaBlockDecorator decorator, Class block);
public void registerDecorator (IWailaFMPDecorator decorator, String name);
/* Selective NBT key syncing. Will register a key to sync over the network for the given class (block, te or ent).
* Accept * as a ending wildcard
* registerNBTKey("bob.*", MyBlock.class)
* registerNBTKey("data.life", MyEntity.class)
* registerNBTKey("*", MyTileEntity.class) will reproduce the full tag syncing from 1.4.5
* */
public void registerSyncedNBTKey(String key, Class target);
/* UNUSED FOR NOW (Will be used for the ingame wiki */
public void registerDocTextFile (String filename);
public void registerShortDataProvider (IWailaSummaryProvider dataProvider, Class item);
}

View file

@ -0,0 +1,21 @@
package mcp.mobius.waila.api;
import java.util.LinkedHashMap;
import net.minecraft.item.ItemStack;
public interface IWailaSummaryProvider {
/* This interface is used to control the display data in the description screen */
/* BASIC TOOLS & ITEMS DATA */
//EnumToolMaterial getMaterial(ItemStack stack);
//String getMaterialName(ItemStack stack);
//String getEffectiveBlock(ItemStack stack);
//int getHarvestLevel(ItemStack stack);
//float getEfficiencyOnProperMaterial(ItemStack stack);
//int getEnchantability(ItemStack stack);
//int getDamageVsEntity(ItemStack stack);
//int getDurability(ItemStack stack);
LinkedHashMap<String, String> getSummary(ItemStack stack, LinkedHashMap<String, String> currentSummary, IWailaConfigHandler config);
}

View file

@ -0,0 +1,40 @@
package mcp.mobius.waila.api;
public class SpecialChars {
public static String MCStyle = "\u00A7";
public static String BLACK = MCStyle + "0";
public static String DBLUE = MCStyle + "1";
public static String DGREEN = MCStyle + "2";
public static String DAQUA = MCStyle + "3";
public static String DRED = MCStyle + "4";
public static String DPURPLE = MCStyle + "5";
public static String GOLD = MCStyle + "6";
public static String GRAY = MCStyle + "7";
public static String DGRAY = MCStyle + "8";
public static String BLUE = MCStyle + "9";
public static String GREEN = MCStyle + "a";
public static String AQUA = MCStyle + "b";
public static String RED = MCStyle + "c";
public static String LPURPLE = MCStyle + "d";
public static String YELLOW = MCStyle + "e";
public static String WHITE = MCStyle + "f";
public static String OBF = MCStyle + "k";
public static String BOLD = MCStyle + "l";
public static String STRIKE = MCStyle + "m";
public static String UNDER = MCStyle + "n";
public static String ITALIC = MCStyle + "o";
public static String RESET = MCStyle + "r";
public static String WailaStyle = "\u00A4";
public static String WailaIcon = "\u00A5";
public static String TAB = WailaStyle + WailaStyle +"a";
public static String ALIGNRIGHT = WailaStyle + WailaStyle +"b";
public static String ALIGNCENTER = WailaStyle + WailaStyle +"c";
public static String HEART = WailaStyle + WailaIcon +"a";
public static String HHEART = WailaStyle + WailaIcon +"b";
public static String EHEART = WailaStyle + WailaIcon +"c";
}

View file

@ -0,0 +1,3 @@
@API(apiVersion="1.0",owner="Waila",provides="WailaAPI")
package mcp.mobius.waila.api;
import cpw.mods.fml.common.API;

View file

@ -1,25 +1,16 @@
package resonantinduction.archaic;
import calclavia.lib.content.ContentRegistry;
import calclavia.lib.network.PacketAnnotation;
import calclavia.lib.network.PacketHandler;
import calclavia.lib.prefab.item.ItemBlockMetadata;
import calclavia.lib.recipe.UniversalRecipe;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import resonant.lib.content.ContentRegistry;
import resonant.lib.modproxy.ProxyHandler;
import resonant.lib.network.PacketAnnotation;
import resonant.lib.network.PacketHandler;
import resonant.lib.prefab.item.ItemBlockMetadata;
import resonant.lib.recipe.UniversalRecipe;
import resonantinduction.archaic.blocks.TileTurntable;
import resonantinduction.archaic.crate.BlockCrate;
import resonantinduction.archaic.crate.ItemBlockCrate;
@ -40,120 +31,142 @@ import resonantinduction.archaic.process.BlockCastingMold;
import resonantinduction.archaic.process.BlockMillstone;
import resonantinduction.archaic.process.TileCastingMold;
import resonantinduction.archaic.process.TileMillstone;
import resonantinduction.archaic.waila.Waila;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.Settings;
import resonantinduction.core.TabRI;
import resonantinduction.core.prefab.imprint.ItemImprint;
import resonantinduction.core.resource.ItemHandCrank;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
/**
* Resonant Induction Archaic Module
*
* @author DarkCow, Calclavia
*/
/** Resonant Induction Archaic Module
*
* @author DarkCow, Calclavia */
@Mod(modid = Archaic.ID, name = Archaic.NAME, version = Reference.VERSION, dependencies = "required-after:" + ResonantInduction.ID)
@NetworkMod(channels = Reference.CHANNEL, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
public class Archaic
{
/**
* Mod Information
*/
public static final String ID = "ResonantInduction|Archaic";
public static final String NAME = Reference.NAME + " Archaic";
public static final ContentRegistry contentRegistry = new ContentRegistry(Settings.CONFIGURATION, Settings.idManager, ID).setPrefix(Reference.PREFIX).setTab(TabRI.DEFAULT);
@Instance(ID)
public static Archaic INSTANCE;
@SidedProxy(clientSide = "resonantinduction.archaic.ClientProxy", serverSide = "resonantinduction.archaic.CommonProxy")
public static CommonProxy proxy;
@Mod.Metadata(ID)
public static ModMetadata metadata;
public static Block blockEngineeringTable;
public static Block blockCrate;
public static Block blockImprinter;
public static Block blockTurntable;
public static Block blockFirebox;
public static Block blockHotPlate;
public static Block blockMillstone;
public static Block blockCast;
public static Item itemImprint;
/** Mod Information */
public static final String ID = "ResonantInduction|Archaic";
public static final String NAME = Reference.NAME + " Archaic";
public static final ContentRegistry contentRegistry = new ContentRegistry(Settings.CONFIGURATION, Settings.idManager, ID).setPrefix(Reference.PREFIX).setTab(TabRI.DEFAULT);
@Instance(ID)
public static Archaic INSTANCE;
@SidedProxy(clientSide = "resonantinduction.archaic.ClientProxy", serverSide = "resonantinduction.archaic.CommonProxy")
public static CommonProxy proxy;
@Mod.Metadata(ID)
public static ModMetadata metadata;
public static Block blockEngineeringTable;
public static Block blockCrate;
public static Block blockImprinter;
public static Block blockTurntable;
public static Block blockFirebox;
public static Block blockHotPlate;
public static Block blockMillstone;
public static Block blockCast;
public static Item itemImprint;
// Machine and Processing
public static Item itemHammer;
public static Item itemHandCrank;
public static Block blockFilter;
// Machine and Processing
public static Item itemHammer;
public static Item itemHandCrank;
public static Block blockFilter;
// Fluid
public static Block blockGrate;
public static Block blockGutter;
public static Block blockTank;
// Fluid
public static Block blockGrate;
public static Block blockGutter;
public static Block blockTank;
@EventHandler
public void preInit(FMLPreInitializationEvent evt)
{
NetworkRegistry.instance().registerGuiHandler(this, proxy);
Settings.CONFIGURATION.load();
blockEngineeringTable = contentRegistry.newBlock(TileEngineeringTable.class);
blockCrate = contentRegistry.createBlock(BlockCrate.class, ItemBlockCrate.class, TileCrate.class);
blockImprinter = contentRegistry.createTile(BlockImprinter.class, TileImprinter.class);
blockTurntable = contentRegistry.newBlock(TileTurntable.class);
blockFirebox = contentRegistry.createBlock(BlockFirebox.class, ItemBlockMetadata.class, TileFirebox.class);
blockHotPlate = contentRegistry.createTile(BlockHotPlate.class, TileHotPlate.class);
blockMillstone = contentRegistry.createTile(BlockMillstone.class, TileMillstone.class);
blockCast = contentRegistry.createTile(BlockCastingMold.class, TileCastingMold.class);
blockGutter = contentRegistry.newBlock(TileGutter.class);
blockGrate = contentRegistry.newBlock(TileGrate.class);
blockFilter = contentRegistry.newBlock(TileFilter.class);
blockTank = contentRegistry.newBlock(TileTank.class);
public ProxyHandler modproxies;
itemHandCrank = contentRegistry.createItem(ItemHandCrank.class);
itemImprint = contentRegistry.createItem(ItemImprint.class);
itemHammer = contentRegistry.createItem(ItemHammer.class);
@EventHandler
public void preInit(FMLPreInitializationEvent evt)
{
modproxies = new ProxyHandler();
NetworkRegistry.instance().registerGuiHandler(this, proxy);
Settings.CONFIGURATION.load();
blockEngineeringTable = contentRegistry.newBlock(TileEngineeringTable.class);
blockCrate = contentRegistry.createBlock(BlockCrate.class, ItemBlockCrate.class, TileCrate.class);
blockImprinter = contentRegistry.createTile(BlockImprinter.class, TileImprinter.class);
blockTurntable = contentRegistry.newBlock(TileTurntable.class);
blockFirebox = contentRegistry.createBlock(BlockFirebox.class, ItemBlockMetadata.class, TileFirebox.class);
blockHotPlate = contentRegistry.createTile(BlockHotPlate.class, TileHotPlate.class);
blockMillstone = contentRegistry.createTile(BlockMillstone.class, TileMillstone.class);
blockCast = contentRegistry.createTile(BlockCastingMold.class, TileCastingMold.class);
blockGutter = contentRegistry.newBlock(TileGutter.class);
blockGrate = contentRegistry.newBlock(TileGrate.class);
blockFilter = contentRegistry.newBlock(TileFilter.class);
blockTank = contentRegistry.newBlock(TileTank.class);
proxy.preInit();
Settings.CONFIGURATION.save();
itemHandCrank = contentRegistry.createItem(ItemHandCrank.class);
itemImprint = contentRegistry.createItem(ItemImprint.class);
itemHammer = contentRegistry.createItem(ItemHammer.class);
PacketAnnotation.register(TileFirebox.class);
PacketAnnotation.register(TileFilter.class);
proxy.preInit();
}
modproxies.applyModule(Waila.class, true);
Settings.CONFIGURATION.save();
@EventHandler
public void init(FMLInitializationEvent evt)
{
Settings.setModMetadata(metadata, ID, NAME, ResonantInduction.ID);
proxy.init();
}
PacketAnnotation.register(TileFirebox.class);
PacketAnnotation.register(TileFilter.class);
proxy.preInit();
modproxies.preInit();
}
@EventHandler
public void postInit(FMLPostInitializationEvent evt)
{
TabRI.ITEMSTACK = new ItemStack(blockEngineeringTable);
@EventHandler
public void init(FMLInitializationEvent evt)
{
Settings.setModMetadata(metadata, ID, NAME, ResonantInduction.ID);
proxy.init();
modproxies.init();
}
// Add recipes
GameRegistry.addRecipe(new ShapedOreRecipe(blockEngineeringTable, "P", "C", 'P', Block.pressurePlatePlanks, 'C', Block.workbench));
GameRegistry.addRecipe(new ShapedOreRecipe(blockFilter, "B", "P", "B", 'B', Block.fenceIron, 'P', Item.paper));
@EventHandler
public void postInit(FMLPostInitializationEvent evt)
{
TabRI.ITEMSTACK = new ItemStack(blockEngineeringTable);
if (OreDictionary.getOres("cobblestone") == null)
{
OreDictionary.registerOre("cobblestone", Block.cobblestone);
}
if (OreDictionary.getOres("stickWood") == null)
{
OreDictionary.registerOre("stickWood", Item.stick);
}
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockCrate, 1, 0), "WWW", "WSW", "WWW", 'S', Item.stick, 'W', "logWood"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockCrate, 1, 1), "WWW", "WSW", "WWW", 'S', new ItemStack(blockCrate, 1, 0), 'W', "ingotIron"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockCrate, 1, 2), "WWW", "WSW", "WWW", 'S', new ItemStack(blockCrate, 1, 1), 'W', UniversalRecipe.PRIMARY_METAL.get()));
// Add recipes
GameRegistry.addRecipe(new ShapedOreRecipe(blockEngineeringTable, "P", "C", 'P', Block.pressurePlatePlanks, 'C', Block.workbench));
GameRegistry.addRecipe(new ShapedOreRecipe(blockFilter, "B", "P", "B", 'B', Block.fenceIron, 'P', Item.paper));
GameRegistry.addRecipe(new ShapedOreRecipe(blockFirebox, "III", "SFS", "SSS", 'I', Item.ingotIron, 'F', Block.furnaceIdle, 'S', Block.stone));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockFirebox, 1, 1), "III", "SFS", "SSS", 'I', UniversalRecipe.PRIMARY_METAL.get(), 'F', new ItemStack(blockFirebox, 1, 0), 'S', UniversalRecipe.WIRE.get()));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockCrate, 1, 0), "WWW", "WSW", "WWW", 'S', "stickWood", 'W', "logWood"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockCrate, 1, 1), "WWW", "WSW", "WWW", 'S', new ItemStack(blockCrate, 1, 0), 'W', "ingotIron"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockCrate, 1, 2), "WWW", "WSW", "WWW", 'S', new ItemStack(blockCrate, 1, 1), 'W', UniversalRecipe.PRIMARY_METAL.get()));
GameRegistry.addRecipe(new ShapedOreRecipe(blockImprinter, "SSS", "W W", "PPP", 'S', Block.stone, 'P', Block.pistonBase, 'W', "logWood"));
GameRegistry.addRecipe(new ShapedOreRecipe(blockFirebox, "III", "SFS", "SSS", 'I', Item.ingotIron, 'F', Block.furnaceIdle, 'S', Block.stone));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockFirebox, 1, 1), "III", "SFS", "SSS", 'I', UniversalRecipe.PRIMARY_METAL.get(), 'F', new ItemStack(blockFirebox, 1, 0), 'S', UniversalRecipe.WIRE.get()));
GameRegistry.addRecipe(new ShapedOreRecipe(blockTurntable, "SSS", "PGP", "WWW", 'S', Block.stone, 'G', Item.redstone, 'P', Block.pistonBase, 'W', "logWood"));
GameRegistry.addRecipe(new ShapedOreRecipe(blockCast, "I I", "IBI", "III", 'S', Item.ingotIron, 'B', Block.fenceIron));
GameRegistry.addRecipe(new ShapedOreRecipe(blockGutter, "S S", "I I", "III", 'S', Item.stick, 'I', Block.cobblestone));
GameRegistry.addRecipe(new ShapedOreRecipe(blockGrate, "WBW", "B B", "WBW", 'B', Block.fenceIron, 'W', "plankWood"));
GameRegistry.addRecipe(new ShapedOreRecipe(blockHotPlate, "SSS", "III", 'I', Item.ingotIron, 'S', Block.stone));
GameRegistry.addRecipe(new ShapedOreRecipe(blockMillstone, "SPS", "SAS", "SSS", 'P', Block.pistonBase, 'A', Item.pickaxeStone, 'S', Block.stone));
GameRegistry.addRecipe(new ShapedOreRecipe(blockTank, "GGG", "GSG", "GGG", 'G', Block.glass, 'S', Item.ingotIron));
GameRegistry.addRecipe(new ShapedOreRecipe(blockImprinter, "SSS", "W W", "PPP", 'S', Block.stone, 'P', Block.pistonBase, 'W', "logWood"));
GameRegistry.addRecipe(new ShapedOreRecipe(itemHandCrank, "S ", "SSS", " S", 'S', Item.stick));
GameRegistry.addRecipe(new ShapedOreRecipe(itemImprint, "PPP", "PIP", "PPP", 'P', Item.paper, 'I', new ItemStack(Item.dyePowder, 0)));
GameRegistry.addRecipe(new ShapedOreRecipe(itemHammer, "CC ", "CS ", " S", 'C', Block.cobblestone, 'S', Item.stick));
proxy.postInit();
}
GameRegistry.addRecipe(new ShapedOreRecipe(blockTurntable, "SSS", "PGP", "WWW", 'S', Block.stone, 'G', Item.redstone, 'P', Block.pistonBase, 'W', "logWood"));
GameRegistry.addRecipe(new ShapedOreRecipe(blockCast, "I I", "IBI", "III", 'S', Item.ingotIron, 'B', Block.fenceIron));
GameRegistry.addRecipe(new ShapedOreRecipe(blockGutter, "S S", "I I", "III", 'S', Item.stick, 'I', "cobblestone"));
GameRegistry.addRecipe(new ShapedOreRecipe(blockGrate, "WBW", "B B", "WBW", 'B', Block.fenceIron, 'W', "plankWood"));
GameRegistry.addRecipe(new ShapedOreRecipe(blockHotPlate, "SSS", "III", 'I', Item.ingotIron, 'S', Block.stone));
GameRegistry.addRecipe(new ShapedOreRecipe(blockMillstone, "SPS", "SAS", "SSS", 'P', Block.pistonBase, 'A', Item.pickaxeStone, 'S', Block.stone));
GameRegistry.addRecipe(new ShapedOreRecipe(blockTank, "GGG", "GSG", "GGG", 'G', Block.glass, 'S', Item.ingotIron));
GameRegistry.addRecipe(new ShapedOreRecipe(itemHandCrank, "S ", "SSS", " S", 'S', "stickWood"));
GameRegistry.addRecipe(new ShapedOreRecipe(itemImprint, "PPP", "PIP", "PPP", 'P', Item.paper, 'I', new ItemStack(Item.dyePowder, 0)));
GameRegistry.addRecipe(new ShapedOreRecipe(itemHammer, "CC ", "CS ", " S", 'C', "cobblestone", 'S', "stickWood"));
proxy.postInit();
modproxies.postInit();
}
}

View file

@ -1,6 +1,6 @@
package resonantinduction.archaic;
import calclavia.lib.prefab.ProxyBase;
import resonant.lib.prefab.ProxyBase;
public class CommonProxy extends ProxyBase
{

View file

@ -1,5 +1,7 @@
package resonantinduction.archaic.blocks
import codechicken.multipart.TileMultipart
import cpw.mods.fml.relauncher.SideOnly
import net.minecraft.block.Block
import net.minecraft.block.material.Material
import net.minecraft.client.renderer.texture.IconRegister
@ -8,110 +10,92 @@ import net.minecraft.util.Icon
import net.minecraft.world.IBlockAccess
import net.minecraft.world.World
import net.minecraftforge.common.ForgeDirection
import resonant.api.IRotatable
import resonant.api.blocks.IRotatableBlock
import resonant.api.blocks.IRotatableBlock
import resonant.lib.content.module.TileBlock
import resonant.lib.content.module.TileRender
import resonant.lib.render.RotatedTextureRenderer
import resonantinduction.core.Reference
import universalelectricity.api.vector.Vector3
import calclavia.lib.prefab.block.IRotatableBlock
import calclavia.lib.prefab.tile.IRotatable
import codechicken.multipart.TileMultipart
import cpw.mods.fml.relauncher.Side
import cpw.mods.fml.relauncher.SideOnly
import calclavia.lib.content.module.{TileRender, TileBlock}
import calclavia.lib.render.RotatedTextureRenderer
class TileTurntable extends TileBlock(Material.piston) with IRotatable
{
class TileTurntable extends TileBlock(Material.piston) with IRotatable {
textureName = "turntable_side"
tickRandomly = true
rotationMask = Integer.parseInt("111111", 2).toByte
override def tickRate(par1World: World): Int =
{
return 5
}
{
return 5
}
@SideOnly(Side.CLIENT) override def registerIcons(iconReg: IconRegister)
{
@SideOnly(Side.CLIENT) override def registerIcons(iconReg: IconRegister) {
super.registerIcons(iconReg)
TileTurntable.top = iconReg.registerIcon(Reference.PREFIX + "turntable")
}
override def updateEntity()
{
override def updateEntity() {
updateTurntableState(world, x, y, z)
}
@SideOnly(Side.CLIENT) override def getIcon(access: IBlockAccess, side: Int): Icon =
{
if (side == super.metadata())
{
return TileTurntable.top
}
if (side == super.metadata()) {
return TileTurntable.top
}
return getIcon
}
return getIcon
}
@SideOnly(Side.CLIENT) override def getIcon(side: Int, meta: Int): Icon =
{
if (side == 1)
{
return TileTurntable.top
if (side == 1) {
return TileTurntable.top
}
return getIcon
}
return getIcon
}
override def onNeighborChanged()
{
override def onNeighborChanged() {
scheduelTick(10)
}
private def updateTurntableState(world: World, x: Int, y: Int, z: Int)
{
if (world.isBlockIndirectlyGettingPowered(x, y, z))
{
try
{
private def updateTurntableState(world: World, x: Int, y: Int, z: Int) {
if (world.isBlockIndirectlyGettingPowered(x, y, z)) {
try {
val facing: ForgeDirection = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z))
val position: Vector3 = new Vector3(x, y, z).translate(facing)
val tileEntity: TileEntity = position.getTileEntity(world)
val block: Block = Block.blocksList(position.getBlockID(world))
if (!(tileEntity.isInstanceOf[TileMultipart]))
{
if (tileEntity.isInstanceOf[IRotatable])
{
if (!(tileEntity.isInstanceOf[TileMultipart])) {
if (tileEntity.isInstanceOf[IRotatable]) {
val blockRotation: ForgeDirection = (tileEntity.asInstanceOf[IRotatable]).getDirection
(tileEntity.asInstanceOf[IRotatable]).setDirection(blockRotation.getRotation(facing.getOpposite))
}
else if (block.isInstanceOf[IRotatableBlock])
{
} else if (block.isInstanceOf[IRotatableBlock]) {
val blockRotation: ForgeDirection = (block.asInstanceOf[IRotatableBlock]).getDirection(world, position.intX, position.intY, position.intZ)
(block.asInstanceOf[IRotatableBlock]).setDirection(world, position.intX, position.intY, position.intZ, blockRotation.getRotation(facing.getOpposite))
}
else if (block != null)
{
} else if (block != null) {
Block.blocksList(blockID).rotateBlock(world, position.intX, position.intY, position.intZ, facing.getOpposite)
}
world.markBlockForUpdate(position.intX, position.intY, position.intZ)
world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "tile.piston.in", 0.5F, world.rand.nextFloat * 0.15F + 0.6F)
}
}
catch
{
case e: Exception =>
} catch {
case e: Exception =>
{
System.out.println("Error while rotating a block near " + x + "x " + y + "y " + z + "z " + (if (world != null && world.provider != null) world.provider.dimensionId + "d" else "null:world"))
e.printStackTrace
}
}
}
}
}
@SideOnly(Side.CLIENT) protected override def newRenderer: TileRender =
{
return new RotatedTextureRenderer(this)
}
{
return new RotatedTextureRenderer(this)
}
}
object TileTurntable
{
object TileTurntable {
var top: Icon = null
}

View file

@ -10,437 +10,418 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatMessageComponent;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import resonant.lib.prefab.block.BlockTile;
import resonant.lib.utility.LanguageUtility;
import resonant.lib.utility.inventory.InventoryUtility;
import resonantinduction.core.Reference;
import universalelectricity.api.UniversalElectricity;
import calclavia.lib.prefab.block.BlockTile;
import calclavia.lib.utility.WrenchUtility;
import codechicken.multipart.ControlKeyModifer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* A block that allows the placement of mass amount of a specific item within it. It will be allowed
/** A block that allows the placement of mass amount of a specific item within it. It will be allowed
* to go on Conveyor Belts.
*
* NOTE: Crates should be upgraded with an item.
*
* @author DarkGuardsman
*/
* @author DarkGuardsman */
public class BlockCrate extends BlockTile
{
Icon advanced, elite;
Icon advanced, elite;
public BlockCrate(int id)
{
super(id, UniversalElectricity.machine);
}
public BlockCrate(int id)
{
super(id, UniversalElectricity.machine);
}
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IconRegister iconReg)
{
this.blockIcon = iconReg.registerIcon(Reference.PREFIX + "crate_wood");
this.advanced = iconReg.registerIcon(Reference.PREFIX + "crate_iron");
this.elite = iconReg.registerIcon(Reference.PREFIX + "crate_steel");
}
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IconRegister iconReg)
{
this.blockIcon = iconReg.registerIcon(Reference.PREFIX + "crate_wood");
this.advanced = iconReg.registerIcon(Reference.PREFIX + "crate_iron");
this.elite = iconReg.registerIcon(Reference.PREFIX + "crate_steel");
}
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int meta)
{
if (meta == 1)
{
return advanced;
}
else if (meta == 2)
{
return elite;
}
return this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int meta)
{
if (meta == 1)
{
return advanced;
}
else if (meta == 2)
{
return elite;
}
return this.blockIcon;
}
@Override
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player)
{
if (!world.isRemote)
{
if (world.getBlockTileEntity(x, y, z) instanceof TileCrate)
{
TileCrate tileEntity = (TileCrate) world.getBlockTileEntity(x, y, z);
@Override
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player)
{
if (!world.isRemote && world.getBlockTileEntity(x, y, z) instanceof TileCrate)
{
TileCrate tileEntity = (TileCrate) world.getBlockTileEntity(x, y, z);
this.tryEject(tileEntity, player, world.getWorldTime() - tileEntity.prevClickTime < 10);
tileEntity.prevClickTime = world.getWorldTime();
}
}
/** Make double clicking input all stacks. */
boolean allMode = (world.getWorldTime() - tileEntity.prevClickTime < 10);
@Override
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if (!world.isRemote && world.getBlockTileEntity(x, y, z) instanceof TileCrate)
{
TileCrate tile = (TileCrate) world.getBlockTileEntity(x, y, z);
tile.buildSampleStack();
ItemStack sampleStack = tile.getSampleStack();
int oreID = OreDictionary.getOreID(sampleStack);
tileEntity.prevClickTime = world.getWorldTime();
if (ControlKeyModifer.isControlDown(player))
{
tile.oreFilterEnabled = !tile.oreFilterEnabled;
player.sendChatToPlayer(ChatMessageComponent.createFromText(LanguageUtility.getLocal("crate.orefilter." + tile.oreFilterEnabled)));
}
else if (oreID != -1)
{
/* Switches ore itemStack around */
ArrayList<ItemStack> ores = OreDictionary.getOres(oreID);
this.tryEject(tileEntity, player, allMode);
}
for (int oreIndex = 0; oreIndex < ores.size(); oreIndex++)
{
if (ores.get(oreIndex).isItemEqual(sampleStack))
{
int nextIndex = (oreIndex + 1) % ores.size();
ItemStack desiredStack = ores.get(nextIndex).copy();
desiredStack.stackSize = sampleStack.stackSize;
}
}
for (int index = 0; index < tile.getSizeInventory(); index++)
tile.setInventorySlotContents(index, null);
/** Placed the item the player is holding into the crate. */
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if (!world.isRemote)
{
if (world.getBlockTileEntity(x, y, z) instanceof TileCrate)
{
TileCrate tile = (TileCrate) world.getBlockTileEntity(x, y, z);
tile.addStackToStorage(desiredStack);
break;
}
}
}
}
return true;
}
if (player.getCurrentEquippedItem() != null && WrenchUtility.isWrench(player.getCurrentEquippedItem()))
{
if (player.isSneaking())
{
ItemStack containingStack = tile.getSampleStack();
tile.buildSampleStack();
@Override
public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if (!world.isRemote && world.getBlockTileEntity(x, y, z) instanceof TileCrate)
{
TileCrate tile = (TileCrate) world.getBlockTileEntity(x, y, z);
tile.buildSampleStack();
ItemStack sampleStack = tile.getSampleStack();
if (containingStack != null)
{
if (containingStack.stackSize > 0)
{
float area = 0.7F;
double dropX = (world.rand.nextFloat() * area) + (1.0F - area) * 0.5D;
double dropY = (world.rand.nextFloat() * area) + (1.0F - area) * 0.5D;
double dropZ = (world.rand.nextFloat() * area) + (1.0F - area) * 0.5D;
if (sampleStack != null && sampleStack.stackSize > 0)
{
ItemStack dropStack = new ItemStack(this, 1, world.getBlockMetadata(x, y, z));
ItemBlockCrate.setContainingItemStack(dropStack, sampleStack);
InventoryUtility.dropItemStack(world, x, y, z, dropStack, 10, 0);
ItemStack dropStack = new ItemStack(this, 1, tile.getBlockMetadata());
ItemBlockCrate.setContainingItemStack(dropStack, containingStack);
for (int i = 0; i < tile.getInventory().getSizeInventory(); i++)
{
tile.getInventory().setInventorySlotContents(i, null);
}
world.setBlock(x, y, z, 0, 0, 3);
}
}
return true;
}
EntityItem var13 = new EntityItem(world, x + dropX, y + dropY, z + dropZ, dropStack);
var13.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(var13);
@Override
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if (!world.isRemote && world.getBlockTileEntity(x, y, z) instanceof TileCrate)
{
TileCrate tile = (TileCrate) world.getBlockTileEntity(x, y, z);
for (int i = 0; i < tile.getInventory().getSizeInventory(); i++)
{
tile.getInventory().setInventorySlotContents(i, null);
}
world.setBlock(x, y, z, 0, 0, 3);
return true;
}
}
if (ControlKeyModifer.isControlDown(player))
{
if (player.getCurrentEquippedItem() != null && (!player.getCurrentEquippedItem().getItem().isDamageable() || player.getCurrentEquippedItem().getItem().getDamage(player.getCurrentEquippedItem()) > 0))
{
ItemStack filter = player.getCurrentEquippedItem().copy();
filter.stackSize = 0;
tile.setFilter(filter);
}
else
{
tile.setFilter(null);
}
}
else
{
/* Creative mode way to fill crates to max in one click */
ItemStack current = player.inventory.getCurrentItem();
if (player.capabilities.isCreativeMode)
{
if (side == 1 && current != null && tile.getSampleStack() == null)
{
ItemStack cStack = current.copy();
cStack.stackSize = TileCrate.getSlotCount(world.getBlockMetadata(x, y, z)) * 64;
addStackToCrate(tile, cStack);
}
else if (hitY >= 0.5)
{
tryEject(tile, player, world.getWorldTime() - tile.prevClickTime < 10);
}
}
else
{
tryInsert(tile, player, world.getWorldTime() - tile.prevClickTime < 10);
}
return false;
}
}
tile.prevClickTime = world.getWorldTime();
}
return true;
}
/**
* Swap oredict nodes if the player is wrenching the crate.
*/
ItemStack sampleStack = tile.getSampleStack();
/** Try to inject it into the crate. Otherwise, look around for nearby crates and try to put them
* in. */
public void tryInsert(TileCrate tileEntity, EntityPlayer player, boolean allMode, boolean doSearch)
{
boolean success = allMode ? this.insertAllItems(tileEntity, player) : this.insertCurrentItem(tileEntity, player);
int oreID = OreDictionary.getOreID(sampleStack);
if (!success && doSearch)
{
PathfinderCrate pathfinder = new PathfinderCrate().init(tileEntity);
if (oreID != -1)
{
ArrayList<ItemStack> ores = OreDictionary.getOres(oreID);
for (TileEntity checkTile : pathfinder.iteratedNodes)
{
if (checkTile instanceof TileCrate)
{
this.tryInsert(((TileCrate) checkTile), player, allMode, false);
}
}
}
}
for (int i = 0; i < ores.size(); i++)
{
if (ores.get(i).isItemEqual(sampleStack))
{
int nextIndex = (i + 1) % ores.size();
ItemStack desiredStack = ores.get(nextIndex).copy();
desiredStack.stackSize = sampleStack.stackSize;
public void tryInsert(TileCrate tileEntity, EntityPlayer player, boolean allMode)
{
tryInsert(tileEntity, player, allMode, true);
}
for (int index = 0; index < tile.getSizeInventory(); index++)
tile.setInventorySlotContents(index, null);
public void tryEject(TileCrate tileEntity, EntityPlayer player, boolean allMode)
{
if (tileEntity.getSampleStack() == null)
{
return;
}
if (allMode && !player.isSneaking())
{
this.ejectItems(tileEntity, player, tileEntity.getSlotCount() * 64);
}
else
{
if (player.isSneaking())
{
this.ejectItems(tileEntity, player, 1);
}
else
{
this.ejectItems(tileEntity, player, tileEntity.getSampleStack().getMaxStackSize());
}
}
}
tile.addStackToStorage(desiredStack);
break;
}
}
}
}
/** Inserts a the itemStack the player is holding into the crate. */
public boolean insertCurrentItem(TileCrate tileEntity, EntityPlayer player)
{
ItemStack currentStack = player.getCurrentEquippedItem();
/** Make double clicking input all stacks. */
boolean allMode = (world.getWorldTime() - tile.prevClickTime < 10);
if (currentStack != null)
{
if (currentStack.getItem().itemID == blockID)
{
ItemStack containedStack = ItemBlockCrate.getContainingItemStack(currentStack);
ItemStack crateStack = tileEntity.getSampleStack();
tile.prevClickTime = world.getWorldTime();
if (containedStack != null && (crateStack == null || ItemStack.areItemStacksEqual(containedStack, crateStack)))
{
ItemStack returned = BlockCrate.addStackToCrate(tileEntity, containedStack);
ItemBlockCrate.setContainingItemStack(currentStack, returned);
return true;
}
}
else
{
if (tileEntity.getSampleStack() != null)
{
if (!(tileEntity.getSampleStack().isItemEqual(currentStack) || (tileEntity.oreFilterEnabled && !OreDictionary.getOreName(OreDictionary.getOreID(tileEntity.getSampleStack())).equals("Unknown") && OreDictionary.getOreID(tileEntity.getSampleStack()) == OreDictionary.getOreID(currentStack))))
{
return false;
}
}
if (ControlKeyModifer.isControlDown(player))
{
tryEject(tile, player, allMode);
}
else
{
ItemStack current = player.inventory.getCurrentItem();
if (side == 1 && player.capabilities.isCreativeMode)
{
if (current != null && tile.getSampleStack() == null)
{
ItemStack cStack = current.copy();
cStack.stackSize = TileCrate.getSlotCount(world.getBlockMetadata(x, y, z)) * 64;
addStackToCrate(tile, cStack);
}
}
player.inventory.setInventorySlotContents(player.inventory.currentItem, BlockCrate.addStackToCrate(tileEntity, currentStack));
return true;
}
}
tryInsert(tile, player, allMode);
}
}
}
return false;
}
return true;
}
/** Inserts all items of the same type this player has into the crate.
*
* @return True on success */
public boolean insertAllItems(TileCrate tileEntity, EntityPlayer player)
{
ItemStack requestStack = null;
/**
* Try to inject it into the crate. Otherwise, look around for nearby crates and try to put them
* in.
*/
public void tryInsert(TileCrate tileEntity, EntityPlayer player, boolean allMode, boolean doSearch)
{
boolean success;
if (tileEntity.getSampleStack() != null)
{
requestStack = tileEntity.getSampleStack().copy();
}
if (allMode)
{
success = this.insertAllItems(tileEntity, player);
}
else
{
success = this.insertCurrentItem(tileEntity, player);
}
if (requestStack == null)
{
requestStack = player.getCurrentEquippedItem();
}
if (!success && doSearch)
{
PathfinderCrate pathfinder = new PathfinderCrate().init(tileEntity);
if (requestStack != null && requestStack.itemID != this.blockID)
{
boolean success = false;
for (TileEntity checkTile : pathfinder.iteratedNodes)
{
if (checkTile instanceof TileCrate)
{
this.tryInsert(((TileCrate) checkTile), player, allMode, false);
}
}
}
}
for (int i = 0; i < player.inventory.getSizeInventory(); i++)
{
ItemStack currentStack = player.inventory.getStackInSlot(i);
public void tryInsert(TileCrate tileEntity, EntityPlayer player, boolean allMode)
{
tryInsert(tileEntity, player, allMode, true);
}
if (currentStack != null)
{
if (requestStack.isItemEqual(currentStack))
{
player.inventory.setInventorySlotContents(i, BlockCrate.addStackToCrate(tileEntity, currentStack));
public void tryEject(TileCrate tileEntity, EntityPlayer player, boolean allMode)
{
if (tileEntity.getSampleStack() == null)
{
return;
}
if (allMode && !player.isSneaking())
{
this.ejectItems(tileEntity, player, tileEntity.getSlotCount() * 64);
}
else
{
if (player.isSneaking())
{
this.ejectItems(tileEntity, player, 1);
}
else
{
this.ejectItems(tileEntity, player, tileEntity.getSampleStack().getMaxStackSize());
}
}
}
if (player instanceof EntityPlayerMP)
{
((EntityPlayerMP) player).sendContainerToPlayer(player.inventoryContainer);
}
/** Inserts a the itemStack the player is holding into the crate. */
public boolean insertCurrentItem(TileCrate tileEntity, EntityPlayer player)
{
ItemStack currentStack = player.getCurrentEquippedItem();
success = true;
}
}
}
return success;
}
return false;
}
if (currentStack != null)
{
if (currentStack.getItem().itemID == blockID)
{
ItemStack containedStack = ItemBlockCrate.getContainingItemStack(currentStack);
ItemStack crateStack = tileEntity.getSampleStack();
/** Ejects and item out of the crate and spawn it under the player entity.
*
* @param tileEntity
* @param player
* @param requestSize - The maximum stack size to take out. Default should be 64.
* @return True on success */
public boolean ejectItems(TileCrate tileEntity, EntityPlayer player, int requestSize)
{
World world = tileEntity.worldObj;
if (!world.isRemote)
{
ItemStack sampleStack = tileEntity.getSampleStack();
int ammountEjected = 0;
if (sampleStack != null && requestSize > 0)
{
for (int slot = 0; slot < tileEntity.getInventory().getSizeInventory(); slot++)
{
ItemStack slotStack = tileEntity.getInventory().getStackInSlot(slot);
if (containedStack != null && (crateStack == null || ItemStack.areItemStacksEqual(containedStack, crateStack)))
{
ItemStack returned = BlockCrate.addStackToCrate(tileEntity, containedStack);
ItemBlockCrate.setContainingItemStack(currentStack, returned);
return true;
}
}
else
{
if (tileEntity.getSampleStack() != null)
{
if (!(tileEntity.getSampleStack().isItemEqual(currentStack) || (!OreDictionary.getOreName(OreDictionary.getOreID(tileEntity.getSampleStack())).equals("Unknown") && OreDictionary.getOreID(tileEntity.getSampleStack()) == OreDictionary.getOreID(currentStack))))
{
return false;
}
}
if (slotStack != null && slotStack.stackSize > 0)
{
int amountToTake = Math.min(slotStack.stackSize, requestSize);
player.inventory.setInventorySlotContents(player.inventory.currentItem, BlockCrate.addStackToCrate(tileEntity, currentStack));
return true;
}
}
ItemStack dropStack = slotStack.copy();
dropStack.stackSize = amountToTake;
return false;
}
EntityItem entityItem = new EntityItem(world, player.posX, player.posY, player.posZ, dropStack);
entityItem.delayBeforeCanPickup = 0;
world.spawnEntityInWorld(entityItem);
/**
* Inserts all items of the same type this player has into the crate.
*
* @return True on success
*/
public boolean insertAllItems(TileCrate tileEntity, EntityPlayer player)
{
ItemStack requestStack = null;
slotStack.stackSize -= amountToTake;
ammountEjected += amountToTake;
if (slotStack.stackSize <= 0)
{
slotStack = null;
}
tileEntity.getInventory().setInventorySlotContents(slot, slotStack);
if (tileEntity.getSampleStack() != null)
{
requestStack = tileEntity.getSampleStack().copy();
}
}
if (ammountEjected >= requestSize)
{
return true;
}
}
tileEntity.onInventoryChanged();
return true;
}
}
return false;
}
if (requestStack == null)
{
requestStack = player.getCurrentEquippedItem();
}
/** Puts an itemStack into the crate.
*
* @param tileEntity
* @param itemStack */
public static ItemStack addStackToCrate(TileCrate tileEntity, ItemStack itemStack)
{
if (itemStack == null || itemStack.getItem().isDamageable() && itemStack.getItem().getDamage(itemStack) > 0)
{
return itemStack;
}
if (requestStack != null && requestStack.itemID != this.blockID)
{
boolean success = false;
ItemStack containingStack = tileEntity.getSampleStack();
for (int i = 0; i < player.inventory.getSizeInventory(); i++)
{
ItemStack currentStack = player.inventory.getStackInSlot(i);
if (containingStack == null || (containingStack.isItemEqual(itemStack) || (tileEntity.oreFilterEnabled && OreDictionary.getOreID(containingStack) == OreDictionary.getOreID(itemStack))))
{
int room = Math.max((tileEntity.getInventory().getSizeInventory() * 64) - (containingStack != null ? containingStack.stackSize : 0), 0);
if (itemStack.stackSize <= room)
{
tileEntity.addToStack(itemStack);
itemStack = null;
}
else
{
tileEntity.addToStack(itemStack, room);
itemStack.stackSize -= room;
}
return itemStack;
if (currentStack != null)
{
if (requestStack.isItemEqual(currentStack))
{
player.inventory.setInventorySlotContents(i, BlockCrate.addStackToCrate(tileEntity, currentStack));
}
if (player instanceof EntityPlayerMP)
{
((EntityPlayerMP) player).sendContainerToPlayer(player.inventoryContainer);
}
if (itemStack.stackSize <= 0)
{
return null;
}
success = true;
}
}
}
return success;
}
return false;
}
return itemStack;
}
/**
* Ejects and item out of the crate and spawn it under the player entity.
*
* @param tileEntity
* @param player
* @param requestSize - The maximum stack size to take out. Default should be 64.
* @return True on success
*/
public boolean ejectItems(TileCrate tileEntity, EntityPlayer player, int requestSize)
{
World world = tileEntity.worldObj;
if (!world.isRemote)
{
ItemStack sampleStack = tileEntity.getSampleStack();
int ammountEjected = 0;
if (sampleStack != null && requestSize > 0)
{
for (int slot = 0; slot < tileEntity.getInventory().getSizeInventory(); slot++)
{
ItemStack slotStack = tileEntity.getInventory().getStackInSlot(slot);
@Override
public int damageDropped(int metadata)
{
return metadata;
}
if (slotStack != null && slotStack.stackSize > 0)
{
int amountToTake = Math.min(slotStack.stackSize, requestSize);
@Override
public TileEntity createNewTileEntity(World var1)
{
return new TileCrate();
}
ItemStack dropStack = slotStack.copy();
dropStack.stackSize = amountToTake;
EntityItem entityItem = new EntityItem(world, player.posX, player.posY, player.posZ, dropStack);
entityItem.delayBeforeCanPickup = 0;
world.spawnEntityInWorld(entityItem);
slotStack.stackSize -= amountToTake;
ammountEjected += amountToTake;
if (slotStack.stackSize <= 0)
{
slotStack = null;
}
tileEntity.getInventory().setInventorySlotContents(slot, slotStack);
}
if (ammountEjected >= requestSize)
{
tileEntity.onInventoryChanged();
return true;
}
}
tileEntity.onInventoryChanged();
return true;
}
}
tileEntity.onInventoryChanged();
return false;
}
/**
* Puts an itemStack into the crate.
*
* @param tileEntity
* @param itemStack
*/
public static ItemStack addStackToCrate(TileCrate tileEntity, ItemStack itemStack)
{
if (itemStack == null || itemStack.getItem().isDamageable() && itemStack.getItem().getDamage(itemStack) > 0)
{
return itemStack;
}
ItemStack containingStack = tileEntity.getSampleStack();
if (containingStack == null || (containingStack.isItemEqual(itemStack) || OreDictionary.getOreID(containingStack) == OreDictionary.getOreID(itemStack)))
{
int room = Math.max((tileEntity.getInventory().getSizeInventory() * 64) - (containingStack != null ? containingStack.stackSize : 0), 0);
if (itemStack.stackSize <= room)
{
tileEntity.addToStack(itemStack);
itemStack = null;
}
else
{
tileEntity.addToStack(itemStack, room);
itemStack.stackSize -= room;
}
return itemStack;
}
if (itemStack.stackSize <= 0)
{
return null;
}
return itemStack;
}
@Override
public int damageDropped(int metadata)
{
return metadata;
}
@Override
public TileEntity createNewTileEntity(World var1)
{
return new TileCrate();
}
@Override
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
par3List.add(new ItemStack(par1, 1, 0));
par3List.add(new ItemStack(par1, 1, 1));
par3List.add(new ItemStack(par1, 1, 2));
}
@Override
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
par3List.add(new ItemStack(par1, 1, 0));
par3List.add(new ItemStack(par1, 1, 1));
par3List.add(new ItemStack(par1, 1, 2));
}
}

View file

@ -3,7 +3,7 @@ package resonantinduction.archaic.crate;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import calclavia.lib.utility.inventory.ExternalInventory;
import resonant.lib.utility.inventory.ExternalInventory;
public class InventoryCrate extends ExternalInventory
{

View file

@ -4,145 +4,147 @@ import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import resonant.lib.prefab.item.ItemBlockTooltip;
import resonant.lib.utility.LanguageUtility;
public class ItemBlockCrate extends ItemBlock
public class ItemBlockCrate extends ItemBlockTooltip
{
public ItemBlockCrate(int par1)
{
super(par1);
this.setHasSubtypes(true);
}
public ItemBlockCrate(int id)
{
super(id);
this.setHasSubtypes(true);
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
return this.getUnlocalizedName() + "." + itemStack.getItemDamage();
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
return this.getUnlocalizedName() + "." + itemStack.getItemDamage();
}
@Override
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
ItemStack containingStack = getContainingItemStack(itemStack);
@Override
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List list, boolean par4)
{
super.addInformation(itemStack, par2EntityPlayer, list, par4);
ItemStack containingStack = getContainingItemStack(itemStack);
if (containingStack != null)
{
par3List.add(containingStack.getDisplayName());
par3List.add("Amount: " + containingStack.stackSize);
}
}
if (containingStack != null)
{
list.add(containingStack.getDisplayName());
list.add(LanguageUtility.getLocal("crate.tooltip.amount") + " " + containingStack.stackSize);
}
}
@Override
public int getItemStackLimit(ItemStack stack)
{
ItemStack containingStack = getContainingItemStack(stack);
if (containingStack != null)
{
return 1;
}
return this.maxStackSize;
}
@Override
public int getItemStackLimit(ItemStack stack)
{
ItemStack containingStack = getContainingItemStack(stack);
if (containingStack != null)
{
return 1;
}
return this.maxStackSize;
}
@Override
public void onUpdate(ItemStack itemStack, World par2World, Entity entity, int par4, boolean par5)
{
if (entity instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) entity;
ItemStack containingStack = getContainingItemStack(itemStack);
@Override
public void onUpdate(ItemStack itemStack, World par2World, Entity entity, int par4, boolean par5)
{
if (entity instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) entity;
ItemStack containingStack = getContainingItemStack(itemStack);
if (containingStack != null && !player.capabilities.isCreativeMode)
{
player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 5, (int) ((float) containingStack.stackSize / (float) TileCrate.getSlotCount(itemStack.getItemDamage())) * 5));
}
}
}
if (containingStack != null && !player.capabilities.isCreativeMode)
{
player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 5, (int) ((float) containingStack.stackSize / (float) TileCrate.getSlotCount(itemStack.getItemDamage())) * 5));
}
}
}
public static void setContainingItemStack(ItemStack itemStack, ItemStack containingStack)
{
if (itemStack.stackTagCompound == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
public static void setContainingItemStack(ItemStack itemStack, ItemStack containingStack)
{
if (itemStack.stackTagCompound == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
if (containingStack != null)
{
NBTTagCompound itemTagCompound = new NBTTagCompound();
containingStack.stackSize = Math.abs(containingStack.stackSize);
containingStack.writeToNBT(itemTagCompound);
itemStack.getTagCompound().setTag("Item", itemTagCompound);
if (containingStack != null)
{
NBTTagCompound itemTagCompound = new NBTTagCompound();
containingStack.stackSize = Math.abs(containingStack.stackSize);
containingStack.writeToNBT(itemTagCompound);
itemStack.getTagCompound().setTag("Item", itemTagCompound);
itemStack.getTagCompound().setInteger("Count", containingStack.stackSize);
}
else
{
itemStack.getTagCompound().setTag("Item", new NBTTagCompound());
itemStack.getTagCompound().setInteger("Count", 0);
}
}
itemStack.getTagCompound().setInteger("Count", containingStack.stackSize);
}
else
{
itemStack.getTagCompound().setTag("Item", new NBTTagCompound());
itemStack.getTagCompound().setInteger("Count", 0);
}
}
public static ItemStack getContainingItemStack(ItemStack itemStack)
{
if (itemStack.stackTagCompound == null)
{
itemStack.setTagCompound(new NBTTagCompound());
return null;
}
public static ItemStack getContainingItemStack(ItemStack itemStack)
{
if (itemStack.stackTagCompound == null)
{
itemStack.setTagCompound(new NBTTagCompound());
return null;
}
NBTTagCompound itemTagCompound = itemStack.getTagCompound().getCompoundTag("Item");
ItemStack containingStack = ItemStack.loadItemStackFromNBT(itemTagCompound);
NBTTagCompound itemTagCompound = itemStack.getTagCompound().getCompoundTag("Item");
ItemStack containingStack = ItemStack.loadItemStackFromNBT(itemTagCompound);
if (containingStack != null)
{
containingStack.stackSize = itemStack.getTagCompound().getInteger("Count");
}
if (containingStack != null)
{
containingStack.stackSize = itemStack.getTagCompound().getInteger("Count");
}
return containingStack;
}
return containingStack;
}
@Override
public int getMetadata(int metadata)
{
return metadata;
}
@Override
public int getMetadata(int metadata)
{
return metadata;
}
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
{
if (super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata))
{
ItemStack containingItem = getContainingItemStack(stack);
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
{
if (super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata))
{
ItemStack containingItem = getContainingItemStack(stack);
if (world.getBlockTileEntity(x, y, z) != null && containingItem != null)
{
if (containingItem.stackSize > 0)
{
TileCrate tileEntity = (TileCrate) world.getBlockTileEntity(x, y, z);
int count = containingItem.stackSize;
if (world.getBlockTileEntity(x, y, z) != null && containingItem != null)
{
if (containingItem.stackSize > 0)
{
TileCrate tileEntity = (TileCrate) world.getBlockTileEntity(x, y, z);
int count = containingItem.stackSize;
for (int slot = 0; slot < tileEntity.getInventory().getSizeInventory(); slot++)
{
int stackSize = Math.min(64, count);
tileEntity.getInventory().setInventorySlotContents(slot, new ItemStack(containingItem.itemID, stackSize, containingItem.getItemDamage()));
count -= stackSize;
for (int slot = 0; slot < tileEntity.getInventory().getSizeInventory(); slot++)
{
int stackSize = Math.min(64, count);
tileEntity.getInventory().setInventorySlotContents(slot, new ItemStack(containingItem.itemID, stackSize, containingItem.getItemDamage()));
count -= stackSize;
if (count <= 0)
{
containingItem = null;
break;
}
if (count <= 0)
{
containingItem = null;
break;
}
}
tileEntity.buildSampleStack();
}
}
}
}
tileEntity.buildSampleStack();
}
}
}
return true;
}
return true;
}
}

View file

@ -1,11 +0,0 @@
package resonantinduction.archaic.crate;
/**
* Can that is used to store items such as food, parts, or solid fuels.
*
* @author DarkGuardsman
*/
public class ItemStorageCan
{
}

View file

@ -5,8 +5,8 @@ import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11;
import calclavia.lib.render.RenderItemOverlayUtility;
import calclavia.lib.utility.LanguageUtility;
import resonant.lib.render.RenderItemOverlayUtility;
import resonant.lib.utility.LanguageUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View file

@ -1,289 +1,350 @@
package resonantinduction.archaic.crate;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary;
import resonant.api.IExtendedStorage;
import resonant.api.IFilterable;
import resonant.lib.network.IPacketReceiver;
import resonant.lib.network.PacketHandler;
import resonant.lib.prefab.tile.TileExternalInventory;
import resonantinduction.core.ResonantInduction;
import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.PacketHandler;
import calclavia.lib.prefab.tile.TileExternalInventory;
import calclavia.lib.utility.inventory.IExtendedStorage;
import com.google.common.io.ByteArrayDataInput;
/**
* Basic single stack inventory.
*
/** Basic single stack inventory.
* <p/>
* TODO: Add filter-locking feature. Put filter in, locks the crate to only use that item.
*
* @author DarkGuardsman
*/
public class TileCrate extends TileExternalInventory implements IPacketReceiver, IExtendedStorage
* @author DarkGuardsman */
public class TileCrate extends TileExternalInventory implements IPacketReceiver, IExtendedStorage, IFilterable
{
/*
* TODO
* Fix issues with ItemStacks with NBT tags having issues
* Fix possible render issues with some items
* Yell at MachineMuse for her items rendering threw walls
* Add support to disable sides of crates when rendering items are unwanted
* Simplify item rendering to decrease graphic lag
* Add crafting manger to prevent crafting with full crates
* As well keep item stacks when upgrade crate threw crafting
* Add upgrade item for crate
* Add crate swapping in which an advanced can trade place with a basic while keeping inventory
* at the locaiton
*/
/** Collective total stack of all inv slots */
private ItemStack sampleStack;
/** max meta size of the crate */
public static final int maxSize = 2;
/** delay from last click */
public long prevClickTime = -1000;
/** max meta size of the crate */
public static final int maxSize = 2;
/** delay from last click */
public long prevClickTime = -1000;
@Override
public InventoryCrate getInventory()
{
if (this.inventory == null)
{
inventory = new InventoryCrate(this);
}
return (InventoryCrate) this.inventory;
}
/** Check to see if oreName items can be force stacked */
public boolean oreFilterEnabled = false;
/** Gets the sample stack that represent the total inv */
public ItemStack getSampleStack()
{
if (this.sampleStack == null)
{
this.buildSampleStack();
}
return this.sampleStack;
}
/** Collective total stack of all inv slots */
private ItemStack sampleStack;
private ItemStack filterStack;
/**
* Turns the inventory array into a single stack of matching items. This assumes that all items
* in the crate are the same TODO eject minority items and only keep the majority that are the
* same to prevent duplication issues
* TODO: Add Force?
* @param force - force a rebuild of the inventory from the single stack created
*/
public void buildSampleStack()
{
ItemStack stack = null;
private long updateTick = 1;
private boolean doUpdate = false;
boolean rebuildBase = false;
@Override
public void updateEntity()
{
super.updateEntity();
if (!worldObj.isRemote)
{
this.writeToNBT(new NBTTagCompound());
if (ticks % updateTick == 0)
{
updateTick = 5 + worldObj.rand.nextInt(50);
doUpdate = true;
}
if (doUpdate)
{
doUpdate = false;
PacketHandler.sendPacketToClients(getDescriptionPacket(), this.worldObj);
}
}
/* Creates the sample stack that is used as a collective itemstack */
for (int i = 0; i < this.getInventory().getContainedItems().length; i++)
{
ItemStack s = this.getInventory().getContainedItems()[i];
if (s != null && s.itemID > 0 && s.stackSize > 0)
{
if (stack == null)
{
stack = s.copy();
}
else
{
stack.stackSize += this.getInventory().getContainedItems()[i].stackSize;
}
if (this.getInventory().getContainedItems()[i].stackSize > this.getInventory().getContainedItems()[i].getMaxStackSize())
{
rebuildBase = true;
}
}
}
if (stack == null || stack.itemID == 0 || stack.stackSize == 0)
{
this.sampleStack = null;
}
else
{
this.sampleStack = stack.copy();
}
/* if one stack is over sized this rebuilds the inv to redistribute the items in the slots */
if ((rebuildBase || this.getInventory().getContainedItems().length > this.getSlotCount()) && this.sampleStack != null)
{
this.getInventory().buildInventory(this.sampleStack);
}
}
}
/** Adds an item to the stack */
public void addToStack(ItemStack stack, int amount)
{
if (stack != null)
{
this.addToStack(new ItemStack(stack.stackSize, amount, stack.getItemDamage()));
}
}
/** Gets the slot count for the crate meta */
public static int getSlotCount(int metadata)
{
if (metadata >= 2)
{
return 256;
}
else if (metadata >= 1)
{
return 64;
}
return 32;
}
/** Adds the stack to the sample stack */
public void addToStack(ItemStack stack)
{
if (stack != null)
{
this.buildSampleStack();
boolean flag = false;
@Override
public InventoryCrate getInventory()
{
if (this.inventory == null)
{
inventory = new InventoryCrate(this);
}
return (InventoryCrate) this.inventory;
}
if (this.sampleStack == null)
{
this.sampleStack = stack;
flag = true;
}
else if (this.sampleStack.isItemEqual(stack) || OreDictionary.getOreID(sampleStack) == OreDictionary.getOreID(stack))
{
this.sampleStack.stackSize += stack.stackSize;
flag = true;
}
/** Gets the sample stack that represent the total inventory */
public ItemStack getSampleStack()
{
if (this.sampleStack == null)
{
this.buildSampleStack();
}
return this.sampleStack;
}
if (flag)
{
this.getInventory().buildInventory(this.sampleStack);
this.onInventoryChanged();
}
}
}
/** Builds the sample stack using the inventory as a point of reference. Assumes all items match
* each other, and only takes into account stack sizes */
public void buildSampleStack()
{
buildSampleStack(true);
}
@Override
public void onInventoryChanged()
{
super.onInventoryChanged();
public void buildSampleStack(boolean buildInv)
{
if (worldObj == null || !worldObj.isRemote)
{
ItemStack newSampleStack = null;
boolean rebuildBase = false;
if (worldObj != null && !worldObj.isRemote)
{
PacketHandler.sendPacketToClients(getDescriptionPacket(), this.worldObj);
}
}
/* Creates the sample stack that is used as a collective itemstack */
for (int slot = 0; slot < this.getSizeInventory(); slot++)
{
ItemStack slotStack = this.getInventory().getContainedItems()[slot];
if (slotStack != null && Item.itemsList[slotStack.itemID] != null && slotStack.stackSize > 0)
{
if (newSampleStack == null)
{
newSampleStack = slotStack.copy();
}
else
{
newSampleStack.stackSize += slotStack.stackSize;
}
@Override
public boolean canStore(ItemStack stack, int slot, ForgeDirection side)
{
return sampleStack == null || stack != null && (stack.isItemEqual(sampleStack) || OreDictionary.getOreID(sampleStack) == OreDictionary.getOreID(stack));
}
if (slotStack.stackSize > slotStack.getMaxStackSize())
{
rebuildBase = true;
}
}
}
if (newSampleStack == null || newSampleStack.itemID == 0 || newSampleStack.stackSize <= 0)
{
this.sampleStack = this.getFilter() != null ? this.getFilter().copy() : null;
}
else
{
this.sampleStack = newSampleStack.copy();
}
/** Gets the current slot count for the crate */
public int getSlotCount()
{
if (this.worldObj == null)
{
return TileCrate.getSlotCount(TileCrate.maxSize);
}
return TileCrate.getSlotCount(this.getBlockMetadata());
}
/* Rebuild inventory if the inventory is not valid */
if (buildInv && this.sampleStack != null && (rebuildBase || this.getInventory().getContainedItems().length > this.getSizeInventory()))
{
this.getInventory().buildInventory(this.sampleStack);
}
}
}
/** Gets the slot count for the crate meta */
public static int getSlotCount(int metadata)
{
if (metadata >= 2)
{
return 256;
}
else if (metadata >= 1)
{
return 64;
}
return 32;
}
@Override
public ItemStack addStackToStorage(ItemStack stack)
{
return BlockCrate.addStackToCrate(this, stack);
}
@Override
public boolean canUpdate()
{
return false;
}
/** Adds an item to the stack */
public void addToStack(ItemStack stack, int amount)
{
if (stack != null)
{
ItemStack newStack = stack.copy();
newStack.stackSize = amount;
this.addToStack(newStack);
}
}
@Override
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
{
if (this.worldObj.isRemote)
{
try
{
if (data.readBoolean())
{
this.sampleStack = ItemStack.loadItemStackFromNBT(PacketHandler.readNBTTagCompound(data));
this.sampleStack.stackSize = data.readInt();
}
else
{
this.sampleStack = null;
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
/** Adds the stack to the sample stack */
public void addToStack(ItemStack stack)
{
if (stack != null && stack.stackSize > 0)
{
if (this.getSampleStack() == null)
{
this.sampleStack = stack;
getInventory().buildInventory(getSampleStack());
}
else if (this.getSampleStack().isItemEqual(stack) || (this.oreFilterEnabled && OreDictionary.getOreID(getSampleStack()) == OreDictionary.getOreID(stack)))
{
getSampleStack().stackSize += stack.stackSize;
getInventory().buildInventory(getSampleStack());
}
}
}
@Override
public Packet getDescriptionPacket()
{
this.buildSampleStack();
ItemStack stack = this.getSampleStack();
if (stack != null)
{
return ResonantInduction.PACKET_TILE.getPacket(this, true, stack.writeToNBT(new NBTTagCompound()), stack.stackSize);
}
else
{
return ResonantInduction.PACKET_TILE.getPacket(this, false);
}
}
@Override
public ItemStack decrStackSize(int slot, int amount)
{
if (sampleStack != null)
{
ItemStack var3;
/** NBT Data */
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
/* Load current two inv methods */
ItemStack stack = null;
int count = nbt.getInteger("Count");
if (nbt.hasKey("itemID"))
{
stack = new ItemStack(nbt.getInteger("itemID"), count, nbt.getInteger("itemMeta"));
}
else
{
stack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("stack"));
if (stack != null)
{
stack.stackSize = count;
}
}
if (sampleStack.stackSize <= amount)
{
var3 = sampleStack;
sampleStack = null;
this.onInventoryChanged();
getInventory().buildInventory(getSampleStack());
return var3;
}
else
{
var3 = sampleStack.splitStack(amount);
/* Only load sample stack if the read stack is valid */
if (stack != null && stack.itemID != 0 && stack.stackSize > 0)
{
this.sampleStack = stack;
this.getInventory().buildInventory(this.sampleStack);
}
if (sampleStack.stackSize == 0)
{
sampleStack = null;
}
}
getInventory().buildInventory(getSampleStack());
onInventoryChanged();
return var3;
}
}
else
{
return null;
}
}
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
/* Re-Build sample stack for saving */
this.buildSampleStack();
ItemStack stack = this.getSampleStack();
/* Save sample stack */
if (stack != null)
{
nbt.setInteger("Count", stack.stackSize);
nbt.setCompoundTag("stack", stack.writeToNBT(new NBTTagCompound()));
}
@Override
public void onInventoryChanged()
{
super.onInventoryChanged();
if (worldObj != null && !worldObj.isRemote)
doUpdate = true;
}
}
@Override
public boolean canStore(ItemStack stack, int slot, ForgeDirection side)
{
return getSampleStack() == null || stack != null && (stack.isItemEqual(getSampleStack()) || (this.oreFilterEnabled && OreDictionary.getOreID(getSampleStack()) == OreDictionary.getOreID(stack)));
}
@Override
public ItemStack addStackToStorage(ItemStack stack)
{
return BlockCrate.addStackToCrate(this, stack);
}
/** Gets the current slot count for the crate */
public int getSlotCount()
{
if (this.worldObj == null)
{
return TileCrate.getSlotCount(TileCrate.maxSize);
}
return TileCrate.getSlotCount(this.getBlockMetadata());
}
@Override
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
{
if (this.worldObj.isRemote)
{
try
{
if (data.readBoolean())
{
this.sampleStack = ItemStack.loadItemStackFromNBT(PacketHandler.readNBTTagCompound(data));
this.sampleStack.stackSize = data.readInt();
}
else
{
this.sampleStack = null;
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
@Override
public Packet getDescriptionPacket()
{
this.buildSampleStack();
ItemStack stack = this.getSampleStack();
if (stack != null)
{
return ResonantInduction.PACKET_TILE.getPacket(this, true, stack.writeToNBT(new NBTTagCompound()), stack.stackSize);
}
else
{
return ResonantInduction.PACKET_TILE.getPacket(this, false);
}
}
/** NBT Data */
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
/* Load current two inv methods */
ItemStack stack = null;
int count = nbt.getInteger("Count");
if (nbt.hasKey("itemID"))
{
stack = new ItemStack(nbt.getInteger("itemID"), count, nbt.getInteger("itemMeta"));
}
else
{
stack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("stack"));
if (stack != null)
{
stack.stackSize = count;
}
}
/* Only load sample stack if the read stack is valid */
if (stack != null && stack.itemID != 0 && stack.stackSize > 0)
{
this.sampleStack = stack;
this.getInventory().buildInventory(this.sampleStack);
}
this.oreFilterEnabled = nbt.getBoolean("oreFilter");
if (nbt.hasKey("filter"))
{
filterStack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("filter"));
}
}
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
/* Re-Build sample stack for saving */
this.buildSampleStack(false);
ItemStack stack = this.getSampleStack();
/* Save sample stack */
if (stack != null)
{
nbt.setInteger("Count", stack.stackSize);
nbt.setCompoundTag("stack", stack.writeToNBT(new NBTTagCompound()));
}
nbt.setBoolean("oreFilter", this.oreFilterEnabled);
if (this.filterStack != null)
{
nbt.setCompoundTag("filter", filterStack.writeToNBT(new NBTTagCompound()));
}
}
@Override
public ItemStack getFilter()
{
return this.filterStack;
}
@Override
public void setFilter(ItemStack filter)
{
this.filterStack = filter;
this.onInventoryChanged();
}
}

View file

@ -1,77 +1,14 @@
package resonantinduction.archaic.engineering;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.ResonantInduction.RecipeType;
import universalelectricity.api.vector.Vector3;
import calclavia.api.recipe.MachineRecipes;
import calclavia.api.recipe.RecipeResource;
import calclavia.lib.utility.inventory.InventoryUtility;
/** Item used to interact with engineering table to crush ore */
public class ItemHammer extends Item
{
public ItemHammer(int id)
{
super(id);
setMaxStackSize(1);
setMaxDamage(400);
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity instanceof TileEngineeringTable)
{
TileEngineeringTable tile = (TileEngineeringTable) tileEntity;
// We don't want to bash the output slots
for (int i = 0; i < TileEngineeringTable.CRAFTING_OUTPUT_END; i++)
{
ItemStack inputStack = tile.getStackInSlot(i);
if (inputStack != null)
{
String oreName = OreDictionary.getOreName(OreDictionary.getOreID(inputStack));
if (oreName != null && !oreName.equals("Unknown"))
{
RecipeResource[] outputs = MachineRecipes.INSTANCE.getOutput(RecipeType.CRUSHER.name(), oreName);
if (outputs.length > 0)
{
if (!world.isRemote && world.rand.nextFloat() < 0.04)
{
for (RecipeResource resource : outputs)
{
ItemStack outputStack = resource.getItemStack().copy();
if (outputStack != null)
{
InventoryUtility.dropItemStack(world, new Vector3(player), outputStack, 0);
tile.setInventorySlotContents(i, --inputStack.stackSize <= 0 ? null : inputStack);
}
}
}
ResonantInduction.proxy.renderBlockParticle(world, new Vector3(x + 0.5, y + 0.5, z + 0.5), new Vector3((Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3), inputStack.itemID, 1);
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, Reference.PREFIX + "hammer", 0.5f, 0.8f + (0.2f * world.rand.nextFloat()));
player.addExhaustion(0.3f);
stack.damageItem(1, player);
return true;
}
}
}
}
}
return false;
}
public ItemHammer(int id)
{
super(id);
setMaxStackSize(1);
setMaxDamage(400);
}
}

View file

@ -9,14 +9,14 @@ import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import resonant.lib.prefab.block.BlockTile;
import resonant.lib.utility.inventory.InventoryUtility;
import resonantinduction.core.Reference;
import resonantinduction.core.prefab.imprint.ItemImprint;
import universalelectricity.api.UniversalElectricity;
import universalelectricity.api.vector.Vector2;
import universalelectricity.api.vector.Vector3;
import universalelectricity.api.vector.VectorWorld;
import calclavia.lib.prefab.block.BlockTile;
import calclavia.lib.utility.inventory.InventoryUtility;
import codechicken.multipart.ControlKeyModifer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View file

@ -4,7 +4,7 @@ import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import calclavia.lib.render.RenderItemOverlayUtility;
import resonant.lib.render.RenderItemOverlayUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View file

@ -12,6 +12,16 @@ import net.minecraft.network.packet.Packet;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.IFluidHandler;
import resonant.api.IFilterable;
import resonant.api.recipe.MachineRecipes;
import resonant.api.recipe.RecipeResource;
import resonant.lib.content.module.TileRender;
import resonant.lib.network.Synced.SyncedInput;
import resonant.lib.network.Synced.SyncedOutput;
import resonant.lib.prefab.vector.Cuboid;
import resonant.lib.render.RenderItemOverlayUtility;
import resonant.lib.utility.LanguageUtility;
import resonant.lib.utility.inventory.InventoryUtility;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.ResonantInduction.RecipeType;
import resonantinduction.core.prefab.imprint.ItemImprint;
@ -19,16 +29,6 @@ import resonantinduction.core.prefab.imprint.TileFilterable;
import resonantinduction.core.resource.ResourceGenerator;
import resonantinduction.core.resource.fluid.BlockFluidMixture;
import universalelectricity.api.vector.Vector3;
import calclavia.api.recipe.MachineRecipes;
import calclavia.api.recipe.RecipeResource;
import calclavia.api.resonantinduction.IFilterable;
import calclavia.lib.content.module.TileRender;
import calclavia.lib.network.Synced.SyncedInput;
import calclavia.lib.network.Synced.SyncedOutput;
import calclavia.lib.prefab.vector.Cuboid;
import calclavia.lib.render.RenderItemOverlayUtility;
import calclavia.lib.utility.LanguageUtility;
import calclavia.lib.utility.inventory.InventoryUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -84,7 +84,6 @@ public class TileFilter extends TileFilterable implements IFilterable
Vector3 checkBelow = position.clone().translate(ForgeDirection.DOWN);
Block bAbove = Block.blocksList[checkAbove.getBlockID(worldObj)];
Block bBelow = Block.blocksList[checkAbove.getBlockID(worldObj)];
if (bAbove instanceof BlockFluidMixture && (worldObj.isAirBlock(checkBelow.intX(), checkBelow.intY(), checkBelow.intZ()) || checkBelow.getTileEntity(worldObj) instanceof IFluidHandler))
{
@ -100,8 +99,9 @@ public class TileFilter extends TileFilterable implements IFilterable
/**
* Drop item from fluid.
*/
for (RecipeResource resoure : MachineRecipes.INSTANCE.getOutput(RecipeType.MIXER.name(), "dust" + LanguageUtility.capitalizeFirst(ResourceGenerator.mixtureToMaterial(fluidBlock.getFluid().getName()))))
for (RecipeResource resoure : MachineRecipes.INSTANCE.getOutput(RecipeType.MIXER.name(), "dirtyDust" + LanguageUtility.capitalizeFirst(ResourceGenerator.mixtureToMaterial(fluidBlock.getFluid().getName()))))
{
InventoryUtility.dropItemStack(worldObj, checkAbove.clone().add(0.5), resoure.getItemStack().copy(), 0, 0);
}

View file

@ -10,11 +10,11 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.packet.Packet;
import resonant.lib.network.IPacketReceiver;
import resonant.lib.network.PacketHandler;
import resonant.lib.prefab.tile.TileAdvanced;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.prefab.imprint.ItemImprint;
import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.PacketHandler;
import calclavia.lib.prefab.tile.TileAdvanced;
import com.google.common.io.ByteArrayDataInput;

View file

@ -13,9 +13,9 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import resonant.lib.prefab.block.BlockTile;
import resonant.lib.utility.FluidUtility;
import resonantinduction.core.Reference;
import calclavia.lib.prefab.block.BlockTile;
import calclavia.lib.utility.FluidUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View file

@ -10,10 +10,10 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import resonant.lib.prefab.block.BlockTile;
import resonantinduction.core.Reference;
import universalelectricity.api.vector.Vector2;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.prefab.block.BlockTile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View file

@ -4,7 +4,7 @@ import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import calclavia.lib.render.RenderItemOverlayUtility;
import resonant.lib.render.RenderItemOverlayUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View file

@ -1,11 +1,5 @@
package resonantinduction.archaic.firebox;
import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.Synced;
import calclavia.lib.prefab.tile.TileElectricalInventory;
import calclavia.lib.thermal.BoilEvent;
import calclavia.lib.thermal.ThermalPhysics;
import com.google.common.io.ByteArrayDataInput;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -15,7 +9,18 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.*;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import resonant.lib.network.IPacketReceiver;
import resonant.lib.network.Synced;
import resonant.lib.prefab.tile.TileElectricalInventory;
import resonant.lib.thermal.BoilEvent;
import resonant.lib.thermal.ThermalPhysics;
import resonantinduction.archaic.Archaic;
import resonantinduction.archaic.fluid.gutter.TileGutter;
import resonantinduction.core.ResonantInduction;
@ -24,6 +29,8 @@ import resonantinduction.core.resource.TileMaterial;
import universalelectricity.api.energy.EnergyStorageHandler;
import universalelectricity.api.vector.Vector3;
import com.google.common.io.ByteArrayDataInput;
/**
* Meant to replace the furnace class.
*
@ -143,7 +150,7 @@ public class TileFirebox extends TileElectricalInventory implements IPacketRecei
{
if (FluidRegistry.getFluid("steam") != null)
{
MinecraftForge.EVENT_BUS.post(new BoilEvent(worldObj, new Vector3(this).translate(0, 1, 0), new FluidStack(FluidRegistry.WATER, volume), new FluidStack(FluidRegistry.getFluid("steam"), volume), 2));
MinecraftForge.EVENT_BUS.post(new BoilEvent(worldObj, new Vector3(this).translate(0, 1, 0), new FluidStack(FluidRegistry.WATER, volume), new FluidStack(FluidRegistry.getFluid("steam"), volume), 2, false));
boiledVolume += volume;
}
@ -168,7 +175,7 @@ public class TileFirebox extends TileElectricalInventory implements IPacketRecei
{
if (FluidRegistry.getFluid("steam") != null)
{
MinecraftForge.EVENT_BUS.post(new BoilEvent(worldObj, new Vector3(this).translate(0, 1, 0), new FluidStack(FluidRegistry.WATER, volume), new FluidStack(FluidRegistry.getFluid("steam"), volume), 2));
MinecraftForge.EVENT_BUS.post(new BoilEvent(worldObj, new Vector3(this).translate(0, 1, 0), new FluidStack(FluidRegistry.WATER, volume), new FluidStack(FluidRegistry.getFluid("steam"), volume), 2, false));
((TileGutter) tileEntity).drain(ForgeDirection.DOWN, volume, true);
}

View file

@ -9,11 +9,11 @@ import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import net.minecraft.tileentity.TileEntity;
import resonant.lib.network.IPacketReceiver;
import resonant.lib.network.IPacketSender;
import resonant.lib.network.PacketHandler;
import resonant.lib.prefab.tile.TileExternalInventory;
import resonantinduction.core.ResonantInduction;
import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.IPacketSender;
import calclavia.lib.network.PacketHandler;
import calclavia.lib.prefab.tile.TileExternalInventory;
import com.google.common.io.ByteArrayDataInput;

View file

@ -1,10 +1,10 @@
package resonantinduction.archaic.fluid.grate;
import calclavia.lib.config.Config;
import calclavia.lib.prefab.tile.IRotatable;
import calclavia.lib.utility.FluidUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.PriorityQueue;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
@ -12,16 +12,20 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.*;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import resonant.api.IRotatable;
import resonant.lib.config.Config;
import resonant.lib.utility.FluidUtility;
import resonantinduction.core.Reference;
import resonantinduction.core.fluid.TilePressureNode;
import resonantinduction.core.grid.fluid.FluidPressureNode;
import universalelectricity.api.vector.Vector3;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.PriorityQueue;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TileGrate extends TilePressureNode implements IRotatable
{

View file

@ -1,16 +1,8 @@
package resonantinduction.archaic.fluid.gutter;
import calclavia.api.recipe.MachineRecipes;
import calclavia.api.recipe.RecipeResource;
import calclavia.lib.content.module.TileRender;
import calclavia.lib.prefab.vector.Cuboid;
import calclavia.lib.render.FluidRenderUtility;
import calclavia.lib.render.RenderUtility;
import calclavia.lib.utility.FluidUtility;
import calclavia.lib.utility.WorldUtility;
import calclavia.lib.utility.inventory.InventoryUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.Entity;
@ -22,8 +14,24 @@ import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.*;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.IFluidTank;
import org.lwjgl.opengl.GL11;
import resonant.api.recipe.MachineRecipes;
import resonant.api.recipe.RecipeResource;
import resonant.lib.content.module.TileRender;
import resonant.lib.prefab.vector.Cuboid;
import resonant.lib.render.FluidRenderUtility;
import resonant.lib.render.RenderUtility;
import resonant.lib.utility.FluidUtility;
import resonant.lib.utility.WorldUtility;
import resonant.lib.utility.inventory.InventoryUtility;
import resonantinduction.archaic.fluid.grate.TileGrate;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction.RecipeType;
@ -31,9 +39,8 @@ import resonantinduction.core.fluid.TilePressureNode;
import resonantinduction.core.grid.fluid.FluidPressureNode;
import resonantinduction.core.grid.fluid.IPressureNodeProvider;
import universalelectricity.api.vector.Vector3;
import java.util.ArrayList;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* The gutter, used for fluid transfer.

View file

@ -1,138 +0,0 @@
package resonantinduction.archaic.fluid.tank;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import resonantinduction.archaic.Archaic;
import resonantinduction.core.fluid.TileFluidDistribution;
import universalelectricity.api.energy.UnitDisplay;
import universalelectricity.api.energy.UnitDisplay.Unit;
import universalelectricity.api.energy.UnitDisplay.UnitPrefix;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.utility.LanguageUtility;
/** @author Darkguardsman */
public class ItemBlockFluidContainer extends ItemBlock
{
public ItemBlockFluidContainer(int id)
{
super(id);
this.setMaxDamage(0);
this.setHasSubtypes(true);
}
@Override
public int getMetadata(int damage)
{
return damage;
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
{
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("fluid"))
{
FluidStack fluid = FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag("fluid"));
if (fluid != null)
{
list.add("Fluid: " + fluid.getFluid().getLocalizedName());
list.add("Volume: " + UnitDisplay.getDisplay(fluid.amount, Unit.LITER, UnitPrefix.MILLI));
}
}
}
public static ItemStack getWrenchedItem(World world, Vector3 vec)
{
TileEntity entity = vec.getTileEntity(world);
if (entity instanceof TileTank && ((TileTank) entity).getInternalTank() != null && ((TileTank) entity).getInternalTank().getFluid() != null)
{
ItemStack itemStack = new ItemStack(Archaic.blockTank);
FluidStack stack = ((TileTank) entity).getInternalTank().getFluid();
if (itemStack.getTagCompound() == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
if (stack != null)
{
((TileTank) entity).drain(ForgeDirection.UNKNOWN, stack.amount, true);
itemStack.getTagCompound().setCompoundTag("fluid", stack.writeToNBT(new NBTTagCompound()));
}
return itemStack;
}
return null;
}
@Override
public void onUpdate(ItemStack itemStack, World par2World, Entity entity, int par4, boolean par5)
{
if (entity instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) entity;
if (itemStack.getTagCompound() != null && !player.capabilities.isCreativeMode && itemStack.getTagCompound().hasKey("fluid"))
{
player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 5, 0));
}
}
}
@Override
public int getItemStackLimit(ItemStack stack)
{
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("fluid"))
{
return 1;
}
return this.maxStackSize;
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
String translation = LanguageUtility.getLocal(Block.blocksList[this.getBlockID()].getUnlocalizedName() + "." + itemStack.getItemDamage());
if (translation == null || translation.isEmpty())
{
return Block.blocksList[this.getBlockID()].getUnlocalizedName();
}
return Block.blocksList[this.getBlockID()].getUnlocalizedName() + "." + itemStack.getItemDamage();
}
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
{
if (super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata))
{
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof TileFluidDistribution)
{
((TileFluidDistribution) tile).setSubID(stack.getItemDamage());
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("fluid"))
{
((TileFluidDistribution) tile).getInternalTank().fill(FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag("fluid")), true);
}
}
return true;
}
return false;
}
}

View file

@ -0,0 +1,245 @@
package resonantinduction.archaic.fluid.tank;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import resonant.lib.utility.LanguageUtility;
import resonantinduction.archaic.Archaic;
import resonantinduction.core.fluid.TileFluidDistribution;
import universalelectricity.api.energy.UnitDisplay;
import universalelectricity.api.energy.UnitDisplay.Unit;
import universalelectricity.api.energy.UnitDisplay.UnitPrefix;
import universalelectricity.api.vector.Vector3;
/** @author Darkguardsman */
public class ItemBlockTank extends ItemBlock implements IFluidContainerItem
{
public ItemBlockTank(int id)
{
super(id);
this.setMaxDamage(0);
this.setHasSubtypes(true);
}
@Override
public int getMetadata(int damage)
{
return damage;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
{
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("fluid"))
{
FluidStack fluid = getFluid(stack);
if (fluid != null)
{
list.add("Fluid: " + fluid.getFluid().getLocalizedName());
list.add("Volume: " + UnitDisplay.getDisplay(fluid.amount, Unit.LITER, UnitPrefix.MILLI));
}
}
}
public static ItemStack getWrenchedItem(World world, Vector3 vec)
{
TileEntity entity = vec.getTileEntity(world);
if (entity instanceof TileTank && ((TileTank) entity).getInternalTank() != null && ((TileTank) entity).getInternalTank().getFluid() != null)
{
ItemStack itemStack = new ItemStack(Archaic.blockTank);
FluidStack stack = ((TileTank) entity).getInternalTank().getFluid();
if (stack != null)
{
if (itemStack.getTagCompound() == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
((TileTank) entity).drain(ForgeDirection.UNKNOWN, stack.amount, true);
itemStack.getTagCompound().setCompoundTag("fluid", stack.writeToNBT(new NBTTagCompound()));
}
return itemStack;
}
return null;
}
@Override
public int getItemStackLimit(ItemStack stack)
{
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("fluid"))
{
return 1;
}
return this.maxStackSize;
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
String translation = LanguageUtility.getLocal(Block.blocksList[this.getBlockID()].getUnlocalizedName() + "." + itemStack.getItemDamage());
if (translation == null || translation.isEmpty())
{
return Block.blocksList[this.getBlockID()].getUnlocalizedName();
}
return Block.blocksList[this.getBlockID()].getUnlocalizedName() + "." + itemStack.getItemDamage();
}
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
{
if (super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata))
{
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof TileFluidDistribution)
{
((TileFluidDistribution) tile).setSubID(stack.getItemDamage());
((TileFluidDistribution) tile).getInternalTank().fill(getFluid(stack), true);
}
return true;
}
return false;
}
@Override
public FluidStack getFluid(ItemStack container)
{
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("fluid"))
{
return null;
}
return FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("fluid"));
}
@Override
public int getCapacity(ItemStack container)
{
return TileTank.VOLUME;
}
@Override
public int fill(ItemStack container, FluidStack resource, boolean doFill)
{
if (resource == null)
{
return 0;
}
if (!doFill)
{
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("fluid"))
{
return Math.min(getCapacity(container), resource.amount);
}
FluidStack stack = FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("fluid"));
if (stack == null)
{
return Math.min(getCapacity(container), resource.amount);
}
if (!stack.isFluidEqual(resource))
{
return 0;
}
return Math.min(getCapacity(container) - stack.amount, resource.amount);
}
if (container.stackTagCompound == null)
{
container.stackTagCompound = new NBTTagCompound();
}
if (!container.stackTagCompound.hasKey("fluid"))
{
NBTTagCompound fluidTag = resource.writeToNBT(new NBTTagCompound());
if (getCapacity(container) < resource.amount)
{
fluidTag.setInteger("Amount", getCapacity(container));
container.stackTagCompound.setTag("fluid", fluidTag);
return getCapacity(container);
}
container.stackTagCompound.setTag("fluid", fluidTag);
return resource.amount;
}
NBTTagCompound fluidTag = container.stackTagCompound.getCompoundTag("fluid");
FluidStack stack = FluidStack.loadFluidStackFromNBT(fluidTag);
if (!stack.isFluidEqual(resource))
{
return 0;
}
int filled = getCapacity(container) - stack.amount;
if (resource.amount < filled)
{
stack.amount += resource.amount;
filled = resource.amount;
}
else
{
stack.amount = getCapacity(container);
}
container.stackTagCompound.setTag("fluid", stack.writeToNBT(fluidTag));
return filled;
}
@Override
public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain)
{
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("fluid") || maxDrain == 0)
{
return null;
}
FluidStack stack = FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("fluid"));
if (stack == null)
{
return null;
}
int drained = Math.min(stack.amount, maxDrain);
if (doDrain)
{
if (maxDrain >= stack.amount)
{
container.stackTagCompound.removeTag("fluid");
if (container.stackTagCompound.hasNoTags())
{
container.stackTagCompound = null;
}
return stack;
}
NBTTagCompound fluidTag = container.stackTagCompound.getCompoundTag("fluid");
fluidTag.setInteger("Amount", fluidTag.getInteger("Amount") - maxDrain);
container.stackTagCompound.setTag("fluid", fluidTag);
}
stack.amount = drained;
return stack;
}
}

View file

@ -3,13 +3,12 @@ package resonantinduction.archaic.fluid.tank;
import java.util.Comparator;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.Random;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.FluidStack;
import resonant.lib.utility.FluidUtility;
import resonantinduction.core.fluid.FluidDistributionetwork;
import resonantinduction.core.fluid.IFluidDistribution;
import calclavia.lib.utility.FluidUtility;
/**
* Network that handles connected tanks

View file

@ -1,15 +1,7 @@
package resonantinduction.archaic.fluid.tank;
import calclavia.lib.content.module.TileBlock.IComparatorInputOverride;
import calclavia.lib.content.module.TileRender;
import calclavia.lib.render.FluidRenderUtility;
import calclavia.lib.render.RenderUtility;
import calclavia.lib.utility.FluidUtility;
import calclavia.lib.utility.WorldUtility;
import calclavia.lib.utility.inventory.InventoryUtility;
import calclavia.lib.utility.render.RenderBlockUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.awt.Color;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -19,7 +11,17 @@ import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import org.lwjgl.opengl.GL11;
import resonant.lib.content.module.TileBlock.IComparatorInputOverride;
import resonant.lib.content.module.TileRender;
import resonant.lib.render.FluidRenderUtility;
import resonant.lib.render.RenderUtility;
import resonant.lib.utility.FluidUtility;
import resonant.lib.utility.WorldUtility;
import resonant.lib.utility.inventory.InventoryUtility;
import resonant.lib.utility.render.RenderBlockUtility;
import resonantinduction.archaic.Archaic;
import resonantinduction.core.Reference;
import resonantinduction.core.fluid.FluidDistributionetwork;
@ -27,8 +29,8 @@ import resonantinduction.core.fluid.IFluidDistribution;
import resonantinduction.core.fluid.TileFluidDistribution;
import universalelectricity.api.UniversalElectricity;
import universalelectricity.api.vector.Vector3;
import java.awt.*;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TileTank extends TileFluidDistribution implements IComparatorInputOverride
{
@ -40,7 +42,7 @@ public class TileTank extends TileFluidDistribution implements IComparatorInputO
this.getInternalTank().setCapacity(VOLUME * FluidContainerRegistry.BUCKET_VOLUME);
isOpaqueCube = false;
normalRender = false;
itemBlock = ItemBlockFluidContainer.class;
itemBlock = ItemBlockTank.class;
}
@Override
@ -56,7 +58,7 @@ public class TileTank extends TileFluidDistribution implements IComparatorInputO
{
if (player.isSneaking())
{
ItemStack dropStack = ItemBlockFluidContainer.getWrenchedItem(world(), position());
ItemStack dropStack = ItemBlockTank.getWrenchedItem(world(), position());
if (dropStack != null)
{
if (player.getHeldItem() == null)

View file

@ -5,11 +5,11 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import resonant.lib.prefab.block.BlockTile;
import resonant.lib.render.block.BlockRenderingHandler;
import resonant.lib.utility.inventory.InventoryUtility;
import resonantinduction.core.Reference;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.prefab.block.BlockTile;
import calclavia.lib.render.block.BlockRenderingHandler;
import calclavia.lib.utility.inventory.InventoryUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View file

@ -8,11 +8,11 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import resonant.lib.prefab.block.BlockTile;
import resonant.lib.utility.inventory.InventoryUtility;
import resonantinduction.core.Reference;
import resonantinduction.core.resource.ItemHandCrank;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.prefab.block.BlockTile;
import calclavia.lib.utility.inventory.InventoryUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View file

@ -7,9 +7,9 @@ import net.minecraftforge.client.model.IModelCustom;
import org.lwjgl.opengl.GL11;
import resonant.lib.render.RenderItemOverlayUtility;
import resonant.lib.render.RenderUtility;
import resonantinduction.core.Reference;
import calclavia.lib.render.RenderItemOverlayUtility;
import calclavia.lib.render.RenderUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View file

@ -3,7 +3,7 @@ package resonantinduction.archaic.process;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import calclavia.lib.render.RenderItemOverlayUtility;
import resonant.lib.render.RenderItemOverlayUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View file

@ -10,15 +10,15 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import resonant.api.recipe.MachineRecipes;
import resonant.api.recipe.RecipeResource;
import resonant.lib.network.IPacketReceiver;
import resonant.lib.network.PacketHandler;
import resonant.lib.prefab.tile.TileExternalInventory;
import resonant.lib.utility.FluidUtility;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.ResonantInduction.RecipeType;
import universalelectricity.api.vector.Vector3;
import calclavia.api.recipe.MachineRecipes;
import calclavia.api.recipe.RecipeResource;
import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.PacketHandler;
import calclavia.lib.prefab.tile.TileExternalInventory;
import calclavia.lib.utility.FluidUtility;
import com.google.common.io.ByteArrayDataInput;

View file

@ -5,15 +5,15 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import net.minecraftforge.common.ForgeDirection;
import resonant.api.recipe.MachineRecipes;
import resonant.api.recipe.RecipeResource;
import resonant.lib.network.IPacketReceiver;
import resonant.lib.network.PacketHandler;
import resonant.lib.prefab.tile.TileExternalInventory;
import resonant.lib.utility.inventory.InventoryUtility;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.ResonantInduction.RecipeType;
import universalelectricity.api.vector.Vector3;
import calclavia.api.recipe.MachineRecipes;
import calclavia.api.recipe.RecipeResource;
import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.PacketHandler;
import calclavia.lib.prefab.tile.TileExternalInventory;
import calclavia.lib.utility.inventory.InventoryUtility;
import com.google.common.io.ByteArrayDataInput;

View file

@ -0,0 +1,36 @@
package resonantinduction.archaic.waila;
import resonant.lib.modproxy.ICompatProxy;
import resonant.lib.utility.Mods;
import cpw.mods.fml.common.event.FMLInterModComms;
/**
* @since 21/03/14
* @author tgame14
*/
public class Waila implements ICompatProxy
{
@Override
public void preInit ()
{
// nothing
}
@Override
public void init ()
{
FMLInterModComms.sendMessage(Mods.WAILA(), "register", "resonantinduction.archaic.waila.WailaRegistrar.wailaCallBack");
}
@Override
public void postInit ()
{
// nothing
}
@Override
public String modId ()
{
return Mods.WAILA();
}
}

View file

@ -0,0 +1,57 @@
package resonantinduction.archaic.waila;
import java.util.List;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import resonant.lib.utility.LanguageUtility;
import resonantinduction.archaic.crate.TileCrate;
/** Waila support for crates
*
* @author Darkguardsman */
public class WailaCrate implements IWailaDataProvider
{
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config)
{
TileEntity tile = accessor.getTileEntity();
if (tile instanceof TileCrate)
{
ItemStack stored = ((TileCrate) tile).getSampleStack();
int cap = ((TileCrate) tile).getSlotCount() * 64;
if (stored != null)
{
currenttip.add(LanguageUtility.getLocal("info.waila.crate.stack") + " " + stored.getDisplayName());
currenttip.add(LanguageUtility.getLocal("info.waila.crate.stored") + " " + stored.stackSize + " / " + cap);
}
else
{
currenttip.add(LanguageUtility.getLocal("info.waila.crate.empty"));
}
}
return currenttip;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config)
{
return currenttip;
}
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config)
{
return null;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config)
{
return currenttip;
}
}

View file

@ -0,0 +1,57 @@
package resonantinduction.archaic.waila;
import java.util.List;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.FluidTank;
import resonant.lib.utility.LanguageUtility;
import resonantinduction.archaic.fluid.tank.TileTank;
/** Waila support for tanks
*
* @author Darkguardsman */
public class WailaFluidTank implements IWailaDataProvider
{
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config)
{
TileEntity tile = accessor.getTileEntity();
if (tile instanceof TileTank)
{
FluidTank tank = ((TileTank) tile).getInternalTank();
if (tank != null && tank.getFluid() != null)
{
currenttip.add(LanguageUtility.getLocal("info.waila.tank.fluid") + " " + tank.getFluid().getFluid().getLocalizedName());
currenttip.add(LanguageUtility.getLocal("info.waila.tank.vol") + " " + tank.getFluidAmount() + " / " + tank.getCapacity());
}
else
{
currenttip.add(LanguageUtility.getLocal("info.waila.tank.empty"));
}
}
return currenttip;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config)
{
return currenttip;
}
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config)
{
return null;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config)
{
return currenttip;
}
}

View file

@ -0,0 +1,14 @@
package resonantinduction.archaic.waila;
import mcp.mobius.waila.api.IWailaRegistrar;
import resonantinduction.archaic.crate.TileCrate;
import resonantinduction.archaic.fluid.tank.TileTank;
public class WailaRegistrar
{
public static void wailaCallBack(IWailaRegistrar registrar)
{
registrar.registerBodyProvider(new WailaCrate(), TileCrate.class);
registrar.registerBodyProvider(new WailaFluidTank(), TileTank.class);
}
}

View file

@ -1,137 +0,0 @@
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.0-SNAPSHOT'
}
}
apply plugin: 'forge'
apply plugin: 'maven-publish'
sourceSets {
main {
java {
srcDirs 'src/main/java', 'archaic/src/main/java', 'electrical/src/main/java', 'mechanical/src/main/java'
//exclude 'resonantinduction/core/nei/**'
}
}
}
ext.buildProps = file "build.properties"
buildProps.withReader {
def prop = new Properties()
prop.load(it)
ext.config = new ConfigSlurper().parse prop
}
version = "${config.version.mod.major}.${config.version.mod.minor}.${config.version.mod.revis}"
group = "resonantinduction"
archivesBaseName = "${System.getenv().JOB_NAME}"
minecraft {
version = "${config.version.minecraft}-${config.version.forge}"
replaceIn "Reference.java"
replace "@MAJOR@", config.version.mod.major
replace "@MINOR@", config.version.mod.minor
replace "@REVIS@", config.version.mod.revis
replace "@BUILD@", System.getenv("BUILD_NUMBER")
}
if (System.getenv("BUILD_NUMBER") != null)
version += ".${System.getenv("BUILD_NUMBER")}"
processResources {
from 'build.properties'
}
task copyBuildXml(type: Copy) {
from 'build.properties'
into 'output'
}
task apiZip(type: Zip) {
classifier = 'api'
from sourceSets*.allSource
include 'resonantinduction/api/**'
destinationDir = file 'output'
}
artifacts {
archives apiZip
}
jar {
dependsOn copyBuildXml
classifier = ''
destinationDir = file 'output'
}
repositories {
maven {
name 'Calclavia Maven'
url 'http://calclavia.com/maven'
}
ivy {
name 'FMP'
artifactPattern "http://files.minecraftforge.net/[module]/[module]-dev-[revision].[ext]"
}
ivy {
artifactPattern "http://www.chickenbones.craftsaddle.org/Files/New_Versions/1.6.4/[module]-dev%20[revision].[ext]"
}
}
dependencies {
compile group: 'universalelectricity', name: 'Universal-Electricity', version: "${config.version.universalelectricity}", classifier: "dev"
compile group: 'calclaviacore', name: 'calclavia-core', version: "${config.version.calclaviacore}", classifier: "dev"
compile name: 'CodeChickenLib', version: "${config.version.minecraft}-${config.version.cclib}", ext: 'jar'
compile name: 'ForgeMultipart', version: "${config.version.minecraft}-${config.version.fmp}", ext: 'jar'
compile name: 'NotEnoughItems', version: "${config.version.nei}", ext: 'jar'
compile name: 'CodeChickenCore', version: "${config.version.cccore}", ext: 'jar'
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
/*artifact apiZip*/
artifact {
file 'output/build.properties'
}
}
}
repositories {
maven {
url "file://var/www/maven"
}
}
}
import net.minecraftforge.gradle.tasks.dev.ChangelogTask
import net.minecraftforge.gradle.common.Constants
import net.minecraftforge.gradle.delayed.*
task createChangelog(type: ChangelogTask) {
def jobName = "${System.getenv().JOB_NAME}"
def buildNumber = "${System.getenv().BUILD_NUMBER}"
jobName.replaceAll(' ','%20')
setServerRoot(new DelayedString(project, 'http://ci.calclavia.com/'))
setJobName(new DelayedString(project, jobName.toString()));
setAuthName(new DelayedString(project, 'console_script'));
setAuthPassword(new DelayedString(project, '625d2ac53190be3422faa0c474fb299b'));
setTargetBuild({buildNumber.toString()});
setOutput(new DelayedFile(project, 'output/' + jobName + "-${project.version}" + '-changelog' + '.txt'));
}
build.dependsOn "createChangelog"

View file

@ -67,10 +67,7 @@ allprojects {
dependencies {
compile group: 'universalelectricity', name: 'Universal-Electricity', version: "${rootProject.config.version.universalelectricity}", classifier: "dev"
if (System.getenv().JOB_NAME == "Resonant-Induction-Development")
compile group: 'calclavia-core-development', name: 'calclavia-core', version: "${rootProject.config.version.calclaviacore}", classifier: "dev"
else
compile group: 'calclavia-core', name: 'calclavia-core', version: "${config.version.calclaviacore}", classifier: "dev"
compile group: 'resonant-engine-development', name: 'resonant-engine', version: "${config.version.resonantengine}", classifier: "dev"
compile name: 'CodeChickenLib', version: "${config.version.minecraft}-${config.version.cclib}", ext: 'jar'
compile name: 'ForgeMultipart', version: "${config.version.minecraft}-${config.version.fmp}", ext: 'jar'
@ -99,8 +96,8 @@ allprojects {
}
subprojects {
archivesBaseName = "${System.getenv().JOB_NAME}"
archivesBaseName = "${System.getenv().JOB_NAME}"
sourceSets.main.compileClasspath += rootProject.sourceSets.api.output
dependencies {
compile rootProject
}
@ -127,7 +124,7 @@ task apiZip(type: Zip) {
include 'resonantinduction/api/**'
destinationDir = file 'output'
}
artifacts {
archives apiZip
}

View file

@ -3,7 +3,7 @@ dir.mcp=${dir.development}forge/mcp
version.minecraft=1.6.4
version.forge=9.11.1.964
version.universalelectricity=3.1.+
version.calclaviacore=1.2.+
version.resonantengine=1.2.+
version.cclib=1.0.0.61
version.cccore=0.9.0.9
version.fmp=1.0.0.244

View file

@ -3,12 +3,14 @@ package resonantinduction.electrical;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import resonant.lib.render.item.GlobalItemRenderer;
import resonantinduction.electrical.battery.RenderBattery;
import resonantinduction.electrical.battery.TileBattery;
import resonantinduction.electrical.charger.RenderCharger;
import resonantinduction.electrical.encoder.TileEncoder;
import resonantinduction.electrical.encoder.gui.GuiEncoderInventory;
import resonantinduction.electrical.generator.solar.TileSolarPanel;
import resonantinduction.electrical.laser.gun.RenderMiningLaserGun;
import resonantinduction.electrical.levitator.RenderLevitator;
import resonantinduction.electrical.multimeter.GuiMultimeter;
import resonantinduction.electrical.multimeter.PartMultimeter;
@ -19,7 +21,6 @@ import resonantinduction.electrical.tesla.TileTesla;
import resonantinduction.electrical.transformer.RenderTransformer;
import resonantinduction.quantum.gate.RenderQuantumGlyph;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.render.item.GlobalItemRenderer;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TileMultipart;
import cpw.mods.fml.client.FMLClientHandler;
@ -40,6 +41,7 @@ public class ClientProxy extends CommonProxy
GlobalItemRenderer.register(Electrical.itemCharger.itemID, RenderCharger.INSTANCE);
GlobalItemRenderer.register(Electrical.itemLevitator.itemID, RenderLevitator.INSTANCE);
GlobalItemRenderer.register(Electrical.itemQuantumGlyph.itemID, RenderQuantumGlyph.INSTANCE);
MinecraftForgeClient.registerItemRenderer(Electrical.itemLaserGun.itemID, new RenderMiningLaserGun());
ClientRegistry.bindTileEntitySpecialRenderer(TileTesla.class, new RenderTesla());
ClientRegistry.bindTileEntitySpecialRenderer(TileBattery.class, new RenderBattery());
}

View file

@ -5,12 +5,12 @@ import java.awt.Color;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import resonant.lib.prefab.ProxyBase;
import resonantinduction.electrical.encoder.TileEncoder;
import resonantinduction.electrical.encoder.gui.ContainerEncoder;
import resonantinduction.electrical.multimeter.ContainerMultimeter;
import resonantinduction.electrical.multimeter.PartMultimeter;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.prefab.ProxyBase;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TileMultipart;

View file

@ -7,6 +7,10 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import resonant.lib.content.ContentRegistry;
import resonant.lib.modproxy.ProxyHandler;
import resonant.lib.network.PacketHandler;
import resonant.lib.recipe.UniversalRecipe;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.Settings;
@ -21,6 +25,8 @@ import resonantinduction.electrical.generator.TileMotor;
import resonantinduction.electrical.generator.solar.TileSolarPanel;
import resonantinduction.electrical.generator.thermopile.BlockThermopile;
import resonantinduction.electrical.generator.thermopile.TileThermopile;
import resonantinduction.electrical.itemrailing.ItemItemRailing;
import resonantinduction.electrical.laser.gun.ItemMiningLaser;
import resonantinduction.electrical.levitator.ItemLevitator;
import resonantinduction.electrical.multimeter.ItemMultimeter;
import resonantinduction.electrical.tesla.BlockTesla;
@ -29,9 +35,6 @@ import resonantinduction.electrical.transformer.ItemTransformer;
import resonantinduction.electrical.wire.EnumWireMaterial;
import resonantinduction.electrical.wire.ItemWire;
import resonantinduction.quantum.gate.ItemQuantumGlyph;
import calclavia.lib.content.ContentRegistry;
import calclavia.lib.network.PacketHandler;
import calclavia.lib.recipe.UniversalRecipe;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
@ -77,7 +80,10 @@ public class Electrical
public static Item itemCharger;
public static Block blockTesla;
public static Block blockBattery;
public static Block blockEncoder;
public static Block blockEncoder;
// Railings
public static Item itemRailing;
// Generators
public static Block blockSolarPanel;
@ -93,10 +99,16 @@ public class Electrical
// Quantum
public static Block blockQuantumGate;
public static Item itemQuantumGlyph;
// Tools
public static Item itemLaserGun;
public ProxyHandler modproxies;
@EventHandler
public void preInit(FMLPreInitializationEvent evt)
{
modproxies = new ProxyHandler();
NetworkRegistry.instance().registerGuiHandler(this, proxy);
Settings.CONFIGURATION.load();
@ -115,6 +127,7 @@ public class Electrical
// blockEncoder = contentRegistry.createTile(BlockEncoder.cass);
// itemDisk = contentRegistry.createItem(ItemDisk.class);
itemInsulation = contentRegistry.createItem("insulation", ItemResourcePart.class);
itemLaserGun = contentRegistry.createItem("laserDrill", ItemMiningLaser.class);
// Generator
blockSolarPanel = contentRegistry.newBlock(TileSolarPanel.class);
@ -123,6 +136,10 @@ public class Electrical
// Quantum
itemQuantumGlyph = contentRegistry.createItem(ItemQuantumGlyph.class);
//Railings
itemRailing = contentRegistry.createItem(ItemItemRailing.class);
Settings.CONFIGURATION.save();
OreDictionary.registerOre("wire", itemWire);
@ -141,6 +158,7 @@ public class Electrical
}
proxy.preInit();
modproxies.preInit();
}
@EventHandler
@ -149,6 +167,7 @@ public class Electrical
Settings.setModMetadata(metadata, ID, NAME, ResonantInduction.ID);
MultipartElectrical.INSTANCE = new MultipartElectrical();
proxy.init();
modproxies.init();
}
@EventHandler
@ -176,8 +195,8 @@ public class Electrical
GameRegistry.addRecipe(new ShapedOreRecipe(tierThreeBattery, "RRR", "RIR", "RRR", 'R', tierTwoBattery, 'I', Block.blockDiamond));
/** Wires **/
GameRegistry.addRecipe(new ShapelessOreRecipe(itemInsulation, Item.slimeBall, new ItemStack(Block.cloth, 2, OreDictionary.WILDCARD_VALUE)));
GameRegistry.addRecipe(new ShapelessOreRecipe(itemInsulation, "slimeball", new ItemStack(Block.cloth, 2, OreDictionary.WILDCARD_VALUE)));
//GameRegistry.addRecipe(new ShapelessOreRecipe(itemInsulation, Item.slimeBall, new ItemStack(Block.cloth, 2, OreDictionary.WILDCARD_VALUE)));
//GameRegistry.addRecipe(new ShapelessOreRecipe(itemInsulation, "slimeball", new ItemStack(Block.cloth, 2, OreDictionary.WILDCARD_VALUE)));
GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.COPPER.getWire(3), "MMM", 'M', "ingotCopper"));
GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.TIN.getWire(3), "MMM", 'M', "ingotTin"));
@ -189,7 +208,7 @@ public class Electrical
GameRegistry.addRecipe(new ShapedOreRecipe(itemCharger, "WWW", "ICI", 'W', "wire", 'I', UniversalRecipe.PRIMARY_METAL.get(), 'C', UniversalRecipe.CIRCUIT_T1.get()));
GameRegistry.addRecipe(new ShapedOreRecipe(itemTransformer, "WWW", "WWW", "III", 'W', "wire", 'I', UniversalRecipe.PRIMARY_METAL.get()));
GameRegistry.addRecipe(new ShapedOreRecipe(itemLevitator, " G ", "SDS", "SWS", 'W', "wire", 'G', Block.glass, 'D', Block.blockDiamond, 'S', UniversalRecipe.PRIMARY_METAL.get()));
//GameRegistry.addRecipe(new ShapedOreRecipe(itemLevitator, " G ", "SDS", "SWS", 'W', "wire", 'G', Block.glass, 'D', Block.blockDiamond, 'S', UniversalRecipe.PRIMARY_METAL.get()));
/** Quantum Gates */
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemQuantumGlyph, 1, 0), " CT", "LBL", "TCT", 'B', Block.blockDiamond, 'L', itemLevitator, 'C', itemCharger, 'T', blockTesla));
@ -202,6 +221,9 @@ public class Electrical
GameRegistry.addRecipe(new ShapedOreRecipe(blockMotor, "SRS", "SMS", "SWS", 'W', "wire", 'R', Item.redstone, 'M', Block.blockIron, 'S', UniversalRecipe.PRIMARY_METAL.get()));
GameRegistry.addRecipe(new ShapedOreRecipe(blockThermopile, "ORO", "OWO", "OOO", 'W', "wire", 'O', Block.obsidian, 'R', Item.redstone));
GameRegistry.addRecipe(new ShapedOreRecipe(itemLaserGun, "RDR", "RDR", "ICB", 'R', Item.redstone, 'D', Item.diamond, 'I', Item.ingotGold, 'C', UniversalRecipe.CIRCUIT_T2.get(), 'B', ItemBlockBattery.setTier(new ItemStack(blockBattery, 1, 0), (byte) 0)));
/** Wire Compatiblity **/
if (Loader.isModLoaded("IC2"))
{
@ -217,5 +239,6 @@ public class Electrical
}
proxy.postInit();
modproxies.postInit();
}
}

View file

@ -1,6 +1,7 @@
package resonantinduction.electrical;
import resonantinduction.electrical.charger.PartCharger;
import resonantinduction.electrical.itemrailing.PartRailing;
import resonantinduction.electrical.levitator.PartLevitator;
import resonantinduction.electrical.multimeter.PartMultimeter;
import resonantinduction.electrical.transformer.PartTransformer;
@ -18,7 +19,7 @@ public class MultipartElectrical implements IPartFactory
{
public static MultipartElectrical INSTANCE;
public static final String[] PART_TYPES = { "resonant_induction_quantum_glyph", "resonant_induction_wire", "resonant_induction_switch_wire", "resonant_induction_flat_wire", "resonant_induction_flat_switch_wire", "resonant_induction_multimeter", "resonant_induction_transformer", "resonant_induction_charger", "resonant_induction_levitator" };
public static final String[] PART_TYPES = { "resonant_induction_quantum_glyph", "resonant_induction_wire", "resonant_induction_switch_wire", "resonant_induction_flat_wire", "resonant_induction_flat_switch_wire", "resonant_induction_multimeter", "resonant_induction_transformer", "resonant_induction_charger", "resonant_induction_levitator", "resonant_induction_itemrailing" };
public MultipartElectrical()
{
@ -51,6 +52,8 @@ public class MultipartElectrical implements IPartFactory
return new PartLevitator();
else if (name.equals("resonant_induction_quantum_glyph"))
return new PartQuantumGlyph();
else if (name.equals("resonant_induction_itemrailing"))
return new PartRailing();
return null;
}

View file

@ -7,95 +7,95 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import resonant.core.ResonantEngine;
import resonant.lib.multiblock.IBlockActivate;
import resonant.lib.multiblock.IMultiBlock;
import resonant.lib.prefab.block.BlockTile;
import resonant.lib.render.block.BlockRenderingHandler;
import universalelectricity.api.UniversalElectricity;
import calclavia.components.CalclaviaLoader;
import calclavia.lib.multiblock.fake.IBlockActivate;
import calclavia.lib.multiblock.fake.IMultiBlock;
import calclavia.lib.prefab.block.BlockTile;
import calclavia.lib.render.block.BlockRenderingHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockArmbot extends BlockTile
{
public BlockArmbot(int id)
{
super(id, UniversalElectricity.machine);
}
public BlockArmbot(int id)
{
super(id, UniversalElectricity.machine);
}
@Override
public boolean canBlockStay(World world, int x, int y, int z)
{
return world.getBlockMaterial(x, y - 1, z).isSolid();
}
@Override
public boolean canBlockStay(World world, int x, int y, int z)
{
return world.getBlockMaterial(x, y - 1, z).isSolid();
}
@Override
public void onBlockAdded(World world, int x, int y, int z)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
@Override
public void onBlockAdded(World world, int x, int y, int z)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity instanceof IMultiBlock)
{
CalclaviaLoader.blockMulti.createMultiBlockStructure((IMultiBlock) tileEntity);
}
}
if (tileEntity instanceof IMultiBlock)
{
ResonantEngine.blockMulti.createMultiBlockStructure((IMultiBlock) tileEntity);
}
}
@Override
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
@Override
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity instanceof IBlockActivate)
{
return ((IBlockActivate) tileEntity).onActivated(player);
}
if (tileEntity instanceof IBlockActivate)
{
return ((IBlockActivate) tileEntity).onActivated(player);
}
return false;
}
return false;
}
@Override
public void breakBlock(World world, int x, int y, int z, int par5, int par6)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
@Override
public void breakBlock(World world, int x, int y, int z, int par5, int par6)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity instanceof TileArmbot)
{
((TileArmbot) tileEntity).dropHeldObject();
CalclaviaLoader.blockMulti.destroyMultiBlockStructure((TileArmbot) tileEntity);
}
if (tileEntity instanceof TileArmbot)
{
((TileArmbot) tileEntity).dropHeldObject();
ResonantEngine.blockMulti.destroyMultiBlockStructure((TileArmbot) tileEntity);
}
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(this));
super.breakBlock(world, x, y, z, par5, par6);
}
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(this));
super.breakBlock(world, x, y, z, par5, par6);
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
return new ItemStack(this);
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
return new ItemStack(this);
}
@Override
public int quantityDropped(Random par1Random)
{
return 0;
}
@Override
public int quantityDropped(Random par1Random)
{
return 0;
}
@Override
public TileEntity createNewTileEntity(World var1)
{
return new TileArmbot();
}
@Override
public TileEntity createNewTileEntity(World var1)
{
return new TileArmbot();
}
@SideOnly(Side.CLIENT)
@Override
public int getRenderType()
{
return BlockRenderingHandler.ID;
}
@SideOnly(Side.CLIENT)
@Override
public int getRenderType()
{
return BlockRenderingHandler.ID;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
}

View file

@ -7,13 +7,13 @@ import java.util.Map.Entry;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import resonant.lib.utility.nbt.NBTUtility;
import resonantinduction.electrical.encoder.coding.ILogicTask;
import resonantinduction.electrical.encoder.coding.IProgram;
import resonantinduction.electrical.encoder.coding.IProgrammableMachine;
import resonantinduction.electrical.encoder.coding.ITask;
import resonantinduction.electrical.encoder.coding.TaskRegistry;
import universalelectricity.api.vector.Vector2;
import calclavia.lib.utility.nbt.NBTUtility;
public class Program implements IProgram
{

View file

@ -14,10 +14,10 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import resonant.api.items.ISimpleItemRenderer;
import resonant.lib.render.RenderUtility;
import resonantinduction.core.Reference;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.render.RenderUtility;
import calclavia.lib.render.item.ISimpleItemRenderer;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View file

@ -5,12 +5,12 @@ import java.util.List;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import resonant.lib.utility.nbt.NBTUtility;
import resonantinduction.core.ArgumentData;
import resonantinduction.electrical.encoder.coding.IProgram;
import resonantinduction.electrical.encoder.coding.IProgrammableMachine;
import resonantinduction.electrical.encoder.coding.ITask;
import universalelectricity.api.vector.Vector2;
import calclavia.lib.utility.nbt.NBTUtility;
/** @author DarkGuardsman */
public abstract class TaskBase implements ITask

View file

@ -1,10 +1,10 @@
package resonantinduction.electrical.armbot;
import calclavia.lib.science.units.UnitHelper;
import net.minecraft.item.ItemStack;
import resonant.lib.science.units.UnitHelper;
import resonantinduction.electrical.encoder.coding.IProcessTask;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import net.minecraft.item.ItemStack;
import resonantinduction.electrical.encoder.coding.IProcessTask;
/**
* Basic command prefab used by machines like an armbot. You are not required to use this in order

View file

@ -9,6 +9,13 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import resonant.lib.multiblock.IMultiBlock;
import resonant.lib.network.IPacketReceiverWithID;
import resonant.lib.network.PacketHandler;
import resonant.lib.prefab.tile.TileElectrical;
import resonant.lib.type.Pair;
import resonant.lib.utility.MathUtility;
import resonant.lib.utility.inventory.InventoryUtility;
import resonantinduction.core.ResonantInduction;
import resonantinduction.electrical.armbot.task.TaskDrop;
import resonantinduction.electrical.armbot.task.TaskGOTO;
@ -20,13 +27,6 @@ import resonantinduction.electrical.encoder.coding.ProgramHelper;
import universalelectricity.api.energy.EnergyStorageHandler;
import universalelectricity.api.vector.Vector2;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.type.Pair;
import calclavia.lib.multiblock.fake.IMultiBlock;
import calclavia.lib.network.IPacketReceiverWithID;
import calclavia.lib.network.PacketHandler;
import calclavia.lib.prefab.tile.TileElectrical;
import calclavia.lib.utility.MathUtility;
import calclavia.lib.utility.inventory.InventoryUtility;
import com.google.common.io.ByteArrayDataInput;

View file

@ -7,13 +7,13 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import resonant.lib.type.Pair;
import resonant.lib.utility.inventory.InventoryUtility;
import resonantinduction.electrical.armbot.IArmbot;
import resonantinduction.electrical.armbot.TaskBaseArmbot;
import resonantinduction.electrical.armbot.TaskBaseProcess;
import resonantinduction.electrical.encoder.coding.ITask;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.type.Pair;
import calclavia.lib.utility.inventory.InventoryUtility;
/**
* Used by arms to break a specific block in a position.

View file

@ -9,13 +9,13 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import resonant.lib.science.units.UnitHelper;
import resonant.lib.type.Pair;
import resonantinduction.electrical.armbot.IArmbot;
import resonantinduction.electrical.armbot.TaskBaseArmbot;
import resonantinduction.electrical.armbot.TaskBaseProcess;
import resonantinduction.electrical.encoder.coding.args.ArgumentFloatData;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.type.Pair;
import calclavia.lib.science.units.UnitHelper;
public class TaskFire extends TaskBaseArmbot
{

View file

@ -8,15 +8,15 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import resonant.lib.science.units.UnitHelper;
import resonant.lib.utility.MathUtility;
import resonant.lib.utility.inventory.InternalInventoryHandler;
import resonantinduction.electrical.armbot.IArmbot;
import resonantinduction.electrical.armbot.TaskBaseArmbot;
import resonantinduction.electrical.armbot.TaskBaseProcess;
import resonantinduction.electrical.encoder.coding.args.ArgumentIntData;
import universalelectricity.api.vector.Vector2;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.science.units.UnitHelper;
import calclavia.lib.utility.MathUtility;
import calclavia.lib.utility.inventory.InternalInventoryHandler;
public class TaskGive extends TaskBaseArmbot
{

View file

@ -8,10 +8,10 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import resonant.api.ai.EntitySettings;
import resonantinduction.core.ArgumentData;
import resonantinduction.electrical.armbot.IArmbot;
import resonantinduction.electrical.armbot.TaskBaseProcess;
import calclavia.api.resonantinduction.electrical.ArmbotEntity;
public class TaskGrabEntity extends TaskGrabPrefab
{
@ -98,7 +98,7 @@ public class TaskGrabEntity extends TaskGrabPrefab
{
super.loadProgress(taskCompound);
this.child = taskCompound.getBoolean("child");
this.entityToInclude = ArmbotEntity.get(taskCompound.getString("name"));
this.entityToInclude = EntitySettings.get(taskCompound.getString("name"));
}
@Override
@ -106,7 +106,7 @@ public class TaskGrabEntity extends TaskGrabPrefab
{
super.saveProgress(taskCompound);
taskCompound.setBoolean("child", child);
taskCompound.setString("name", ((this.entityToInclude != null) ? ArmbotEntity.get(this.entityToInclude) : ""));
taskCompound.setString("name", ((this.entityToInclude != null) ? EntitySettings.get(this.entityToInclude) : ""));
}
@Override
@ -116,7 +116,7 @@ public class TaskGrabEntity extends TaskGrabPrefab
String entity = "";
if (this.entityToInclude != null)
{
entity = ArmbotEntity.get(this.entityToInclude);
entity = EntitySettings.get(this.entityToInclude);
if (this.child)
{
// TODO do check for EntityAgable

View file

@ -6,10 +6,10 @@ import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import resonant.lib.science.units.UnitHelper;
import resonantinduction.electrical.armbot.IArmbot;
import resonantinduction.electrical.armbot.TaskBaseProcess;
import resonantinduction.electrical.encoder.coding.args.ArgumentIntData;
import calclavia.lib.science.units.UnitHelper;
public class TaskGrabItem extends TaskGrabPrefab
{

View file

@ -2,11 +2,11 @@ package resonantinduction.electrical.armbot.task;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import resonant.api.IEntityConveyor;
import resonantinduction.electrical.armbot.IArmbot;
import resonantinduction.electrical.armbot.TaskBaseArmbot;
import universalelectricity.api.vector.Vector2;
import universalelectricity.api.vector.Vector3;
import calclavia.api.resonantinduction.mechanical.IBelt;
/**
* Prefab for grab based commands
@ -17,7 +17,7 @@ public abstract class TaskGrabPrefab extends TaskBaseArmbot
{
public static final float radius = 0.5f;
protected Vector3 armPos;
protected IBelt belt;
protected IEntityConveyor belt;
public TaskGrabPrefab(String name)
{
@ -37,9 +37,9 @@ public abstract class TaskGrabPrefab extends TaskBaseArmbot
{
entity = this.armPos.clone().translate(new Vector3(ForgeDirection.DOWN)).getTileEntity(this.program.getMachine().getLocation().left());
}
if (entity instanceof IBelt)
if (entity instanceof IEntityConveyor)
{
this.belt = (IBelt) entity;
this.belt = (IEntityConveyor) entity;
}
return ProcessReturn.CONTINUE;
}

View file

@ -3,10 +3,10 @@ package resonantinduction.electrical.armbot.task;
import java.util.List;
import net.minecraft.nbt.NBTTagCompound;
import resonant.lib.science.units.UnitHelper;
import resonantinduction.core.ArgumentData;
import resonantinduction.electrical.armbot.TaskBaseProcess;
import resonantinduction.electrical.encoder.coding.IProgrammableMachine;
import calclavia.lib.science.units.UnitHelper;
public class TaskIdle extends TaskBaseProcess
{

View file

@ -3,13 +3,13 @@ package resonantinduction.electrical.armbot.task;
import java.util.List;
import net.minecraft.nbt.NBTTagCompound;
import resonant.lib.science.units.UnitHelper;
import resonant.lib.utility.MathUtility;
import resonantinduction.electrical.armbot.IArmbot;
import resonantinduction.electrical.armbot.TaskBaseArmbot;
import resonantinduction.electrical.armbot.TaskBaseProcess;
import resonantinduction.electrical.encoder.coding.args.ArgumentIntData;
import universalelectricity.api.vector.Vector2;
import calclavia.lib.science.units.UnitHelper;
import calclavia.lib.utility.MathUtility;
/**
* Rotates an armbot by a set amount

View file

@ -3,13 +3,13 @@ package resonantinduction.electrical.armbot.task;
import java.util.List;
import net.minecraft.nbt.NBTTagCompound;
import resonant.lib.science.units.UnitHelper;
import resonant.lib.utility.MathUtility;
import resonantinduction.electrical.armbot.IArmbot;
import resonantinduction.electrical.armbot.TaskBaseArmbot;
import resonantinduction.electrical.armbot.TaskBaseProcess;
import resonantinduction.electrical.encoder.coding.args.ArgumentIntData;
import universalelectricity.api.vector.Vector2;
import calclavia.lib.science.units.UnitHelper;
import calclavia.lib.utility.MathUtility;
/**
* Rotates the armbot to a specific direction.

View file

@ -8,15 +8,15 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import resonant.lib.science.units.UnitHelper;
import resonant.lib.utility.MathUtility;
import resonant.lib.utility.inventory.InternalInventoryHandler;
import resonantinduction.electrical.armbot.IArmbot;
import resonantinduction.electrical.armbot.TaskBaseArmbot;
import resonantinduction.electrical.armbot.TaskBaseProcess;
import resonantinduction.electrical.encoder.coding.args.ArgumentIntData;
import universalelectricity.api.vector.Vector2;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.science.units.UnitHelper;
import calclavia.lib.utility.MathUtility;
import calclavia.lib.utility.inventory.InternalInventoryHandler;
public class TaskTake extends TaskBaseArmbot
{

View file

@ -5,13 +5,13 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import resonant.lib.science.units.UnitHelper;
import resonantinduction.electrical.armbot.IArmbot;
import resonantinduction.electrical.armbot.IArmbotUseable;
import resonantinduction.electrical.armbot.TaskBaseArmbot;
import resonantinduction.electrical.armbot.TaskBaseProcess;
import resonantinduction.electrical.encoder.coding.IProcessTask;
import resonantinduction.electrical.encoder.coding.args.ArgumentIntData;
import calclavia.lib.science.units.UnitHelper;
public class TaskUse extends TaskBaseArmbot
{

View file

@ -13,12 +13,12 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import resonant.lib.prefab.block.BlockSidedIO;
import resonant.lib.render.block.BlockRenderingHandler;
import resonant.lib.utility.inventory.InventoryUtility;
import resonantinduction.core.Reference;
import universalelectricity.api.CompatibilityModule;
import universalelectricity.api.UniversalElectricity;
import calclavia.lib.prefab.block.BlockSidedIO;
import calclavia.lib.render.block.BlockRenderingHandler;
import calclavia.lib.utility.inventory.InventoryUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -64,8 +64,8 @@ public class BlockBattery extends BlockSidedIO implements ITileEntityProvider
{
ItemBlockBattery itemBlock = (ItemBlockBattery) itemStack.getItem();
TileBattery battery = (TileBattery) world.getBlockTileEntity(x, y, z);
battery.energy.setCapacity(TileBattery.getEnergyForTier(ItemBlockBattery.getTier(itemStack)));
battery.energy.setEnergy(itemBlock.getEnergy(itemStack));
battery.getEnergyHandler().setCapacity(TileBattery.getEnergyForTier(ItemBlockBattery.getTier(itemStack)));
battery.getEnergyHandler().setEnergy(itemBlock.getEnergy(itemStack));
battery.updateStructure();
world.setBlockMetadataWithNotify(x, y, z, ItemBlockBattery.getTier(itemStack), 3);
}
@ -98,7 +98,7 @@ public class BlockBattery extends BlockSidedIO implements ITileEntityProvider
TileBattery battery = (TileBattery) world.getBlockTileEntity(x, y, z);
ItemBlockBattery itemBlock = (ItemBlockBattery) itemStack.getItem();
ItemBlockBattery.setTier(itemStack, (byte) world.getBlockMetadata(x, y, z));
itemBlock.setEnergy(itemStack, battery.energy.getEnergy());
itemBlock.setEnergy(itemStack, battery.getEnergyHandler().getEnergy());
}
ret.add(itemStack);
return ret;
@ -146,6 +146,6 @@ public class BlockBattery extends BlockSidedIO implements ITileEntityProvider
}
TileBattery battery = (TileBattery) world.getBlockTileEntity(x, y, z);
return CompatibilityModule.getItemWithCharge(ItemBlockBattery.setTier(new ItemStack(id, 1, 0), (byte) world.getBlockMetadata(x, y, z)), battery.energy.getEnergy());
return CompatibilityModule.getItemWithCharge(ItemBlockBattery.setTier(new ItemStack(id, 1, 0), (byte) world.getBlockMetadata(x, y, z)), battery.getEnergyHandler().getEnergy());
}
}

View file

@ -6,106 +6,104 @@ import java.util.Set;
import universalelectricity.core.net.Network;
/** Energy network designed to allow several tiles to act as if they share the same energy
* level */
public class EnergyDistributionNetwork extends Network<EnergyDistributionNetwork, TileEnergyDistribution>
{
public long totalEnergy = 0;
public long totalCapacity = 0;
public long totalEnergy = 0;
public long totalCapacity = 0;
public EnergyDistributionNetwork()
{
super(TileEnergyDistribution.class);
}
public EnergyDistributionNetwork()
{
super(TileEnergyDistribution.class);
}
public void redistribute(TileEnergyDistribution... exclusion)
{
int lowestY = 255, highestY = 0;
public void redistribute(TileEnergyDistribution... exclusion)
{
int lowestY = 255, highestY = 0;
totalEnergy = 0;
totalCapacity = 0;
totalEnergy = 0;
totalCapacity = 0;
for (TileEnergyDistribution connector : this.getConnectors())
{
totalEnergy += connector.energy.getEnergy();
totalCapacity += connector.energy.getEnergyCapacity();
for (TileEnergyDistribution connector : this.getConnectors())
{
totalEnergy += connector.getEnergyHandler().getEnergy();
totalCapacity += connector.getEnergyHandler().getEnergyCapacity();
lowestY = Math.min(connector.yCoord, lowestY);
highestY = Math.max(connector.yCoord, highestY);
lowestY = Math.min(connector.yCoord, lowestY);
highestY = Math.max(connector.yCoord, highestY);
connector.renderEnergyAmount = 0;
}
connector.renderEnergyAmount = 0;
}
/**
* Apply render
*/
long remainingRenderEnergy = totalEnergy;
/** Apply render */
long remainingRenderEnergy = totalEnergy;
for (int y = lowestY; y <= highestY; y++)
{
Set<TileEnergyDistribution> connectorsInlevel = new LinkedHashSet<TileEnergyDistribution>();
for (int y = lowestY; y <= highestY; y++)
{
Set<TileEnergyDistribution> connectorsInlevel = new LinkedHashSet<TileEnergyDistribution>();
for (TileEnergyDistribution connector : this.getConnectors())
{
if (connector.yCoord == y)
{
connectorsInlevel.add(connector);
}
}
for (TileEnergyDistribution connector : this.getConnectors())
{
if (connector.yCoord == y)
{
connectorsInlevel.add(connector);
}
}
int levelSize = connectorsInlevel.size();
long used = 0;
int levelSize = connectorsInlevel.size();
long used = 0;
for (TileEnergyDistribution connector : connectorsInlevel)
{
long tryInject = Math.min(remainingRenderEnergy / levelSize, connector.energy.getEnergyCapacity());
connector.renderEnergyAmount = tryInject;
used += tryInject;
}
for (TileEnergyDistribution connector : connectorsInlevel)
{
long tryInject = Math.min(remainingRenderEnergy / levelSize, connector.getEnergyHandler().getEnergyCapacity());
connector.renderEnergyAmount = tryInject;
used += tryInject;
}
remainingRenderEnergy -= used;
remainingRenderEnergy -= used;
if (remainingRenderEnergy <= 0)
break;
}
if (remainingRenderEnergy <= 0)
break;
}
/**
* Apply energy loss.
*/
double percentageLoss = 0;// Math.max(0, (1 - (getConnectors().size() * 6 / 100d)));
long energyLoss = (long) (percentageLoss * 100);
totalEnergy -= energyLoss;
/** Apply energy loss. */
double percentageLoss = 0;// Math.max(0, (1 - (getConnectors().size() * 6 / 100d)));
long energyLoss = (long) (percentageLoss * 100);
totalEnergy -= energyLoss;
int amountOfNodes = this.getConnectors().size() - exclusion.length;
int amountOfNodes = this.getConnectors().size() - exclusion.length;
if (totalEnergy > 0 && amountOfNodes > 0)
{
long remainingEnergy = totalEnergy;
if (totalEnergy > 0 && amountOfNodes > 0)
{
long remainingEnergy = totalEnergy;
TileEnergyDistribution firstNode = this.getFirstConnector();
TileEnergyDistribution firstNode = this.getFirstConnector();
for (TileEnergyDistribution node : this.getConnectors())
{
if (node != firstNode && !Arrays.asList(exclusion).contains(node))
{
double percentage = ((double) node.energy.getEnergyCapacity() / (double) totalCapacity);
long energyForBattery = Math.max(Math.round(totalEnergy * percentage), 0);
node.energy.setEnergy(energyForBattery);
remainingEnergy -= energyForBattery;
}
}
for (TileEnergyDistribution node : this.getConnectors())
{
if (node != firstNode && !Arrays.asList(exclusion).contains(node))
{
double percentage = ((double) node.getEnergyHandler().getEnergyCapacity() / (double) totalCapacity);
long energyForBattery = Math.max(Math.round(totalEnergy * percentage), 0);
node.getEnergyHandler().setEnergy(energyForBattery);
remainingEnergy -= energyForBattery;
}
}
firstNode.energy.setEnergy(Math.max(remainingEnergy, 0));
}
}
firstNode.getEnergyHandler().setEnergy(Math.max(remainingEnergy, 0));
}
}
@Override
protected void reconstructConnector(TileEnergyDistribution node)
{
node.setNetwork(this);
}
@Override
protected void reconstructConnector(TileEnergyDistribution node)
{
node.setNetwork(this);
}
@Override
public EnergyDistributionNetwork newInstance()
{
return new EnergyDistributionNetwork();
}
@Override
public EnergyDistributionNetwork newInstance()
{
return new EnergyDistributionNetwork();
}
}

View file

@ -8,6 +8,8 @@ import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import resonant.lib.render.EnumColor;
import resonant.lib.utility.LanguageUtility;
import universalelectricity.api.CompatibilityModule;
import universalelectricity.api.UniversalClass;
import universalelectricity.api.UniversalElectricity;
@ -15,8 +17,6 @@ import universalelectricity.api.energy.UnitDisplay;
import universalelectricity.api.energy.UnitDisplay.Unit;
import universalelectricity.api.item.IEnergyItem;
import universalelectricity.api.item.IVoltageItem;
import calclavia.lib.render.EnumColor;
import calclavia.lib.utility.LanguageUtility;
@UniversalClass
public class ItemBlockBattery extends ItemBlock implements IEnergyItem, IVoltageItem

View file

@ -19,10 +19,10 @@ import net.minecraftforge.common.ForgeDirection;
import org.lwjgl.opengl.GL11;
import resonant.api.items.ISimpleItemRenderer;
import resonant.lib.render.RenderUtility;
import resonantinduction.core.Reference;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.render.RenderUtility;
import calclavia.lib.render.item.ISimpleItemRenderer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -80,7 +80,7 @@ public class RenderBattery extends TileEntitySpecialRenderer implements ISimpleI
TileBattery tile = (TileBattery) t;
int energyLevel = (int) Math.round(((double) tile.energy.getEnergy() / (double) TileBattery.getEnergyForTier(tile.getBlockMetadata())) * 8);
int energyLevel = (int) Math.round(((double) tile.getEnergyHandler().getEnergy() / (double) TileBattery.getEnergyForTier(tile.getBlockMetadata())) * 8);
RenderUtility.bind(Reference.DOMAIN, Reference.MODEL_PATH + "battery/battery.png");
List<String> disabledParts = new ArrayList<String>();

View file

@ -5,6 +5,8 @@ import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.packet.Packet;
import net.minecraftforge.common.ForgeDirection;
import resonant.lib.network.IPacketReceiver;
import resonant.lib.network.IPacketSender;
import resonantinduction.core.ResonantInduction;
import universalelectricity.api.UniversalElectricity;
import universalelectricity.api.electricity.IVoltageInput;
@ -12,110 +14,104 @@ import universalelectricity.api.electricity.IVoltageOutput;
import universalelectricity.api.energy.EnergyStorageHandler;
import universalelectricity.api.energy.IEnergyContainer;
import universalelectricity.api.energy.IEnergyInterface;
import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.IPacketSender;
import com.google.common.io.ByteArrayDataInput;
/**
* A modular battery.
/** A modular battery box that allows shared connections with boxes next to it.
*
* @author Calclavia
*/
* @author Calclavia */
public class TileBattery extends TileEnergyDistribution implements IVoltageInput, IVoltageOutput, IPacketSender, IPacketReceiver, IEnergyInterface, IEnergyContainer
{
/**
* Tiers: 0, 1, 2
*/
public static final int MAX_TIER = 2;
/** Tiers: 0, 1, 2 */
public static final int MAX_TIER = 2;
/** The transfer rate **/
public static final long DEFAULT_WATTAGE = getEnergyForTier(0);
/** The transfer rate **/
public static final long DEFAULT_WATTAGE = getEnergyForTier(0);
/** Voltage increases as series connection increases */
public static final long DEFAULT_VOLTAGE = UniversalElectricity.DEFAULT_VOLTAGE;
public TileBattery()
{
this.setEnergyHandler(new EnergyStorageHandler(0));
this.getEnergyHandler().setCapacity(Long.MAX_VALUE);
this.ioMap = 0;
this.saveIOMap = true;
}
public TileBattery()
{
this.energy = new EnergyStorageHandler(0);
this.ioMap = 0;
this.saveIOMap = true;
}
/** @param tier - 0, 1, 2
* @return */
public static long getEnergyForTier(int tier)
{
return Math.round(Math.pow(500000000, (tier / (MAX_TIER + 0.7f)) + 1) / (500000000)) * (500000000);
}
/**
* @param tier - 0, 1, 2
* @return
*/
public static long getEnergyForTier(int tier)
{
return Math.round(Math.pow(500000000, (tier / (MAX_TIER + 0.7f)) + 1) / (500000000)) * (500000000);
}
@Override
public void initiate()
{
super.initiate();
getEnergyHandler().setCapacity(getEnergyForTier(getBlockMetadata()));
getEnergyHandler().setMaxTransfer(getEnergyHandler().getEnergyCapacity());
}
@Override
public void initiate()
{
super.initiate();
energy.setCapacity(getEnergyForTier(getBlockMetadata()));
}
@Override
public void updateEntity()
{
if (!this.worldObj.isRemote)
{
markDistributionUpdate |= produce() > 0;
}
@Override
public void updateEntity()
{
if (!this.worldObj.isRemote)
{
// energy.setMaxTransfer((long) Math.min(Math.pow(10000,
// this.getNetwork().getConnectors().size()), energy.getEnergyCapacity()));
energy.setMaxTransfer(energy.getEnergyCapacity());
markDistributionUpdate |= produce() > 0;
}
super.updateEntity();
}
super.updateEntity();
}
@Override
public Packet getDescriptionPacket()
{
return ResonantInduction.PACKET_TILE.getPacket(this, getPacketData(0).toArray());
}
@Override
public Packet getDescriptionPacket()
{
return ResonantInduction.PACKET_TILE.getPacket(this, getPacketData(0).toArray());
}
@Override
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
{
getEnergyHandler().setEnergy(data.readLong());
ioMap = data.readShort();
}
@Override
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
{
energy.setEnergy(data.readLong());
ioMap = data.readShort();
}
@Override
public ArrayList getPacketData(int type)
{
ArrayList data = new ArrayList();
data.add(renderEnergyAmount);
data.add(ioMap);
return data;
}
@Override
public ArrayList getPacketData(int type)
{
ArrayList data = new ArrayList();
data.add(renderEnergyAmount);
data.add(ioMap);
return data;
}
@Override
public long getVoltageOutput(ForgeDirection side)
{
return UniversalElectricity.DEFAULT_VOLTAGE;
}
@Override
public long getVoltageOutput(ForgeDirection side)
{
return DEFAULT_VOLTAGE;
}
@Override
public long getVoltageInput(ForgeDirection direction)
{
return UniversalElectricity.DEFAULT_VOLTAGE;
}
@Override
public long getVoltageInput(ForgeDirection direction)
{
return DEFAULT_VOLTAGE;
}
@Override
public void onWrongVoltage(ForgeDirection direction, long voltage)
{
@Override
public void onWrongVoltage(ForgeDirection direction, long voltage)
{
}
}
@Override
public void setIO(ForgeDirection dir, int type)
{
super.setIO(dir, type);
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public void setIO(ForgeDirection dir, int type)
{
super.setIO(dir, type);
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public String toString()
{
return "[TileBattery]" + x() + "x " + y() + "y " + z() + "z ";
}
}

View file

@ -1,171 +1,170 @@
package resonantinduction.electrical.battery;
import calclavia.lib.prefab.tile.TileElectrical;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import resonant.lib.prefab.tile.TileElectrical;
import universalelectricity.api.net.IConnector;
import universalelectricity.api.vector.Vector3;
public class TileEnergyDistribution extends TileElectrical
implements IConnector<EnergyDistributionNetwork>
public class TileEnergyDistribution extends TileElectrical implements IConnector<EnergyDistributionNetwork>
{
public boolean markClientUpdate = false;
public boolean markDistributionUpdate = false;
public long renderEnergyAmount = 0;
private EnergyDistributionNetwork network;
public boolean markClientUpdate = false;
public boolean markDistributionUpdate = false;
public long renderEnergyAmount = 0;
private EnergyDistributionNetwork network;
public TileEnergyDistribution()
{
super(null);
}
public TileEnergyDistribution()
{
super(null);
}
public TileEnergyDistribution(Material material)
{
super(material);
}
public TileEnergyDistribution(Material material)
{
super(material);
}
@Override
public void initiate()
{
super.initiate();
this.updateStructure();
}
@Override
public void initiate()
{
super.initiate();
this.updateStructure();
}
@Override
public void onAdded()
{
if (!world().isRemote)
{
updateStructure();
}
}
@Override
public void onAdded()
{
if (!world().isRemote)
{
updateStructure();
}
}
@Override
public void onNeighborChanged()
{
if (!world().isRemote)
{
updateStructure();
}
}
@Override
public void onNeighborChanged()
{
if (!world().isRemote)
{
updateStructure();
}
}
@Override
public void updateEntity()
{
super.updateEntity();
@Override
public void updateEntity()
{
super.updateEntity();
if (!this.worldObj.isRemote)
{
if (markDistributionUpdate && ticks % 5 == 0)
{
getNetwork().redistribute();
markDistributionUpdate = false;
}
if (!this.worldObj.isRemote)
{
if (markDistributionUpdate && ticks % 5 == 0)
{
getNetwork().redistribute();
markDistributionUpdate = false;
}
if (markClientUpdate && ticks % 5 == 0)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
}
if (markClientUpdate && ticks % 5 == 0)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
}
@Override
public long getEnergy(ForgeDirection from)
{
return getNetwork().totalEnergy;
}
@Override
public long getEnergy(ForgeDirection from)
{
return getNetwork().totalEnergy;
}
@Override
public long getEnergyCapacity(ForgeDirection from)
{
return getNetwork().totalCapacity;
@Override
public long getEnergyCapacity(ForgeDirection from)
{
return getNetwork().totalCapacity;
}
}
@Override
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
{
long returnValue = super.onReceiveEnergy(from, receive, doReceive);
markDistributionUpdate = true;
markClientUpdate = true;
return returnValue;
}
@Override
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
{
long returnValue = super.onReceiveEnergy(from, receive, doReceive);
markDistributionUpdate = true;
markClientUpdate = true;
return returnValue;
}
@Override
public long onExtractEnergy(ForgeDirection from, long extract, boolean doExtract)
{
long returnValue = super.onExtractEnergy(from, extract, doExtract);
markDistributionUpdate = true;
markClientUpdate = true;
return returnValue;
}
@Override
public long onExtractEnergy(ForgeDirection from, long extract, boolean doExtract)
{
long returnValue = super.onExtractEnergy(from, extract, doExtract);
markDistributionUpdate = true;
markClientUpdate = true;
return returnValue;
}
@Override
public EnergyDistributionNetwork getNetwork()
{
if (this.network == null)
{
this.network = new EnergyDistributionNetwork();
this.network.addConnector(this);
}
@Override
public EnergyDistributionNetwork getNetwork()
{
if (this.network == null)
{
this.network = new EnergyDistributionNetwork();
this.network.addConnector(this);
}
return this.network;
}
return this.network;
}
@Override
public void setNetwork(EnergyDistributionNetwork structure)
{
this.network = structure;
}
@Override
public void setNetwork(EnergyDistributionNetwork structure)
{
this.network = structure;
}
public void updateStructure()
{
if (!this.worldObj.isRemote)
{
for (Object obj : getConnections())
{
if (obj != null)
{
this.getNetwork().merge(((TileEnergyDistribution) obj).getNetwork());
}
}
public void updateStructure()
{
if (!this.worldObj.isRemote)
{
for (Object obj : getConnections())
{
if (obj != null)
{
this.getNetwork().merge(((TileEnergyDistribution) obj).getNetwork());
}
}
markDistributionUpdate = true;
markClientUpdate = true;
}
}
markDistributionUpdate = true;
markClientUpdate = true;
}
}
@Override
public Object[] getConnections()
{
Object[] connections = new Object[6];
@Override
public Object[] getConnections()
{
Object[] connections = new Object[6];
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tile = new Vector3(this).translate(dir).getTileEntity(this.worldObj);
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tile = new Vector3(this).translate(dir).getTileEntity(this.worldObj);
if (tile != null && tile.getClass() == this.getClass())
{
connections[dir.ordinal()] = tile;
}
}
if (tile != null && tile.getClass() == this.getClass())
{
connections[dir.ordinal()] = tile;
}
}
return connections;
}
return connections;
}
@Override
public void invalidate()
{
this.getNetwork().redistribute(this);
this.getNetwork().split(this);
super.invalidate();
}
@Override
public void invalidate()
{
this.getNetwork().redistribute(this);
this.getNetwork().split(this);
super.invalidate();
}
@Override
public IConnector<EnergyDistributionNetwork> getInstance(ForgeDirection from)
{
return this;
}
@Override
public IConnector<EnergyDistributionNetwork> getInstance(ForgeDirection from)
{
return this;
}
}

View file

@ -4,325 +4,146 @@ import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.prefab.part.PartFace;
import resonant.lib.utility.WrenchUtility;
import resonant.lib.utility.inventory.InventoryUtility;
import resonantinduction.core.prefab.part.PartInventoryPanel;
import resonantinduction.electrical.Electrical;
import universalelectricity.api.CompatibilityModule;
import universalelectricity.api.UniversalClass;
import universalelectricity.api.energy.IEnergyInterface;
import calclavia.lib.utility.WrenchUtility;
import calclavia.lib.utility.inventory.ExternalInventory;
import calclavia.lib.utility.inventory.IExternalInventory;
import calclavia.lib.utility.inventory.IExternalInventoryBox;
import calclavia.lib.utility.inventory.InventoryUtility;
import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput;
import codechicken.lib.vec.Vector3;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* TODO: This DOES NOT WORK when @UniversalClass is not annotated. Flat wires seem to only interact
* with TE multiparts.
/** Micro part machine designed to charge all items contained inside of it. Doesn't contain its own
* battery and only acts as an inventory. Items are charged each time doReceive is called by an
* energy supplier.
*
* @author Calclavia
*
*/
* @author Darkguardsman, converted to Part by Calclavia */
@UniversalClass
public class PartCharger extends PartFace implements IExternalInventory, ISidedInventory, IEnergyInterface
public class PartCharger extends PartInventoryPanel implements IEnergyInterface
{
private long lastPacket;
@Override
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item)
{
if (WrenchUtility.isUsableWrench(player, player.inventory.getCurrentItem(), x(), y(), z()))
{
if (!world().isRemote)
{
WrenchUtility.damageWrench(player, player.inventory.getCurrentItem(), x(), y(), z());
facing = (byte) ((facing + 1) % 4);
sendDescUpdate();
tile().notifyPartChange(this);
}
@Override
public void readDesc(MCDataInput packet)
{
super.readDesc(packet);
getInventory().load(packet.readNBTTagCompound());
}
return true;
}
@Override
public void writeDesc(MCDataOutput packet)
{
super.writeDesc(packet);
NBTTagCompound nbt = new NBTTagCompound();
getInventory().save(nbt);
packet.writeNBTTagCompound(nbt);
}
if (item != null)
{
if (getStackInSlot(0) == null && item != null && CompatibilityModule.isHandler(item.getItem()))
{
setInventorySlotContents(0, item);
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
@Override
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item)
{
if (WrenchUtility.isUsableWrench(player, player.inventory.getCurrentItem(), x(), y(), z()))
{
if (!world().isRemote)
{
WrenchUtility.damageWrench(player, player.inventory.getCurrentItem(), x(), y(), z());
facing = (byte) ((facing + 1) % 4);
sendDescUpdate();
tile().notifyPartChange(this);
}
if (!world().isRemote)
sendDescUpdate();
return true;
}
return true;
}
}
if (item != null)
{
if (getStackInSlot(0) == null && item != null && CompatibilityModule.isHandler(item.getItem()))
{
setInventorySlotContents(0, item);
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
if (getStackInSlot(0) != null)
{
InventoryUtility.dropItemStack(world(), new universalelectricity.api.vector.Vector3(player), getStackInSlot(0), 0);
setInventorySlotContents(0, null);
if (!world().isRemote)
sendDescUpdate();
}
if (!world().isRemote)
sendDescUpdate();
return true;
}
return true;
}
}
@Override
public boolean canConnect(ForgeDirection direction, Object obj)
{
return obj instanceof IEnergyInterface && placementSide != direction.getOpposite();
}
if (getStackInSlot(0) != null)
{
InventoryUtility.dropItemStack(world(), new universalelectricity.api.vector.Vector3(player), getStackInSlot(0), 0);
setInventorySlotContents(0, null);
if (!world().isRemote)
sendDescUpdate();
}
@Override
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
{
if (receive > 0)
{
long energyUsed = 0;
for (int slot = 0; slot < this.getSizeInventory(); slot++)
{
energyUsed += CompatibilityModule.chargeItem(this.getStackInSlot(slot), receive - energyUsed, doReceive);
if (energyUsed >= receive)
break;
}
return true;
}
if (energyUsed > 0)
this.markedForUpdate = true;
@Override
public boolean canConnect(ForgeDirection direction, Object obj)
{
return obj instanceof IEnergyInterface;
}
return energyUsed;
}
return 0;
}
@Override
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
{
long energyUsed = 0;
long energyLeft = receive;
for (int i = 0; i < this.getSizeInventory(); i++)
{
long input = CompatibilityModule.chargeItem(this.getStackInSlot(i), energyLeft, true);
energyUsed += input;
energyLeft -= input;
if (energyLeft <= 0)
break;
}
@Override
public long onExtractEnergy(ForgeDirection from, long extract, boolean doExtract)
{
return 0;
}
if (!world().isRemote && energyUsed > 0 && System.currentTimeMillis() - this.lastPacket >= 50)
{
this.lastPacket = System.currentTimeMillis();
sendDescUpdate();
}
return energyUsed;
}
@Override
@SideOnly(Side.CLIENT)
public void renderDynamic(Vector3 pos, float frame, int pass)
{
if (pass == 0)
{
RenderCharger.INSTANCE.render(this, pos.x, pos.y, pos.z);
}
}
@Override
public long onExtractEnergy(ForgeDirection from, long extract, boolean doExtract)
{
return 0;
}
@Override
protected ItemStack getItem()
{
return new ItemStack(Electrical.itemCharger);
}
@Override
@SideOnly(Side.CLIENT)
public void renderDynamic(Vector3 pos, float frame, int pass)
{
if (pass == 0)
{
RenderCharger.INSTANCE.render(this, pos.x, pos.y, pos.z);
}
}
@Override
public String getType()
{
return "resonant_induction_charger";
}
@Override
protected ItemStack getItem()
{
return new ItemStack(Electrical.itemCharger);
}
@Override
public Iterable<ItemStack> getDrops()
{
List<ItemStack> drops = new ArrayList<ItemStack>();
drops.add(getItem());
@Override
public String getType()
{
return "resonant_induction_charger";
}
for (int i = 0; i < getSizeInventory(); i++)
if (getStackInSlot(i) != null)
drops.add(getStackInSlot(i));
@Override
public Iterable<ItemStack> getDrops()
{
List<ItemStack> drops = new ArrayList<ItemStack>();
drops.add(getItem());
return drops;
}
for (int i = 0; i < getSizeInventory(); i++)
if (getStackInSlot(i) != null)
drops.add(getStackInSlot(i));
return drops;
}
/**
* Save and load
*/
@Override
public void load(NBTTagCompound nbt)
{
super.load(nbt);
this.getInventory().load(nbt);
}
@Override
public void save(NBTTagCompound nbt)
{
super.save(nbt);
this.getInventory().save(nbt);
}
/**
* Inventory Methods
*/
protected IExternalInventoryBox inventory;
protected int maxSlots = 1;
@Override
public IExternalInventoryBox getInventory()
{
if (inventory == null)
{
inventory = new ExternalInventory(null, this, this.maxSlots);
}
return inventory;
}
@Override
public int getSizeInventory()
{
return this.getInventory().getSizeInventory();
}
@Override
public ItemStack getStackInSlot(int i)
{
return this.getInventory().getStackInSlot(i);
}
@Override
public ItemStack decrStackSize(int i, int j)
{
return this.getInventory().decrStackSize(i, j);
}
public void incrStackSize(int slot, ItemStack itemStack)
{
if (this.getStackInSlot(slot) == null)
{
setInventorySlotContents(slot, itemStack.copy());
}
else if (this.getStackInSlot(slot).isItemEqual(itemStack))
{
getStackInSlot(slot).stackSize += itemStack.stackSize;
}
onInventoryChanged();
}
@Override
public ItemStack getStackInSlotOnClosing(int i)
{
return this.getInventory().getStackInSlotOnClosing(i);
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack)
{
this.getInventory().setInventorySlotContents(i, itemstack);
}
@Override
public String getInvName()
{
return "";
}
@Override
public boolean isInvNameLocalized()
{
return true;
}
@Override
public int getInventoryStackLimit()
{
return this.getInventory().getInventoryStackLimit();
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer)
{
return this.getInventory().isUseableByPlayer(entityplayer);
}
@Override
public void openChest()
{
this.getInventory().openChest();
}
@Override
public void closeChest()
{
this.getInventory().closeChest();
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
{
return this.getInventory().isItemValidForSlot(i, itemstack);
}
@Override
public int[] getAccessibleSlotsFromSide(int var1)
{
return this.getInventory().getAccessibleSlotsFromSide(var1);
}
@Override
public boolean canInsertItem(int i, ItemStack itemstack, int j)
{
return this.getInventory().canInsertItem(i, itemstack, j);
}
@Override
public boolean canExtractItem(int i, ItemStack itemstack, int j)
{
return this.getInventory().canExtractItem(i, itemstack, j);
}
@Override
public boolean canStore(ItemStack stack, int slot, ForgeDirection side)
{
return false;
}
@Override
public boolean canRemove(ItemStack stack, int slot, ForgeDirection side)
{
if (slot >= this.getSizeInventory())
{
return false;
}
return true;
}
@Override
public void onInventoryChanged()
{
}
@Override
public boolean canStore(ItemStack stack, int slot, ForgeDirection side)
{
return slot < this.getSizeInventory() && stack != null && CompatibilityModule.isHandler(stack.getItem());
}
@Override
public String toString()
{
return "[PartCharger]" + x() + "x " + y() + "y " + z() + "z " + getSlotMask() + "s ";
}
}

View file

@ -11,14 +11,14 @@ import net.minecraftforge.client.model.IModelCustom;
import org.lwjgl.opengl.GL11;
import resonant.api.items.ISimpleItemRenderer;
import resonant.lib.render.RenderItemOverlayUtility;
import resonant.lib.render.RenderUtility;
import resonantinduction.core.Reference;
import universalelectricity.api.CompatibilityModule;
import universalelectricity.api.energy.UnitDisplay;
import universalelectricity.api.energy.UnitDisplay.Unit;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.render.RenderItemOverlayUtility;
import calclavia.lib.render.RenderUtility;
import calclavia.lib.render.item.ISimpleItemRenderer;
/**
* Renderer for electric item charger

View file

@ -1,19 +1,18 @@
package resonantinduction.electrical.distributor
import calclavia.lib.content.prefab.{TraitElectrical, TraitInventory}
import net.minecraft.block.material.Material
import calclavia.lib.content.module.TileBase
import universalelectricity.api.vector.Vector3
import net.minecraft.inventory.IInventory
import net.minecraftforge.common.ForgeDirection
import calclavia.lib.utility.inventory.InventoryUtility
import net.minecraft.item.ItemStack
import java.util.Collections
import java.util
import java.util.Collections
import scala.util.control.Breaks._
import net.minecraft.block.material.Material
import net.minecraft.inventory.IInventory
import net.minecraft.item.ItemStack
import net.minecraft.tileentity.TileEntity
import net.minecraftforge.common.ForgeDirection
import resonant.lib.content.module.TileBase
import resonant.lib.content.prefab.TraitElectrical
import resonant.lib.content.prefab.TraitInventory
import resonant.lib.utility.inventory.InventoryUtility
import universalelectricity.api.vector.Vector3
/**
* A Block that interacts with connected inventories

View file

@ -6,10 +6,10 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import resonant.lib.prefab.block.BlockTile;
import resonantinduction.core.Reference;
import resonantinduction.electrical.Electrical;
import universalelectricity.api.UniversalElectricity;
import calclavia.lib.prefab.block.BlockTile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View file

@ -7,6 +7,9 @@ import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import resonant.lib.network.IPacketReceiver;
import resonant.lib.network.PacketHandler;
import resonant.lib.prefab.tile.TileExternalInventory;
import resonantinduction.core.ResonantInduction;
import resonantinduction.electrical.armbot.Program;
import resonantinduction.electrical.armbot.task.TaskRotateTo;
@ -14,9 +17,6 @@ import resonantinduction.electrical.encoder.coding.IProgram;
import resonantinduction.electrical.encoder.coding.ITask;
import resonantinduction.electrical.encoder.coding.TaskRegistry;
import universalelectricity.api.vector.Vector2;
import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.PacketHandler;
import calclavia.lib.prefab.tile.TileExternalInventory;
import com.google.common.io.ByteArrayDataInput;

View file

@ -1,8 +1,8 @@
package resonantinduction.electrical.encoder.coding;
import net.minecraft.world.World;
import resonant.lib.type.Pair;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.type.Pair;
/**
* Simple interface too say an object is programmable

View file

@ -4,9 +4,9 @@ import java.util.List;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import resonant.lib.utility.nbt.ISaveObj;
import resonantinduction.core.ArgumentData;
import universalelectricity.api.vector.Vector2;
import calclavia.lib.utility.nbt.ISaveObj;
/** @author DarkGuardsman */
public interface ITask extends Cloneable, ISaveObj

View file

@ -2,10 +2,10 @@ package resonantinduction.electrical.encoder.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import resonant.lib.gui.ContainerBase;
import resonant.lib.prefab.slot.SlotSpecific;
import resonantinduction.electrical.encoder.ItemDisk;
import resonantinduction.electrical.encoder.TileEncoder;
import calclavia.lib.gui.ContainerBase;
import calclavia.lib.prefab.slot.SlotSpecific;
public class ContainerEncoder extends ContainerBase
{

View file

@ -2,9 +2,9 @@ package resonantinduction.electrical.encoder.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import resonant.lib.gui.ContainerDummy;
import resonant.lib.gui.GuiContainerBase;
import resonantinduction.electrical.encoder.TileEncoder;
import calclavia.lib.gui.ContainerDummy;
import calclavia.lib.gui.GuiContainerBase;
public class GuiEncoderBase extends GuiContainerBase
{

View file

@ -8,12 +8,12 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import resonant.lib.gui.ContainerDummy;
import resonant.lib.gui.GuiContainerBase;
import resonantinduction.core.ArgumentData;
import resonantinduction.core.Reference;
import resonantinduction.electrical.encoder.coding.ITask;
import universalelectricity.api.vector.Vector2;
import calclavia.lib.gui.ContainerDummy;
import calclavia.lib.gui.GuiContainerBase;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.FMLCommonHandler;

View file

@ -6,6 +6,7 @@ import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11;
import resonant.api.IScroll;
import resonantinduction.electrical.armbot.task.TaskEnd;
import resonantinduction.electrical.armbot.task.TaskIdle;
import resonantinduction.electrical.armbot.task.TaskStart;
@ -13,7 +14,6 @@ import resonantinduction.electrical.encoder.TileEncoder;
import resonantinduction.electrical.encoder.coding.IProgram;
import resonantinduction.electrical.encoder.coding.IRedirectTask;
import resonantinduction.electrical.encoder.coding.ITask;
import calclavia.lib.prefab.terminal.IScroll;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.FMLCommonHandler;

View file

@ -4,10 +4,10 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import resonant.lib.prefab.block.BlockRotatable;
import resonant.lib.render.block.BlockRenderingHandler;
import resonantinduction.core.Reference;
import universalelectricity.api.UniversalElectricity;
import calclavia.lib.prefab.block.BlockRotatable;
import calclavia.lib.render.block.BlockRenderingHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View file

@ -10,9 +10,9 @@ import net.minecraftforge.common.ForgeDirection;
import org.lwjgl.opengl.GL11;
import resonant.api.items.ISimpleItemRenderer;
import resonant.lib.render.RenderUtility;
import resonantinduction.core.Reference;
import calclavia.lib.render.RenderUtility;
import calclavia.lib.render.item.ISimpleItemRenderer;
/**
* @author Calclavia

View file

@ -4,13 +4,13 @@ import java.util.EnumSet;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.ForgeDirection;
import resonant.api.IMechanicalNode;
import resonant.api.IRotatable;
import resonant.api.grid.INode;
import resonant.api.grid.INodeProvider;
import resonant.lib.grid.NodeRegistry;
import resonant.lib.prefab.tile.TileElectrical;
import universalelectricity.api.energy.EnergyStorageHandler;
import calclavia.api.resonantinduction.IMechanicalNode;
import calclavia.lib.grid.INode;
import calclavia.lib.grid.INodeProvider;
import calclavia.lib.grid.NodeRegistry;
import calclavia.lib.prefab.tile.IRotatable;
import calclavia.lib.prefab.tile.TileElectrical;
/**
* A kinetic energy to electrical energy converter.
@ -43,7 +43,8 @@ public class TileMotor extends TileElectrical implements IRotatable, INodeProvid
public void initiate()
{
super.initiate();
node.reconstruct();
if (node != null)
node.reconstruct();
}
@Override
@ -81,7 +82,7 @@ public class TileMotor extends TileElectrical implements IRotatable, INodeProvid
if (receive > 0)
{
double percentageUsed = receive / power;
node.apply(-node.getTorque() * percentageUsed, -node.getAngularVelocity() * percentageUsed);
node.apply(this, -node.getTorque() * percentageUsed, -node.getAngularVelocity() * percentageUsed);
}
}
@ -111,7 +112,7 @@ public class TileMotor extends TileElectrical implements IRotatable, INodeProvid
if (currentVelo != 0)
setAngularVelocity = Math.min(+setAngularVelocity, maxAngularVelocity) * (node.getAngularVelocity() / currentVelo);
node.apply(setTorque - node.getTorque(), setAngularVelocity - node.getAngularVelocity());
node.apply(this, setTorque - node.getTorque(), setAngularVelocity - node.getAngularVelocity());
energy.extractEnergy((long) Math.abs(setTorque * setAngularVelocity), true);
}
}

View file

@ -1,26 +1,28 @@
package resonantinduction.electrical.generator.solar;
import calclavia.lib.content.module.TileRender;
import calclavia.lib.prefab.vector.Cuboid;
import calclavia.lib.render.ConnectedTextureRenderer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
import resonant.lib.content.module.TileRender;
import resonant.lib.prefab.vector.Cuboid;
import resonant.lib.utility.ConnectedTextureRenderer;
import resonantinduction.core.Reference;
import resonantinduction.core.Settings;
import resonantinduction.electrical.battery.TileEnergyDistribution;
import universalelectricity.api.energy.EnergyStorageHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TileSolarPanel extends TileEnergyDistribution
{
@SideOnly(Side.CLIENT)
public static Icon sideIcon, bottomIcon;
public TileSolarPanel()
{
super(Material.iron);
energy = new EnergyStorageHandler(800);
energy = new EnergyStorageHandler(Settings.SOLAR_ENERGY * 20);
ioMap = 728;
textureName = "solarPanel_top";
bounds = new Cuboid(0, 0, 0, 1, 0.3f, 1);
@ -64,7 +66,7 @@ public class TileSolarPanel extends TileEnergyDistribution
{
if (!(this.worldObj.isThundering() || this.worldObj.isRaining()))
{
this.energy.receiveEnergy(25, true);
this.energy.receiveEnergy(Settings.SOLAR_ENERGY, true);
markDistributionUpdate |= produce() > 0;
}
}

View file

@ -4,9 +4,9 @@ import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import resonant.lib.prefab.block.BlockTile;
import resonantinduction.core.Reference;
import universalelectricity.api.UniversalElectricity;
import calclavia.lib.prefab.block.BlockTile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View file

@ -2,9 +2,9 @@ package resonantinduction.electrical.generator.thermopile;
import net.minecraft.block.Block;
import net.minecraftforge.common.ForgeDirection;
import resonant.lib.prefab.tile.TileElectrical;
import universalelectricity.api.energy.EnergyStorageHandler;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.prefab.tile.TileElectrical;
public class TileThermopile extends TileElectrical
{

View file

@ -1,15 +1,57 @@
package resonantinduction.electrical.itemrailing;
import calclavia.lib.grid.NodeGrid;
import java.util.Arrays;
import net.minecraft.item.ItemStack;
import resonant.lib.grid.TickingGrid;
import resonantinduction.electrical.itemrailing.interfaces.IItemRailing;
import resonantinduction.electrical.itemrailing.interfaces.IItemRailingTransfer;
/**
* @since 18/03/14
* @author tgame14
*/
public class GridRailing extends NodeGrid<NodeRailing>
public class GridRailing extends TickingGrid<NodeRailing>
{
public GridRailing (Class type)
public final static String CATEGORY_RAILING = "Item_Railings";
public GridRailing (NodeRailing railing, Class type)
{
super(type);
super(railing, type);
}
public IItemRailing findTargetForIItemTransfer(IItemRailingTransfer itemwrapper)
{
if (itemwrapper.getColor() == null)
{
return findNearestInventory(itemwrapper);
}
return findNearestColoredTarget(itemwrapper);
}
public IItemRailing findNearestInventory(IItemRailingTransfer itemwrapper)
{
IItemRailing[] arr = (IItemRailing[]) this.getNodes().toArray();
Arrays.sort(arr, new RailingDistanceComparator.RailingInventoryDistanceComparator(itemwrapper.getRailing()));
return arr[0];
}
public IItemRailing findNearestColoredTarget(IItemRailingTransfer itemwrapper)
{
IItemRailing[] arr = (IItemRailing[]) this.getNodes().toArray();
Arrays.sort(arr, new RailingDistanceComparator.RailingColoredDistanceComparator(itemwrapper.getRailing(), itemwrapper.getColor()));
return arr[0];
}
public IItemRailing chooseNextInstantGoal(IItemRailingTransfer itemwrapper)
{
IItemRailing[] arr = (IItemRailing[]) itemwrapper.getRailing().getConnectionMap().entrySet().toArray();
Arrays.sort(arr, new RailingDistanceComparator(itemwrapper.getEndGoal()));
return arr[0];
}
public void onItemEnterGrid(IItemRailing railing, ItemStack item)
{
}
}

Some files were not shown because too many files have changed in this diff Show more