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

7
.gitignore vendored
View file

@ -37,3 +37,10 @@
.Trashes
ehthumbs.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,25 +31,33 @@ 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
/** Resonant Induction Archaic Module
*
* @author DarkCow, Calclavia
*/
* @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
*/
/** 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);
@ -88,9 +87,12 @@ public class Archaic
public static Block blockGutter;
public static Block blockTank;
public ProxyHandler modproxies;
@EventHandler
public void preInit(FMLPreInitializationEvent evt)
{
modproxies = new ProxyHandler();
NetworkRegistry.instance().registerGuiHandler(this, proxy);
Settings.CONFIGURATION.load();
blockEngineeringTable = contentRegistry.newBlock(TileEngineeringTable.class);
@ -110,12 +112,13 @@ public class Archaic
itemImprint = contentRegistry.createItem(ItemImprint.class);
itemHammer = contentRegistry.createItem(ItemHammer.class);
proxy.preInit();
modproxies.applyModule(Waila.class, true);
Settings.CONFIGURATION.save();
PacketAnnotation.register(TileFirebox.class);
PacketAnnotation.register(TileFilter.class);
proxy.preInit();
modproxies.preInit();
}
@EventHandler
@ -123,18 +126,27 @@ public class Archaic
{
Settings.setModMetadata(metadata, ID, NAME, ResonantInduction.ID);
proxy.init();
modproxies.init();
}
@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);
}
// 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(new ItemStack(blockCrate, 1, 0), "WWW", "WSW", "WWW", 'S', Item.stick, 'W', "logWood"));
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()));
@ -145,15 +157,16 @@ public class Archaic
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(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', Item.stick));
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', Block.cobblestone, 'S', Item.stick));
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,18 +10,17 @@ 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
@ -29,21 +30,18 @@ class TileTurntable extends TileBlock(Material.piston) with IRotatable
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())
{
if (side == super.metadata()) {
return TileTurntable.top
}
@ -52,50 +50,37 @@ class TileTurntable extends TileBlock(Material.piston) with IRotatable
@SideOnly(Side.CLIENT) override def getIcon(side: Int, meta: Int): Icon =
{
if (side == 1)
{
if (side == 1) {
return TileTurntable.top
}
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
{
} 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"))
@ -111,7 +96,6 @@ class TileTurntable extends TileBlock(Material.piston) with IRotatable
}
}
object TileTurntable
{
object TileTurntable {
var top: Icon = null
}

View file

@ -10,25 +10,25 @@ 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;
@ -65,84 +65,39 @@ public class BlockCrate extends BlockTile
@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)
if (!world.isRemote && world.getBlockTileEntity(x, y, z) instanceof TileCrate)
{
TileCrate tileEntity = (TileCrate) world.getBlockTileEntity(x, y, z);
/** Make double clicking input all stacks. */
boolean allMode = (world.getWorldTime() - tileEntity.prevClickTime < 10);
this.tryEject(tileEntity, player, world.getWorldTime() - tileEntity.prevClickTime < 10);
tileEntity.prevClickTime = world.getWorldTime();
this.tryEject(tileEntity, player, allMode);
}
}
}
/** 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)
public boolean onUseWrench(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)
if (!world.isRemote && world.getBlockTileEntity(x, y, z) instanceof TileCrate)
{
TileCrate tile = (TileCrate) world.getBlockTileEntity(x, y, z);
if (player.getCurrentEquippedItem() != null && WrenchUtility.isWrench(player.getCurrentEquippedItem()))
{
if (player.isSneaking())
{
ItemStack containingStack = tile.getSampleStack();
tile.buildSampleStack();
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;
ItemStack dropStack = new ItemStack(this, 1, tile.getBlockMetadata());
ItemBlockCrate.setContainingItemStack(dropStack, containingStack);
EntityItem var13 = new EntityItem(world, x + dropX, y + dropY, z + dropZ, dropStack);
var13.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(var13);
for (int i = 0; i < tile.getInventory().getSizeInventory(); i++)
{
tile.getInventory().setInventorySlotContents(i, null);
}
world.setBlock(x, y, z, 0, 0, 3);
return true;
}
}
return false;
}
/**
* Swap oredict nodes if the player is wrenching the crate.
*/
ItemStack sampleStack = tile.getSampleStack();
int oreID = OreDictionary.getOreID(sampleStack);
if (oreID != -1)
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);
for (int i = 0; i < ores.size(); i++)
for (int oreIndex = 0; oreIndex < ores.size(); oreIndex++)
{
if (ores.get(i).isItemEqual(sampleStack))
if (ores.get(oreIndex).isItemEqual(sampleStack))
{
int nextIndex = (i + 1) % ores.size();
int nextIndex = (oreIndex + 1) % ores.size();
ItemStack desiredStack = ores.get(nextIndex).copy();
desiredStack.stackSize = sampleStack.stackSize;
@ -155,54 +110,88 @@ public class BlockCrate extends BlockTile
}
}
}
return true;
}
/** Make double clicking input all stacks. */
boolean allMode = (world.getWorldTime() - tile.prevClickTime < 10);
@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();
tile.prevClickTime = world.getWorldTime();
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);
for (int i = 0; i < tile.getInventory().getSizeInventory(); i++)
{
tile.getInventory().setInventorySlotContents(i, null);
}
world.setBlock(x, y, z, 0, 0, 3);
}
}
return true;
}
@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);
if (ControlKeyModifer.isControlDown(player))
{
tryEject(tile, player, allMode);
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
{
ItemStack current = player.inventory.getCurrentItem();
if (side == 1 && player.capabilities.isCreativeMode)
tile.setFilter(null);
}
}
else
{
if (current != null && tile.getSampleStack() == null)
/* 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);
}
}
tryInsert(tile, player, allMode);
}
}
}
return true;
}
/**
* 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)
else if (hitY >= 0.5)
{
boolean success;
if (allMode)
{
success = this.insertAllItems(tileEntity, player);
tryEject(tile, player, world.getWorldTime() - tile.prevClickTime < 10);
}
}
else
{
success = this.insertCurrentItem(tileEntity, player);
tryInsert(tile, player, world.getWorldTime() - tile.prevClickTime < 10);
}
}
tile.prevClickTime = world.getWorldTime();
}
return true;
}
/** 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);
if (!success && doSearch)
{
PathfinderCrate pathfinder = new PathfinderCrate().init(tileEntity);
@ -268,7 +257,7 @@ public class BlockCrate extends BlockTile
{
if (tileEntity.getSampleStack() != null)
{
if (!(tileEntity.getSampleStack().isItemEqual(currentStack) || (!OreDictionary.getOreName(OreDictionary.getOreID(tileEntity.getSampleStack())).equals("Unknown") && OreDictionary.getOreID(tileEntity.getSampleStack()) == OreDictionary.getOreID(currentStack))))
if (!(tileEntity.getSampleStack().isItemEqual(currentStack) || (tileEntity.oreFilterEnabled && !OreDictionary.getOreName(OreDictionary.getOreID(tileEntity.getSampleStack())).equals("Unknown") && OreDictionary.getOreID(tileEntity.getSampleStack()) == OreDictionary.getOreID(currentStack))))
{
return false;
}
@ -282,11 +271,9 @@ public class BlockCrate extends BlockTile
return false;
}
/**
* Inserts all items of the same type this player has into the crate.
/** Inserts all items of the same type this player has into the crate.
*
* @return True on success
*/
* @return True on success */
public boolean insertAllItems(TileCrate tileEntity, EntityPlayer player)
{
ItemStack requestStack = null;
@ -329,14 +316,12 @@ public class BlockCrate extends BlockTile
return false;
}
/**
* Ejects and item out of the crate and spawn it under the player entity.
/** 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
*/
* @return True on success */
public boolean ejectItems(TileCrate tileEntity, EntityPlayer player, int requestSize)
{
World world = tileEntity.worldObj;
@ -372,7 +357,6 @@ public class BlockCrate extends BlockTile
}
if (ammountEjected >= requestSize)
{
tileEntity.onInventoryChanged();
return true;
}
}
@ -380,16 +364,13 @@ public class BlockCrate extends BlockTile
return true;
}
}
tileEntity.onInventoryChanged();
return false;
}
/**
* Puts an itemStack into the crate.
/** Puts an itemStack into the crate.
*
* @param tileEntity
* @param itemStack
*/
* @param itemStack */
public static ItemStack addStackToCrate(TileCrate tileEntity, ItemStack itemStack)
{
if (itemStack == null || itemStack.getItem().isDamageable() && itemStack.getItem().getDamage(itemStack) > 0)
@ -399,7 +380,7 @@ public class BlockCrate extends BlockTile
ItemStack containingStack = tileEntity.getSampleStack();
if (containingStack == null || (containingStack.isItemEqual(itemStack) || OreDictionary.getOreID(containingStack) == OreDictionary.getOreID(itemStack)))
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)

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,18 +4,19 @@ 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)
public ItemBlockCrate(int id)
{
super(par1);
super(id);
this.setHasSubtypes(true);
}
@ -26,14 +27,15 @@ public class ItemBlockCrate extends ItemBlock
}
@Override
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
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);
list.add(containingStack.getDisplayName());
list.add(LanguageUtility.getLocal("crate.tooltip.amount") + " " + containingStack.stackSize);
}
}

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,178 +1,63 @@
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;
/** delay from last click */
public long prevClickTime = -1000;
/** max meta size of the crate */
public static final int maxSize = 2;
@Override
public InventoryCrate getInventory()
{
if (this.inventory == null)
{
inventory = new InventoryCrate(this);
}
return (InventoryCrate) this.inventory;
}
/** delay from last click */
public long prevClickTime = -1000;
/** Gets the sample stack that represent the total inv */
public ItemStack getSampleStack()
{
if (this.sampleStack == null)
{
this.buildSampleStack();
}
return this.sampleStack;
}
/** Check to see if oreName items can be force stacked */
public boolean oreFilterEnabled = false;
/**
* 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;
/** Collective total stack of all inv slots */
private ItemStack sampleStack;
private ItemStack filterStack;
boolean rebuildBase = false;
/* 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()));
}
}
/** Adds the stack to the sample stack */
public void addToStack(ItemStack stack)
{
if (stack != null)
{
this.buildSampleStack();
boolean flag = false;
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;
}
if (flag)
{
this.getInventory().buildInventory(this.sampleStack);
this.onInventoryChanged();
}
}
}
private long updateTick = 1;
private boolean doUpdate = false;
@Override
public void onInventoryChanged()
public void updateEntity()
{
super.onInventoryChanged();
if (worldObj != null && !worldObj.isRemote)
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);
}
}
@Override
public boolean canStore(ItemStack stack, int slot, ForgeDirection side)
{
return sampleStack == null || stack != null && (stack.isItemEqual(sampleStack) || OreDictionary.getOreID(sampleStack) == OreDictionary.getOreID(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());
}
/** Gets the slot count for the crate meta */
@ -190,9 +75,169 @@ public class TileCrate extends TileExternalInventory implements IPacketReceiver,
}
@Override
public boolean canUpdate()
public InventoryCrate getInventory()
{
return false;
if (this.inventory == null)
{
inventory = new InventoryCrate(this);
}
return (InventoryCrate) this.inventory;
}
/** Gets the sample stack that represent the total inventory */
public ItemStack getSampleStack()
{
if (this.sampleStack == null)
{
this.buildSampleStack();
}
return this.sampleStack;
}
/** 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);
}
public void buildSampleStack(boolean buildInv)
{
if (worldObj == null || !worldObj.isRemote)
{
ItemStack newSampleStack = null;
boolean rebuildBase = false;
/* 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;
}
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();
}
/* 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);
}
}
}
@Override
public ItemStack addStackToStorage(ItemStack stack)
{
return BlockCrate.addStackToCrate(this, stack);
}
/** 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);
}
}
/** 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 ItemStack decrStackSize(int slot, int amount)
{
if (sampleStack != null)
{
ItemStack var3;
if (sampleStack.stackSize <= amount)
{
var3 = sampleStack;
sampleStack = null;
this.onInventoryChanged();
getInventory().buildInventory(getSampleStack());
return var3;
}
else
{
var3 = sampleStack.splitStack(amount);
if (sampleStack.stackSize == 0)
{
sampleStack = null;
}
getInventory().buildInventory(getSampleStack());
onInventoryChanged();
return var3;
}
}
else
{
return null;
}
}
@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)));
}
/** 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
@ -261,6 +306,11 @@ public class TileCrate extends TileExternalInventory implements IPacketReceiver,
this.sampleStack = stack;
this.getInventory().buildInventory(this.sampleStack);
}
this.oreFilterEnabled = nbt.getBoolean("oreFilter");
if (nbt.hasKey("filter"))
{
filterStack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("filter"));
}
}
@ -269,7 +319,7 @@ public class TileCrate extends TileExternalInventory implements IPacketReceiver,
{
super.writeToNBT(nbt);
/* Re-Build sample stack for saving */
this.buildSampleStack();
this.buildSampleStack(false);
ItemStack stack = this.getSampleStack();
/* Save sample stack */
if (stack != null)
@ -277,13 +327,24 @@ public class TileCrate extends TileExternalInventory implements IPacketReceiver,
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 addStackToStorage(ItemStack stack)
public ItemStack getFilter()
{
return BlockCrate.addStackToCrate(this, stack);
return this.filterStack;
}
@Override
public void setFilter(ItemStack filter)
{
this.filterStack = filter;
this.onInventoryChanged();
}
}

View file

@ -1,19 +1,8 @@
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)
@ -22,56 +11,4 @@ public class ItemHammer extends Item
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;
}
}

View file

@ -19,29 +19,35 @@ import net.minecraft.network.packet.Packet;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary;
import org.apache.commons.lang3.ArrayUtils;
import org.lwjgl.opengl.GL11;
import resonant.api.IRotatable;
import resonant.api.ISlotPickResult;
import resonant.api.recipe.MachineRecipes;
import resonant.api.recipe.RecipeResource;
import resonant.lib.content.module.TileRender;
import resonant.lib.content.module.prefab.TileInventory;
import resonant.lib.gui.ContainerDummy;
import resonant.lib.network.IPacketReceiver;
import resonant.lib.network.PacketHandler;
import resonant.lib.prefab.item.ItemBlockSaved;
import resonant.lib.prefab.vector.Cuboid;
import resonant.lib.render.RenderItemOverlayUtility;
import resonant.lib.type.Pair;
import resonant.lib.utility.LanguageUtility;
import resonant.lib.utility.WorldUtility;
import resonant.lib.utility.inventory.AutoCraftingManager;
import resonant.lib.utility.inventory.AutoCraftingManager.IAutoCrafter;
import resonant.lib.utility.inventory.InventoryUtility;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.ResonantInduction.RecipeType;
import resonantinduction.core.prefab.imprint.ItemImprint;
import universalelectricity.api.vector.Vector2;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.content.module.TileRender;
import calclavia.lib.content.module.prefab.TileInventory;
import calclavia.lib.gui.ContainerDummy;
import calclavia.lib.type.Pair;
import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.PacketHandler;
import calclavia.lib.prefab.item.ItemBlockSaved;
import calclavia.lib.prefab.slot.ISlotPickResult;
import calclavia.lib.prefab.tile.IRotatable;
import calclavia.lib.prefab.vector.Cuboid;
import calclavia.lib.render.RenderItemOverlayUtility;
import calclavia.lib.utility.WorldUtility;
import calclavia.lib.utility.inventory.AutoCraftingManager;
import calclavia.lib.utility.inventory.AutoCraftingManager.IAutoCrafter;
import calclavia.lib.utility.inventory.InventoryUtility;
import codechicken.multipart.ControlKeyModifer;
import com.google.common.io.ByteArrayDataInput;
@ -49,6 +55,10 @@ import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/** Advanced crafting table that stores its crafting grid, can craft out of the player's inv, and be
* configed to auto craft.
*
* @author DarkGuardsman, Calclavia */
public class TileEngineeringTable extends TileInventory implements IPacketReceiver, IRotatable, ISidedInventory, ISlotPickResult, IAutoCrafter
{
public static final int CRAFTING_MATRIX_END = 9;
@ -58,7 +68,6 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv
// Relative slot IDs
public static final int CRAFTING_OUTPUT_SLOT = 0;
private static final int IMPRINT_SLOT = 1;
private AutoCraftingManager craftManager;
@ -110,24 +119,15 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv
{
if (!world().isRemote && ControlKeyModifer.isControlDown(player))
{
if (this instanceof IInventory)
{
IInventory inventory = this;
// Don't drop the output, so subtract by one.
for (int i = 0; i < inventory.getSizeInventory() - 1; ++i)
for (int i = 0; i < getSizeInventory() - 1; ++i)
{
ItemStack dropStack = inventory.getStackInSlot(i);
if (dropStack != null)
if (getStackInSlot(i) != null)
{
InventoryUtility.dropItemStack(world(), new Vector3(player), dropStack);
inventory.setInventorySlotContents(i, null);
InventoryUtility.dropItemStack(world(), new Vector3(player), getStackInSlot(i));
setInventorySlotContents(i, null);
}
}
inventory.onInventoryChanged();
}
}
}
@ -136,7 +136,44 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv
{
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemHammer)
{
return false;
for (int slot = 0; slot < TileEngineeringTable.CRAFTING_OUTPUT_END; slot++)
{
ItemStack inputStack = getStackInSlot(slot);
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 != null && outputs.length > 0)
{
if (!world().isRemote && world().rand.nextFloat() < 0.2)
{
for (RecipeResource resource : outputs)
{
ItemStack outputStack = resource.getItemStack().copy();
if (outputStack != null)
{
InventoryUtility.dropItemStack(world(), new Vector3(player), outputStack, 0);
setInventorySlotContents(slot, --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.1f);
player.getCurrentEquippedItem().damageItem(1, player);
return true;
}
}
}
}
return true;
}
if (hitSide == 1)
@ -214,13 +251,12 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv
if (player.isSneaking())
{
searchInventories = !searchInventories;
if (!world().isRemote)
{
if (searchInventories)
player.addChatMessage("Engineering table will now search for nearby inventories for resources.");
player.addChatMessage(LanguageUtility.getLocal("engineerTable.config.inventory.true"));
else
player.addChatMessage("Engineering table will not search for nearby inventories for resources.");
player.addChatMessage(LanguageUtility.getLocal("engineerTable.config.inventory.false"));
}
markUpdate();
@ -422,10 +458,8 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv
onInventoryChanged();
}
/**
* When some containers are closed they call this on each slot, then drop whatever it returns as
* an EntityItem - like when you close a workbench GUI.
*/
/** When some containers are closed they call this on each slot, then drop whatever it returns as
* an EntityItem - like when you close a workbench GUI. */
@Override
public ItemStack getStackInSlotOnClosing(int slot)
{
@ -459,11 +493,9 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv
this.onInventoryChanged();
}
/**
* Construct an InventoryCrafting Matrix on the fly.
/** Construct an InventoryCrafting Matrix on the fly.
*
* @return
*/
* @return */
public InventoryCrafting getCraftingMatrix()
{
InventoryCrafting inventoryCrafting = new InventoryCrafting(new ContainerDummy(this), 3, 3);

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'
@ -100,7 +97,7 @@ allprojects {
subprojects {
archivesBaseName = "${System.getenv().JOB_NAME}"
sourceSets.main.compileClasspath += rootProject.sourceSets.api.output
dependencies {
compile rootProject
}

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;
@ -79,6 +82,9 @@ public class Electrical
public static Block blockBattery;
public static Block blockEncoder;
// Railings
public static Item itemRailing;
// Generators
public static Block blockSolarPanel;
public static Block blockMotor;
@ -94,9 +100,15 @@ public class Electrical
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,12 +7,12 @@ 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;
@ -36,7 +36,7 @@ public class BlockArmbot extends BlockTile
if (tileEntity instanceof IMultiBlock)
{
CalclaviaLoader.blockMulti.createMultiBlockStructure((IMultiBlock) tileEntity);
ResonantEngine.blockMulti.createMultiBlockStructure((IMultiBlock) tileEntity);
}
}
@ -61,7 +61,7 @@ public class BlockArmbot extends BlockTile
if (tileEntity instanceof TileArmbot)
{
((TileArmbot) tileEntity).dropHeldObject();
CalclaviaLoader.blockMulti.destroyMultiBlockStructure((TileArmbot) tileEntity);
ResonantEngine.blockMulti.destroyMultiBlockStructure((TileArmbot) tileEntity);
}
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(this));

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,6 +6,8 @@ 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;
@ -25,8 +27,8 @@ public class EnergyDistributionNetwork extends Network<EnergyDistributionNetwork
for (TileEnergyDistribution connector : this.getConnectors())
{
totalEnergy += connector.energy.getEnergy();
totalCapacity += connector.energy.getEnergyCapacity();
totalEnergy += connector.getEnergyHandler().getEnergy();
totalCapacity += connector.getEnergyHandler().getEnergyCapacity();
lowestY = Math.min(connector.yCoord, lowestY);
highestY = Math.max(connector.yCoord, highestY);
@ -34,9 +36,7 @@ public class EnergyDistributionNetwork extends Network<EnergyDistributionNetwork
connector.renderEnergyAmount = 0;
}
/**
* Apply render
*/
/** Apply render */
long remainingRenderEnergy = totalEnergy;
for (int y = lowestY; y <= highestY; y++)
@ -56,7 +56,7 @@ public class EnergyDistributionNetwork extends Network<EnergyDistributionNetwork
for (TileEnergyDistribution connector : connectorsInlevel)
{
long tryInject = Math.min(remainingRenderEnergy / levelSize, connector.energy.getEnergyCapacity());
long tryInject = Math.min(remainingRenderEnergy / levelSize, connector.getEnergyHandler().getEnergyCapacity());
connector.renderEnergyAmount = tryInject;
used += tryInject;
}
@ -67,9 +67,7 @@ public class EnergyDistributionNetwork extends Network<EnergyDistributionNetwork
break;
}
/**
* Apply energy loss.
*/
/** Apply energy loss. */
double percentageLoss = 0;// Math.max(0, (1 - (getConnectors().size() * 6 / 100d)));
long energyLoss = (long) (percentageLoss * 100);
totalEnergy -= energyLoss;
@ -86,14 +84,14 @@ public class EnergyDistributionNetwork extends Network<EnergyDistributionNetwork
{
if (node != firstNode && !Arrays.asList(exclusion).contains(node))
{
double percentage = ((double) node.energy.getEnergyCapacity() / (double) totalCapacity);
double percentage = ((double) node.getEnergyHandler().getEnergyCapacity() / (double) totalCapacity);
long energyForBattery = Math.max(Math.round(totalEnergy * percentage), 0);
node.energy.setEnergy(energyForBattery);
node.getEnergyHandler().setEnergy(energyForBattery);
remainingEnergy -= energyForBattery;
}
}
firstNode.energy.setEnergy(Math.max(remainingEnergy, 0));
firstNode.getEnergyHandler().setEnergy(Math.max(remainingEnergy, 0));
}
}

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,40 +14,30 @@ 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
*/
/** Tiers: 0, 1, 2 */
public static final int MAX_TIER = 2;
/** 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.energy = new EnergyStorageHandler(0);
this.setEnergyHandler(new EnergyStorageHandler(0));
this.getEnergyHandler().setCapacity(Long.MAX_VALUE);
this.ioMap = 0;
this.saveIOMap = true;
}
/**
* @param tier - 0, 1, 2
* @return
*/
/** @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);
@ -55,7 +47,8 @@ public class TileBattery extends TileEnergyDistribution implements IVoltageInput
public void initiate()
{
super.initiate();
energy.setCapacity(getEnergyForTier(getBlockMetadata()));
getEnergyHandler().setCapacity(getEnergyForTier(getBlockMetadata()));
getEnergyHandler().setMaxTransfer(getEnergyHandler().getEnergyCapacity());
}
@Override
@ -63,9 +56,6 @@ public class TileBattery extends TileEnergyDistribution implements IVoltageInput
{
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;
}
@ -81,7 +71,7 @@ public class TileBattery extends TileEnergyDistribution implements IVoltageInput
@Override
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
{
energy.setEnergy(data.readLong());
getEnergyHandler().setEnergy(data.readLong());
ioMap = data.readShort();
}
@ -97,13 +87,13 @@ public class TileBattery extends TileEnergyDistribution implements IVoltageInput
@Override
public long getVoltageOutput(ForgeDirection side)
{
return DEFAULT_VOLTAGE;
return UniversalElectricity.DEFAULT_VOLTAGE;
}
@Override
public long getVoltageInput(ForgeDirection direction)
{
return DEFAULT_VOLTAGE;
return UniversalElectricity.DEFAULT_VOLTAGE;
}
@Override
@ -118,4 +108,10 @@ public class TileBattery extends TileEnergyDistribution implements IVoltageInput
super.setIO(dir, type);
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public String toString()
{
return "[TileBattery]" + x() + "x " + y() + "y " + z() + "z ";
}
}

View file

@ -1,14 +1,13 @@
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;

View file

@ -4,55 +4,28 @@ 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 void readDesc(MCDataInput packet)
{
super.readDesc(packet);
getInventory().load(packet.readNBTTagCompound());
}
@Override
public void writeDesc(MCDataOutput packet)
{
super.writeDesc(packet);
NBTTagCompound nbt = new NBTTagCompound();
getInventory().save(nbt);
packet.writeNBTTagCompound(nbt);
}
@Override
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item)
{
@ -97,30 +70,29 @@ public class PartCharger extends PartFace implements IExternalInventory, ISidedI
@Override
public boolean canConnect(ForgeDirection direction, Object obj)
{
return obj instanceof IEnergyInterface;
return obj instanceof IEnergyInterface && placementSide != direction.getOpposite();
}
@Override
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
{
long energyUsed = 0;
long energyLeft = receive;
for (int i = 0; i < this.getSizeInventory(); i++)
if (receive > 0)
{
long input = CompatibilityModule.chargeItem(this.getStackInSlot(i), energyLeft, true);
energyUsed += input;
energyLeft -= input;
if (energyLeft <= 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;
}
if (!world().isRemote && energyUsed > 0 && System.currentTimeMillis() - this.lastPacket >= 50)
{
this.lastPacket = System.currentTimeMillis();
sendDescUpdate();
}
if (energyUsed > 0)
this.markedForUpdate = true;
return energyUsed;
}
return 0;
}
@Override
public long onExtractEnergy(ForgeDirection from, long extract, boolean doExtract)
@ -163,166 +135,15 @@ public class PartCharger extends PartFace implements IExternalInventory, ISidedI
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;
return slot < this.getSizeInventory() && stack != null && CompatibilityModule.isHandler(stack.getItem());
}
@Override
public boolean canRemove(ItemStack stack, int slot, ForgeDirection side)
public String toString()
{
if (slot >= this.getSizeInventory())
{
return false;
return "[PartCharger]" + x() + "x " + y() + "y " + z() + "z " + getSlotMask() + "s ";
}
return true;
}
@Override
public void onInventoryChanged()
{
}
}

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,6 +43,7 @@ public class TileMotor extends TileElectrical implements IRotatable, INodeProvid
public void initiate()
{
super.initiate();
if (node != null)
node.reconstruct();
}
@ -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