Removed archives
This commit is contained in:
parent
ee72700954
commit
8f11e8fcf1
399 changed files with 0 additions and 48288 deletions
|
@ -1,77 +0,0 @@
|
||||||
package resonantinduction.core;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import resonant.lib.utility.nbt.ISaveObj;
|
|
||||||
import resonant.lib.utility.nbt.NBTUtility;
|
|
||||||
|
|
||||||
/** Used to store arguments in a way that can be easier to loaded, saved, and limited without knowing
|
|
||||||
* what the data contains.
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman */
|
|
||||||
public class ArgumentData implements ISaveObj
|
|
||||||
{
|
|
||||||
protected String name;
|
|
||||||
protected Object currentValue;
|
|
||||||
protected final Object defaultValue;
|
|
||||||
|
|
||||||
public ArgumentData(String name, Object defaultValue)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
this.defaultValue = defaultValue;
|
|
||||||
this.currentValue = defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Sets the value
|
|
||||||
*
|
|
||||||
* @return true if the value was accepted */
|
|
||||||
public boolean setData(Object object)
|
|
||||||
{
|
|
||||||
if (this.isValid(object))
|
|
||||||
{
|
|
||||||
this.currentValue = object;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Gets the value of the stored data */
|
|
||||||
public Object getData()
|
|
||||||
{
|
|
||||||
return this.currentValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isValid(Object object)
|
|
||||||
{
|
|
||||||
return object != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Is this argument valid. */
|
|
||||||
public boolean isValid()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Used by things like a gui to give a warning such as limits of data this can accept */
|
|
||||||
public String warning()
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
NBTUtility.saveObject(nbt, "ObjectData", this.currentValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
this.currentValue = NBTUtility.loadObject(nbt, "ObjectData");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
package dark.lib;
|
|
||||||
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.client.renderer.texture.IconRegister;
|
|
||||||
import net.minecraft.util.Icon;
|
|
||||||
import net.minecraftforge.common.Configuration;
|
|
||||||
import net.minecraftforge.fluids.BlockFluidFinite;
|
|
||||||
import net.minecraftforge.fluids.Fluid;
|
|
||||||
import resonantinduction.core.Settings;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
public class BlockFluid extends BlockFluidFinite
|
|
||||||
{
|
|
||||||
Icon flowing;
|
|
||||||
Icon still;
|
|
||||||
Fluid fluid;
|
|
||||||
String prefix = "";
|
|
||||||
|
|
||||||
public BlockFluid(String prefix, Fluid fluid, Configuration config)
|
|
||||||
{
|
|
||||||
this(prefix, Settings.getNextBlockID(), fluid, config);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockFluid(String prefix, int id, Fluid fluid, Configuration config)
|
|
||||||
{
|
|
||||||
super(config.getBlock("BlockFluid" + fluid.getName(), id).getInt(), fluid, Material.water);
|
|
||||||
this.fluid = fluid;
|
|
||||||
if (prefix != null && prefix.contains(":"))
|
|
||||||
{
|
|
||||||
this.prefix = prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void registerIcons(IconRegister par1IconRegister)
|
|
||||||
{
|
|
||||||
this.flowing = par1IconRegister.registerIcon(prefix + this.getUnlocalizedName().replace("tile.", "") + "_flowing");
|
|
||||||
this.still = par1IconRegister.registerIcon(prefix + this.getUnlocalizedName().replace("tile.", "") + "_still");
|
|
||||||
fluid.setIcons(still, flowing);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public Icon getIcon(int par1, int par2)
|
|
||||||
{
|
|
||||||
return still;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
package dark.lib;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
||||||
import net.minecraft.item.ItemBlock;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
|
|
||||||
import com.builtbroken.common.Pair;
|
|
||||||
|
|
||||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
|
||||||
import dark.lib.IExtraInfo.IExtraBlockInfo;
|
|
||||||
|
|
||||||
public class ClientRegistryProxy extends RegistryProxy
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void registerBlock(Block block, Class<? extends ItemBlock> itemClass, String name, String modID)
|
|
||||||
{
|
|
||||||
super.registerBlock(block, itemClass, name, modID);
|
|
||||||
if (block instanceof IExtraBlockInfo)
|
|
||||||
{
|
|
||||||
List<Pair<Class<? extends TileEntity>, TileEntitySpecialRenderer>> set = new ArrayList<Pair<Class<? extends TileEntity>, TileEntitySpecialRenderer>>();
|
|
||||||
((IExtraBlockInfo) block).getClientTileEntityRenderers(set);
|
|
||||||
for (Pair<Class<? extends TileEntity>, TileEntitySpecialRenderer> par : set)
|
|
||||||
{
|
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(par.left(), par.right());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,257 +0,0 @@
|
||||||
package dark.lib;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemBlock;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraftforge.common.Configuration;
|
|
||||||
import net.minecraftforge.fluids.Fluid;
|
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
|
||||||
|
|
||||||
import com.builtbroken.common.Pair;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
|
||||||
import cpw.mods.fml.common.Loader;
|
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
|
||||||
import dark.lib.IExtraInfo.IExtraBlockInfo;
|
|
||||||
import dark.lib.IExtraInfo.IExtraItemInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handler to make registering all parts of a mod's objects that are loaded into the game by forge
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public class CoreRegistry
|
|
||||||
{
|
|
||||||
public static HashMap<Block, String> registredBlocks = new HashMap<Block, String>();
|
|
||||||
public static HashMap<Item, String> registredItems = new HashMap<Item, String>();
|
|
||||||
|
|
||||||
//@SidedProxy(clientSide = "com.builtbroken.minecraft.ClientRegistryProxy", serverSide = "com.builtbroken.minecraft.RegistryProxy")
|
|
||||||
public static RegistryProxy prox;
|
|
||||||
|
|
||||||
public static RegistryProxy proxy()
|
|
||||||
{
|
|
||||||
if (prox == null)
|
|
||||||
{
|
|
||||||
if (FMLCommonHandler.instance().getSide().isClient())
|
|
||||||
{
|
|
||||||
prox = new ClientRegistryProxy();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
prox = new RegistryProxy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return prox;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Configuration masterBlockConfig = new Configuration(new File(Loader.instance().getConfigDir(), "objects/EnabledBlocks.cfg"));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a block using reflection, and runs it threw config checks
|
|
||||||
*
|
|
||||||
* @param name - name to register the block with
|
|
||||||
* @param modID - mod id to register the block to
|
|
||||||
* @param blockClass - class to generate the instance from
|
|
||||||
*/
|
|
||||||
public static Block createNewBlock(String name, String modID, Class<? extends Block> blockClass)
|
|
||||||
{
|
|
||||||
return CoreRegistry.createNewBlock(name, modID, blockClass, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a block using reflection, and runs it threw config checks
|
|
||||||
*
|
|
||||||
* @param name - name to register the block with
|
|
||||||
* @param modID - mod id to register the block to
|
|
||||||
* @param blockClass - class to generate the instance from
|
|
||||||
* @param canDisable - should we allow the player the option to disable the block
|
|
||||||
*/
|
|
||||||
public static Block createNewBlock(String name, String modID, Class<? extends Block> blockClass, boolean canDisable)
|
|
||||||
{
|
|
||||||
return CoreRegistry.createNewBlock(name, modID, blockClass, null, canDisable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a block using reflection, and runs it threw config checks
|
|
||||||
*
|
|
||||||
* @param name - name to register the block with
|
|
||||||
* @param modID - mod id to register the block to
|
|
||||||
* @param blockClass - class to generate the instance from
|
|
||||||
* @param itemClass - item block to register with the block
|
|
||||||
*/
|
|
||||||
public static Block createNewBlock(String name, String modID, Class<? extends Block> blockClass, Class<? extends ItemBlock> itemClass)
|
|
||||||
{
|
|
||||||
return createNewBlock(name, modID, blockClass, itemClass, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a block using reflection, and runs it threw config checks
|
|
||||||
*
|
|
||||||
* @param name - name to register the block with
|
|
||||||
* @param modID - mod id to register the block to
|
|
||||||
* @param blockClass - class to generate the instance from
|
|
||||||
* @param canDisable - should we allow the player the option to disable the block
|
|
||||||
* @param itemClass - item block to register with the block
|
|
||||||
*/
|
|
||||||
public static Block createNewBlock(String name, String modID, Class<? extends Block> blockClass, Class<? extends ItemBlock> itemClass, boolean canDisable)
|
|
||||||
{
|
|
||||||
Block block = null;
|
|
||||||
if (blockClass != null && (!canDisable || canDisable && masterBlockConfig.get("Enabled_List", "Enabled_" + name, true).getBoolean(true)))
|
|
||||||
{
|
|
||||||
// TODO redesign to catch blockID conflict
|
|
||||||
try
|
|
||||||
{
|
|
||||||
block = blockClass.newInstance();
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException e)
|
|
||||||
{
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
System.out.println("\n\nWarning: Block [" + name + "] failed to be created\n");
|
|
||||||
e.printStackTrace();
|
|
||||||
System.out.println("\n\n");
|
|
||||||
}
|
|
||||||
if (block != null)
|
|
||||||
{
|
|
||||||
registredBlocks.put(block, name);
|
|
||||||
proxy().registerBlock(block, itemClass, name, modID);
|
|
||||||
CoreRegistry.finishCreation(block);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return block;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Finishes the creation of the block loading config files and tile entities */
|
|
||||||
public static void finishCreation(Block block)
|
|
||||||
{
|
|
||||||
if (block instanceof IExtraInfo)
|
|
||||||
{
|
|
||||||
if (((IExtraInfo) block).hasExtraConfigs())
|
|
||||||
{
|
|
||||||
Configuration extraBlockConfig = new Configuration(new File(Loader.instance().getConfigDir(), "objects/blocks/" + block.getUnlocalizedName() + ".cfg"));
|
|
||||||
extraBlockConfig.load();
|
|
||||||
((IExtraInfo) block).loadExtraConfigs(extraBlockConfig);
|
|
||||||
extraBlockConfig.save();
|
|
||||||
}
|
|
||||||
if (block instanceof IExtraBlockInfo)
|
|
||||||
{
|
|
||||||
((IExtraBlockInfo) block).loadOreNames();
|
|
||||||
Set<Pair<String, Class<? extends TileEntity>>> tileListNew = new HashSet<Pair<String, Class<? extends TileEntity>>>();
|
|
||||||
((IExtraBlockInfo) block).getTileEntities(block.blockID, tileListNew);
|
|
||||||
for (Pair<String, Class<? extends TileEntity>> par : tileListNew)
|
|
||||||
{
|
|
||||||
proxy().regiserTileEntity(par.left(), par.right());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to get block via name
|
|
||||||
*
|
|
||||||
* @param blockName
|
|
||||||
* @return Block requested
|
|
||||||
*/
|
|
||||||
public static Block getBlock(String blockName)
|
|
||||||
{
|
|
||||||
for (Entry<Block, String> entry : registredBlocks.entrySet())
|
|
||||||
{
|
|
||||||
String name = entry.getKey().getUnlocalizedName().replace("tile.", "");
|
|
||||||
if (name.equalsIgnoreCase(blockName))
|
|
||||||
{
|
|
||||||
return entry.getKey();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new fluid block using the prefab following a few conditions.
|
|
||||||
*
|
|
||||||
* @param modDomainPrefix - prefix of the mod, used for texture refrence and block registry
|
|
||||||
* @param config - config file to pull the blockID from
|
|
||||||
* @param fluid - fluid to link to this block
|
|
||||||
*/
|
|
||||||
public static Block createNewFluidBlock(String modDomainPrefix, Configuration config, Fluid fluid)
|
|
||||||
{
|
|
||||||
Block fluidBlock = null;
|
|
||||||
Fluid fluidActual = null;
|
|
||||||
if (config != null && fluid != null && config.get("general", "EnableFluid_" + fluid.getName(), true).getBoolean(true) && FluidRegistry.getFluid(fluid.getName()) == null)
|
|
||||||
{
|
|
||||||
FluidRegistry.registerFluid(fluid);
|
|
||||||
fluidActual = FluidRegistry.getFluid(fluid.getName());
|
|
||||||
if (fluidActual == null)
|
|
||||||
{
|
|
||||||
fluidActual = fluid;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fluidActual.getBlockID() == -1 && masterBlockConfig.get("Enabled_List", "Enabled_" + fluid.getName() + "Block", true).getBoolean(true))
|
|
||||||
{
|
|
||||||
fluidBlock = new BlockFluid(modDomainPrefix, fluidActual, config).setUnlocalizedName("tile.Fluid." + fluid.getName());
|
|
||||||
proxy().registerBlock(fluidBlock, null, "DMBlockFluid" + fluid.getName(), modDomainPrefix);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fluidBlock = Block.blocksList[fluid.getBlockID()];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return fluidBlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new item using reflection as well runs it threw some check to activate any
|
|
||||||
* interface methods
|
|
||||||
*
|
|
||||||
* @param name - name to register the item with
|
|
||||||
* @param modid - mods that the item comes from
|
|
||||||
* @param clazz - item class
|
|
||||||
* @param canDisable - can a user disable this item
|
|
||||||
* @return the new item
|
|
||||||
*/
|
|
||||||
public static Item createNewItem(String name, String modid, Class<? extends Item> clazz, boolean canDisable)
|
|
||||||
{
|
|
||||||
Item item = null;
|
|
||||||
if (clazz != null && (!canDisable || canDisable && masterBlockConfig.get("Enabled_List", "Enabled_" + name, true).getBoolean(true)))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
item = clazz.newInstance();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if (item != null)
|
|
||||||
{
|
|
||||||
registredItems.put(item, name);
|
|
||||||
GameRegistry.registerItem(item, name, modid);
|
|
||||||
if (item instanceof IExtraInfo)
|
|
||||||
{
|
|
||||||
if (((IExtraInfo) item).hasExtraConfigs())
|
|
||||||
{
|
|
||||||
Configuration extraBlockConfig = new Configuration(new File(Loader.instance().getConfigDir(), "objects/items/" + item.getUnlocalizedName() + ".cfg"));
|
|
||||||
extraBlockConfig.load();
|
|
||||||
((IExtraInfo) item).loadExtraConfigs(extraBlockConfig);
|
|
||||||
extraBlockConfig.save();
|
|
||||||
}
|
|
||||||
if (item instanceof IExtraItemInfo)
|
|
||||||
{
|
|
||||||
((IExtraItemInfo) item).loadOreNames();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,143 +0,0 @@
|
||||||
package dark.lib;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.item.EnumToolMaterial;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.Icon;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class for storing materials, there icon names, sub items to be made from them or there sub ores
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public enum EnumMaterial
|
|
||||||
{
|
|
||||||
WOOD("Wood", EnumToolMaterial.WOOD, EnumOrePart.INGOTS, EnumOrePart.PLATES, EnumOrePart.RUBBLE, EnumOrePart.ROD, EnumOrePart.MOLTEN),
|
|
||||||
STONE("Stone", EnumToolMaterial.STONE, EnumOrePart.INGOTS, EnumOrePart.SCRAPS, EnumOrePart.MOLTEN),
|
|
||||||
IRON("Iron", EnumToolMaterial.IRON, EnumOrePart.INGOTS),
|
|
||||||
OBBY("Obby", true, 7.0f, 500, 4, EnumOrePart.INGOTS, EnumOrePart.RUBBLE, EnumOrePart.SCRAPS, EnumOrePart.PLATES, EnumOrePart.MOLTEN),
|
|
||||||
GOLD("Gold", EnumToolMaterial.GOLD, EnumOrePart.GEARS, EnumOrePart.INGOTS),
|
|
||||||
COAL("Coal", EnumToolMaterial.WOOD, EnumOrePart.GEARS, EnumOrePart.TUBE, EnumOrePart.PLATES, EnumOrePart.RUBBLE, EnumOrePart.SCRAPS, EnumOrePart.MOLTEN),
|
|
||||||
|
|
||||||
COPPER("Copper", true, 3.5f, 79, 1),
|
|
||||||
TIN("Tin", true, 2.0f, 50, 1, EnumOrePart.GEARS, EnumOrePart.TUBE),
|
|
||||||
LEAD("Lead", false, 0, 0, 1, EnumOrePart.GEARS, EnumOrePart.TUBE),
|
|
||||||
ALUMINIUM("Aluminum", true, 5.0f, 100, 2, EnumOrePart.GEARS, EnumOrePart.TUBE),
|
|
||||||
SILVER("Silver", true, 11.0f, 30, 0, EnumOrePart.GEARS),
|
|
||||||
STEEL("Steel", true, 7.0f, 4, 1000, EnumOrePart.RUBBLE),
|
|
||||||
BRONZE("Bronze", true, 6.5f, 3, 560, EnumOrePart.RUBBLE);
|
|
||||||
|
|
||||||
/** Name of the material */
|
|
||||||
public String simpleName;
|
|
||||||
/** List of ore parts that to not be created for the material */
|
|
||||||
public List<EnumOrePart> unneedItems;
|
|
||||||
|
|
||||||
public boolean hasTools = false;
|
|
||||||
|
|
||||||
/** Limit by which each material is restricted by for creating orePart sub items */
|
|
||||||
public static final int itemCountPerMaterial = 50;
|
|
||||||
|
|
||||||
/** Client side only var used by ore items to store icon per material set */
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public Icon[] itemIcons;
|
|
||||||
|
|
||||||
public float materialEffectiveness = 2.0f;
|
|
||||||
public int maxUses = 100;
|
|
||||||
public float damageBoost = 0;
|
|
||||||
|
|
||||||
private EnumMaterial(String name, EnumToolMaterial material, EnumOrePart... enumOreParts)
|
|
||||||
{
|
|
||||||
this(name, false, material.getEfficiencyOnProperMaterial(), material.getMaxUses(), material.getDamageVsEntity(), enumOreParts);
|
|
||||||
}
|
|
||||||
|
|
||||||
private EnumMaterial(String name, boolean tool, float effectiveness, int toolUses, float damage, EnumOrePart... enumOreParts)
|
|
||||||
{
|
|
||||||
this.simpleName = name;
|
|
||||||
this.hasTools = tool;
|
|
||||||
this.materialEffectiveness = effectiveness;
|
|
||||||
this.maxUses = toolUses;
|
|
||||||
this.damageBoost = damage;
|
|
||||||
unneedItems = new ArrayList<EnumOrePart>();
|
|
||||||
for (int i = 0; enumOreParts != null && i < enumOreParts.length; i++)
|
|
||||||
{
|
|
||||||
unneedItems.add(enumOreParts[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new item stack using material and part given. Uses a preset length of 50 for parts
|
|
||||||
* enum so to prevent any unwanted changes in loading of itemStacks metadata.
|
|
||||||
*
|
|
||||||
* @param mat - material
|
|
||||||
* @param part - part
|
|
||||||
* @return new ItemStack created from the two enums as long as everything goes right
|
|
||||||
*/
|
|
||||||
public static ItemStack getStack(Item item, EnumMaterial mat, EnumOrePart part, int ammount)
|
|
||||||
{
|
|
||||||
ItemStack reStack = null;
|
|
||||||
if (mat != null && part != null)
|
|
||||||
{
|
|
||||||
if (part == EnumOrePart.INGOTS)
|
|
||||||
{
|
|
||||||
if (mat == EnumMaterial.IRON)
|
|
||||||
{
|
|
||||||
return new ItemStack(Item.ingotIron, 1);
|
|
||||||
}
|
|
||||||
else if (mat == EnumMaterial.GOLD)
|
|
||||||
{
|
|
||||||
return new ItemStack(Item.ingotGold, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int meta = mat.ordinal() * itemCountPerMaterial;
|
|
||||||
meta += part.ordinal();
|
|
||||||
return new ItemStack(item, ammount, meta);
|
|
||||||
}
|
|
||||||
return reStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getStack(Item item, EnumOrePart part)
|
|
||||||
{
|
|
||||||
return this.getStack(item, part, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getStack(Item item, EnumOrePart part, int ammount)
|
|
||||||
{
|
|
||||||
return getStack(item, this, part, ammount);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Icon getIcon(int metadata)
|
|
||||||
{
|
|
||||||
int mat = metadata / EnumMaterial.itemCountPerMaterial;
|
|
||||||
if (mat < EnumMaterial.values().length)
|
|
||||||
{
|
|
||||||
return EnumMaterial.values()[metadata / EnumMaterial.itemCountPerMaterial].itemIcons[metadata % EnumMaterial.itemCountPerMaterial];
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getOreName(EnumMaterial mat, EnumOrePart part)
|
|
||||||
{
|
|
||||||
return mat.getOreName(part);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOreName(EnumOrePart part)
|
|
||||||
{
|
|
||||||
return part.simpleName.toLowerCase() + this.simpleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean shouldCreateItem(EnumOrePart part)
|
|
||||||
{
|
|
||||||
return this.unneedItems == null || !this.unneedItems.contains(part);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean shouldCreateTool()
|
|
||||||
{
|
|
||||||
return this.hasTools;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
package dark.lib;
|
|
||||||
|
|
||||||
public enum EnumOrePart
|
|
||||||
{
|
|
||||||
|
|
||||||
RUBBLE("Rubble"), DUST("Dust"), INGOTS("Ingot"), PLATES("Plate"), GEARS("Gears"), TUBE("Tube"),
|
|
||||||
ROD("Rod"), SCRAPS("Scraps"), MOLTEN("Molten");
|
|
||||||
|
|
||||||
public String simpleName;
|
|
||||||
|
|
||||||
private EnumOrePart(String name)
|
|
||||||
{
|
|
||||||
this.simpleName = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This gets the part name based on the meta value of the ore dirv item. However can also be
|
|
||||||
* used to get the part name if under X value
|
|
||||||
*/
|
|
||||||
public static String getPartName(int meta)
|
|
||||||
{
|
|
||||||
int partID = meta % EnumMaterial.itemCountPerMaterial;
|
|
||||||
if (partID < EnumOrePart.values().length)
|
|
||||||
{
|
|
||||||
return EnumOrePart.values()[partID].simpleName;
|
|
||||||
}
|
|
||||||
return "Part[" + partID + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
/** This gets the full name based on the metadata of the ore dirv item */
|
|
||||||
public static String getFullName(int itemMetaData)
|
|
||||||
{
|
|
||||||
int matID = itemMetaData / EnumMaterial.itemCountPerMaterial;
|
|
||||||
int partID = itemMetaData % EnumMaterial.itemCountPerMaterial;
|
|
||||||
if (matID < EnumMaterial.values().length && partID < EnumOrePart.values().length)
|
|
||||||
{
|
|
||||||
return EnumMaterial.values()[matID].simpleName + EnumOrePart.values()[partID].simpleName;
|
|
||||||
}
|
|
||||||
return "OrePart[" + matID + "][" + partID + "]";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
package dark.lib;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraftforge.common.Configuration;
|
|
||||||
|
|
||||||
import com.builtbroken.common.Pair;
|
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to handle info about the block that would normally be handled by the mod main class. Use the
|
|
||||||
* BlockRegistry in order for these methods to be called on load of the mod.
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public interface IExtraInfo
|
|
||||||
{
|
|
||||||
|
|
||||||
/** Does this object need to generate a settings config */
|
|
||||||
public boolean hasExtraConfigs();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the config file for this block. This is a single config file that is tied to just this
|
|
||||||
* block alone. Anything can be stored in the config file but its suggested to use it for
|
|
||||||
* advanced settings for the block/tile. Things like power, update rate, optional features,
|
|
||||||
* graphics, or crafting cost
|
|
||||||
*/
|
|
||||||
public void loadExtraConfigs(Configuration config);
|
|
||||||
|
|
||||||
public static interface IExtraBlockInfo extends IExtraInfo, ITileEntityProvider
|
|
||||||
{
|
|
||||||
|
|
||||||
/** Loads the names used to reference this item in a recipe */
|
|
||||||
public void loadOreNames();
|
|
||||||
|
|
||||||
/** List of all tileEntities this block needs */
|
|
||||||
public void getTileEntities(int blockID, Set<Pair<String, Class<? extends TileEntity>>> list);
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void getClientTileEntityRenderers(List<Pair<Class<? extends TileEntity>, TileEntitySpecialRenderer>> list);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static interface IExtraTileEntityInfo extends IExtraInfo
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static interface IExtraItemInfo extends IExtraInfo
|
|
||||||
{
|
|
||||||
/** Loads the names used to reference this item in a recipe */
|
|
||||||
public void loadOreNames();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
package dark.lib;
|
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.monster.EntityCreeper;
|
|
||||||
import net.minecraft.util.EntityDamageSource;
|
|
||||||
import net.minecraftforge.event.ForgeSubscribe;
|
|
||||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
|
||||||
|
|
||||||
public class LaserEntityDamageSource extends EntityDamageSource
|
|
||||||
{
|
|
||||||
public LaserEntityDamageSource(Entity par2Entity)
|
|
||||||
{
|
|
||||||
super("Laser", par2Entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ForgeSubscribe
|
|
||||||
public void LivingDeathEvent(LivingDeathEvent event)
|
|
||||||
{
|
|
||||||
if (event.entity instanceof EntityCreeper)
|
|
||||||
{
|
|
||||||
if (!event.entity.worldObj.isRemote && event.source instanceof LaserEntityDamageSource)
|
|
||||||
{
|
|
||||||
boolean flag = event.entity.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing");
|
|
||||||
|
|
||||||
if (((EntityCreeper) event.entity).getPowered())
|
|
||||||
{
|
|
||||||
event.entity.worldObj.createExplosion(event.entity, event.entity.posX, event.entity.posY, event.entity.posZ, 3 * 2, flag);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
event.entity.worldObj.createExplosion(event.entity, event.entity.posX, event.entity.posY, event.entity.posZ, 3, flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
package dark.lib;
|
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.EntityLiving;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.DamageSource;
|
|
||||||
|
|
||||||
public class OtherDamageSource extends DamageSource
|
|
||||||
{
|
|
||||||
protected Object damageSource;
|
|
||||||
|
|
||||||
public OtherDamageSource(String damageName, Object attacker)
|
|
||||||
{
|
|
||||||
super(damageName);
|
|
||||||
this.damageSource = attacker;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Entity getEntity()
|
|
||||||
{
|
|
||||||
return damageSource instanceof Entity ? ((Entity) damageSource) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileEntity getTileEntity()
|
|
||||||
{
|
|
||||||
return damageSource instanceof TileEntity ? ((TileEntity) damageSource) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isDifficultyScaled()
|
|
||||||
{
|
|
||||||
return this.damageSource != null && this.damageSource instanceof EntityLiving && !(this.damageSource instanceof EntityPlayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OtherDamageSource setProjectile()
|
|
||||||
{
|
|
||||||
super.setProjectile();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OtherDamageSource doBulletDamage(Object object)
|
|
||||||
{
|
|
||||||
return new OtherDamageSource("Bullets", object).setProjectile();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OtherDamageSource doLaserDamage(Object object)
|
|
||||||
{
|
|
||||||
return new OtherDamageSource("Laser", object).setProjectile();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
package dark.lib;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.item.ItemBlock;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
|
||||||
|
|
||||||
public class RegistryProxy
|
|
||||||
{
|
|
||||||
public void registerBlock(Block block, Class<? extends ItemBlock> itemClass, String name, String modID)
|
|
||||||
{
|
|
||||||
if (block != null && name != null)
|
|
||||||
{
|
|
||||||
GameRegistry.registerBlock(block, itemClass == null ? ItemBlock.class : itemClass, name, modID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void regiserTileEntity(String name, Class<? extends TileEntity> clazz)
|
|
||||||
{
|
|
||||||
GameRegistry.registerTileEntityWithAlternatives(clazz, name, "DM" + name);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,95 +0,0 @@
|
||||||
package dark.lib.helpers;
|
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
public enum ColorCode
|
|
||||||
{
|
|
||||||
BLACK("Black", Color.black), RED("Red", Color.red), GREEN("Green", Color.green),
|
|
||||||
BROWN("Brown", new Color(139, 69, 19)), BLUE("Blue", Color.BLUE),
|
|
||||||
PURPLE("Purple", new Color(75, 0, 130)), CYAN("Cyan", Color.cyan),
|
|
||||||
SILVER("Silver", new Color(192, 192, 192)), GREY("Grey", Color.gray), PINK("Pink", Color.pink),
|
|
||||||
LIME("Lime", new Color(0, 255, 0)), YELLOW("Yellow", Color.yellow),
|
|
||||||
LIGHTBLUE("LightBlue", new Color(135, 206, 250)), MAGENTA("Magenta", Color.magenta),
|
|
||||||
ORANGE("Orange", Color.orange), WHITE("White", Color.white), UNKOWN("", Color.BLACK);
|
|
||||||
|
|
||||||
public String name;
|
|
||||||
public Color color;
|
|
||||||
|
|
||||||
private ColorCode(String name, Color color)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
this.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gets a ColorCode from any of the following
|
|
||||||
*
|
|
||||||
* @param obj - Integer,String,LiquidData,ColorCode
|
|
||||||
* @return Color NONE if it can't find it
|
|
||||||
*/
|
|
||||||
public static ColorCode get(Object obj)
|
|
||||||
{
|
|
||||||
if (obj instanceof Integer && ((Integer) obj) < ColorCode.values().length)
|
|
||||||
{
|
|
||||||
return ColorCode.values()[((Integer) obj)];
|
|
||||||
}
|
|
||||||
else if (obj instanceof ColorCode)
|
|
||||||
{
|
|
||||||
return (ColorCode) obj;
|
|
||||||
}
|
|
||||||
else if (obj instanceof String)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < ColorCode.values().length; i++)
|
|
||||||
{
|
|
||||||
if (((String) obj).equalsIgnoreCase(ColorCode.get(i).getName()))
|
|
||||||
{
|
|
||||||
return ColorCode.get(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return UNKOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Used on anything that is coded for a set color for varies reasons */
|
|
||||||
public static interface IColorCoded
|
|
||||||
{
|
|
||||||
/** Returns the ColorCode of the object */
|
|
||||||
public ColorCode getColor();
|
|
||||||
|
|
||||||
/** Sets the ColorCode of the Object */
|
|
||||||
public boolean setColor(Object obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static interface IColoredItem
|
|
||||||
{
|
|
||||||
/** Returns the ColorCode of the object */
|
|
||||||
public ColorCode getColor(ItemStack stack);
|
|
||||||
|
|
||||||
/** Sets the ColorCode of the Object */
|
|
||||||
public boolean setColor(ItemStack stack, Object obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static interface IColoredId
|
|
||||||
{
|
|
||||||
/** Returns the ColorCode of the object */
|
|
||||||
public ColorCode getColor(int i);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static interface IColoredBlock
|
|
||||||
{
|
|
||||||
/** Returns the ColorCode of the object */
|
|
||||||
public ColorCode getColor(World world, int x, int y, int z);
|
|
||||||
|
|
||||||
/** Sets the ColorCode of the Object */
|
|
||||||
public void setColor(World world, int x, int y, int z, Object obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package dark.lib.interfaces;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applied to objects that can be control by the player using the keyboard
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public interface IControlReceiver
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Called when the player presses a key
|
|
||||||
*
|
|
||||||
* @param player - client player
|
|
||||||
* @param character - character code
|
|
||||||
* @param keycode - keyboard code
|
|
||||||
*/
|
|
||||||
public boolean keyTyped(EntityPlayer player, int keycode);
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
package dark.lib.interfaces;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applied to blocks that store items in stacks above 64 and as one large collective of items
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public interface IExtendedStorage
|
|
||||||
{
|
|
||||||
public ItemStack addStackToStorage(ItemStack stack);
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
package dark.lib.interfaces;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
|
|
||||||
public interface IExternalInv
|
|
||||||
{
|
|
||||||
public IInvBox getInventory();
|
|
||||||
|
|
||||||
public boolean canStore(ItemStack stack, int slot, ForgeDirection side);
|
|
||||||
|
|
||||||
public boolean canRemove(ItemStack stack, int slot, ForgeDirection side);
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
package dark.lib.interfaces;
|
|
||||||
|
|
||||||
import net.minecraft.inventory.ISidedInventory;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
|
|
||||||
/** @author DarkGuardsman */
|
|
||||||
public interface IInvBox extends ISidedInventory
|
|
||||||
{
|
|
||||||
/** Gets the inventory array. ForgeDirection.UNKOWN must return all sides */
|
|
||||||
public ItemStack[] getContainedItems();
|
|
||||||
|
|
||||||
/** Called to save the inventory array */
|
|
||||||
public NBTTagCompound saveInv(NBTTagCompound tag);
|
|
||||||
|
|
||||||
/** Called to load the inventory array */
|
|
||||||
public void loadInv(NBTTagCompound tag);
|
|
||||||
|
|
||||||
/** Dels all the items in the inventory */
|
|
||||||
public void clear();
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package dark.lib.interfaces;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applied to devices that have the option to run without power. Normally this option is only shown
|
|
||||||
* to creative mode players
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public interface IPowerLess
|
|
||||||
{
|
|
||||||
/** Should this run without power */
|
|
||||||
public boolean runPowerLess();
|
|
||||||
|
|
||||||
/** Set if this should run powerless */
|
|
||||||
public void setPowerLess(boolean bool);
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
package dark.lib.interfaces;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple way to control the read-out display over several tools when they are used on the
|
|
||||||
* tileEntity
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public interface IReadOut
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Grabs the message displayed to the user on right click of the machine with the given tool
|
|
||||||
*
|
|
||||||
* @param user
|
|
||||||
* @param side - may not work correctly yet but should give you a side
|
|
||||||
* @return - a string to be displayed to the player for a reading. automatically adds ReadOut:
|
|
||||||
* to the beginning
|
|
||||||
*/
|
|
||||||
public String getMeterReading(EntityPlayer user, ForgeDirection side, EnumTools tool);
|
|
||||||
|
|
||||||
public static enum EnumTools
|
|
||||||
{
|
|
||||||
PIPE_GUAGE(), MULTI_METER();
|
|
||||||
|
|
||||||
public static EnumTools get(int meta)
|
|
||||||
{
|
|
||||||
if (meta < EnumTools.values().length)
|
|
||||||
{
|
|
||||||
return EnumTools.values()[meta];
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
package dark.lib.interfaces;
|
|
||||||
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The interface is applied to Blocks that can rotate.
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
|
|
||||||
public interface IRotatableBlock
|
|
||||||
{
|
|
||||||
/** @return Gets the facing direction. Always returns the front side of the block. */
|
|
||||||
public ForgeDirection getDirection(World world, int x, int y, int z);
|
|
||||||
|
|
||||||
/** @param Sets the facing direction. */
|
|
||||||
public void setDirection(World world, int x, int y, int z, ForgeDirection direection);
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
package dark.lib.prefab.invgui;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.inventory.Container;
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows the use of a tile inv without the need for a container class
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public class ContainerFake extends Container
|
|
||||||
{
|
|
||||||
TileEntity entity = null;
|
|
||||||
|
|
||||||
public ContainerFake(TileEntity entity)
|
|
||||||
{
|
|
||||||
this.entity = entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
|
|
||||||
{
|
|
||||||
if (entity instanceof IInventory)
|
|
||||||
{
|
|
||||||
return ((IInventory) this.entity).isUseableByPlayer(par1EntityPlayer);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,167 +0,0 @@
|
||||||
package dark.lib.prefab.invgui;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
import net.minecraft.client.renderer.OpenGlHelper;
|
|
||||||
import net.minecraft.client.renderer.RenderHelper;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
import org.lwjgl.opengl.GL12;
|
|
||||||
|
|
||||||
import universalelectricity.api.vector.Vector2;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public abstract class GuiBase extends GuiScreen
|
|
||||||
{
|
|
||||||
|
|
||||||
protected Vector2 c;
|
|
||||||
protected Vector2 guiSize = new Vector2(176, 166);
|
|
||||||
|
|
||||||
/** Adds the buttons (and other controls) to the screen in question. */
|
|
||||||
@Override
|
|
||||||
public void initGui()
|
|
||||||
{
|
|
||||||
super.initGui();
|
|
||||||
c = new Vector2((this.width - this.guiSize.intX()) / 2, (this.height - this.guiSize.intY()) / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Draws the screen and all the components in it. */
|
|
||||||
@Override
|
|
||||||
public void drawScreen(int par1, int par2, float par3)
|
|
||||||
{
|
|
||||||
this.drawDefaultBackground();
|
|
||||||
int var4 = (int) this.c.x;
|
|
||||||
int var5 = (int) this.c.y;
|
|
||||||
this.drawBackgroundLayer(par1, par2, par3);
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glTranslatef(var4, var5, 0.0F);
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
|
||||||
short var7 = 240;
|
|
||||||
short var8 = 240;
|
|
||||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var7 / 1.0F, var8 / 1.0F);
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
|
|
||||||
this.drawForegroundLayer(par1, par2, par3);
|
|
||||||
|
|
||||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
super.drawScreen(par1, par2, par3);
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Draws the foreground layer for the GUI */
|
|
||||||
protected abstract void drawForegroundLayer(int var2, int var3, float var1);
|
|
||||||
|
|
||||||
/** Draws the background layer for the GUI */
|
|
||||||
|
|
||||||
protected abstract void drawBackgroundLayer(int var2, int var3, float var1);
|
|
||||||
|
|
||||||
/** Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e). */
|
|
||||||
@Override
|
|
||||||
protected void keyTyped(char x, int y)
|
|
||||||
{
|
|
||||||
if (y == 1 || y == this.mc.gameSettings.keyBindInventory.keyCode)
|
|
||||||
{
|
|
||||||
this.mc.thePlayer.closeScreen();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns true if this GUI should pause the game when it is displayed in single-player */
|
|
||||||
@Override
|
|
||||||
public boolean doesGuiPauseGame()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Called from the main game loop to update the screen. */
|
|
||||||
@Override
|
|
||||||
public void updateScreen()
|
|
||||||
{
|
|
||||||
super.updateScreen();
|
|
||||||
|
|
||||||
if (!this.mc.thePlayer.isEntityAlive() || this.mc.thePlayer.isDead)
|
|
||||||
{
|
|
||||||
this.mc.thePlayer.closeScreen();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawTooltip(int x, int y, String... toolTips)
|
|
||||||
{
|
|
||||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
|
||||||
RenderHelper.disableStandardItemLighting();
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
|
||||||
|
|
||||||
if (toolTips != null)
|
|
||||||
{
|
|
||||||
int var5 = 0;
|
|
||||||
int var6;
|
|
||||||
int var7;
|
|
||||||
|
|
||||||
for (var6 = 0; var6 < toolTips.length; ++var6)
|
|
||||||
{
|
|
||||||
var7 = this.fontRenderer.getStringWidth(toolTips[var6]);
|
|
||||||
|
|
||||||
if (var7 > var5)
|
|
||||||
{
|
|
||||||
var5 = var7;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var6 = x + 12;
|
|
||||||
var7 = y - 12;
|
|
||||||
int var9 = 8;
|
|
||||||
|
|
||||||
if (toolTips.length > 1)
|
|
||||||
{
|
|
||||||
var9 += 2 + (toolTips.length - 1) * 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.c.intY() + var7 + var9 + 6 > this.height)
|
|
||||||
{
|
|
||||||
var7 = this.height - var9 - this.c.intY() - 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.zLevel = 300.0F;
|
|
||||||
int var10 = -267386864;
|
|
||||||
this.drawGradientRect(var6 - 3, var7 - 4, var6 + var5 + 3, var7 - 3, var10, var10);
|
|
||||||
this.drawGradientRect(var6 - 3, var7 + var9 + 3, var6 + var5 + 3, var7 + var9 + 4, var10, var10);
|
|
||||||
this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3, var7 + var9 + 3, var10, var10);
|
|
||||||
this.drawGradientRect(var6 - 4, var7 - 3, var6 - 3, var7 + var9 + 3, var10, var10);
|
|
||||||
this.drawGradientRect(var6 + var5 + 3, var7 - 3, var6 + var5 + 4, var7 + var9 + 3, var10, var10);
|
|
||||||
int var11 = 1347420415;
|
|
||||||
int var12 = (var11 & 16711422) >> 1 | var11 & -16777216;
|
|
||||||
this.drawGradientRect(var6 - 3, var7 - 3 + 1, var6 - 3 + 1, var7 + var9 + 3 - 1, var11, var12);
|
|
||||||
this.drawGradientRect(var6 + var5 + 2, var7 - 3 + 1, var6 + var5 + 3, var7 + var9 + 3 - 1, var11, var12);
|
|
||||||
this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3, var7 - 3 + 1, var11, var11);
|
|
||||||
this.drawGradientRect(var6 - 3, var7 + var9 + 2, var6 + var5 + 3, var7 + var9 + 3, var12, var12);
|
|
||||||
|
|
||||||
for (int var13 = 0; var13 < toolTips.length; ++var13)
|
|
||||||
{
|
|
||||||
String var14 = toolTips[var13];
|
|
||||||
|
|
||||||
this.fontRenderer.drawStringWithShadow(var14, var6, var7, -1);
|
|
||||||
|
|
||||||
if (var13 == 0)
|
|
||||||
{
|
|
||||||
var7 += 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
var7 += 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.zLevel = 0.0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
RenderHelper.enableGUIStandardItemLighting();
|
|
||||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,78 +0,0 @@
|
||||||
package dark.lib.prefab.invgui;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class GuiButtonImage extends GuiButton
|
|
||||||
{
|
|
||||||
public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.GUI_DIRECTORY + "gui_button.png");
|
|
||||||
|
|
||||||
private ButtonIcon buttonIcon = ButtonIcon.BLANK;
|
|
||||||
|
|
||||||
public GuiButtonImage(int buttonID, int xx, int yy, ButtonIcon icon)
|
|
||||||
{
|
|
||||||
super(buttonID, xx, yy, 20, 20, "");
|
|
||||||
this.buttonIcon = icon;
|
|
||||||
this.width = icon.sizeX;
|
|
||||||
this.height = icon.sizeY;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Draws this button to the screen. */
|
|
||||||
@Override
|
|
||||||
public void drawButton(Minecraft mc, int width, int hight)
|
|
||||||
{
|
|
||||||
if (this.drawButton)
|
|
||||||
{
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
boolean hovering = width >= this.xPosition && hight >= this.yPosition && width < this.xPosition + this.width && hight < this.yPosition + this.height;
|
|
||||||
int vv = buttonIcon.vv;
|
|
||||||
int uu = buttonIcon.uu;
|
|
||||||
if (hovering)
|
|
||||||
{
|
|
||||||
vv += this.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.drawTexturedModalRect(this.xPosition, this.yPosition, this.buttonIcon.uu, this.buttonIcon.vv, this.width, this.height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Checks to see if the x and y coords are intersecting with the button. */
|
|
||||||
public boolean isIntersect(int x, int y)
|
|
||||||
{
|
|
||||||
return x >= this.xPosition && y >= this.yPosition && x < this.xPosition + this.width && y < this.yPosition + this.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum ButtonIcon
|
|
||||||
{
|
|
||||||
PERSON(0, 0), ARROW_LEFT(30, 0, 10, 10), ARROW_RIGHT(20, 0, 10, 10),
|
|
||||||
ARROW_DOWN(30, 20, 10, 10), ARROW_UP(20, 20, 10, 10), CHEST(60, 0), LOCKED(80, 0),
|
|
||||||
UNLOCKED(100, 0), BLANK(120, 0), RED_ON(140, 0), RED_OFF(160, 0), FURNACE_OFF(180, 0),
|
|
||||||
FURNACE_ON(200, 0);
|
|
||||||
|
|
||||||
int vv, uu;
|
|
||||||
int sizeX = 20, sizeY = 20;
|
|
||||||
|
|
||||||
private ButtonIcon(int xx, int yy)
|
|
||||||
{
|
|
||||||
this.vv = yy;
|
|
||||||
this.uu = xx;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ButtonIcon(int xx, int yy, int cx, int cy)
|
|
||||||
{
|
|
||||||
this(xx, yy);
|
|
||||||
this.sizeX = cx;
|
|
||||||
this.sizeY = cy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,209 +0,0 @@
|
||||||
package dark.lib.prefab.invgui;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
||||||
import net.minecraft.client.renderer.RenderHelper;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
|
||||||
import net.minecraft.inventory.Container;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
import org.lwjgl.opengl.GL12;
|
|
||||||
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import resonantinduction.core.prefab.tile.TileEntityMachine;
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import dark.lib.prefab.invgui.GuiButtonImage.ButtonIcon;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public abstract class GuiMachineContainer extends GuiContainer
|
|
||||||
{
|
|
||||||
protected static final int MAX_BUTTON_ID = 3;
|
|
||||||
protected TileEntityMachine tileEntity;
|
|
||||||
protected EntityPlayer entityPlayer;
|
|
||||||
protected Object mod;
|
|
||||||
protected int guiID = -1, guiID2 = -1, guiID3 = -1;
|
|
||||||
protected ButtonIcon guiIcon = ButtonIcon.CHEST, guiIcon2 = ButtonIcon.PERSON,
|
|
||||||
guiIcon3 = ButtonIcon.BLANK;
|
|
||||||
protected String invName = "Home", invName2 = "2", invName3 = "3";
|
|
||||||
|
|
||||||
public ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.GUI_DIRECTORY + "gui_grey.png");
|
|
||||||
|
|
||||||
protected int containerWidth;
|
|
||||||
protected int containerHeight;
|
|
||||||
|
|
||||||
public GuiMachineContainer(Object mod, Container container, InventoryPlayer inventoryPlayer, TileEntityMachine tileEntity)
|
|
||||||
{
|
|
||||||
super(container);
|
|
||||||
this.tileEntity = tileEntity;
|
|
||||||
this.entityPlayer = inventoryPlayer.player;
|
|
||||||
this.ySize = 380 / 2;
|
|
||||||
this.mod = mod;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void initGui()
|
|
||||||
{
|
|
||||||
super.initGui();
|
|
||||||
this.buttonList.clear();
|
|
||||||
containerWidth = (this.width - this.xSize) / 2;
|
|
||||||
containerHeight = (this.height - this.ySize) / 2;
|
|
||||||
if (guiID != -1)
|
|
||||||
this.buttonList.add(new GuiButtonImage(0, containerWidth - 22, containerHeight + 0, guiIcon));
|
|
||||||
if (guiID2 != -1)
|
|
||||||
this.buttonList.add(new GuiButtonImage(1, containerWidth - 22, containerHeight + 22, guiIcon2));
|
|
||||||
if (guiID3 != -1)
|
|
||||||
this.buttonList.add(new GuiButtonImage(2, containerWidth - 22, containerHeight + 44, guiIcon3));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void actionPerformed(GuiButton button)
|
|
||||||
{
|
|
||||||
super.actionPerformed(button);
|
|
||||||
switch (button.id)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
if (guiID != -1)
|
|
||||||
this.entityPlayer.openGui(mod, guiID, this.tileEntity.worldObj, this.tileEntity.xCoord, this.tileEntity.yCoord, this.tileEntity.zCoord);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
if (guiID2 != -1)
|
|
||||||
this.entityPlayer.openGui(mod, guiID2, this.tileEntity.worldObj, this.tileEntity.xCoord, this.tileEntity.yCoord, this.tileEntity.zCoord);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2:
|
|
||||||
{
|
|
||||||
if (guiID3 != -1)
|
|
||||||
this.entityPlayer.openGui(mod, guiID3, this.tileEntity.worldObj, this.tileEntity.xCoord, this.tileEntity.yCoord, this.tileEntity.zCoord);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Draw the foreground layer for the GuiContainer (everything in front of the items) */
|
|
||||||
@Override
|
|
||||||
protected void drawGuiContainerForegroundLayer(int x, int y)
|
|
||||||
{
|
|
||||||
this.fontRenderer.drawString("\u00a77" + tileEntity.getInvName(), (int) (this.xSize / 2 - 7 * 2.5), 4, 4210752);
|
|
||||||
|
|
||||||
/** Render Tool Tips */
|
|
||||||
if (((GuiButtonImage) this.buttonList.get(0)).isIntersect(x, y))
|
|
||||||
{
|
|
||||||
this.drawTooltip(x - this.guiLeft, y - this.guiTop + 10, invName);
|
|
||||||
}
|
|
||||||
else if (((GuiButtonImage) this.buttonList.get(1)).isIntersect(x, y))
|
|
||||||
{
|
|
||||||
this.drawTooltip(x - this.guiLeft, y - this.guiTop + 10, invName2);
|
|
||||||
}
|
|
||||||
else if (((GuiButtonImage) this.buttonList.get(2)).isIntersect(x, y))
|
|
||||||
{
|
|
||||||
this.drawTooltip(x - this.guiLeft, y - this.guiTop + 10, invName3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Draw the background layer for the GuiContainer (everything behind the items) */
|
|
||||||
@Override
|
|
||||||
protected void drawGuiContainerBackgroundLayer(float par1, int x, int y)
|
|
||||||
{
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
|
|
||||||
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
|
|
||||||
int containerWidth = (this.width - this.xSize) / 2;
|
|
||||||
int containerHeight = (this.height - this.ySize) / 2;
|
|
||||||
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawTooltip(int x, int y, String... toolTips)
|
|
||||||
{
|
|
||||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
|
||||||
RenderHelper.disableStandardItemLighting();
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
|
||||||
|
|
||||||
if (toolTips != null)
|
|
||||||
{
|
|
||||||
int var5 = 0;
|
|
||||||
int var6;
|
|
||||||
int var7;
|
|
||||||
|
|
||||||
for (var6 = 0; var6 < toolTips.length; ++var6)
|
|
||||||
{
|
|
||||||
var7 = this.fontRenderer.getStringWidth(toolTips[var6]);
|
|
||||||
|
|
||||||
if (var7 > var5)
|
|
||||||
{
|
|
||||||
var5 = var7;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var6 = x + 12;
|
|
||||||
var7 = y - 12;
|
|
||||||
int var9 = 8;
|
|
||||||
|
|
||||||
if (toolTips.length > 1)
|
|
||||||
{
|
|
||||||
var9 += 2 + (toolTips.length - 1) * 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.guiTop + var7 + var9 + 6 > this.height)
|
|
||||||
{
|
|
||||||
var7 = this.height - var9 - this.guiTop - 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.zLevel = 300.0F;
|
|
||||||
int var10 = -267386864;
|
|
||||||
this.drawGradientRect(var6 - 3, var7 - 4, var6 + var5 + 3, var7 - 3, var10, var10);
|
|
||||||
this.drawGradientRect(var6 - 3, var7 + var9 + 3, var6 + var5 + 3, var7 + var9 + 4, var10, var10);
|
|
||||||
this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3, var7 + var9 + 3, var10, var10);
|
|
||||||
this.drawGradientRect(var6 - 4, var7 - 3, var6 - 3, var7 + var9 + 3, var10, var10);
|
|
||||||
this.drawGradientRect(var6 + var5 + 3, var7 - 3, var6 + var5 + 4, var7 + var9 + 3, var10, var10);
|
|
||||||
int var11 = 1347420415;
|
|
||||||
int var12 = (var11 & 16711422) >> 1 | var11 & -16777216;
|
|
||||||
this.drawGradientRect(var6 - 3, var7 - 3 + 1, var6 - 3 + 1, var7 + var9 + 3 - 1, var11, var12);
|
|
||||||
this.drawGradientRect(var6 + var5 + 2, var7 - 3 + 1, var6 + var5 + 3, var7 + var9 + 3 - 1, var11, var12);
|
|
||||||
this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3, var7 - 3 + 1, var11, var11);
|
|
||||||
this.drawGradientRect(var6 - 3, var7 + var9 + 2, var6 + var5 + 3, var7 + var9 + 3, var12, var12);
|
|
||||||
|
|
||||||
for (int var13 = 0; var13 < toolTips.length; ++var13)
|
|
||||||
{
|
|
||||||
String var14 = "\u00a77" + toolTips[var13];
|
|
||||||
|
|
||||||
this.fontRenderer.drawStringWithShadow(var14, var6, var7, -1);
|
|
||||||
|
|
||||||
if (var13 == 0)
|
|
||||||
{
|
|
||||||
var7 += 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
var7 += 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.zLevel = 0.0F;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getGuiTop()
|
|
||||||
{
|
|
||||||
return this.guiTop;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getGuiLeft()
|
|
||||||
{
|
|
||||||
return this.guiLeft;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileEntity getTile()
|
|
||||||
{
|
|
||||||
return this.tileEntity;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,109 +0,0 @@
|
||||||
package dark.lib.prefab.invgui;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
|
||||||
|
|
||||||
public class GuiMessageBox extends GuiBase
|
|
||||||
{
|
|
||||||
public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.GUI_DIRECTORY + "gui_message_box.png");
|
|
||||||
|
|
||||||
GuiBase returnGuiYes, returnGuiNo;
|
|
||||||
int id;
|
|
||||||
String title;
|
|
||||||
String message;
|
|
||||||
|
|
||||||
public GuiMessageBox(GuiBase returnGui, int id, String title, String message)
|
|
||||||
{
|
|
||||||
this.guiSize.y = 380 / 2;
|
|
||||||
this.returnGuiYes = returnGui;
|
|
||||||
this.returnGuiNo = returnGui;
|
|
||||||
this.id = id;
|
|
||||||
this.title = title;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuiMessageBox(GuiBase returnGui, GuiBase returnGuiNo, int id, String title, String message)
|
|
||||||
{
|
|
||||||
this(returnGui, id, title, message);
|
|
||||||
this.returnGuiNo = returnGuiNo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void initGui()
|
|
||||||
{
|
|
||||||
super.initGui();
|
|
||||||
this.buttonList.clear();
|
|
||||||
this.buttonList.add(new GuiButton(0, (this.width - this.guiSize.intX()) / 2 + 25, (this.height - this.guiSize.intY()) / 2 + 35, 50, 20, "Yes"));
|
|
||||||
|
|
||||||
this.buttonList.add(new GuiButton(1, (this.width - this.guiSize.intX()) / 2 + 80, (this.height - this.guiSize.intY()) / 2 + 35, 50, 20, "no"));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGuiClosed()
|
|
||||||
{
|
|
||||||
super.onGuiClosed();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void actionPerformed(GuiButton button)
|
|
||||||
{
|
|
||||||
super.actionPerformed(button);
|
|
||||||
switch (button.id)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
this.exit(true);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
this.exit(false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void drawForegroundLayer(int var2, int var3, float var1)
|
|
||||||
{
|
|
||||||
this.fontRenderer.drawString("" + this.title, (this.guiSize.intX() / 2 - 30), 5, 4210752);
|
|
||||||
this.fontRenderer.drawString("\u00a77" + this.message, ((this.guiSize.intX() / 2) - 50), 20, 4210752);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void drawBackgroundLayer(int var2, int var3, float var1)
|
|
||||||
{
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
|
|
||||||
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
|
|
||||||
int containerWidth = (this.width - this.guiSize.intX()) / 2;
|
|
||||||
int containerHeight = (this.height - this.guiSize.intY()) / 2;
|
|
||||||
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.guiSize.intX(), this.guiSize.intY());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void show()
|
|
||||||
{
|
|
||||||
FMLCommonHandler.instance().showGuiScreen(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void exit(boolean yes)
|
|
||||||
{
|
|
||||||
if (yes)
|
|
||||||
{
|
|
||||||
FMLCommonHandler.instance().showGuiScreen(this.returnGuiYes);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FMLCommonHandler.instance().showGuiScreen(this.returnGuiNo);
|
|
||||||
}
|
|
||||||
if (this.returnGuiYes instanceof IMessageBoxDialog)
|
|
||||||
{
|
|
||||||
((IMessageBoxDialog) this.returnGuiYes).onMessageBoxClosed(this.id, yes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
package dark.lib.prefab.invgui;
|
|
||||||
|
|
||||||
public interface IMessageBoxDialog
|
|
||||||
{
|
|
||||||
public void onMessageBoxClosed(int id, boolean yes);
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package dark.lib.prefab.invgui;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
/** TileEntities that wish to do something if an item is removed from a slot */
|
|
||||||
public interface ISlotPickResult
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* If the slot in the gui does something if the item is removed
|
|
||||||
*
|
|
||||||
* @param entityPlayer - player who removed the item, will pass null from automation
|
|
||||||
* @param slot - slot in the container class the item came from
|
|
||||||
* @param itemStack - item stack pulled from the slot
|
|
||||||
*/
|
|
||||||
public void onPickUpFromSlot(EntityPlayer entityPlayer, int slot, ItemStack itemStack);
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package dark.lib.prefab.invgui;
|
|
||||||
|
|
||||||
/** Add this to a container class if using WatchedSlot to trigger the container on slot change */
|
|
||||||
public interface ISlotWatcher
|
|
||||||
{
|
|
||||||
/** Will trigger if the watched slot has changed */
|
|
||||||
public void slotContentsChanged(int slot);
|
|
||||||
}
|
|
|
@ -1,256 +0,0 @@
|
||||||
package dark.lib.prefab.invgui;
|
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.nbt.NBTTagList;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
import dark.lib.interfaces.IExternalInv;
|
|
||||||
import dark.lib.interfaces.IInvBox;
|
|
||||||
|
|
||||||
public class InvChest implements IInvBox
|
|
||||||
{
|
|
||||||
/** Access able slots side all */
|
|
||||||
protected int[] openSlots;
|
|
||||||
/** Items contained in this inv */
|
|
||||||
protected ItemStack[] containedItems;
|
|
||||||
/** Host tileEntity */
|
|
||||||
protected TileEntity hostTile;
|
|
||||||
/** Host tileEntity as external inv */
|
|
||||||
protected IExternalInv inv;
|
|
||||||
/** Default slot max count */
|
|
||||||
protected final int slots;
|
|
||||||
|
|
||||||
public InvChest(TileEntity chest, IExternalInv inv, int slots)
|
|
||||||
{
|
|
||||||
this.hostTile = chest;
|
|
||||||
this.slots = slots;
|
|
||||||
this.inv = inv;
|
|
||||||
}
|
|
||||||
|
|
||||||
public InvChest(TileEntity chest, int slots)
|
|
||||||
{
|
|
||||||
this(chest, ((IExternalInv) chest), slots);
|
|
||||||
}
|
|
||||||
|
|
||||||
public InvChest(Entity entity, int i)
|
|
||||||
{
|
|
||||||
this.slots = i;
|
|
||||||
this.inv = (IExternalInv) entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSizeInventory()
|
|
||||||
{
|
|
||||||
return slots;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getStackInSlot(int slot)
|
|
||||||
{
|
|
||||||
return this.getContainedItems()[slot];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack decrStackSize(int slot, int ammount)
|
|
||||||
{
|
|
||||||
if (this.getContainedItems()[slot] != null)
|
|
||||||
{
|
|
||||||
ItemStack var3;
|
|
||||||
|
|
||||||
if (this.getContainedItems()[slot].stackSize <= ammount)
|
|
||||||
{
|
|
||||||
var3 = this.getContainedItems()[slot];
|
|
||||||
this.getContainedItems()[slot] = null;
|
|
||||||
this.onInventoryChanged();
|
|
||||||
return var3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var3 = this.getContainedItems()[slot].splitStack(ammount);
|
|
||||||
|
|
||||||
if (this.getContainedItems()[slot].stackSize == 0)
|
|
||||||
{
|
|
||||||
this.getContainedItems()[slot] = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.onInventoryChanged();
|
|
||||||
return var3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getStackInSlotOnClosing(int par1)
|
|
||||||
{
|
|
||||||
if (this.getContainedItems()[par1] != null)
|
|
||||||
{
|
|
||||||
ItemStack var2 = this.getContainedItems()[par1];
|
|
||||||
this.getContainedItems()[par1] = null;
|
|
||||||
return var2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
|
|
||||||
{
|
|
||||||
this.getContainedItems()[par1] = par2ItemStack;
|
|
||||||
|
|
||||||
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
|
|
||||||
{
|
|
||||||
par2ItemStack.stackSize = this.getInventoryStackLimit();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.onInventoryChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInvName()
|
|
||||||
{
|
|
||||||
return "container.chest";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openChest()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void closeChest()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isInvNameLocalized()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
|
||||||
{
|
|
||||||
if (i >= this.getSizeInventory())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int[] getAccessibleSlotsFromSide(int var1)
|
|
||||||
{
|
|
||||||
if (openSlots == null || openSlots.length != this.getSizeInventory())
|
|
||||||
{
|
|
||||||
this.openSlots = new int[this.getSizeInventory()];
|
|
||||||
for (int i = 0; i < this.openSlots.length; i++)
|
|
||||||
{
|
|
||||||
openSlots[i] = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.openSlots;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canInsertItem(int i, ItemStack itemstack, int j)
|
|
||||||
{
|
|
||||||
return this.isItemValidForSlot(i, itemstack) && this.inv.canStore(itemstack, i, ForgeDirection.getOrientation(j));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canExtractItem(int i, ItemStack itemstack, int j)
|
|
||||||
{
|
|
||||||
return this.inv.canRemove(itemstack, i, ForgeDirection.getOrientation(j));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getInventoryStackLimit()
|
|
||||||
{
|
|
||||||
return 64;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInventoryChanged()
|
|
||||||
{
|
|
||||||
if (this.hostTile != null)
|
|
||||||
{
|
|
||||||
this.hostTile.onInventoryChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
|
|
||||||
{
|
|
||||||
if (this.hostTile != null)
|
|
||||||
{
|
|
||||||
return this.hostTile.worldObj.getBlockTileEntity(this.hostTile.xCoord, this.hostTile.yCoord, this.hostTile.zCoord) != this.hostTile ? false : par1EntityPlayer.getDistanceSq(this.hostTile.xCoord + 0.5D, this.hostTile.yCoord + 0.5D, this.hostTile.zCoord + 0.5D) <= 64.0D;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack[] getContainedItems()
|
|
||||||
{
|
|
||||||
if (this.containedItems == null)
|
|
||||||
{
|
|
||||||
this.containedItems = new ItemStack[this.getSizeInventory()];
|
|
||||||
}
|
|
||||||
return this.containedItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTTagCompound saveInv(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
NBTTagList itemList = new NBTTagList();
|
|
||||||
for (int s = 0; s < this.getContainedItems().length; ++s)
|
|
||||||
{
|
|
||||||
if (this.getContainedItems()[s] != null)
|
|
||||||
{
|
|
||||||
NBTTagCompound tag = new NBTTagCompound();
|
|
||||||
tag.setByte("Slot", (byte) s);
|
|
||||||
this.getContainedItems()[s].writeToNBT(tag);
|
|
||||||
itemList.appendTag(tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nbt.setTag("Items", itemList);
|
|
||||||
return nbt;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadInv(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
// chest inv reading
|
|
||||||
NBTTagList itemList = nbt.getTagList("Items");
|
|
||||||
|
|
||||||
for (int s = 0; s < itemList.tagCount(); ++s)
|
|
||||||
{
|
|
||||||
NBTTagCompound tag = (NBTTagCompound) itemList.tagAt(s);
|
|
||||||
int slotID = tag.getByte("Slot") & 255;
|
|
||||||
|
|
||||||
if (slotID >= 0 && slotID < this.getContainedItems().length)
|
|
||||||
{
|
|
||||||
this.getContainedItems()[slotID] = ItemStack.loadItemStackFromNBT(tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
this.containedItems = null;
|
|
||||||
this.getContainedItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
package dark.lib.prefab.invgui;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
/** Easy class to create a slot that is used for an event trigger or crafting based event */
|
|
||||||
public class SlotCraftingResult extends WatchedSlot
|
|
||||||
{
|
|
||||||
private ISlotPickResult tile;
|
|
||||||
|
|
||||||
public SlotCraftingResult(ISlotPickResult tile, ISlotWatcher container, IInventory inventory, int par2, int par3, int par4)
|
|
||||||
{
|
|
||||||
super(inventory, par2, par3, par4, container);
|
|
||||||
this.tile = tile;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isItemValid(ItemStack itemStack)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canTakeStack(EntityPlayer player)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** When the slot has changed it calls @ISlotPickResult 's method */
|
|
||||||
@Override
|
|
||||||
public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack)
|
|
||||||
{
|
|
||||||
this.tile.onPickUpFromSlot(entityPlayer, this.slotNumber, itemStack);
|
|
||||||
super.onPickupFromSlot(entityPlayer, itemStack);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package dark.lib.prefab.invgui;
|
|
||||||
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.inventory.Slot;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import universalelectricity.api.CompatibilityModule;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Slot designed to only allow batery like items
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public class SlotEnergyItem extends Slot
|
|
||||||
{
|
|
||||||
|
|
||||||
public SlotEnergyItem(IInventory inventory, int slotID, int xPos, int yPos)
|
|
||||||
{
|
|
||||||
super(inventory, slotID, xPos, yPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isItemValid(ItemStack compareStack)
|
|
||||||
{
|
|
||||||
return compareStack != null && CompatibilityModule.isHandler(compareStack.getItem());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,92 +0,0 @@
|
||||||
package dark.lib.prefab.invgui;
|
|
||||||
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.inventory.Slot;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a slot with a specific amount of items that matches the slot's requirements. Allows easy
|
|
||||||
* shift right clicking management and slot blocking in classes. In your container you can use
|
|
||||||
* this.getSlot(i).isItemValid to justify the player's shift clicking actions to match the slot.
|
|
||||||
*
|
|
||||||
* @author Calclavia
|
|
||||||
*/
|
|
||||||
public class SlotSpecific extends Slot
|
|
||||||
{
|
|
||||||
public ItemStack[] validItemStacks = new ItemStack[0];
|
|
||||||
public Class[] validClasses = new Class[0];
|
|
||||||
|
|
||||||
public boolean isInverted = false;
|
|
||||||
public boolean isMetadataSensitive = false;
|
|
||||||
|
|
||||||
public SlotSpecific(IInventory inventory, int slotID, int xPos, int yPos, ItemStack... itemStacks)
|
|
||||||
{
|
|
||||||
super(inventory, slotID, xPos, yPos);
|
|
||||||
this.setItemStacks(itemStacks);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SlotSpecific(IInventory inventory, int slotID, int xPos, int yPos, Class... validClasses)
|
|
||||||
{
|
|
||||||
super(inventory, slotID, xPos, yPos);
|
|
||||||
this.setClasses(validClasses);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SlotSpecific setMetadataSensitive()
|
|
||||||
{
|
|
||||||
this.isMetadataSensitive = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SlotSpecific setItemStacks(ItemStack... validItemStacks)
|
|
||||||
{
|
|
||||||
this.validItemStacks = validItemStacks;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SlotSpecific setClasses(Class... validClasses)
|
|
||||||
{
|
|
||||||
this.validClasses = validClasses;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SlotSpecific toggleInverted()
|
|
||||||
{
|
|
||||||
this.isInverted = !this.isInverted;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Check if the stack is a valid item for this slot. Always true beside for the armor slots. */
|
|
||||||
@Override
|
|
||||||
public boolean isItemValid(ItemStack compareStack)
|
|
||||||
{
|
|
||||||
boolean returnValue = false;
|
|
||||||
|
|
||||||
for (ItemStack itemStack : this.validItemStacks)
|
|
||||||
{
|
|
||||||
if (compareStack.isItemEqual(itemStack) || (!this.isMetadataSensitive && compareStack.itemID == itemStack.itemID))
|
|
||||||
{
|
|
||||||
returnValue = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!returnValue)
|
|
||||||
{
|
|
||||||
for (Class clazz : this.validClasses)
|
|
||||||
{
|
|
||||||
if (clazz.equals(compareStack.getItem().getClass()) || clazz.isInstance(compareStack.getItem()))
|
|
||||||
{
|
|
||||||
returnValue = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.isInverted)
|
|
||||||
{
|
|
||||||
return !returnValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnValue;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package dark.lib.prefab.invgui;
|
|
||||||
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.inventory.Slot;
|
|
||||||
|
|
||||||
/** A slot that triggers the container class if changed */
|
|
||||||
public class WatchedSlot extends Slot
|
|
||||||
{
|
|
||||||
private ISlotWatcher slotWatcher;
|
|
||||||
|
|
||||||
public WatchedSlot(IInventory inventory, int id, int xPosition, int yPosition, ISlotWatcher slotWatcher)
|
|
||||||
{
|
|
||||||
super(inventory, id, xPosition, yPosition);
|
|
||||||
this.slotWatcher = slotWatcher;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSlotChanged()
|
|
||||||
{
|
|
||||||
if (this.slotWatcher != null)
|
|
||||||
{
|
|
||||||
this.slotWatcher.slotContentsChanged(this.slotNumber);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,313 +0,0 @@
|
||||||
package dark.lib.recipes;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemArmor;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.ItemTool;
|
|
||||||
import resonantinduction.old.api.IProcessable;
|
|
||||||
import calclavia.lib.utility.AutoCraftingManager;
|
|
||||||
|
|
||||||
import com.builtbroken.common.Pair;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Recipes for ore processor machines
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public class MachineRecipeHandler
|
|
||||||
{
|
|
||||||
private static Random random = new Random();
|
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
newProcessorRecipe(ProcessorType.CRUSHER, Block.stone, Block.cobblestone);
|
|
||||||
newProcessorRecipe(ProcessorType.CRUSHER, Block.oreDiamond, Item.diamond);
|
|
||||||
newProcessorRecipe(ProcessorType.CRUSHER, Block.oreLapis, new ItemStack(Item.dyePowder.itemID, 4, 4));
|
|
||||||
newProcessorRecipe(ProcessorType.CRUSHER, Block.oreRedstone, new ItemStack(Item.redstone.itemID, 4, 0));
|
|
||||||
newProcessorRecipe(ProcessorType.CRUSHER, Block.oreEmerald, new ItemStack(Item.redstone.itemID, 4, 0));
|
|
||||||
|
|
||||||
newProcessorRecipe(ProcessorType.GRINDER, new ItemStack(Block.cobblestone.blockID, 1, 0), new ItemStack(Block.sand.blockID, 1, 0));
|
|
||||||
newProcessorRecipe(ProcessorType.GRINDER, Block.glass, Block.sand);
|
|
||||||
|
|
||||||
MachineRecipeHandler.newAltProcessorOutput(ProcessorType.GRINDER, Block.stone, Block.cobblestone);
|
|
||||||
MachineRecipeHandler.newAltProcessorOutput(ProcessorType.GRINDER, Block.cobblestoneMossy, Block.cobblestone);
|
|
||||||
MachineRecipeHandler.newAltProcessorOutput(ProcessorType.GRINDER, Block.glass, Block.sand);
|
|
||||||
MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, Item.stick, null);
|
|
||||||
|
|
||||||
MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, Block.stone, Block.cobblestone);
|
|
||||||
MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, Block.cobblestoneMossy, Block.cobblestone);
|
|
||||||
MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, Item.stick, null);
|
|
||||||
|
|
||||||
// TODO replace these with ItemOreDirv glass shards
|
|
||||||
MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, Block.glass, Block.sand);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new recipe for the type of processor machine
|
|
||||||
*
|
|
||||||
* @param type - machine type
|
|
||||||
* @param in - input item, stacksize is ignored
|
|
||||||
* @param out - output item
|
|
||||||
*/
|
|
||||||
public static void newProcessorRecipe(ProcessorType type, Object in, Object out)
|
|
||||||
{
|
|
||||||
newProcessorRecipe(type, in, out, -1, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new recipe for the type of processor machine
|
|
||||||
*
|
|
||||||
* @param type - machine type
|
|
||||||
* @param in - input item, stacksize is ignored
|
|
||||||
* @param out - output item
|
|
||||||
* @param min - min stacksize to return as output
|
|
||||||
* @param max- max stacksize to return as output
|
|
||||||
*/
|
|
||||||
public static void newProcessorRecipe(ProcessorType type, Object in, Object out, int min, int max)
|
|
||||||
{
|
|
||||||
newProcessorRecipe(type, in, out, min, max, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new recipe for the type of processor machine
|
|
||||||
*
|
|
||||||
* @param type - machine type
|
|
||||||
* @param in - input item, stacksize is ignored
|
|
||||||
* @param out - output item
|
|
||||||
* @param min - min stacksize to return as output
|
|
||||||
* @param max- max stacksize to return as output
|
|
||||||
* @param ignoreNBT - only use this if your item's nbt doesn't play a factor in what items were
|
|
||||||
* used to craft it
|
|
||||||
*/
|
|
||||||
public static void newProcessorRecipe(ProcessorType type, Object in, Object out, int min, int max, boolean ignoreNBT)
|
|
||||||
{
|
|
||||||
if (in != null && out != null && type != null)
|
|
||||||
{
|
|
||||||
ItemStack input = convertToItemStack(in);
|
|
||||||
ItemStack output = convertToItemStack(out);
|
|
||||||
if (input != null && output != null && type.recipes != null)
|
|
||||||
{
|
|
||||||
if (!ignoreNBT && (input.getTagCompound() != null || input.isItemEnchanted()))
|
|
||||||
{
|
|
||||||
System.out.println("[MachineRecipeHandler]Error: NBT or Enchanted Items must use the IProccesable interface to properlly handle recipe outputs.");
|
|
||||||
System.out.println("[MachineRecipeHandler]Item>> Data: " + input.toString() + " Name: " + input.getItem().getUnlocalizedName());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (min == -1)
|
|
||||||
{
|
|
||||||
min = output.stackSize;
|
|
||||||
}
|
|
||||||
if (max == -1 || max < min)
|
|
||||||
{
|
|
||||||
max = output.stackSize;
|
|
||||||
}
|
|
||||||
type.recipes.put(new Pair<Integer, Integer>(input.itemID, input.getItemDamage()), new ProcessorRecipe(output, min, max));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Used to track items that should be converted to different items during salvaging. */
|
|
||||||
public static void newAltProcessorOutput(ProcessorType type, Object in, Object out)
|
|
||||||
{
|
|
||||||
if (in != null && out != null && type != null)
|
|
||||||
{
|
|
||||||
ItemStack input = convertToItemStack(in);
|
|
||||||
ItemStack output = convertToItemStack(out);
|
|
||||||
if (input != null && output != null && type.altOutput != null)
|
|
||||||
{
|
|
||||||
type.altOutput.put(new Pair<Integer, Integer>(input.itemID, input.getItemDamage()), output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Marks an itemstack as unsalvagable by all processors */
|
|
||||||
public static void banProcessingOfItem(ItemStack stack)
|
|
||||||
{
|
|
||||||
if (stack != null)
|
|
||||||
{
|
|
||||||
for (ProcessorType type : ProcessorType.values())
|
|
||||||
{
|
|
||||||
banProcessingOfItem(type, stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Marks an itemstack as unusable by processors. This will jam the processor if the item enters
|
|
||||||
* it
|
|
||||||
*/
|
|
||||||
public static void banProcessingOfItem(ProcessorType type, ItemStack stack)
|
|
||||||
{
|
|
||||||
if (type != null && stack != null)
|
|
||||||
{
|
|
||||||
type.banList.add(new Pair<Integer, Integer>(stack.itemID, stack.getItemDamage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Converts an object input into an itemstack for use */
|
|
||||||
private static ItemStack convertToItemStack(Object object)
|
|
||||||
{
|
|
||||||
if (object instanceof ItemStack)
|
|
||||||
{
|
|
||||||
ItemStack stack = (ItemStack) object;
|
|
||||||
if (stack.getItemDamage() < 0)
|
|
||||||
{
|
|
||||||
stack.setItemDamage(0);
|
|
||||||
}
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
if (object instanceof Block)
|
|
||||||
{
|
|
||||||
return new ItemStack(((Block) object).blockID, 1, -1);
|
|
||||||
}
|
|
||||||
if (object instanceof Item)
|
|
||||||
{
|
|
||||||
return new ItemStack(((Item) object).itemID, 1, -1);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the lit of items that are created from the input item stack. General this will be an
|
|
||||||
* array of one item. However, in salavaging cases it can be up to 8 items.
|
|
||||||
*
|
|
||||||
* @param type - Processor type
|
|
||||||
* @param inputStack - item stack input ignores stacksize
|
|
||||||
* @return array of itemStacks
|
|
||||||
*/
|
|
||||||
public static ItemStack[] getProcessorOutput(ProcessorType type, ItemStack inputStack)
|
|
||||||
{
|
|
||||||
if (inputStack != null && type != null)
|
|
||||||
{
|
|
||||||
ItemStack[] reList = null;
|
|
||||||
if (inputStack.getItem() instanceof IProcessable)
|
|
||||||
{
|
|
||||||
if (!((IProcessable) inputStack.getItem()).canProcess(type, inputStack))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
reList = ((IProcessable) inputStack.getItem()).getProcesserOutput(type, inputStack);
|
|
||||||
}
|
|
||||||
if (reList == null)
|
|
||||||
{
|
|
||||||
reList = getOuputNormal(type, inputStack);
|
|
||||||
}
|
|
||||||
if (reList == null)
|
|
||||||
{
|
|
||||||
// TODO Disabled due to bug and needs to be fixed to make the processors more
|
|
||||||
// functional
|
|
||||||
// reList = salvageItem(type, inputStack);
|
|
||||||
}
|
|
||||||
return reList;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Salvages an itemStack for the items used to craft it
|
|
||||||
*
|
|
||||||
* @param type - processor type used to determine damage results
|
|
||||||
* @param stack - itemStack being salvaged
|
|
||||||
* @return Array of all items salvaged
|
|
||||||
*/
|
|
||||||
public static ItemStack[] salvageItem(ProcessorType type, ItemStack stack)
|
|
||||||
{
|
|
||||||
return salvageItem(type, stack, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Salvages an itemStack for the items used to craft it
|
|
||||||
*
|
|
||||||
* @param type - processor type used to determine damage results
|
|
||||||
* @param stack - itemStack being salvaged
|
|
||||||
* @param damage - damage the output items. Eg ironIngot becomes ironDust, or ironScraps
|
|
||||||
* @return Array of all items salvaged
|
|
||||||
*/
|
|
||||||
public static ItemStack[] salvageItem(ProcessorType type, ItemStack stack, boolean damage)
|
|
||||||
{
|
|
||||||
float bar = 0.1f;
|
|
||||||
// Allow tools and armor to be salvaged but at a very low rate
|
|
||||||
if ((stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemTool) && stack.isItemDamaged())
|
|
||||||
{
|
|
||||||
bar = (stack.getItemDamage() / stack.getMaxDamage());
|
|
||||||
}
|
|
||||||
ItemStack[] reList = salvageItem(stack, bar);
|
|
||||||
if (damage && reList != null && type.altOutput != null)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < reList.length; i++)
|
|
||||||
{
|
|
||||||
if (type.altOutput.containsKey(new Pair<Integer, Integer>(reList[i].itemID, reList[i].getItemDamage())))
|
|
||||||
{
|
|
||||||
reList[i] = convertToItemStack(type.altOutput.get(new Pair<Integer, Integer>(reList[i].itemID, reList[i].getItemDamage())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return reList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Salvages an itemStack for the items used to craft it
|
|
||||||
*
|
|
||||||
* @param stack - itemStack being salvaged
|
|
||||||
* @param bar - chance per item that the random must be above inorder to salvage the output
|
|
||||||
* @return Array of all items salvaged
|
|
||||||
*/
|
|
||||||
public static ItemStack[] salvageItem(ItemStack stack, float bar)
|
|
||||||
{
|
|
||||||
// TODO find a way around having to force recipe to be the same stack size of the salvage.
|
|
||||||
// Maybe percentage based salvaging or min stacksize from machine?
|
|
||||||
ItemStack[] recipeList = AutoCraftingManager.getReverseRecipe(stack.copy(), stack.stackSize);
|
|
||||||
if (recipeList != null)
|
|
||||||
{
|
|
||||||
ItemStack[] reList = new ItemStack[recipeList.length];
|
|
||||||
boolean items = false;
|
|
||||||
for (int i = 0; i < recipeList.length; i++)
|
|
||||||
{
|
|
||||||
if (random.nextFloat() >= bar)
|
|
||||||
{
|
|
||||||
reList[i] = recipeList[i].copy();
|
|
||||||
items = true;
|
|
||||||
if (recipeList[i].itemID < Block.blocksList.length && Block.blocksList[recipeList[i].itemID] != null && recipeList[i].getItemDamage() > 16)
|
|
||||||
{
|
|
||||||
reList[i].setItemDamage(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return items ? reList : null;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack[] getOuputNormal(ProcessorType type, ItemStack stack)
|
|
||||||
{
|
|
||||||
if (type.recipes != null)
|
|
||||||
{
|
|
||||||
ProcessorRecipe re = type.recipes.get(new Pair<Integer, Integer>(stack.itemID, -1));
|
|
||||||
if (re == null || re.output == null)
|
|
||||||
{
|
|
||||||
re = type.recipes.get(new Pair<Integer, Integer>(stack.itemID, stack.getItemDamage()));
|
|
||||||
}
|
|
||||||
if (type.altOutput != null && (re == null || re.output == null))
|
|
||||||
{
|
|
||||||
return new ItemStack[] { type.altOutput.get(new Pair<Integer, Integer>(stack.itemID, stack.getItemDamage())) };
|
|
||||||
}
|
|
||||||
if (re != null && re.output != null)
|
|
||||||
{
|
|
||||||
ItemStack output = re.output.copy();
|
|
||||||
output.stackSize = Math.min(re.maxItemsOut, re.minItemsOut + random.nextInt(re.minItemsOut));
|
|
||||||
if (re.chancePerItem < 1.0f)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
return new ItemStack[] { output };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
package dark.lib.recipes;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
/** Processor Recipe output Container. Input is controlled by the processor recipes class. */
|
|
||||||
public class ProcessorRecipe
|
|
||||||
{
|
|
||||||
/** Output of the recipe */
|
|
||||||
public ItemStack output;
|
|
||||||
/** Chance per item after the stack size has been calculated from min and max size */
|
|
||||||
public float chancePerItem = 1.0f;
|
|
||||||
/** Min the recipe can output */
|
|
||||||
public int minItemsOut = -1;
|
|
||||||
/** Max the recipe can output */
|
|
||||||
public int maxItemsOut = -1;
|
|
||||||
|
|
||||||
public ProcessorRecipe(ItemStack output, int min, int max)
|
|
||||||
{
|
|
||||||
this.output = output;
|
|
||||||
this.minItemsOut = min;
|
|
||||||
this.maxItemsOut = max;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
package dark.lib.recipes;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
import com.builtbroken.common.Pair;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enum of machines that support a simple A -> B processor recipe format. More complex machine will
|
|
||||||
* have there own recipe handlers
|
|
||||||
*
|
|
||||||
* @author Darkguardsman
|
|
||||||
*/
|
|
||||||
public enum ProcessorType
|
|
||||||
{
|
|
||||||
/** Pistons that smash the object */
|
|
||||||
CRUSHER(),
|
|
||||||
/** Several disks that shred the item up */
|
|
||||||
GRINDER(),
|
|
||||||
/** Grinds the edge or surface of the item sharpening it */
|
|
||||||
SHARPENING_STONE(),
|
|
||||||
/** Breaks down an item carefully giving an almost complete output of item used to craft it */
|
|
||||||
SALVAGER();
|
|
||||||
public HashMap<Pair<Integer, Integer>, ProcessorRecipe> recipes = new HashMap();
|
|
||||||
public HashMap<Pair<Integer, Integer>, ItemStack> altOutput = new HashMap();
|
|
||||||
public List<Pair<Integer, Integer>> banList = new ArrayList();
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
package resonantinduction.api.events;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.event.Cancelable;
|
|
||||||
import net.minecraftforge.event.Event;
|
|
||||||
import universalelectricity.api.vector.Vector3;
|
|
||||||
import calclavia.lib.utility.AutoCraftingManager.IAutoCrafter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Events called when an automated crafter is working on crafting an item
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public class AutoCraftEvent extends Event
|
|
||||||
{
|
|
||||||
World world;
|
|
||||||
Vector3 spot;
|
|
||||||
IAutoCrafter crafter;
|
|
||||||
ItemStack craftingResult;
|
|
||||||
|
|
||||||
public AutoCraftEvent(World world, Vector3 spot, IAutoCrafter craft, ItemStack stack)
|
|
||||||
{
|
|
||||||
this.world = world;
|
|
||||||
this.spot = spot;
|
|
||||||
this.crafter = craft;
|
|
||||||
this.craftingResult = stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cancelable
|
|
||||||
/** Called before a crafter checks if it can craft. Use this to cancel crafting */
|
|
||||||
public static class PreCraft extends AutoCraftEvent
|
|
||||||
{
|
|
||||||
public PreCraft(World world, Vector3 spot, IAutoCrafter craft, ItemStack stack)
|
|
||||||
{
|
|
||||||
super(world, spot, craft, stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,280 +0,0 @@
|
||||||
package resonantinduction.api.events;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
import net.minecraft.entity.item.EntityTNTPrimed;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
import net.minecraftforge.common.IPlantable;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.event.Cancelable;
|
|
||||||
import net.minecraftforge.event.Event;
|
|
||||||
import universalelectricity.api.vector.Vector3;
|
|
||||||
import calclavia.lib.utility.HelperMethods;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An event triggered by entities or tiles that create lasers
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public class LaserEvent extends Event
|
|
||||||
{
|
|
||||||
public World world;
|
|
||||||
public Vector3 spot;
|
|
||||||
public Vector3 target;
|
|
||||||
|
|
||||||
public LaserEvent(World world, Vector3 spot, Vector3 target)
|
|
||||||
{
|
|
||||||
this.world = world;
|
|
||||||
this.spot = spot;
|
|
||||||
this.target = target;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Called when a laser is fired */
|
|
||||||
@Cancelable
|
|
||||||
public static class LaserFireEvent extends LaserEvent
|
|
||||||
{
|
|
||||||
public Object shooter;
|
|
||||||
|
|
||||||
public LaserFireEvent(World world, Vector3 spot, Vector3 target, Object shooter)
|
|
||||||
{
|
|
||||||
super(world, spot, target);
|
|
||||||
this.shooter = shooter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LaserFireEvent(TileEntity tileEntity, MovingObjectPosition hit)
|
|
||||||
{
|
|
||||||
super(tileEntity.worldObj, new Vector3(tileEntity), new Vector3(hit));
|
|
||||||
this.shooter = tileEntity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Called when a player fires a laser. Use this to cancel a laser hit event */
|
|
||||||
@Cancelable
|
|
||||||
public static class LaserFiredPlayerEvent extends LaserFireEvent
|
|
||||||
{
|
|
||||||
public ItemStack laserItem;
|
|
||||||
public MovingObjectPosition hit;
|
|
||||||
|
|
||||||
public LaserFiredPlayerEvent(EntityPlayer player, MovingObjectPosition hit, ItemStack stack)
|
|
||||||
{
|
|
||||||
super(player.worldObj, new Vector3(player), new Vector3(hit), player);
|
|
||||||
this.laserItem = stack;
|
|
||||||
this.hit = hit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Called when a laser is heating up a block to be mined */
|
|
||||||
public static class LaserMeltBlockEvent extends LaserEvent
|
|
||||||
{
|
|
||||||
public Object shooter;
|
|
||||||
|
|
||||||
public LaserMeltBlockEvent(World world, Vector3 spot, Vector3 hit, Object shooter)
|
|
||||||
{
|
|
||||||
super(world, spot, hit);
|
|
||||||
this.shooter = shooter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Use this to change what drops when the laser finishes mining a block */
|
|
||||||
public static class LaserDropItemEvent extends LaserEvent
|
|
||||||
{
|
|
||||||
public List<ItemStack> items;
|
|
||||||
|
|
||||||
public LaserDropItemEvent(World world, Vector3 spot, Vector3 hit, List<ItemStack> items)
|
|
||||||
{
|
|
||||||
super(world, spot, hit);
|
|
||||||
this.items = items;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Called before a laser mines a block */
|
|
||||||
@Cancelable
|
|
||||||
public static class LaserMineBlockEvent extends LaserEvent
|
|
||||||
{
|
|
||||||
public Object shooter;
|
|
||||||
|
|
||||||
public LaserMineBlockEvent(World world, Vector3 spot, Vector3 hit, Object shooter)
|
|
||||||
{
|
|
||||||
super(world, spot, hit);
|
|
||||||
this.shooter = shooter;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean doLaserHarvestCheck(World world, Vector3 pos, Object player, Vector3 hit)
|
|
||||||
{
|
|
||||||
LaserEvent event = new LaserMineBlockEvent(world, pos, hit, player);
|
|
||||||
MinecraftForge.EVENT_BUS.post(event);
|
|
||||||
return !event.isCanceled();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Called while the block is being mined */
|
|
||||||
public static void onLaserHitBlock(World world, Object player, Vector3 vec, ForgeDirection side)
|
|
||||||
{
|
|
||||||
int id = vec.getBlockID(world);
|
|
||||||
int meta = vec.getBlockID(world);
|
|
||||||
Block block = Block.blocksList[id];
|
|
||||||
|
|
||||||
Vector3 faceVec = vec.clone().modifyPositionFromSide(side);
|
|
||||||
int id2 = faceVec.getBlockID(world);
|
|
||||||
Block block2 = Block.blocksList[id2];
|
|
||||||
|
|
||||||
Vector3 start = null;
|
|
||||||
|
|
||||||
if (player instanceof Entity)
|
|
||||||
{
|
|
||||||
start = new Vector3((Entity) player);
|
|
||||||
}
|
|
||||||
else if (player instanceof TileEntity)
|
|
||||||
{
|
|
||||||
start = new Vector3((TileEntity) player);
|
|
||||||
}
|
|
||||||
if (block != null)
|
|
||||||
{
|
|
||||||
float chance = world.rand.nextFloat();
|
|
||||||
|
|
||||||
int fireChance = block.getFlammability(world, vec.intX(), vec.intY(), vec.intZ(), meta, side);
|
|
||||||
if ((fireChance / 300) >= chance && (block2 == null || block2.isAirBlock(world, vec.intX(), vec.intY(), vec.intZ())))
|
|
||||||
{
|
|
||||||
world.setBlock(vec.intX(), vec.intY(), vec.intZ(), Block.fire.blockID, 0, 3);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (block.blockID == Block.grass.blockID && (block2 == null || block2.isAirBlock(world, vec.intX(), vec.intY() + 1, vec.intZ())))
|
|
||||||
{
|
|
||||||
world.setBlock(vec.intX(), vec.intY() + 1, vec.intZ(), Block.fire.blockID, 0, 3);
|
|
||||||
world.setBlock(vec.intX(), vec.intY(), vec.intZ(), Block.dirt.blockID, 0, 3);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (chance > 0.8f)
|
|
||||||
{
|
|
||||||
// TODO turn water into steam
|
|
||||||
if (block.blockID == Block.sand.blockID)
|
|
||||||
{
|
|
||||||
world.setBlock(vec.intX(), vec.intY(), vec.intZ(), Block.glass.blockID, 0, 3);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (block.blockID == Block.cobblestone.blockID)
|
|
||||||
{
|
|
||||||
world.setBlock(vec.intX(), vec.intY(), vec.intZ(), 1, 0, 3);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (block.blockID == Block.ice.blockID)
|
|
||||||
{
|
|
||||||
world.setBlock(vec.intX(), vec.intY(), vec.intZ(), Block.waterStill.blockID, 15, 3);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (block.blockID == Block.obsidian.blockID)
|
|
||||||
{
|
|
||||||
world.setBlock(vec.intX(), vec.intY(), vec.intZ(), Block.lavaStill.blockID, 15, 3);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MinecraftForge.EVENT_BUS.post(new LaserEvent.LaserMeltBlockEvent(world, start, vec, player));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Called when the block is actually mined */
|
|
||||||
public static void onBlockMinedByLaser(World world, Object player, Vector3 vec)
|
|
||||||
{
|
|
||||||
int id = vec.getBlockID(world);
|
|
||||||
int meta = vec.getBlockID(world);
|
|
||||||
Block block = Block.blocksList[id];
|
|
||||||
|
|
||||||
Vector3 start = null;
|
|
||||||
if (player instanceof Entity)
|
|
||||||
{
|
|
||||||
start = new Vector3((Entity) player);
|
|
||||||
}
|
|
||||||
else if (player instanceof TileEntity)
|
|
||||||
{
|
|
||||||
start = new Vector3((TileEntity) player);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO make this use or call to the correct methods, and events so it can be canceled
|
|
||||||
if (block != null && block.getBlockHardness(world, vec.intX(), vec.intY(), vec.intZ()) >= 0 && doLaserHarvestCheck(world, start, player, vec))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
Block blockBellow = Block.blocksList[vec.clone().modifyPositionFromSide(ForgeDirection.DOWN).getBlockID(world)];
|
|
||||||
if (block != null)
|
|
||||||
{
|
|
||||||
if (block.blockID == Block.tnt.blockID)
|
|
||||||
{
|
|
||||||
world.setBlock(vec.intX(), vec.intY(), vec.intZ(), 0, 0, 3);
|
|
||||||
EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (vec.intX() + 0.5F), (vec.intY() + 0.5F), (vec.intZ() + 0.5F), player instanceof EntityLivingBase ? ((EntityLivingBase) player) : null);
|
|
||||||
entitytntprimed.fuse = world.rand.nextInt(entitytntprimed.fuse / 4) + entitytntprimed.fuse / 8;
|
|
||||||
world.spawnEntityInWorld(entitytntprimed);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (block.blockMaterial == Material.wood || block.blockMaterial == Material.plants || block.blockMaterial == Material.vine || block.blockMaterial == Material.plants || block.blockMaterial == Material.pumpkin || block.blockMaterial == Material.cloth || block.blockMaterial == Material.web)
|
|
||||||
{
|
|
||||||
if (blockBellow != null && blockBellow.blockID == Block.tilledField.blockID && block instanceof IPlantable)
|
|
||||||
{
|
|
||||||
vec.clone().translate(new Vector3(0, -1, 0)).setBlock(world, Block.dirt.blockID, 0, 3);
|
|
||||||
}
|
|
||||||
vec.setBlock(world, Block.fire.blockID, 0, 3);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<ItemStack> items = block.getBlockDropped(world, vec.intX(), vec.intY(), vec.intZ(), meta, 1);
|
|
||||||
if (items == null)
|
|
||||||
{
|
|
||||||
items = new ArrayList<ItemStack>();
|
|
||||||
}
|
|
||||||
// TODO have glass refract the laser causing it to hit random things
|
|
||||||
if (id == Block.glass.blockID)
|
|
||||||
{
|
|
||||||
items.add(new ItemStack(Block.glass, 1, meta));
|
|
||||||
}
|
|
||||||
if (id == Block.thinGlass.blockID)
|
|
||||||
{
|
|
||||||
items.add(new ItemStack(Block.thinGlass, 1));
|
|
||||||
}
|
|
||||||
List<ItemStack> removeList = new ArrayList<ItemStack>();
|
|
||||||
for (int i = 0; i < items.size(); i++)
|
|
||||||
{
|
|
||||||
if (items.get(i).itemID == Block.wood.blockID)
|
|
||||||
{
|
|
||||||
items.set(i, new ItemStack(Item.coal, 1, 1));
|
|
||||||
}
|
|
||||||
else if (items.get(i).itemID == Block.wood.blockID)
|
|
||||||
{
|
|
||||||
if (world.rand.nextFloat() < .25f)
|
|
||||||
{
|
|
||||||
items.set(i, new ItemStack(Item.coal, 1, 1));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
removeList.add(items.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
items.removeAll(removeList);
|
|
||||||
LaserEvent.LaserDropItemEvent event = new LaserEvent.LaserDropItemEvent(world, start, vec, items);
|
|
||||||
MinecraftForge.EVENT_BUS.post(event);
|
|
||||||
items = event.items;
|
|
||||||
for (ItemStack stack : items)
|
|
||||||
{
|
|
||||||
HelperMethods.dropItemStack(world, vec.translate(0.5), stack, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
world.setBlockToAir(vec.intX(), vec.intY(), vec.intZ());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
package resonantinduction.api.events;
|
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.event.Event;
|
|
||||||
import universalelectricity.api.vector.Vector3;
|
|
||||||
|
|
||||||
/** Prefab for all machine based events
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman */
|
|
||||||
public class MachineEvent extends Event
|
|
||||||
{
|
|
||||||
public final World world;
|
|
||||||
public final Vector3 spot;
|
|
||||||
public TileEntity machine;
|
|
||||||
|
|
||||||
public MachineEvent(World world, Vector3 spot)
|
|
||||||
{
|
|
||||||
this.world = world;
|
|
||||||
this.spot = spot;
|
|
||||||
machine = spot.getTileEntity(world);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MachineEvent(TileEntity machine)
|
|
||||||
{
|
|
||||||
this.world = machine.worldObj;
|
|
||||||
this.spot = new Vector3(machine);
|
|
||||||
this.machine = machine;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,83 +0,0 @@
|
||||||
package resonantinduction.api.events;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.event.Cancelable;
|
|
||||||
import universalelectricity.api.vector.Vector3;
|
|
||||||
|
|
||||||
/** Event called at all stages of mining a block using a machine
|
|
||||||
*
|
|
||||||
* @author Darkguardsman */
|
|
||||||
public class MachineMiningEvent extends MachineEvent
|
|
||||||
{
|
|
||||||
public final Vector3 targetBlock;
|
|
||||||
|
|
||||||
public MachineMiningEvent(World world, Vector3 spot, Vector3 target)
|
|
||||||
{
|
|
||||||
super(world, spot);
|
|
||||||
this.targetBlock = target;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cancelable
|
|
||||||
public static class PreMine extends MachineMiningEvent
|
|
||||||
{
|
|
||||||
public PreMine(World world, Vector3 spot, Vector3 target)
|
|
||||||
{
|
|
||||||
super(world, spot, target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class MiningDrop extends MachineMiningEvent
|
|
||||||
{
|
|
||||||
List<ItemStack> items;
|
|
||||||
|
|
||||||
public MiningDrop(World world, Vector3 spot, Vector3 target, List<ItemStack> items)
|
|
||||||
{
|
|
||||||
super(world, spot, target);
|
|
||||||
this.items = items;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class PostMine extends MachineMiningEvent
|
|
||||||
{
|
|
||||||
public PostMine(World world, Vector3 spot, Vector3 target)
|
|
||||||
{
|
|
||||||
super(world, spot, target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean doMachineMiningCheck(World world, Vector3 target, TileEntity machine)
|
|
||||||
{
|
|
||||||
Block block = Block.blocksList[target.getBlockID(world)];
|
|
||||||
|
|
||||||
return block != null && target.getTileEntity(world) == null && !block.isAirBlock(world, target.intX(), target.intY(), target.intZ()) && block.getBlockHardness(world, target.intX(), target.intY(), target.intZ()) >= 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<ItemStack> getItemsMined(World world, Vector3 spot, Vector3 target)
|
|
||||||
{
|
|
||||||
Block block = Block.blocksList[target.getBlockID(world)];
|
|
||||||
if (block != null)
|
|
||||||
{
|
|
||||||
List<ItemStack> items = block.getBlockDropped(world, target.intX(), target.intY(), target.intZ(), target.getBlockMetadata(world), 1);
|
|
||||||
if (items != null)
|
|
||||||
{
|
|
||||||
MiningDrop event = new MiningDrop(world, spot, target, items);
|
|
||||||
MinecraftForge.EVENT_BUS.post(event);
|
|
||||||
items = event.items;
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<ItemStack> getItemsMined(TileEntity entity, Vector3 target)
|
|
||||||
{
|
|
||||||
return getItemsMined(entity.worldObj, new Vector3(entity), target);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,103 +0,0 @@
|
||||||
package resonantinduction.api.recipe;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import resonantinduction.api.recipe.RecipeUtils.ItemStackResource;
|
|
||||||
import resonantinduction.api.recipe.RecipeUtils.OreDictResource;
|
|
||||||
import resonantinduction.api.recipe.RecipeUtils.Resource;
|
|
||||||
|
|
||||||
public final class MachineRecipes
|
|
||||||
{
|
|
||||||
public static enum RecipeType
|
|
||||||
{
|
|
||||||
GRINDER, SAWMILL, SMELTER;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Map<RecipeType, Map<Resource[], Resource[]>> recipes = new HashMap<RecipeType, Map<Resource[], Resource[]>>();
|
|
||||||
|
|
||||||
public static final MachineRecipes INSTANCE = new MachineRecipes();
|
|
||||||
|
|
||||||
private MachineRecipes()
|
|
||||||
{
|
|
||||||
for (RecipeType machine : RecipeType.values())
|
|
||||||
{
|
|
||||||
this.recipes.put(machine, new HashMap<Resource[], Resource[]>());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addRecipe(RecipeType machine, Resource[] input, Resource[] output)
|
|
||||||
{
|
|
||||||
this.recipes.get(machine).put(input, output);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addRecipe(RecipeType machine, ItemStack input, ItemStack output)
|
|
||||||
{
|
|
||||||
this.addRecipe(machine, new ItemStackResource[] { new ItemStackResource(input) }, new ItemStackResource[] { new ItemStackResource(output) });
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addRecipe(RecipeType machine, String input, ItemStack output)
|
|
||||||
{
|
|
||||||
this.addRecipe(machine, new OreDictResource[] { new OreDictResource(input) }, new ItemStackResource[] { new ItemStackResource(output) });
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeRecipe(RecipeType machine, Resource[] input)
|
|
||||||
{
|
|
||||||
this.recipes.get(machine).remove(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<Resource[], Resource[]> getRecipes(RecipeType machine)
|
|
||||||
{
|
|
||||||
return new HashMap<Resource[], Resource[]>(this.recipes.get(machine));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<RecipeType, Map<Resource[], Resource[]>> getRecipes()
|
|
||||||
{
|
|
||||||
return new HashMap<RecipeType, Map<Resource[], Resource[]>>(this.recipes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Resource[] getOutput(RecipeType machine, Resource[] input)
|
|
||||||
{
|
|
||||||
Iterator<Entry<Resource[], Resource[]>> it = this.getRecipes(machine).entrySet().iterator();
|
|
||||||
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
Entry<Resource[], Resource[]> entry = it.next();
|
|
||||||
|
|
||||||
if (Arrays.equals(entry.getKey(), input))
|
|
||||||
{
|
|
||||||
return entry.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Resource[] {};
|
|
||||||
}
|
|
||||||
|
|
||||||
public Resource[] getRecipe(RecipeType machine, ItemStack... inputs)
|
|
||||||
{
|
|
||||||
Resource[] resourceInputs = new Resource[inputs.length];
|
|
||||||
|
|
||||||
for (int i = 0; i < inputs.length; i++)
|
|
||||||
{
|
|
||||||
resourceInputs[i] = new ItemStackResource(inputs[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.getOutput(machine, resourceInputs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Resource[] getRecipe(RecipeType machine, String... oreDictNames)
|
|
||||||
{
|
|
||||||
Resource[] resourceInputs = new Resource[oreDictNames.length];
|
|
||||||
|
|
||||||
for (int i = 0; i < oreDictNames.length; i++)
|
|
||||||
{
|
|
||||||
resourceInputs[i] = new OreDictResource(oreDictNames[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.getOutput(machine, resourceInputs);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
package resonantinduction.api.recipe;
|
|
||||||
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class OreDetectionBlackList
|
|
||||||
{
|
|
||||||
private static final Set<String> oreBlackList = new LinkedHashSet<String>();
|
|
||||||
private static final Set<String> ingotBlackList = new LinkedHashSet<String>();
|
|
||||||
|
|
||||||
public static void addOre(String s)
|
|
||||||
{
|
|
||||||
oreBlackList.add(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addIngot(String s)
|
|
||||||
{
|
|
||||||
ingotBlackList.add(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isOreBlackListed(String s)
|
|
||||||
{
|
|
||||||
return oreBlackList.contains(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isIngotBlackListed(String s)
|
|
||||||
{
|
|
||||||
return ingotBlackList.contains(s);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,120 +0,0 @@
|
||||||
package resonantinduction.api.recipe;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
public class RecipeUtils
|
|
||||||
{
|
|
||||||
public static abstract class Resource
|
|
||||||
{
|
|
||||||
public final boolean hasChance;
|
|
||||||
public final float chance;
|
|
||||||
|
|
||||||
protected Resource()
|
|
||||||
{
|
|
||||||
this.hasChance = false;
|
|
||||||
this.chance = 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Resource(float chance)
|
|
||||||
{
|
|
||||||
this.hasChance = true;
|
|
||||||
this.chance = chance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasChance()
|
|
||||||
{
|
|
||||||
return this.hasChance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getChance()
|
|
||||||
{
|
|
||||||
return this.chance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ItemStackResource extends Resource
|
|
||||||
{
|
|
||||||
public final ItemStack itemStack;
|
|
||||||
|
|
||||||
public ItemStackResource(ItemStack is)
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
this.itemStack = is;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStackResource(ItemStack is, float chance)
|
|
||||||
{
|
|
||||||
super(chance);
|
|
||||||
this.itemStack = is;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj)
|
|
||||||
{
|
|
||||||
if (obj instanceof ItemStackResource)
|
|
||||||
{
|
|
||||||
return this.itemStack.isItemEqual(((ItemStackResource) obj).itemStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class OreDictResource extends Resource
|
|
||||||
{
|
|
||||||
public final String name;
|
|
||||||
|
|
||||||
public OreDictResource(String s)
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
this.name = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OreDictResource(String s, float chance)
|
|
||||||
{
|
|
||||||
super(chance);
|
|
||||||
this.name = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj)
|
|
||||||
{
|
|
||||||
if (obj instanceof OreDictResource)
|
|
||||||
{
|
|
||||||
return this.name.equals(((OreDictResource) obj).name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (obj instanceof ItemStackResource)
|
|
||||||
{
|
|
||||||
return this.name.equals(OreDictionary.getOreName(OreDictionary.getOreID(((ItemStackResource) obj).itemStack)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class FluidStackResource extends Resource
|
|
||||||
{
|
|
||||||
public final FluidStack fluidStack;
|
|
||||||
|
|
||||||
public FluidStackResource(FluidStack fs)
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
this.fluidStack = fs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FluidStackResource(FluidStack fs, float chance)
|
|
||||||
{
|
|
||||||
super(chance);
|
|
||||||
this.fluidStack = fs;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj)
|
|
||||||
{
|
|
||||||
return (obj instanceof FluidStack) ? ((FluidStack) obj).equals(obj) : false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
package resonantinduction.archaic;
|
|
||||||
|
|
||||||
import resonantinduction.archaic.CommonProxy;
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import resonantinduction.core.ResonantInduction;
|
|
||||||
import resonantinduction.core.Settings;
|
|
||||||
import calclavia.lib.network.PacketHandler;
|
|
||||||
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.FMLPreInitializationEvent;
|
|
||||||
import cpw.mods.fml.common.network.NetworkMod;
|
|
||||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resonant Induction Archaic Module
|
|
||||||
*
|
|
||||||
* @author DarkCow, Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Mod(modid = Archaic.ID, name = Archaic.NAME, version = Reference.VERSION, dependencies = "required-after:" + ResonantInduction.ID)
|
|
||||||
@NetworkMod(channels = Reference.CHANNEL, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
|
|
||||||
public class Archaic
|
|
||||||
{
|
|
||||||
/** Mod Information */
|
|
||||||
public static final String ID = "ResonantInduction|Archaic";
|
|
||||||
public static final String NAME = Reference.NAME + " Archaic";
|
|
||||||
|
|
||||||
@Instance(ID)
|
|
||||||
public static Archaic INSTANCE;
|
|
||||||
|
|
||||||
@SidedProxy(clientSide = "resonantinduction.archaic.ClientProxy", serverSide = "resonantinduction.archaic.CommonProxy")
|
|
||||||
public static CommonProxy proxy;
|
|
||||||
|
|
||||||
@Mod.Metadata(ID)
|
|
||||||
public static ModMetadata metadata;
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void preInit(FMLPreInitializationEvent evt)
|
|
||||||
{
|
|
||||||
NetworkRegistry.instance().registerGuiHandler(this, proxy);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void init(FMLInitializationEvent evt)
|
|
||||||
{
|
|
||||||
Settings.setModMetadata(metadata, ID, NAME);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package resonantinduction.archaic;
|
|
||||||
|
|
||||||
import resonantinduction.archaic.CommonProxy;
|
|
||||||
|
|
||||||
public class ClientProxy extends CommonProxy
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package resonantinduction.archaic;
|
|
||||||
|
|
||||||
import resonantinduction.core.prefab.ProxyBase;
|
|
||||||
|
|
||||||
public class CommonProxy extends ProxyBase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,59 +0,0 @@
|
||||||
package resonantinduction.archaic.blocks;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import resonantinduction.core.Settings;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
public class BlockColorGlass extends BlockColored
|
|
||||||
{
|
|
||||||
|
|
||||||
public BlockColorGlass(String name)
|
|
||||||
{
|
|
||||||
super(name, Settings.config.getBlock(name, Settings.getNextBlockID()).getInt(), Material.glass);
|
|
||||||
this.setCreativeTab(CreativeTabs.tabDecorations);
|
|
||||||
this.setHardness(.5f);
|
|
||||||
this.setResistance(.5f);
|
|
||||||
this.setStepSound(soundGlassFootstep);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockColorGlass()
|
|
||||||
{
|
|
||||||
this("StainedGlass");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int quantityDropped(Random par1Random)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@Override
|
|
||||||
public int getRenderBlockPass()
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOpaqueCube()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public boolean renderAsNormalBlock()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean canSilkHarvest()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
package resonantinduction.archaic.blocks;
|
|
||||||
|
|
||||||
public class BlockColorGlowGlass extends BlockColorGlass
|
|
||||||
{
|
|
||||||
|
|
||||||
public BlockColorGlowGlass()
|
|
||||||
{
|
|
||||||
super("GlowGlass");
|
|
||||||
this.setLightOpacity(2);
|
|
||||||
this.setLightValue(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,100 +0,0 @@
|
||||||
package resonantinduction.archaic.blocks;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import resonantinduction.core.Settings;
|
|
||||||
|
|
||||||
//TODO fix instant falling sand
|
|
||||||
public class BlockColorSand extends BlockColored
|
|
||||||
{
|
|
||||||
public BlockColorSand()
|
|
||||||
{
|
|
||||||
super("colorSand", Settings.config.getBlock("colorSand", Settings.getNextBlockID()).getInt(), Material.sand);
|
|
||||||
this.setCreativeTab(CreativeTabs.tabDecorations);
|
|
||||||
this.setHardness(1f);
|
|
||||||
this.setResistance(.5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean fallInstantly = true;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
|
||||||
{
|
|
||||||
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
|
||||||
{
|
|
||||||
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
|
||||||
{
|
|
||||||
if (!par1World.isRemote)
|
|
||||||
{
|
|
||||||
this.tryToFall(par1World, par2, par3, par4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void tryToFall(World par1World, int par2, int par3, int par4)
|
|
||||||
{
|
|
||||||
int meta = par1World.getBlockMetadata(par2, par3, par4);
|
|
||||||
if (canFallBelow(par1World, par2, par3 - 1, par4) && par3 >= 0)
|
|
||||||
{
|
|
||||||
byte var8 = 32;
|
|
||||||
|
|
||||||
if (!fallInstantly && par1World.checkChunksExist(par2 - var8, par3 - var8, par4 - var8, par2 + var8, par3 + var8, par4 + var8))
|
|
||||||
{
|
|
||||||
if (!par1World.isRemote)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
par1World.setBlock(par2, par3, par4, 0);
|
|
||||||
|
|
||||||
while (canFallBelow(par1World, par2, par3 - 1, par4) && par3 > 0)
|
|
||||||
{
|
|
||||||
--par3;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (par3 > 0)
|
|
||||||
{
|
|
||||||
par1World.setBlock(par2, par3, par4, this.blockID, meta, 3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int tickRate()
|
|
||||||
{
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canFallBelow(World par0World, int par1, int par2, int par3)
|
|
||||||
{
|
|
||||||
int var4 = par0World.getBlockId(par1, par2, par3);
|
|
||||||
|
|
||||||
if (var4 == 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (var4 == Block.fire.blockID)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Material var5 = Block.blocksList[var4].blockMaterial;
|
|
||||||
return var5 == Material.water ? true : var5 == Material.lava;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,100 +0,0 @@
|
||||||
package resonantinduction.archaic.blocks;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.client.renderer.texture.IconRegister;
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.Icon;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import dark.lib.helpers.ColorCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prefab class to make any block have 16 separate color instances similar to wool block
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public class BlockColored extends Block
|
|
||||||
{
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
private Icon[] icons;
|
|
||||||
|
|
||||||
/** Use a single icon to create all 16 colors */
|
|
||||||
boolean colorized = true;
|
|
||||||
|
|
||||||
public BlockColored(String name, int id, Material par2Material)
|
|
||||||
{
|
|
||||||
super(id, par2Material);
|
|
||||||
this.setUnlocalizedName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@Override
|
|
||||||
public Icon getIcon(int side, int meta)
|
|
||||||
{
|
|
||||||
if (colorized)
|
|
||||||
{
|
|
||||||
return this.blockIcon;
|
|
||||||
}
|
|
||||||
return this.icons[~meta & 15];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int damageDropped(int meta)
|
|
||||||
{
|
|
||||||
return meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@Override
|
|
||||||
public void getSubBlocks(int par1, CreativeTabs tab, List contentList)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < 16; ++j)
|
|
||||||
{
|
|
||||||
contentList.add(new ItemStack(par1, 1, j));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@Override
|
|
||||||
public void registerIcons(IconRegister iconReg)
|
|
||||||
{
|
|
||||||
if (colorized)
|
|
||||||
{
|
|
||||||
this.blockIcon = iconReg.registerIcon(Reference.PREFIX + this.getUnlocalizedName().replace("tile.", ""));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.icons = new Icon[16];
|
|
||||||
|
|
||||||
for (int i = 0; i < this.icons.length; ++i)
|
|
||||||
{
|
|
||||||
this.icons[i] = iconReg.registerIcon(Reference.PREFIX + ColorCode.get(~i & 15).name + this.getUnlocalizedName().replace("tile.", ""));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@Override
|
|
||||||
public int colorMultiplier(IBlockAccess world, int x, int y, int z)
|
|
||||||
{
|
|
||||||
return this.getRenderColor(world.getBlockMetadata(x, y, z));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@Override
|
|
||||||
public int getRenderColor(int meta)
|
|
||||||
{
|
|
||||||
if (this.colorized)
|
|
||||||
{
|
|
||||||
return ColorCode.get(~meta & 15).color.getRGB();
|
|
||||||
}
|
|
||||||
return super.getRenderColor(meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,260 +0,0 @@
|
||||||
package resonantinduction.archaic.blocks;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.client.renderer.texture.IconRegister;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.Icon;
|
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
import resonantinduction.core.prefab.block.BlockMachine;
|
|
||||||
import resonantinduction.old.transport.ResonantInductionTransport;
|
|
||||||
import universalelectricity.api.vector.Vector3;
|
|
||||||
import calclavia.lib.prefab.tile.IRotatable;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import dark.lib.interfaces.IRotatableBlock;
|
|
||||||
|
|
||||||
public class BlockTurntable extends BlockMachine
|
|
||||||
{
|
|
||||||
private Icon top;
|
|
||||||
|
|
||||||
public BlockTurntable()
|
|
||||||
{
|
|
||||||
super("turntable", Material.piston);
|
|
||||||
this.setTickRandomly(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int tickRate(World par1World)
|
|
||||||
{
|
|
||||||
return 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void registerIcons(IconRegister iconReg)
|
|
||||||
{
|
|
||||||
super.registerIcons(iconReg);
|
|
||||||
this.top = iconReg.registerIcon(ResonantInductionTransport.PREFIX + "turntable");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateTick(World world, int x, int y, int z, Random par5Random)
|
|
||||||
{
|
|
||||||
this.updateTurntableState(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public Icon getIcon(int side, int meta)
|
|
||||||
{
|
|
||||||
if (side == meta)
|
|
||||||
{
|
|
||||||
return this.top;
|
|
||||||
}
|
|
||||||
return this.blockIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack stack)
|
|
||||||
{
|
|
||||||
int angle = MathHelper.floor_double((entityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
|
||||||
int change = 3;
|
|
||||||
|
|
||||||
switch (angle)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
change = 2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
change = 5;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
change = 3;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
change = 4;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, change, 3);
|
|
||||||
world.scheduleBlockUpdate(x, y, z, this.blockID, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNeighborBlockChange(World world, int x, int y, int z, int side)
|
|
||||||
{
|
|
||||||
world.scheduleBlockUpdate(x, y, z, this.blockID, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateTurntableState(World world, int x, int y, int z)
|
|
||||||
{
|
|
||||||
if (world.isBlockIndirectlyGettingPowered(x, y, z))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ForgeDirection direction = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z));
|
|
||||||
ForgeDirection blockRotation = null;
|
|
||||||
|
|
||||||
Vector3 position = new Vector3(x, y, z).modifyPositionFromSide(direction);
|
|
||||||
TileEntity tileEntity = position.getTileEntity(world);
|
|
||||||
int blockID = position.getBlockID(world);
|
|
||||||
|
|
||||||
if (tileEntity instanceof IRotatable)
|
|
||||||
{
|
|
||||||
blockRotation = ((IRotatable) tileEntity).getDirection();
|
|
||||||
}
|
|
||||||
else if (Block.blocksList[blockID] instanceof IRotatableBlock)
|
|
||||||
{
|
|
||||||
blockRotation = ((IRotatableBlock) Block.blocksList[blockID]).getDirection(world, position.intX(), position.intY(), position.intZ());
|
|
||||||
}
|
|
||||||
else if (Block.blocksList[blockID] != null)
|
|
||||||
{
|
|
||||||
Block.blocksList[blockID].rotateBlock(world, position.intX(), position.intY(), position.intZ(), direction.getOpposite());
|
|
||||||
}
|
|
||||||
if (direction != null)
|
|
||||||
{
|
|
||||||
if (direction == ForgeDirection.UP || direction == ForgeDirection.DOWN)
|
|
||||||
{
|
|
||||||
if (blockRotation == ForgeDirection.NORTH)
|
|
||||||
{
|
|
||||||
blockRotation = ForgeDirection.EAST;
|
|
||||||
}
|
|
||||||
else if (blockRotation == ForgeDirection.EAST)
|
|
||||||
{
|
|
||||||
blockRotation = ForgeDirection.SOUTH;
|
|
||||||
}
|
|
||||||
else if (blockRotation == ForgeDirection.SOUTH)
|
|
||||||
{
|
|
||||||
blockRotation = ForgeDirection.WEST;
|
|
||||||
}
|
|
||||||
else if (blockRotation == ForgeDirection.WEST)
|
|
||||||
{
|
|
||||||
blockRotation = ForgeDirection.NORTH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (direction == ForgeDirection.EAST || direction == ForgeDirection.WEST)
|
|
||||||
{
|
|
||||||
if (blockRotation == ForgeDirection.NORTH)
|
|
||||||
{
|
|
||||||
blockRotation = ForgeDirection.UP;
|
|
||||||
}
|
|
||||||
else if (blockRotation == ForgeDirection.UP)
|
|
||||||
{
|
|
||||||
blockRotation = ForgeDirection.SOUTH;
|
|
||||||
}
|
|
||||||
else if (blockRotation == ForgeDirection.SOUTH)
|
|
||||||
{
|
|
||||||
blockRotation = ForgeDirection.DOWN;
|
|
||||||
}
|
|
||||||
else if (blockRotation == ForgeDirection.DOWN)
|
|
||||||
{
|
|
||||||
blockRotation = ForgeDirection.NORTH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (direction == ForgeDirection.NORTH || direction == ForgeDirection.SOUTH)
|
|
||||||
{
|
|
||||||
if (blockRotation == ForgeDirection.EAST)
|
|
||||||
{
|
|
||||||
blockRotation = ForgeDirection.UP;
|
|
||||||
}
|
|
||||||
else if (blockRotation == ForgeDirection.UP)
|
|
||||||
{
|
|
||||||
blockRotation = ForgeDirection.WEST;
|
|
||||||
}
|
|
||||||
else if (blockRotation == ForgeDirection.WEST)
|
|
||||||
{
|
|
||||||
blockRotation = ForgeDirection.DOWN;
|
|
||||||
}
|
|
||||||
else if (blockRotation == ForgeDirection.DOWN)
|
|
||||||
{
|
|
||||||
blockRotation = ForgeDirection.EAST;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
if (tileEntity instanceof IRotatable)
|
|
||||||
{
|
|
||||||
((IRotatable) tileEntity).setDirection(blockRotation);
|
|
||||||
world.scheduleBlockUpdate(position.intX(), position.intY(), position.intZ(), this.blockID, 20);
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (Block.blocksList[blockID] instanceof IRotatableBlock)
|
|
||||||
{
|
|
||||||
((IRotatableBlock) Block.blocksList[blockID]).setDirection(world, position.intX(), position.intY(), position.intZ(), blockRotation);
|
|
||||||
world.scheduleBlockUpdate(position.intX(), position.intY(), position.intZ(), this.blockID, 20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
System.out.println("Error while rotating a block near " + x + "x " + y + "y " + z + "z " + (world != null && world.provider != null ? world.provider.dimensionId + "d" : "null:world"));
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onSneakMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
|
||||||
{
|
|
||||||
if (world.isRemote)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, side, 3);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
|
||||||
{
|
|
||||||
if (world.isRemote)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ForgeDirection currentDirection = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z));
|
|
||||||
if (currentDirection == ForgeDirection.NORTH)
|
|
||||||
{
|
|
||||||
currentDirection = ForgeDirection.UP;
|
|
||||||
}
|
|
||||||
else if (currentDirection == ForgeDirection.UP)
|
|
||||||
{
|
|
||||||
currentDirection = ForgeDirection.DOWN;
|
|
||||||
}
|
|
||||||
else if (currentDirection == ForgeDirection.DOWN)
|
|
||||||
{
|
|
||||||
currentDirection = ForgeDirection.EAST;
|
|
||||||
}
|
|
||||||
else if (currentDirection == ForgeDirection.EAST)
|
|
||||||
{
|
|
||||||
currentDirection = ForgeDirection.SOUTH;
|
|
||||||
}
|
|
||||||
else if (currentDirection == ForgeDirection.SOUTH)
|
|
||||||
{
|
|
||||||
currentDirection = ForgeDirection.WEST;
|
|
||||||
}
|
|
||||||
else if (currentDirection == ForgeDirection.WEST)
|
|
||||||
{
|
|
||||||
currentDirection = ForgeDirection.NORTH;
|
|
||||||
}
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, currentDirection.ordinal(), 3);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createNewTileEntity(World world)
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
package resonantinduction.archaic.blocks;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.item.ItemBlock;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import dark.lib.helpers.ColorCode;
|
|
||||||
|
|
||||||
public class ItemBlockColored extends ItemBlock
|
|
||||||
{
|
|
||||||
public ItemBlockColored(int par1)
|
|
||||||
{
|
|
||||||
super(par1);
|
|
||||||
this.setMaxDamage(0);
|
|
||||||
this.setHasSubtypes(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetadata(int par1)
|
|
||||||
{
|
|
||||||
return par1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUnlocalizedName(ItemStack par1ItemStack)
|
|
||||||
{
|
|
||||||
return Block.blocksList[this.getBlockID()].getUnlocalizedName() + "." + ColorCode.get(par1ItemStack.getItemDamage()).name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUnlocalizedName()
|
|
||||||
{
|
|
||||||
return Block.blocksList[this.getBlockID()].getUnlocalizedName();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
package resonantinduction.core;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class ClientProxy extends CommonProxy
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void preInit()
|
|
||||||
{
|
|
||||||
MinecraftForge.EVENT_BUS.register(SoundHandler.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postInit()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPaused()
|
|
||||||
{
|
|
||||||
if (FMLClientHandler.instance().getClient().isSingleplayer() && !FMLClientHandler.instance().getClient().getIntegratedServer().getPublic())
|
|
||||||
{
|
|
||||||
GuiScreen screen = FMLClientHandler.instance().getClient().currentScreen;
|
|
||||||
|
|
||||||
if (screen != null)
|
|
||||||
{
|
|
||||||
if (screen.doesGuiPauseGame())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isGraphicsFancy()
|
|
||||||
{
|
|
||||||
return FMLClientHandler.instance().getClient().gameSettings.fancyGraphics;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package resonantinduction.core;
|
|
||||||
|
|
||||||
import resonantinduction.core.prefab.ProxyBase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class CommonProxy extends ProxyBase
|
|
||||||
{
|
|
||||||
public boolean isPaused()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isGraphicsFancy()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
package resonantinduction.core;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A class for static references.
|
|
||||||
*
|
|
||||||
* @author Calclavia
|
|
||||||
*/
|
|
||||||
public class Reference
|
|
||||||
{
|
|
||||||
/** The official name of the mod */
|
|
||||||
public static final String NAME = "Resonant Induction";
|
|
||||||
|
|
||||||
public static final String MAJOR_VERSION = "@MAJOR@";
|
|
||||||
public static final String MINOR_VERSION = "@MINOR@";
|
|
||||||
public static final String REVISION_VERSION = "@REVIS@";
|
|
||||||
public static final String BUILD_VERSION = "@BUILD@";
|
|
||||||
public static final String VERSION = MAJOR_VERSION + "." + MINOR_VERSION + "." + REVISION_VERSION;
|
|
||||||
public static final String CHANNEL = "resonindc";
|
|
||||||
/**
|
|
||||||
* Directory Information
|
|
||||||
*/
|
|
||||||
public static final String DOMAIN = "resonantinduction";
|
|
||||||
public static final String PREFIX = DOMAIN + ":";
|
|
||||||
public static final String DIRECTORY = "/assets/" + DOMAIN + "/";
|
|
||||||
public static final String TEXTURE_DIRECTORY = "textures/";
|
|
||||||
public static final String GUI_DIRECTORY = TEXTURE_DIRECTORY + "gui/";
|
|
||||||
public static final String BLOCK_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "blocks/";
|
|
||||||
public static final String ITEM_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "items/";
|
|
||||||
public static final String MODEL_PATH = "models/";
|
|
||||||
public static final String MODEL_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + MODEL_PATH;
|
|
||||||
public static final String MODEL_DIRECTORY = DIRECTORY + MODEL_PATH;
|
|
||||||
public static final String LANGUAGE_DIRECTORY = DIRECTORY + "languages/";
|
|
||||||
public static final String[] LANGUAGES = new String[] { "en_US", "de_DE" };
|
|
||||||
}
|
|
|
@ -1,127 +0,0 @@
|
||||||
package resonantinduction.core;
|
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.fluids.Fluid;
|
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
|
||||||
|
|
||||||
import org.modstats.ModstatInfo;
|
|
||||||
import org.modstats.Modstats;
|
|
||||||
|
|
||||||
import resonantinduction.core.handler.FluidEventHandler;
|
|
||||||
import resonantinduction.core.handler.LinkEventHandler;
|
|
||||||
import resonantinduction.core.prefab.part.PacketMultiPart;
|
|
||||||
import resonantinduction.core.resource.ResourceGenerator;
|
|
||||||
import resonantinduction.core.resource.fluid.BlockFluidMixture;
|
|
||||||
import resonantinduction.core.resource.fluid.TileFluidMixture;
|
|
||||||
import resonantinduction.core.resource.item.ItemDust;
|
|
||||||
import calclavia.lib.multiblock.link.BlockMulti;
|
|
||||||
import calclavia.lib.multiblock.link.TileMultiBlockPart;
|
|
||||||
import calclavia.lib.network.PacketHandler;
|
|
||||||
import calclavia.lib.network.PacketTile;
|
|
||||||
import calclavia.lib.utility.LanguageUtility;
|
|
||||||
import cpw.mods.fml.common.FMLLog;
|
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The core module of Resonant Induction
|
|
||||||
*
|
|
||||||
* @author Calclavia
|
|
||||||
*/
|
|
||||||
@Mod(modid = ResonantInduction.ID, name = ResonantInduction.NAME, version = Reference.VERSION, dependencies = "required-after:CalclaviaCore;before:IC2")
|
|
||||||
@NetworkMod(channels = Reference.CHANNEL, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
|
|
||||||
@ModstatInfo(prefix = "resonantin")
|
|
||||||
public class ResonantInduction
|
|
||||||
{
|
|
||||||
/** Mod Information */
|
|
||||||
public static final String ID = "ResonantInduction|Core";
|
|
||||||
public static final String NAME = Reference.NAME + " Core";
|
|
||||||
|
|
||||||
@Instance(ID)
|
|
||||||
public static ResonantInduction INSTANCE;
|
|
||||||
|
|
||||||
@SidedProxy(clientSide = "resonantinduction.core.ClientProxy", serverSide = "resonantinduction.core.CommonProxy")
|
|
||||||
public static CommonProxy proxy;
|
|
||||||
|
|
||||||
@Mod.Metadata(ID)
|
|
||||||
public static ModMetadata metadata;
|
|
||||||
|
|
||||||
public static final Logger LOGGER = Logger.getLogger(Reference.NAME);
|
|
||||||
|
|
||||||
/** Packets */
|
|
||||||
public static final PacketTile PACKET_TILE = new PacketTile(Reference.CHANNEL);
|
|
||||||
public static final PacketMultiPart PACKET_MULTIPART = new PacketMultiPart(Reference.CHANNEL);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Blocks and Items
|
|
||||||
*/
|
|
||||||
public static BlockMulti blockMulti;
|
|
||||||
|
|
||||||
public static ItemDust itemDust;
|
|
||||||
public static Block blockFluidMixture;
|
|
||||||
|
|
||||||
public static Fluid MIXTURE = null;
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void preInit(FMLPreInitializationEvent evt)
|
|
||||||
{
|
|
||||||
ResonantInduction.LOGGER.setParent(FMLLog.getLogger());
|
|
||||||
NetworkRegistry.instance().registerGuiHandler(this, proxy);
|
|
||||||
Modstats.instance().getReporter().registerMod(this);
|
|
||||||
Settings.load();
|
|
||||||
|
|
||||||
// Register Forge Events
|
|
||||||
MinecraftForge.EVENT_BUS.register(ResourceGenerator.INSTANCE);
|
|
||||||
MinecraftForge.EVENT_BUS.register(new LinkEventHandler());
|
|
||||||
MinecraftForge.EVENT_BUS.register(new FluidEventHandler());
|
|
||||||
|
|
||||||
Settings.config.load();
|
|
||||||
|
|
||||||
blockMulti = new BlockMulti(Settings.getNextBlockID()).setPacketType(PACKET_TILE);
|
|
||||||
|
|
||||||
MIXTURE = new Fluid("mixture");
|
|
||||||
FluidRegistry.registerFluid(MIXTURE);
|
|
||||||
blockFluidMixture = new BlockFluidMixture(Settings.getNextBlockID(), MIXTURE);
|
|
||||||
|
|
||||||
// Items
|
|
||||||
itemDust = new ItemDust(Settings.getNextItemID());
|
|
||||||
GameRegistry.registerItem(itemDust, itemDust.getUnlocalizedName());
|
|
||||||
|
|
||||||
GameRegistry.registerTileEntity(TileMultiBlockPart.class, "TileEntityMultiBlockPart");
|
|
||||||
GameRegistry.registerBlock(blockMulti, "blockMulti");
|
|
||||||
|
|
||||||
GameRegistry.registerBlock(blockFluidMixture, blockFluidMixture.getUnlocalizedName());
|
|
||||||
GameRegistry.registerTileEntity(TileFluidMixture.class, blockFluidMixture.getUnlocalizedName());
|
|
||||||
|
|
||||||
Settings.config.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void init(FMLInitializationEvent evt)
|
|
||||||
{
|
|
||||||
// Load Languages
|
|
||||||
ResonantInduction.LOGGER.fine("Languages Loaded:" + LanguageUtility.loadLanguages(Reference.LANGUAGE_DIRECTORY, Reference.LANGUAGES));
|
|
||||||
// Set Mod Metadata
|
|
||||||
Settings.setModMetadata(metadata, ID, NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void postInit(FMLPostInitializationEvent evt)
|
|
||||||
{
|
|
||||||
// Generate Dusts
|
|
||||||
ResourceGenerator.generateDusts();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package resonantinduction.core;
|
|
||||||
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ResonantInductionTabs extends CreativeTabs
|
|
||||||
{
|
|
||||||
public static final ResonantInductionTabs CORE = new ResonantInductionTabs(CreativeTabs.getNextID(), Reference.DOMAIN);
|
|
||||||
public static ItemStack ITEMSTACK;
|
|
||||||
|
|
||||||
public ResonantInductionTabs(int par1, String par2Str)
|
|
||||||
{
|
|
||||||
super(par1, par2Str);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getIconItemStack()
|
|
||||||
{
|
|
||||||
return ITEMSTACK;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,94 +0,0 @@
|
||||||
package resonantinduction.core;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraftforge.common.Configuration;
|
|
||||||
import calclavia.lib.prefab.block.IDManager;
|
|
||||||
import calclavia.lib.utility.LanguageUtility;
|
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
|
||||||
import cpw.mods.fml.common.Loader;
|
|
||||||
import cpw.mods.fml.common.ModMetadata;
|
|
||||||
|
|
||||||
/** @author Calclavia */
|
|
||||||
public class Settings
|
|
||||||
{
|
|
||||||
/** IDs suggested by Jyzarc and Horfius */
|
|
||||||
public static final IDManager idManager = new IDManager(3200, 20150);
|
|
||||||
|
|
||||||
public static int getNextBlockID()
|
|
||||||
{
|
|
||||||
return idManager.getNextBlockID();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getNextItemID()
|
|
||||||
{
|
|
||||||
return idManager.getNextItemID();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Settings */
|
|
||||||
public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), Reference.NAME + ".cfg"));
|
|
||||||
public static int FURNACE_WATTAGE = 50000;
|
|
||||||
public static boolean SOUND_FXS = true;
|
|
||||||
public static boolean LO_FI_INSULATION = false;
|
|
||||||
public static boolean SHINY_SILVER = true;
|
|
||||||
public static boolean REPLACE_FURNACE = true;
|
|
||||||
public static int MAX_CONTRACTOR_DISTANCE = 200;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called from RI's core.
|
|
||||||
*/
|
|
||||||
public static void load()
|
|
||||||
{
|
|
||||||
CONFIGURATION.load();
|
|
||||||
|
|
||||||
// Config
|
|
||||||
FURNACE_WATTAGE = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Furnace Wattage Per Tick", FURNACE_WATTAGE).getInt(FURNACE_WATTAGE);
|
|
||||||
SOUND_FXS = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Tesla Sound FXs", SOUND_FXS).getBoolean(SOUND_FXS);
|
|
||||||
LO_FI_INSULATION = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Use lo-fi insulation texture", LO_FI_INSULATION).getBoolean(LO_FI_INSULATION);
|
|
||||||
SHINY_SILVER = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Shiny silver wires", SHINY_SILVER).getBoolean(SHINY_SILVER);
|
|
||||||
MAX_CONTRACTOR_DISTANCE = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Max EM Contractor Path", MAX_CONTRACTOR_DISTANCE).getInt(MAX_CONTRACTOR_DISTANCE);
|
|
||||||
REPLACE_FURNACE = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Replace vanilla furnace", REPLACE_FURNACE).getBoolean(REPLACE_FURNACE);
|
|
||||||
|
|
||||||
LEVITATOR_ACCELERATION = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Item Acceleration", Settings.LEVITATOR_ACCELERATION).getDouble(Settings.LEVITATOR_ACCELERATION);
|
|
||||||
LEVITATOR_MAX_REACH = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Max Item Reach", Settings.LEVITATOR_MAX_REACH).getInt(Settings.LEVITATOR_MAX_REACH);
|
|
||||||
LEVITATOR_MAX_SPEED = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Max Item Speed", Settings.LEVITATOR_MAX_SPEED).getDouble(Settings.LEVITATOR_MAX_SPEED);
|
|
||||||
LEVITATOR_PUSH_DELAY = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Item Push Delay", Settings.LEVITATOR_PUSH_DELAY).getInt(Settings.LEVITATOR_PUSH_DELAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void save()
|
|
||||||
{
|
|
||||||
CONFIGURATION.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setModMetadata(ModMetadata metadata, String id, String name)
|
|
||||||
{
|
|
||||||
metadata.modId = id;
|
|
||||||
metadata.name = name;
|
|
||||||
metadata.description = LanguageUtility.getLocal("meta.resonantinduction.description");
|
|
||||||
metadata.url = "http://calclavia.com/resonant-induction";
|
|
||||||
metadata.logoFile = "ri_logo.png";
|
|
||||||
metadata.version = Reference.VERSION + "." + Reference.BUILD_VERSION;
|
|
||||||
metadata.authorList = Arrays.asList(new String[] { "Calclavia", "DarkCow" });
|
|
||||||
metadata.credits = LanguageUtility.getLocal("meta.resonantinduction.credits");
|
|
||||||
metadata.autogenerated = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isOp(String username)
|
|
||||||
{
|
|
||||||
MinecraftServer theServer = FMLCommonHandler.instance().getMinecraftServerInstance();
|
|
||||||
|
|
||||||
if (theServer != null)
|
|
||||||
{
|
|
||||||
return theServer.getConfigurationManager().getOps().contains(username.trim().toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int LEVITATOR_MAX_REACH = 40;
|
|
||||||
public static int LEVITATOR_PUSH_DELAY = 5;
|
|
||||||
public static double LEVITATOR_MAX_SPEED = .2;
|
|
||||||
public static double LEVITATOR_ACCELERATION = .02;
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package resonantinduction.core;
|
|
||||||
|
|
||||||
import net.minecraftforge.client.event.sound.SoundLoadEvent;
|
|
||||||
import net.minecraftforge.event.ForgeSubscribe;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class SoundHandler
|
|
||||||
{
|
|
||||||
public static final SoundHandler INSTANCE = new SoundHandler();
|
|
||||||
|
|
||||||
public static final String[] SOUND_FILES = { "grinder1.ogg", "grinder2.ogg", "electricshock1.ogg", "electricshock2.ogg", "electricshock3.ogg", "electricshock4.ogg", "electricshock5.ogg", "electricshock6.ogg", "electricshock7.ogg" };
|
|
||||||
|
|
||||||
@ForgeSubscribe
|
|
||||||
public void loadSoundEvents(SoundLoadEvent event)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < SOUND_FILES.length; i++)
|
|
||||||
{
|
|
||||||
event.manager.addSound(Reference.PREFIX + SOUND_FILES[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
ResonantInduction.LOGGER.fine("Loaded sound fxs");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
package resonantinduction.core;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
import codechicken.lib.vec.BlockCoord;
|
|
||||||
import codechicken.multipart.TileMultipart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* General Utilities
|
|
||||||
*
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class Utility
|
|
||||||
{
|
|
||||||
public static TileMultipart getMultipartTile(IBlockAccess access, BlockCoord pos)
|
|
||||||
{
|
|
||||||
TileEntity te = access.getBlockTileEntity(pos.x, pos.y, pos.z);
|
|
||||||
return te instanceof TileMultipart ? (TileMultipart) te : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canPlaceWireOnSide(World w, int x, int y, int z, ForgeDirection side, boolean _default)
|
|
||||||
{
|
|
||||||
if (!w.blockExists(x, y, z))
|
|
||||||
return _default;
|
|
||||||
|
|
||||||
Block b = Block.blocksList[w.getBlockId(x, y, z)];
|
|
||||||
if (b == null)
|
|
||||||
return false;
|
|
||||||
// Manual list of allowed blocks that wire can sit on.
|
|
||||||
if (b == Block.glowStone || b == Block.pistonBase || b == Block.pistonStickyBase || b == Block.pistonMoving)
|
|
||||||
return true;
|
|
||||||
return b.isBlockSolidOnSide(w, x, y, z, side);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int isDye(ItemStack is)
|
|
||||||
{
|
|
||||||
String[] dyes = { "dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", "dyePink", "dyeLime", "dyeYellow", "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite" };
|
|
||||||
|
|
||||||
for (int i = 0; i < dyes.length; i++)
|
|
||||||
{
|
|
||||||
if (OreDictionary.getOreID(is) != -1 && OreDictionary.getOreName(OreDictionary.getOreID(is)).equals(dyes[i]))
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,208 +0,0 @@
|
||||||
package resonantinduction.core.debug;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.texture.IconRegister;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.Icon;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.Configuration;
|
|
||||||
import resonantinduction.core.ResonantInductionTabs;
|
|
||||||
import resonantinduction.core.prefab.block.BlockMachine;
|
|
||||||
import resonantinduction.old.transport.ResonantInductionTransport;
|
|
||||||
|
|
||||||
import com.builtbroken.common.Pair;
|
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import dark.lib.IExtraInfo.IExtraBlockInfo;
|
|
||||||
|
|
||||||
public class BlockDebug extends BlockMachine implements IExtraBlockInfo
|
|
||||||
{
|
|
||||||
public static float DebugWattOut, DebugWattDemand;
|
|
||||||
|
|
||||||
public BlockDebug()
|
|
||||||
{
|
|
||||||
super("DebugBlock");
|
|
||||||
this.setCreativeTab(ResonantInductionTabs.CORE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void registerIcons(IconRegister iconReg)
|
|
||||||
{
|
|
||||||
super.registerIcons(iconReg);
|
|
||||||
for (DebugBlocks block : DebugBlocks.values())
|
|
||||||
{
|
|
||||||
if (block.enabled)
|
|
||||||
{
|
|
||||||
block.icon = iconReg.registerIcon(ResonantInductionTransport.PREFIX + block.getTextureName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public Icon getIcon(int side, int meta)
|
|
||||||
{
|
|
||||||
if (meta < DebugBlocks.values().length)
|
|
||||||
{
|
|
||||||
return DebugBlocks.values()[meta].icon;
|
|
||||||
}
|
|
||||||
return this.blockIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createTileEntity(World world, int metadata)
|
|
||||||
{
|
|
||||||
if (metadata < DebugBlocks.values().length)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return DebugBlocks.values()[metadata].clazz.newInstance();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.createTileEntity(world, metadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createNewTileEntity(World world)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBlockAdded(World world, int x, int y, int z)
|
|
||||||
{
|
|
||||||
super.onBlockAdded(world, x, y, z);
|
|
||||||
int meta = world.getBlockMetadata(x, y, z);
|
|
||||||
if (meta >= DebugBlocks.values().length || !DebugBlocks.values()[meta].enabled)
|
|
||||||
{
|
|
||||||
world.setBlock(x, y, z, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getSubBlocks(int blockID, CreativeTabs tab, List creativeTabList)
|
|
||||||
{
|
|
||||||
for (DebugBlocks block : DebugBlocks.values())
|
|
||||||
{
|
|
||||||
if (block.enabled)
|
|
||||||
{
|
|
||||||
creativeTabList.add(new ItemStack(blockID, 1, block.ordinal()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getTileEntities(int blockID, Set<Pair<String, Class<? extends TileEntity>>> list)
|
|
||||||
{
|
|
||||||
for (DebugBlocks block : DebugBlocks.values())
|
|
||||||
{
|
|
||||||
if (block.enabled && block.clazz != null && block.name != null)
|
|
||||||
{
|
|
||||||
list.add(new Pair<String, Class<? extends TileEntity>>(block.name, block.clazz));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadExtraConfigs(Configuration config)
|
|
||||||
{
|
|
||||||
for (DebugBlocks block : DebugBlocks.values())
|
|
||||||
{
|
|
||||||
block.enabled = config.get("Blocks", "Enable" + block.name + "Block", true).getBoolean(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onSneakMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
|
||||||
{
|
|
||||||
return this.onUseWrench(world, x, y, z, entityPlayer, side, hitX, hitY, hitZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum DebugBlocks
|
|
||||||
{
|
|
||||||
SOURCE("UnlimitedPower", TileEntityInfSupply.class, "infSource"),
|
|
||||||
FLUID("UnlimitedFluid", TileEntityInfFluid.class, "infFluid"),
|
|
||||||
VOID("FluidVoid", TileEntityVoid.class, "void"),
|
|
||||||
LOAD("PowerVampire", TileEntityInfLoad.class, "infLoad");
|
|
||||||
public Icon icon;
|
|
||||||
public String name;
|
|
||||||
public String texture;
|
|
||||||
public boolean enabled;
|
|
||||||
Class<? extends TileEntity> clazz;
|
|
||||||
|
|
||||||
private DebugBlocks(String name, Class<? extends TileEntity> clazz)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
this.clazz = clazz;
|
|
||||||
}
|
|
||||||
|
|
||||||
private DebugBlocks(String name, Class<? extends TileEntity> clazz, String texture)
|
|
||||||
{
|
|
||||||
this(name, clazz);
|
|
||||||
this.texture = texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTextureName()
|
|
||||||
{
|
|
||||||
if (texture == null || texture.isEmpty())
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
return texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasExtraConfigs()
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadOreNames()
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getClientTileEntityRenderers(List<Pair<Class<? extends TileEntity>, TileEntitySpecialRenderer>> list)
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
package resonantinduction.core.debug;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import resonantinduction.core.Settings;
|
|
||||||
|
|
||||||
/** Creative mod tool to quickly create a large hole in the ground. Is designed only for debug
|
|
||||||
* testing of ore generation.
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman */
|
|
||||||
public class ItemInstaHole extends Item
|
|
||||||
{
|
|
||||||
|
|
||||||
public ItemInstaHole()
|
|
||||||
{
|
|
||||||
super(Settings.config.getItem("InstaHole", Settings.getNextItemID()).getInt());
|
|
||||||
this.setUnlocalizedName("InstaHole");
|
|
||||||
this.setCreativeTab(CreativeTabs.tabTools);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int xx, int yy, int zz, int par7, float par8, float par9, float par10)
|
|
||||||
{
|
|
||||||
if (player != null && player.capabilities.isCreativeMode)
|
|
||||||
{
|
|
||||||
if (world.isRemote)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
for (int y = yy; y > 0; y--)
|
|
||||||
{
|
|
||||||
for (int x = xx - 10; x < xx + 10; x++)
|
|
||||||
{
|
|
||||||
for (int z = zz - 10; z < zz + 10; z++)
|
|
||||||
{
|
|
||||||
int id = world.getBlockId(x, y, z);
|
|
||||||
if (id == 0)
|
|
||||||
{
|
|
||||||
world.setBlock(x, y, z, 20);
|
|
||||||
}
|
|
||||||
else if (id == Block.sand.blockID || id == Block.gravel.blockID || id == 1 || id == Block.dirt.blockID || id == Block.grass.blockID)
|
|
||||||
{
|
|
||||||
world.setBlock(x, y, z, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,116 +0,0 @@
|
||||||
package resonantinduction.core.debug;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.ChatMessageComponent;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
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 universalelectricity.api.vector.Vector3;
|
|
||||||
import calclavia.lib.multiblock.link.IBlockActivate;
|
|
||||||
import calclavia.lib.utility.FluidHelper;
|
|
||||||
|
|
||||||
import com.builtbroken.common.lang.TextHelper.TextColor;
|
|
||||||
|
|
||||||
public class TileEntityInfFluid extends TileEntity implements IFluidHandler, IBlockActivate
|
|
||||||
{
|
|
||||||
FluidTank tank = new FluidTank(Integer.MAX_VALUE);
|
|
||||||
boolean autoEmpty = false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateEntity()
|
|
||||||
{
|
|
||||||
if (!this.worldObj.isRemote && autoEmpty && this.tank != null && this.tank.getFluid() != null)
|
|
||||||
{
|
|
||||||
FluidHelper.fillTanksAllSides(this.worldObj, new Vector3(this), FluidHelper.getStack(this.tank.getFluid(), 600), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
|
||||||
{
|
|
||||||
if (resource != null)
|
|
||||||
{
|
|
||||||
if (tank == null || tank.getFluid() == null)
|
|
||||||
{
|
|
||||||
tank = new FluidTank(Integer.MAX_VALUE);
|
|
||||||
tank.setFluid(new FluidStack(FluidRegistry.WATER, Integer.MAX_VALUE));
|
|
||||||
}
|
|
||||||
if (tank != null && tank.getFluid() != null && tank.getFluid().containsFluid(resource))
|
|
||||||
{
|
|
||||||
return resource.copy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
|
||||||
{
|
|
||||||
return this.tank != null && this.tank.getFluid() != null ? this.drain(from, FluidHelper.getStack(this.tank.getFluid(), maxDrain), doDrain) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
|
||||||
{
|
|
||||||
return fluid != null && this.tank != null && this.tank.getFluid() != null && this.tank.getFluid().getFluid().equals(fluid);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
|
||||||
{
|
|
||||||
return new FluidTankInfo[] { this.tank.getInfo() };
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onActivated(EntityPlayer entityPlayer)
|
|
||||||
{
|
|
||||||
if (entityPlayer != null && entityPlayer.getHeldItem() != null)
|
|
||||||
{
|
|
||||||
ItemStack held = entityPlayer.getHeldItem();
|
|
||||||
if (held.itemID == Item.stick.itemID)
|
|
||||||
{
|
|
||||||
if (!this.worldObj.isRemote)
|
|
||||||
{
|
|
||||||
this.autoEmpty = !autoEmpty;
|
|
||||||
entityPlayer.sendChatToPlayer(ChatMessageComponent.createFromText("AutoPump > " + (autoEmpty ? TextColor.DARKGREEN + "On" : TextColor.RED + "Off")));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(held);
|
|
||||||
if (fluidStack != null)
|
|
||||||
{
|
|
||||||
if (!this.worldObj.isRemote)
|
|
||||||
{
|
|
||||||
fluidStack = fluidStack.copy();
|
|
||||||
fluidStack.amount = Integer.MAX_VALUE;
|
|
||||||
this.tank.setFluid(fluidStack);
|
|
||||||
entityPlayer.sendChatToPlayer(ChatMessageComponent.createFromText("Fluid Set to > " + fluidStack.getFluid().getName()));
|
|
||||||
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
package resonantinduction.core.debug;
|
|
||||||
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
import resonantinduction.core.prefab.tile.TileEntityEnergyMachine;
|
|
||||||
|
|
||||||
public class TileEntityInfLoad extends TileEntityEnergyMachine
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
|
|
||||||
{
|
|
||||||
return receive;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long onExtractEnergy(ForgeDirection from, long request, boolean doExtract)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canConnect(ForgeDirection direction)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getMaxEnergyStored()
|
|
||||||
{
|
|
||||||
return Long.MAX_VALUE;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
package resonantinduction.core.debug;
|
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
import resonantinduction.core.prefab.tile.TileEntityEnergyMachine;
|
|
||||||
|
|
||||||
public class TileEntityInfSupply extends TileEntityEnergyMachine
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void updateEntity()
|
|
||||||
{
|
|
||||||
super.updateEntity();
|
|
||||||
this.setJoulesPerTick(10000);
|
|
||||||
this.produce();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumSet<ForgeDirection> getOutputDirections()
|
|
||||||
{
|
|
||||||
return EnumSet.allOf(ForgeDirection.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumSet<ForgeDirection> getInputDirections()
|
|
||||||
{
|
|
||||||
return EnumSet.noneOf(ForgeDirection.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long onExtractEnergy(ForgeDirection from, long request, boolean doExtract)
|
|
||||||
{
|
|
||||||
return request;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canConnect(ForgeDirection direction)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getMaxEnergyStored()
|
|
||||||
{
|
|
||||||
return Long.MAX_VALUE;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
package resonantinduction.core.debug;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
import net.minecraftforge.fluids.Fluid;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
import net.minecraftforge.fluids.FluidTank;
|
|
||||||
import net.minecraftforge.fluids.FluidTankInfo;
|
|
||||||
import net.minecraftforge.fluids.IFluidHandler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Designed to debug fluid devices by draining everything that comes in at one time
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public class TileEntityVoid extends TileEntity implements IFluidHandler
|
|
||||||
{
|
|
||||||
// TODO later add to this to make it actually have an ingame use other than debug
|
|
||||||
public static HashMap<FluidStack, Long> storage = new HashMap<FluidStack, Long>();
|
|
||||||
|
|
||||||
FluidTank tank = new FluidTank(1000000);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
|
||||||
{
|
|
||||||
// TODO add wrench toggle options to change amount actually drained
|
|
||||||
return resource != null && this.canFill(from, resource.getFluid()) ? resource.amount : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
|
||||||
{
|
|
||||||
// TODO add wrench settings to close off sides for testing
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
|
||||||
{
|
|
||||||
return new FluidTankInfo[] { this.tank.getInfo() };
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
package resonantinduction.core.handler;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import net.minecraft.util.Icon;
|
|
||||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
|
||||||
import net.minecraftforge.event.ForgeSubscribe;
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import resonantinduction.core.ResonantInduction;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class FluidEventHandler
|
|
||||||
{
|
|
||||||
public static final HashMap<String, Icon> fluidIconMap = new HashMap<String, Icon>();
|
|
||||||
|
|
||||||
public void registerIcon(String name, TextureStitchEvent.Pre event)
|
|
||||||
{
|
|
||||||
fluidIconMap.put(name, event.map.registerIcon(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ForgeSubscribe
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void preTextureHook(TextureStitchEvent.Pre event)
|
|
||||||
{
|
|
||||||
if (event.map.textureType == 0)
|
|
||||||
{
|
|
||||||
registerIcon(Reference.PREFIX + "mixture", event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ForgeSubscribe
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void textureHook(TextureStitchEvent.Post event)
|
|
||||||
{
|
|
||||||
ResonantInduction.MIXTURE.setIcons(fluidIconMap.get(Reference.PREFIX + "mixture"));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
package resonantinduction.core.handler;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import universalelectricity.api.vector.VectorWorld;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public interface ILinkable
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* @param vector
|
|
||||||
* @return True to clear the link.
|
|
||||||
*/
|
|
||||||
public boolean onLink(EntityPlayer player, VectorWorld vector);
|
|
||||||
}
|
|
|
@ -1,81 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package resonantinduction.core.handler;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraftforge.event.Event.Result;
|
|
||||||
import net.minecraftforge.event.ForgeSubscribe;
|
|
||||||
import universalelectricity.api.vector.VectorWorld;
|
|
||||||
import calclavia.components.event.MultitoolEvent;
|
|
||||||
import codechicken.multipart.ControlKeyModifer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Calclavia
|
|
||||||
*/
|
|
||||||
public class LinkEventHandler
|
|
||||||
{
|
|
||||||
@ForgeSubscribe
|
|
||||||
public void linkEvent(MultitoolEvent evt)
|
|
||||||
{
|
|
||||||
if (ControlKeyModifer.isControlDown(evt.player))
|
|
||||||
{
|
|
||||||
TileEntity tile = evt.world.getBlockTileEntity(evt.x, evt.y, evt.z);
|
|
||||||
|
|
||||||
if (tile instanceof ILinkable && this.hasLink(evt.toolStack))
|
|
||||||
{
|
|
||||||
if (!evt.world.isRemote)
|
|
||||||
{
|
|
||||||
if (((ILinkable) tile).onLink(evt.player, this.getLink(evt.toolStack)))
|
|
||||||
{
|
|
||||||
this.clearLink(evt.toolStack);
|
|
||||||
evt.player.addChatMessage("Link cleared.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
evt.setResult(Result.DENY);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!evt.world.isRemote)
|
|
||||||
{
|
|
||||||
evt.player.addChatMessage("Set link to block [" + evt.x + ", " + evt.y + ", " + evt.z + "], Dimension: '" + evt.world.provider.getDimensionName() + "'");
|
|
||||||
this.setLink(evt.toolStack, new VectorWorld(evt.world, evt.x, evt.y, evt.z));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
evt.setCanceled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasLink(ItemStack itemStack)
|
|
||||||
{
|
|
||||||
return getLink(itemStack) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VectorWorld getLink(ItemStack itemStack)
|
|
||||||
{
|
|
||||||
if (itemStack.stackTagCompound == null || !itemStack.getTagCompound().hasKey("link"))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new VectorWorld(itemStack.getTagCompound().getCompoundTag("link"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLink(ItemStack itemStack, VectorWorld vec)
|
|
||||||
{
|
|
||||||
if (itemStack.getTagCompound() == null)
|
|
||||||
{
|
|
||||||
itemStack.setTagCompound(new NBTTagCompound());
|
|
||||||
}
|
|
||||||
|
|
||||||
itemStack.getTagCompound().setCompoundTag("link", vec.writeToNBT(new NBTTagCompound()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearLink(ItemStack itemStack)
|
|
||||||
{
|
|
||||||
itemStack.getTagCompound().removeTag("link");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package resonantinduction.core.network;
|
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.network.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simplified version of IPackerReceiver for tiles that only need a packet ID, data, and player
|
|
||||||
* Reference
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public interface ISimplePacketReceiver
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Simplified version of IPacketReceiver's HandlePacketData
|
|
||||||
*
|
|
||||||
* @param id - packet ID as a string
|
|
||||||
* @param data - data from the packet, after location has been read
|
|
||||||
* @param player - player that the packet was sent to or came from
|
|
||||||
* @return true if the packet was used
|
|
||||||
*/
|
|
||||||
public boolean simplePacket(String id, ByteArrayDataInput data, Player player);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,72 +0,0 @@
|
||||||
package resonantinduction.core.network;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.network.packet.Packet;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import calclavia.lib.network.IPacketReceiver;
|
|
||||||
import calclavia.lib.network.PacketType;
|
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Packet handler for blocks and tile entities.
|
|
||||||
*
|
|
||||||
* @author Calclavia
|
|
||||||
*/
|
|
||||||
public class PacketIDTile extends PacketType
|
|
||||||
{
|
|
||||||
public PacketIDTile(String channel)
|
|
||||||
{
|
|
||||||
super(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Packet getPacket(TileEntity tileEntity, String id, Object... args)
|
|
||||||
{
|
|
||||||
return this.getPacket(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, id, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Packet getPacket(int x, int y, int z, String id, Object... args)
|
|
||||||
{
|
|
||||||
List newArgs = new ArrayList();
|
|
||||||
|
|
||||||
newArgs.add(x);
|
|
||||||
newArgs.add(y);
|
|
||||||
newArgs.add(z);
|
|
||||||
newArgs.add(id);
|
|
||||||
|
|
||||||
for (Object obj : args)
|
|
||||||
{
|
|
||||||
newArgs.add(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getPacket(newArgs.toArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receivePacket(ByteArrayDataInput data, EntityPlayer player)
|
|
||||||
{
|
|
||||||
int x = data.readInt();
|
|
||||||
int y = data.readInt();
|
|
||||||
int z = data.readInt();
|
|
||||||
String id = data.readUTF();
|
|
||||||
TileEntity tileEntity = player.worldObj.getBlockTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if (tileEntity instanceof IPacketReceiver)
|
|
||||||
{
|
|
||||||
((IPacketReceiver) tileEntity).onReceivePacket(data, player);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int blockID = player.worldObj.getBlockId(x, y, z);
|
|
||||||
|
|
||||||
if (Block.blocksList[blockID] instanceof IPacketReceiver)
|
|
||||||
{
|
|
||||||
((IPacketReceiver) Block.blocksList[blockID]).onReceivePacket(data, player, x, y, z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package resonantinduction.core.part;
|
|
||||||
|
|
||||||
import resonantinduction.core.prefab.block.BlockBase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A block used to build machines.
|
|
||||||
*
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class BlockMachinePart extends BlockBase
|
|
||||||
{
|
|
||||||
public BlockMachinePart()
|
|
||||||
{
|
|
||||||
super("machinePart");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
package resonantinduction.core.prefab;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import cpw.mods.fml.common.network.IGuiHandler;
|
|
||||||
|
|
||||||
public abstract class ProxyBase implements IGuiHandler
|
|
||||||
{
|
|
||||||
public void preInit()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void postInit()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package resonantinduction.core.prefab.block;
|
|
||||||
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraftforge.common.Configuration;
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import resonantinduction.core.ResonantInductionTabs;
|
|
||||||
import resonantinduction.core.Settings;
|
|
||||||
import universalelectricity.api.UniversalElectricity;
|
|
||||||
import calclavia.lib.prefab.block.BlockAdvanced;
|
|
||||||
|
|
||||||
/** @author Calclavia */
|
|
||||||
public class BlockBase extends BlockAdvanced
|
|
||||||
{
|
|
||||||
public BlockBase(String name)
|
|
||||||
{
|
|
||||||
this(name, UniversalElectricity.machine);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockBase(String name, Material material)
|
|
||||||
{
|
|
||||||
this(Settings.getNextBlockID(), name, material);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockBase(int id, String name, Material material)
|
|
||||||
{
|
|
||||||
super(Settings.config.get(Configuration.CATEGORY_BLOCK, name, id).getInt(id), material);
|
|
||||||
this.setCreativeTab(ResonantInductionTabs.CORE);
|
|
||||||
this.setUnlocalizedName(Reference.PREFIX + name);
|
|
||||||
this.setTextureName(Reference.PREFIX + name);
|
|
||||||
this.setHardness(1f);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package resonantinduction.core.prefab.block;
|
|
||||||
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraftforge.common.Configuration;
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import resonantinduction.core.ResonantInductionTabs;
|
|
||||||
import resonantinduction.core.Settings;
|
|
||||||
import calclavia.lib.prefab.block.BlockSidedIO;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Blocks that have specific sided input and output should extend this.
|
|
||||||
*
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class BlockIOBase extends BlockSidedIO
|
|
||||||
{
|
|
||||||
public BlockIOBase(String name, int id)
|
|
||||||
{
|
|
||||||
super(Settings.config.get(Configuration.CATEGORY_BLOCK, name, id).getInt(id), Material.piston);
|
|
||||||
this.setCreativeTab(ResonantInductionTabs.CORE);
|
|
||||||
this.setUnlocalizedName(Reference.PREFIX + name);
|
|
||||||
this.setTextureName(Reference.PREFIX + name);
|
|
||||||
this.setHardness(1f);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,145 +0,0 @@
|
||||||
package resonantinduction.core.prefab.block;
|
|
||||||
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
import net.minecraft.entity.item.EntityItem;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import resonantinduction.core.prefab.tile.TileEntityFilterable;
|
|
||||||
import resonantinduction.old.api.IFilterable;
|
|
||||||
import resonantinduction.old.transport.imprinter.ItemImprinter;
|
|
||||||
|
|
||||||
/** Extend this block class if a filter is allowed to be placed inside of this block.
|
|
||||||
*
|
|
||||||
* @author Calclavia */
|
|
||||||
public abstract class BlockImprintable extends BlockMachine
|
|
||||||
{
|
|
||||||
|
|
||||||
public BlockImprintable(String blockName, Material material)
|
|
||||||
{
|
|
||||||
super(blockName, material);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Allows filters to be placed inside of this block. */
|
|
||||||
@Override
|
|
||||||
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
|
|
||||||
{
|
|
||||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if (tileEntity != null)
|
|
||||||
{
|
|
||||||
if (tileEntity instanceof IFilterable)
|
|
||||||
{
|
|
||||||
ItemStack containingStack = ((IFilterable) tileEntity).getFilter();
|
|
||||||
|
|
||||||
if (containingStack != null)
|
|
||||||
{
|
|
||||||
if (!world.isRemote)
|
|
||||||
{
|
|
||||||
EntityItem dropStack = new EntityItem(world, player.posX, player.posY, player.posZ, containingStack);
|
|
||||||
dropStack.delayBeforeCanPickup = 0;
|
|
||||||
world.spawnEntityInWorld(dropStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
((IFilterable) tileEntity).setFilter(null);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (player.getCurrentEquippedItem() != null)
|
|
||||||
{
|
|
||||||
if (player.getCurrentEquippedItem().getItem() instanceof ItemImprinter)
|
|
||||||
{
|
|
||||||
((IFilterable) tileEntity).setFilter(player.getCurrentEquippedItem());
|
|
||||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
|
||||||
{
|
|
||||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if (tileEntity != null)
|
|
||||||
{
|
|
||||||
if (tileEntity instanceof TileEntityFilterable)
|
|
||||||
{
|
|
||||||
((TileEntityFilterable) tileEntity).toggleInversion();
|
|
||||||
world.markBlockForRenderUpdate(x, y, z);
|
|
||||||
world.markBlockForUpdate(x, y, z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onSneakMachineActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
|
||||||
{
|
|
||||||
return this.onMachineActivated(world, x, y, z, player, side, hitX, hitY, hitZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack stack)
|
|
||||||
{
|
|
||||||
int angle = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
|
||||||
int change = 2;
|
|
||||||
|
|
||||||
switch (angle)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
change = 2;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
change = 5;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
change = 3;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
change = 4;
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, change, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
|
||||||
{
|
|
||||||
int original = world.getBlockMetadata(x, y, z);
|
|
||||||
int change = 2;
|
|
||||||
|
|
||||||
switch (original)
|
|
||||||
{
|
|
||||||
case 2:
|
|
||||||
change = 4;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
change = 5;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
change = 3;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
change = 2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, change, 3);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
package resonantinduction.core.prefab.block;
|
|
||||||
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraftforge.common.Configuration;
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import resonantinduction.core.ResonantInductionTabs;
|
|
||||||
import resonantinduction.core.Settings;
|
|
||||||
import universalelectricity.api.UniversalElectricity;
|
|
||||||
import calclavia.lib.prefab.block.BlockTile;
|
|
||||||
/**
|
|
||||||
* Basic prefab for machine
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class BlockMachine extends BlockTile
|
|
||||||
{
|
|
||||||
|
|
||||||
public BlockMachine(String name)
|
|
||||||
{
|
|
||||||
this(name, UniversalElectricity.machine);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockMachine(String name, Material material)
|
|
||||||
{
|
|
||||||
this(Settings.getNextBlockID(), name, material);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockMachine(int id, String name, Material material)
|
|
||||||
{
|
|
||||||
super(Settings.config.get(Configuration.CATEGORY_BLOCK, name, id).getInt(id), material);
|
|
||||||
this.setCreativeTab(ResonantInductionTabs.CORE);
|
|
||||||
this.setUnlocalizedName(Reference.PREFIX + name);
|
|
||||||
this.setTextureName(Reference.PREFIX + name);
|
|
||||||
this.setHardness(1f);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package resonantinduction.core.prefab.block;
|
|
||||||
|
|
||||||
import net.minecraftforge.common.Configuration;
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import resonantinduction.core.ResonantInductionTabs;
|
|
||||||
import resonantinduction.core.Settings;
|
|
||||||
import universalelectricity.api.UniversalElectricity;
|
|
||||||
import calclavia.lib.prefab.block.BlockRotatable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class BlockRotatableBase extends BlockRotatable
|
|
||||||
{
|
|
||||||
public BlockRotatableBase(String name, int id)
|
|
||||||
{
|
|
||||||
super(Settings.config.get(Configuration.CATEGORY_BLOCK, name, id).getInt(id), UniversalElectricity.machine);
|
|
||||||
this.setCreativeTab(ResonantInductionTabs.CORE);
|
|
||||||
this.setUnlocalizedName(Reference.PREFIX + name);
|
|
||||||
this.setTextureName(Reference.PREFIX + name);
|
|
||||||
this.setHardness(1f);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
package resonantinduction.core.prefab.item;
|
|
||||||
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraftforge.common.Configuration;
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import resonantinduction.core.ResonantInductionTabs;
|
|
||||||
import resonantinduction.core.Settings;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author AidanBrady
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ItemBase extends Item
|
|
||||||
{
|
|
||||||
public ItemBase(String name, int id)
|
|
||||||
{
|
|
||||||
super(Settings.config.get(Configuration.CATEGORY_ITEM, name, id).getInt(id));
|
|
||||||
this.setCreativeTab(ResonantInductionTabs.CORE);
|
|
||||||
this.setUnlocalizedName(Reference.PREFIX + name);
|
|
||||||
this.setTextureName(Reference.PREFIX + name);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
package resonantinduction.core.prefab.part;
|
|
||||||
|
|
||||||
import net.minecraftforge.common.Configuration;
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import resonantinduction.core.ResonantInductionTabs;
|
|
||||||
import resonantinduction.core.Settings;
|
|
||||||
import codechicken.multipart.JItemMultiPart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public abstract class ItemMultipartBase extends JItemMultiPart
|
|
||||||
{
|
|
||||||
public ItemMultipartBase(String name, int id)
|
|
||||||
{
|
|
||||||
super(Settings.config.get(Configuration.CATEGORY_ITEM, name, id).getInt(id));
|
|
||||||
this.setCreativeTab(ResonantInductionTabs.CORE);
|
|
||||||
this.setUnlocalizedName(Reference.PREFIX + name);
|
|
||||||
this.setTextureName(Reference.PREFIX + name);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,64 +0,0 @@
|
||||||
package resonantinduction.core.prefab.part;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.network.packet.Packet;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import universalelectricity.api.vector.Vector3;
|
|
||||||
import calclavia.lib.network.IPacketReceiver;
|
|
||||||
import calclavia.lib.network.PacketType;
|
|
||||||
import codechicken.multipart.TMultiPart;
|
|
||||||
import codechicken.multipart.TileMultipart;
|
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Packet handler for blocks and tile entities.
|
|
||||||
*
|
|
||||||
* @author Calclavia
|
|
||||||
*/
|
|
||||||
public class PacketMultiPart extends PacketType
|
|
||||||
{
|
|
||||||
public PacketMultiPart(String channel)
|
|
||||||
{
|
|
||||||
super(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Packet getPacket(Vector3 position, int partID, Object... args)
|
|
||||||
{
|
|
||||||
List newArgs = new ArrayList();
|
|
||||||
|
|
||||||
newArgs.add(position.intX());
|
|
||||||
newArgs.add(position.intY());
|
|
||||||
newArgs.add(position.intZ());
|
|
||||||
newArgs.add(partID);
|
|
||||||
|
|
||||||
for (Object obj : args)
|
|
||||||
{
|
|
||||||
newArgs.add(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getPacket(newArgs.toArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receivePacket(ByteArrayDataInput data, EntityPlayer player)
|
|
||||||
{
|
|
||||||
int x = data.readInt();
|
|
||||||
int y = data.readInt();
|
|
||||||
int z = data.readInt();
|
|
||||||
TileEntity tileEntity = player.worldObj.getBlockTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if (tileEntity instanceof TileMultipart)
|
|
||||||
{
|
|
||||||
TMultiPart part = ((TileMultipart) tileEntity).partMap(data.readInt());
|
|
||||||
|
|
||||||
if (part instanceof IPacketReceiver)
|
|
||||||
{
|
|
||||||
((IPacketReceiver) part).onReceivePacket(data, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
package resonantinduction.core.prefab.part;
|
|
||||||
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import codechicken.multipart.TMultiPart;
|
|
||||||
|
|
||||||
public abstract class PartAdvanced extends TMultiPart
|
|
||||||
{
|
|
||||||
protected long ticks = 0;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update()
|
|
||||||
{
|
|
||||||
if (ticks == 0)
|
|
||||||
{
|
|
||||||
initiate();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ticks >= Long.MAX_VALUE)
|
|
||||||
{
|
|
||||||
ticks = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ticks++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called on the TileEntity's first tick.
|
|
||||||
*/
|
|
||||||
public void initiate()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public World getWorld()
|
|
||||||
{
|
|
||||||
return world();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,421 +0,0 @@
|
||||||
package resonantinduction.core.prefab.tile;
|
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTBase;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.nbt.NBTTagFloat;
|
|
||||||
import net.minecraft.nbt.NBTTagLong;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
import universalelectricity.api.CompatibilityModule;
|
|
||||||
import universalelectricity.api.electricity.IVoltageInput;
|
|
||||||
import universalelectricity.api.electricity.IVoltageOutput;
|
|
||||||
import universalelectricity.api.energy.IEnergyContainer;
|
|
||||||
import universalelectricity.api.energy.IEnergyInterface;
|
|
||||||
import universalelectricity.api.vector.Vector3;
|
|
||||||
import universalelectricity.api.vector.VectorHelper;
|
|
||||||
import dark.lib.interfaces.IPowerLess;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic energy tile that can consume power
|
|
||||||
*
|
|
||||||
* Based off both UE universal electrical tile, and electrical tile prefabs
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public abstract class TileEntityEnergyMachine extends TileEntityMachine implements IEnergyInterface, IEnergyContainer, IPowerLess, IVoltageInput, IVoltageOutput
|
|
||||||
{
|
|
||||||
/** Forge Ore Directory name of the item to toggle infinite power mode */
|
|
||||||
public static String powerToggleItemID = "battery";
|
|
||||||
/** Demand per tick in watts */
|
|
||||||
protected long JOULES_PER_TICK;
|
|
||||||
/** Max limit of the internal battery/buffer of the machine */
|
|
||||||
protected long MAX_JOULES_STORED;
|
|
||||||
/** Current energy stored in the machine's battery/buffer */
|
|
||||||
protected long energyStored = 0;
|
|
||||||
/** Should we run without power */
|
|
||||||
private boolean runWithoutPower = true;
|
|
||||||
/** Point by which this machines suffers low voltage damage */
|
|
||||||
protected long brownOutVoltage = -1;
|
|
||||||
/** Point by which this machines suffers over voltage damage */
|
|
||||||
protected long shortOutVoltage = -1;
|
|
||||||
/** Voltage by which the machine was designed and rated for */
|
|
||||||
protected long ratedVoltage = 240;
|
|
||||||
|
|
||||||
public TileEntityEnergyMachine()
|
|
||||||
{
|
|
||||||
this.brownOutVoltage = this.getVoltage() / 2;
|
|
||||||
this.shortOutVoltage = (long) ((Math.sqrt(2) * this.getVoltage()) + 0.05 * this.getVoltage());
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileEntityEnergyMachine(long wattsPerTick)
|
|
||||||
{
|
|
||||||
this();
|
|
||||||
this.JOULES_PER_TICK = wattsPerTick;
|
|
||||||
this.MAX_JOULES_STORED = wattsPerTick * 20;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileEntityEnergyMachine(long wattsPerTick, long maxEnergy)
|
|
||||||
{
|
|
||||||
this(wattsPerTick);
|
|
||||||
this.MAX_JOULES_STORED = maxEnergy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateEntity()
|
|
||||||
{
|
|
||||||
super.updateEntity();
|
|
||||||
if (!this.worldObj.isRemote && this.isFunctioning())
|
|
||||||
{
|
|
||||||
this.consumePower(this.JOULES_PER_TICK, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Does this tile have power to run and do work */
|
|
||||||
@Override
|
|
||||||
public boolean canFunction()
|
|
||||||
{
|
|
||||||
return super.canFunction() && (this.runPowerLess() || this.consumePower(this.JOULES_PER_TICK, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Called when a player activates the tile's block */
|
|
||||||
public boolean onPlayerActivated(EntityPlayer player)
|
|
||||||
{
|
|
||||||
if (player != null && player.capabilities.isCreativeMode)
|
|
||||||
{
|
|
||||||
ItemStack itemStack = player.getHeldItem();
|
|
||||||
if (itemStack != null)
|
|
||||||
{
|
|
||||||
for (ItemStack stack : OreDictionary.getOres(powerToggleItemID))
|
|
||||||
{
|
|
||||||
if (stack.isItemEqual(itemStack))
|
|
||||||
{
|
|
||||||
this.togglePowerMode();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateContainingBlockInfo()
|
|
||||||
{
|
|
||||||
super.updateContainingBlockInfo();
|
|
||||||
// TODO use this to reset any values that are based on the block as this gets called when
|
|
||||||
// the block changes
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ********************************************
|
|
||||||
* Electricity logic
|
|
||||||
* *********************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
|
|
||||||
{
|
|
||||||
if (!this.runPowerLess() && this.getInputDirections().contains(from) && receive > 0)
|
|
||||||
{
|
|
||||||
long prevEnergyStored = Math.max(this.getEnergy(from), 0);
|
|
||||||
long newStoredEnergy = Math.min(this.getEnergy(from) + receive, this.getEnergyCapacity(from));
|
|
||||||
if (doReceive)
|
|
||||||
{
|
|
||||||
this.setEnergy(from, newStoredEnergy);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Math.max(newStoredEnergy - prevEnergyStored, 0);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Called to consume power from the internal storage */
|
|
||||||
protected boolean consumePower(long watts, boolean doDrain)
|
|
||||||
{
|
|
||||||
if (watts <= 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!this.runPowerLess() && this.getEnergy(ForgeDirection.UNKNOWN) >= watts)
|
|
||||||
{
|
|
||||||
if (doDrain)
|
|
||||||
{
|
|
||||||
this.setEnergy(ForgeDirection.UNKNOWN, this.getEnergyStored() - watts);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return this.runPowerLess();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long onExtractEnergy(ForgeDirection from, long request, boolean doExtract)
|
|
||||||
{
|
|
||||||
if (this.getOutputDirections().contains(from) && request > 0)
|
|
||||||
{
|
|
||||||
long requestedEnergy = Math.min(request, this.energyStored);
|
|
||||||
if (doExtract)
|
|
||||||
{
|
|
||||||
this.setEnergy(from, this.energyStored - requestedEnergy);
|
|
||||||
}
|
|
||||||
return requestedEnergy;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Called to produce power using the output enumset for directions to output in */
|
|
||||||
protected void produce()
|
|
||||||
{
|
|
||||||
for (ForgeDirection direction : this.getOutputDirections())
|
|
||||||
{
|
|
||||||
if (direction != ForgeDirection.UNKNOWN)
|
|
||||||
{
|
|
||||||
TileEntity entity = VectorHelper.getTileEntityFromSide(this.worldObj, new Vector3(this), direction);
|
|
||||||
if (CompatibilityModule.canConnect(entity, direction.getOpposite()))
|
|
||||||
{
|
|
||||||
long output = this.onExtractEnergy(direction, this.JOULES_PER_TICK, false);
|
|
||||||
long input = CompatibilityModule.receiveEnergy(entity, direction.getOpposite(), output, true);
|
|
||||||
if (input > 0 && this.onExtractEnergy(direction, input, true) > 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getVoltageInput(ForgeDirection direction)
|
|
||||||
{
|
|
||||||
if (this.getInputDirections().contains(direction))
|
|
||||||
{
|
|
||||||
return this.ratedVoltage;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onWrongVoltage(ForgeDirection direction, long voltage)
|
|
||||||
{
|
|
||||||
if (voltage > this.ratedVoltage)
|
|
||||||
{
|
|
||||||
if (voltage > this.shortOutVoltage)
|
|
||||||
{
|
|
||||||
// TODO damage machine
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (voltage < this.brownOutVoltage)
|
|
||||||
{
|
|
||||||
// TODO cause machine to run slow
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getVoltageOutput(ForgeDirection direction)
|
|
||||||
{
|
|
||||||
if (this.getOutputDirections().contains(direction))
|
|
||||||
{
|
|
||||||
return this.ratedVoltage;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ********************************************
|
|
||||||
* Electricity connection logic
|
|
||||||
* *********************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canConnect(ForgeDirection direction)
|
|
||||||
{
|
|
||||||
if (direction == null || direction.equals(ForgeDirection.UNKNOWN))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.getInputDirections().contains(direction) || this.getOutputDirections().contains(direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The electrical input direction.
|
|
||||||
*
|
|
||||||
* @return The direction that electricity is entered into the tile. Return null for no input. By
|
|
||||||
* default you can accept power from all sides.
|
|
||||||
*/
|
|
||||||
public EnumSet<ForgeDirection> getInputDirections()
|
|
||||||
{
|
|
||||||
return EnumSet.allOf(ForgeDirection.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The electrical output direction.
|
|
||||||
*
|
|
||||||
* @return The direction that electricity is output from the tile. Return null for no output. By
|
|
||||||
* default it will return an empty EnumSet.
|
|
||||||
*/
|
|
||||||
public EnumSet<ForgeDirection> getOutputDirections()
|
|
||||||
{
|
|
||||||
return EnumSet.noneOf(ForgeDirection.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ********************************************
|
|
||||||
* Machine energy parms
|
|
||||||
* *********************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
public long getVoltage()
|
|
||||||
{
|
|
||||||
return this.ratedVoltage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileEntityEnergyMachine setVoltage(long volts)
|
|
||||||
{
|
|
||||||
this.ratedVoltage = volts;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getMaxEnergyStored()
|
|
||||||
{
|
|
||||||
return this.MAX_JOULES_STORED;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getEnergyCapacity(ForgeDirection from)
|
|
||||||
{
|
|
||||||
if (this.canConnect(from) || from == ForgeDirection.UNKNOWN)
|
|
||||||
{
|
|
||||||
return this.getMaxEnergyStored();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaxEnergyStored(long energy)
|
|
||||||
{
|
|
||||||
this.MAX_JOULES_STORED = energy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getEnergyStored()
|
|
||||||
{
|
|
||||||
return this.energyStored;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setEnergy(ForgeDirection from, long energy)
|
|
||||||
{
|
|
||||||
if (this.canConnect(from) || from == ForgeDirection.UNKNOWN)
|
|
||||||
{
|
|
||||||
this.energyStored = Math.max(Math.min(energy, this.getMaxEnergyStored()), 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getEnergy(ForgeDirection from)
|
|
||||||
{
|
|
||||||
if (this.canConnect(from) || from == ForgeDirection.UNKNOWN)
|
|
||||||
{
|
|
||||||
return this.energyStored;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean runPowerLess()
|
|
||||||
{
|
|
||||||
return !runWithoutPower;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPowerLess(boolean bool)
|
|
||||||
{
|
|
||||||
runWithoutPower = !bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void togglePowerMode()
|
|
||||||
{
|
|
||||||
this.setPowerLess(!this.runPowerLess());
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getJoulesPerTick()
|
|
||||||
{
|
|
||||||
return this.JOULES_PER_TICK;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getJoulesPerSec()
|
|
||||||
{
|
|
||||||
return getJoulesPerTick() * 20;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getJoulesPerMin()
|
|
||||||
{
|
|
||||||
return getJoulesPerSec() * 60;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getJoulesPerHour()
|
|
||||||
{
|
|
||||||
return getJoulesPerMin() * 60;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileEntityEnergyMachine setJoulesPerTick(long energy)
|
|
||||||
{
|
|
||||||
this.JOULES_PER_TICK = energy;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileEntityEnergyMachine setJoulesPerSecound(long energy)
|
|
||||||
{
|
|
||||||
this.JOULES_PER_TICK = energy / 20;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileEntityEnergyMachine setJoulesPerMin(long energy)
|
|
||||||
{
|
|
||||||
this.JOULES_PER_TICK = energy / 1200;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileEntityEnergyMachine setJoulesPerHour(long energy)
|
|
||||||
{
|
|
||||||
this.JOULES_PER_TICK = energy / 72000;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ********************************************
|
|
||||||
* DATA/SAVE/LOAD
|
|
||||||
* *********************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFromNBT(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
super.readFromNBT(nbt);
|
|
||||||
|
|
||||||
NBTBase tag = nbt.getTag("energyStored");
|
|
||||||
if (tag instanceof NBTTagFloat)
|
|
||||||
{
|
|
||||||
this.energyStored = (long) nbt.getFloat("energyStored") * 1000;
|
|
||||||
}
|
|
||||||
else if (tag instanceof NBTTagLong)
|
|
||||||
{
|
|
||||||
this.energyStored = nbt.getLong("energyStored");
|
|
||||||
}
|
|
||||||
|
|
||||||
runWithoutPower = !nbt.getBoolean("shouldPower");
|
|
||||||
this.functioning = nbt.getBoolean("isRunning");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToNBT(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
super.writeToNBT(nbt);
|
|
||||||
nbt.setBoolean("shouldPower", !runWithoutPower);
|
|
||||||
nbt.setLong("energyStored", this.getEnergyStored());
|
|
||||||
nbt.setBoolean("isRunning", this.functioning);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,121 +0,0 @@
|
||||||
package resonantinduction.core.prefab.tile;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
import resonantinduction.old.api.IFilterable;
|
|
||||||
import resonantinduction.old.transport.TileEntityAssembly;
|
|
||||||
import resonantinduction.old.transport.imprinter.ItemImprinter;
|
|
||||||
import calclavia.lib.prefab.tile.IRotatable;
|
|
||||||
|
|
||||||
public abstract class TileEntityFilterable extends TileEntityAssembly implements IRotatable, IFilterable
|
|
||||||
{
|
|
||||||
private ItemStack filterItem;
|
|
||||||
private boolean inverted;
|
|
||||||
public static final int FILTER_SLOT = 0;
|
|
||||||
public static final int BATERY_DRAIN_SLOT = 1;
|
|
||||||
|
|
||||||
public TileEntityFilterable()
|
|
||||||
{
|
|
||||||
super(0);
|
|
||||||
this.invSlots = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileEntityFilterable(long wattsPerTick, long maxEnergy)
|
|
||||||
{
|
|
||||||
super(wattsPerTick, maxEnergy);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileEntityFilterable(long wattsPerTick)
|
|
||||||
{
|
|
||||||
super(wattsPerTick);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Looks through the things in the filter and finds out which item is being filtered.
|
|
||||||
*
|
|
||||||
* @return Is this filterable block filtering this specific ItemStack?
|
|
||||||
*/
|
|
||||||
public boolean isFiltering(ItemStack itemStack)
|
|
||||||
{
|
|
||||||
if (this.getFilter() != null && itemStack != null)
|
|
||||||
{
|
|
||||||
ArrayList<ItemStack> checkStacks = ItemImprinter.getFilters(getFilter());
|
|
||||||
|
|
||||||
if (checkStacks != null)
|
|
||||||
{
|
|
||||||
for (ItemStack stack : checkStacks)
|
|
||||||
{
|
|
||||||
if (stack.isItemEqual(itemStack))
|
|
||||||
{
|
|
||||||
return !inverted;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return inverted;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setFilter(ItemStack filter)
|
|
||||||
{
|
|
||||||
this.filterItem = filter;
|
|
||||||
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getFilter()
|
|
||||||
{
|
|
||||||
return this.filterItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInverted(boolean inverted)
|
|
||||||
{
|
|
||||||
this.inverted = inverted;
|
|
||||||
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInverted()
|
|
||||||
{
|
|
||||||
return this.inverted;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggleInversion()
|
|
||||||
{
|
|
||||||
setInverted(!isInverted());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ForgeDirection getDirection()
|
|
||||||
{
|
|
||||||
return ForgeDirection.getOrientation(this.getBlockMetadata());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDirection(ForgeDirection facingDirection)
|
|
||||||
{
|
|
||||||
this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, facingDirection.ordinal(), 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToNBT(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
super.writeToNBT(nbt);
|
|
||||||
nbt.setBoolean("inverted", inverted);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFromNBT(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
super.readFromNBT(nbt);
|
|
||||||
if (nbt.hasKey("filter"))
|
|
||||||
{
|
|
||||||
this.getInventory().setInventorySlotContents(0, ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("filter")));
|
|
||||||
}
|
|
||||||
inverted = nbt.getBoolean("inverted");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,341 +0,0 @@
|
||||||
package resonantinduction.core.prefab.tile;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.inventory.Container;
|
|
||||||
import net.minecraft.inventory.ISidedInventory;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.nbt.NBTTagList;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
import resonantinduction.core.tilenetwork.prefab.NetworkTileEntities;
|
|
||||||
import universalelectricity.api.vector.Vector3;
|
|
||||||
import calclavia.lib.access.AccessGroup;
|
|
||||||
import calclavia.lib.access.AccessUser;
|
|
||||||
import calclavia.lib.access.GroupRegistry;
|
|
||||||
import calclavia.lib.access.ISpecialAccess;
|
|
||||||
import calclavia.lib.access.Nodes;
|
|
||||||
import calclavia.lib.prefab.tile.TileAdvanced;
|
|
||||||
import dark.lib.interfaces.IExternalInv;
|
|
||||||
import dark.lib.interfaces.IInvBox;
|
|
||||||
import dark.lib.prefab.invgui.InvChest;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prefab for simple object who only need basic inv support and nothing more
|
|
||||||
*
|
|
||||||
* @author Darkguardsman
|
|
||||||
*/
|
|
||||||
public class TileEntityInv extends TileAdvanced implements IExternalInv, ISidedInventory, ISpecialAccess
|
|
||||||
{
|
|
||||||
protected IInvBox inventory;
|
|
||||||
protected boolean lockInv;
|
|
||||||
protected int invSlots = 1;
|
|
||||||
private Vector3 thisPos;
|
|
||||||
/** A list of user access data. */
|
|
||||||
protected List<AccessGroup> groups = new ArrayList<AccessGroup>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initiate()
|
|
||||||
{
|
|
||||||
thisPos = new Vector3(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3 getThisPos()
|
|
||||||
{
|
|
||||||
if (this.thisPos == null || this.thisPos.intX() != xCoord || this.thisPos.intY() != yCoord || this.thisPos.intZ() != zCoord)
|
|
||||||
{
|
|
||||||
this.thisPos = new Vector3(this);
|
|
||||||
}
|
|
||||||
return this.thisPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void invalidate()
|
|
||||||
{
|
|
||||||
super.invalidate();
|
|
||||||
NetworkTileEntities.invalidate(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IInvBox getInventory()
|
|
||||||
{
|
|
||||||
if (inventory == null)
|
|
||||||
{
|
|
||||||
inventory = new InvChest(this, this.invSlots);
|
|
||||||
}
|
|
||||||
return inventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Gets the container class that goes with this tileEntity when creating a gui */
|
|
||||||
public Class<? extends Container> getContainer()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
|
|
||||||
@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 this.getInventory().getInvName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isInvNameLocalized()
|
|
||||||
{
|
|
||||||
return this.getInventory().isInvNameLocalized();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getInventoryStackLimit()
|
|
||||||
{
|
|
||||||
return this.getInventory().getInventoryStackLimit();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
|
||||||
{
|
|
||||||
return this.getInventory().isUseableByPlayer(entityplayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openChest()
|
|
||||||
{
|
|
||||||
this.getInventory().openChest();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void closeChest()
|
|
||||||
{
|
|
||||||
this.getInventory().closeChest();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
|
||||||
{
|
|
||||||
return this.getInventory().isItemValidForSlot(i, itemstack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int[] getAccessibleSlotsFromSide(int var1)
|
|
||||||
{
|
|
||||||
return this.getInventory().getAccessibleSlotsFromSide(var1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canInsertItem(int i, ItemStack itemstack, int j)
|
|
||||||
{
|
|
||||||
return this.getInventory().canInsertItem(i, itemstack, j);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canExtractItem(int i, ItemStack itemstack, int j)
|
|
||||||
{
|
|
||||||
return this.getInventory().canExtractItem(i, itemstack, j);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canStore(ItemStack stack, int slot, ForgeDirection side)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canRemove(ItemStack stack, int slot, ForgeDirection side)
|
|
||||||
{
|
|
||||||
if (slot >= this.getSizeInventory())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* User access
|
|
||||||
*/
|
|
||||||
public boolean canOpen(String username)
|
|
||||||
{
|
|
||||||
return this.getUserAccess(username) != null && this.getUserAccess(username).hasNode(Nodes.INV_OPEN_NODE) || this.getOwnerGroup().getMembers().size() <= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccessUser getUserAccess(String username)
|
|
||||||
{
|
|
||||||
for (AccessGroup group : this.groups)
|
|
||||||
{
|
|
||||||
AccessUser user = group.getMember(username);
|
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new AccessUser(username);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AccessUser> getUsers()
|
|
||||||
{
|
|
||||||
List<AccessUser> users = new ArrayList<AccessUser>();
|
|
||||||
for (AccessGroup group : this.groups)
|
|
||||||
{
|
|
||||||
users.addAll(group.getMembers());
|
|
||||||
}
|
|
||||||
return users;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setUserAccess(String player, AccessGroup g, boolean save)
|
|
||||||
{
|
|
||||||
return setUserAccess(new AccessUser(player).setTempary(save), g);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setUserAccess(AccessUser user, AccessGroup group)
|
|
||||||
{
|
|
||||||
boolean bool = false;
|
|
||||||
|
|
||||||
if (user != null && user.getName() != null)
|
|
||||||
{
|
|
||||||
bool = this.removeUserAccess(user.getName()) && group == null;
|
|
||||||
if (group != null)
|
|
||||||
{
|
|
||||||
bool = group.addMemeber(user);
|
|
||||||
}
|
|
||||||
if (bool)
|
|
||||||
{
|
|
||||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean removeUserAccess(String player)
|
|
||||||
{
|
|
||||||
boolean re = false;
|
|
||||||
for (AccessGroup group : this.groups)
|
|
||||||
{
|
|
||||||
AccessUser user = group.getMember(player);
|
|
||||||
if (user != null && group.removeMemeber(user))
|
|
||||||
{
|
|
||||||
re = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (re)
|
|
||||||
{
|
|
||||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
|
||||||
}
|
|
||||||
return re;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccessGroup getGroup(String name)
|
|
||||||
{
|
|
||||||
for (AccessGroup group : this.getGroups())
|
|
||||||
{
|
|
||||||
if (group.getName().equalsIgnoreCase(name))
|
|
||||||
{
|
|
||||||
return group;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addGroup(AccessGroup group)
|
|
||||||
{
|
|
||||||
if (!this.groups.contains(group))
|
|
||||||
{
|
|
||||||
for (AccessGroup g : this.groups)
|
|
||||||
{
|
|
||||||
if (group.getName().equalsIgnoreCase(g.getName()))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.groups.add(group);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccessGroup getOwnerGroup()
|
|
||||||
{
|
|
||||||
return this.getGroup("owner");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AccessGroup> getGroups()
|
|
||||||
{
|
|
||||||
if (this.groups == null || this.groups.isEmpty())
|
|
||||||
{
|
|
||||||
GroupRegistry.loadNewGroupSet(this);
|
|
||||||
}
|
|
||||||
return this.groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFromNBT(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
super.readFromNBT(nbt);
|
|
||||||
this.getInventory().loadInv(nbt);
|
|
||||||
NBTTagList userList = nbt.getTagList("groups");
|
|
||||||
if (userList != null && userList.tagCount() > 0)
|
|
||||||
{
|
|
||||||
this.groups.clear();
|
|
||||||
for (int i = 0; i < userList.tagCount(); i++)
|
|
||||||
{
|
|
||||||
AccessGroup group = new AccessGroup("");
|
|
||||||
group.load((NBTTagCompound) userList.tagAt(i));
|
|
||||||
this.groups.add(group);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToNBT(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
super.writeToNBT(nbt);
|
|
||||||
this.getInventory().saveInv(nbt);
|
|
||||||
|
|
||||||
NBTTagList usersTag = new NBTTagList();
|
|
||||||
for (AccessGroup group : this.getGroups())
|
|
||||||
{
|
|
||||||
usersTag.appendTag(group.save(new NBTTagCompound()));
|
|
||||||
}
|
|
||||||
nbt.setTag("groups", usersTag);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,245 +0,0 @@
|
||||||
package resonantinduction.core.prefab.tile;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.inventory.ISidedInventory;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.network.packet.Packet;
|
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
|
||||||
import net.minecraftforge.common.Configuration;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
import resonantinduction.core.ResonantInduction;
|
|
||||||
import resonantinduction.core.network.ISimplePacketReceiver;
|
|
||||||
import universalelectricity.api.vector.Vector3;
|
|
||||||
import calclavia.lib.network.PacketHandler;
|
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
|
||||||
import cpw.mods.fml.common.network.Player;
|
|
||||||
import dark.lib.IExtraInfo.IExtraTileEntityInfo;
|
|
||||||
import dark.lib.interfaces.IExternalInv;
|
|
||||||
import dark.lib.interfaces.IInvBox;
|
|
||||||
|
|
||||||
public abstract class TileEntityMachine extends TileEntityInv implements ISidedInventory, IExternalInv, ISimplePacketReceiver, IExtraTileEntityInfo
|
|
||||||
{
|
|
||||||
/** Number of players with the machine's gui container open */
|
|
||||||
protected int playersUsingMachine = 0;
|
|
||||||
/** Is the machine functioning normally */
|
|
||||||
protected boolean functioning = false;
|
|
||||||
/** Prev state of function of last update */
|
|
||||||
protected boolean prevFunctioning = false;
|
|
||||||
/** Does the machine have a gui */
|
|
||||||
protected boolean hasGUI = false;
|
|
||||||
/** Does teh machine rotate in meta groups of four */
|
|
||||||
protected boolean rotateByMetaGroup = false;
|
|
||||||
/** Can the machine be temp disabled */
|
|
||||||
protected boolean canBeDisabled = false;
|
|
||||||
/** Is the machine enabled by the player */
|
|
||||||
protected boolean enabled = true;
|
|
||||||
/** Is the machine locked by the player */
|
|
||||||
protected boolean locked = false;
|
|
||||||
|
|
||||||
/** Inventory manager used by this machine */
|
|
||||||
protected IInvBox inventory;
|
|
||||||
|
|
||||||
/** Default generic packet types used by all machines */
|
|
||||||
public static enum SimplePacketTypes
|
|
||||||
{
|
|
||||||
/** Normal packet data of any kind */
|
|
||||||
GENERIC("generic"),
|
|
||||||
/** Power updates */
|
|
||||||
RUNNING("isRunning"),
|
|
||||||
/** GUI display data update */
|
|
||||||
GUI("guiGeneral"),
|
|
||||||
/** Full tile read/write data from tile NBT */
|
|
||||||
NBT("nbtAll"), GUI_EVENT("clientGui"), GUI_COMMAND("clientCommand"),
|
|
||||||
TERMINAL_OUTPUT("serverTerminal");
|
|
||||||
|
|
||||||
public String name;
|
|
||||||
|
|
||||||
private SimplePacketTypes(String name)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateEntity()
|
|
||||||
{
|
|
||||||
super.updateEntity();
|
|
||||||
if (!this.worldObj.isRemote)
|
|
||||||
{
|
|
||||||
this.prevFunctioning = this.functioning;
|
|
||||||
this.functioning = this.isFunctioning();
|
|
||||||
|
|
||||||
if (prevFunctioning != this.functioning)
|
|
||||||
{
|
|
||||||
this.sendPowerUpdate();
|
|
||||||
}
|
|
||||||
this.sendGUIPacket();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Can this tile function, or run threw normal processes */
|
|
||||||
public boolean canFunction()
|
|
||||||
{
|
|
||||||
return this.enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFunctioning()
|
|
||||||
{
|
|
||||||
if (this.worldObj.isRemote)
|
|
||||||
{
|
|
||||||
return this.functioning;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return this.canFunction();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void doRunningDebug()
|
|
||||||
{
|
|
||||||
System.out.println("\n CanRun: " + this.canFunction());
|
|
||||||
System.out.println(" RedPower: " + this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord));
|
|
||||||
System.out.println(" IsRunning: " + this.functioning);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Called every tick while this tile entity is disabled. */
|
|
||||||
protected void whileDisable()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public ForgeDirection getDirection()
|
|
||||||
{
|
|
||||||
if (this.rotateByMetaGroup)
|
|
||||||
{
|
|
||||||
switch (this.worldObj.getBlockMetadata(xCoord, yCoord, zCoord) % 4)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
return ForgeDirection.NORTH;
|
|
||||||
case 1:
|
|
||||||
return ForgeDirection.SOUTH;
|
|
||||||
case 2:
|
|
||||||
return ForgeDirection.SOUTH;
|
|
||||||
default:
|
|
||||||
return ForgeDirection.WEST;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ForgeDirection.UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDirection(ForgeDirection direction)
|
|
||||||
{
|
|
||||||
if (this.rotateByMetaGroup)
|
|
||||||
{
|
|
||||||
switch (direction)
|
|
||||||
{
|
|
||||||
case NORTH:
|
|
||||||
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, this.worldObj.getBlockMetadata(xCoord, yCoord, zCoord) / 4, 3);
|
|
||||||
case WEST:
|
|
||||||
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, (this.worldObj.getBlockMetadata(xCoord, yCoord, zCoord) / 4) + 1, 3);
|
|
||||||
case SOUTH:
|
|
||||||
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, (this.worldObj.getBlockMetadata(xCoord, yCoord, zCoord) / 4) + 2, 3);
|
|
||||||
default:
|
|
||||||
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, (this.worldObj.getBlockMetadata(xCoord, yCoord, zCoord) / 4) + 3, 3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean simplePacket(String id, ByteArrayDataInput dis, Player player)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (this.worldObj.isRemote)
|
|
||||||
{
|
|
||||||
if (id.equalsIgnoreCase(SimplePacketTypes.RUNNING.name))
|
|
||||||
{
|
|
||||||
this.functioning = dis.readBoolean();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (id.equalsIgnoreCase(SimplePacketTypes.NBT.name))
|
|
||||||
{
|
|
||||||
this.readFromNBT(PacketHandler.readNBTTagCompound(dis));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Sends the tileEntity save data to the client */
|
|
||||||
public void sendNBTPacket()
|
|
||||||
{
|
|
||||||
if (!this.worldObj.isRemote)
|
|
||||||
{
|
|
||||||
NBTTagCompound tag = new NBTTagCompound();
|
|
||||||
this.writeToNBT(tag);
|
|
||||||
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacket(this, SimplePacketTypes.NBT.name, this, tag), worldObj, new Vector3(this), 64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Sends a simple true/false am running power update */
|
|
||||||
public void sendPowerUpdate()
|
|
||||||
{
|
|
||||||
if (!this.worldObj.isRemote)
|
|
||||||
{
|
|
||||||
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacket(this, SimplePacketTypes.RUNNING.name, this, this.functioning), worldObj, new Vector3(this), 64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Sends a gui packet only to the given player */
|
|
||||||
public Packet getGUIPacket()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendGUIPacket()
|
|
||||||
{
|
|
||||||
Packet packet = this.getGUIPacket();
|
|
||||||
if (this.hasGUI && this.getContainer() != null && packet != null)
|
|
||||||
{
|
|
||||||
this.playersUsingMachine = 0;
|
|
||||||
for (Object entity : this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1).expand(10, 10, 10)))
|
|
||||||
{
|
|
||||||
if (entity instanceof EntityPlayer && ((EntityPlayer) entity).openContainer != null)
|
|
||||||
{
|
|
||||||
if (((EntityPlayer) entity).openContainer.getClass().isAssignableFrom(this.getContainer()))
|
|
||||||
{
|
|
||||||
this.playersUsingMachine += 1;
|
|
||||||
PacketDispatcher.sendPacketToPlayer(packet, (Player) entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Packet getDescriptionPacket()
|
|
||||||
{
|
|
||||||
return ResonantInduction.PACKET_TILE.getPacket(this, this.functioning);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasExtraConfigs()
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadExtraConfigs(Configuration config)
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,100 +0,0 @@
|
||||||
package resonantinduction.core.prefab.tile;
|
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
import universalelectricity.api.CompatibilityModule;
|
|
||||||
import universalelectricity.api.vector.Vector3;
|
|
||||||
import universalelectricity.api.vector.VectorHelper;
|
|
||||||
|
|
||||||
public abstract class TileGenerator extends TileEntityEnergyMachine
|
|
||||||
{
|
|
||||||
public TileGenerator()
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileGenerator(long wattsPerTick)
|
|
||||||
{
|
|
||||||
super(wattsPerTick);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileGenerator(long wattsPerTick, long maxEnergy)
|
|
||||||
{
|
|
||||||
super(wattsPerTick, maxEnergy);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateEntity()
|
|
||||||
{
|
|
||||||
super.updateEntity();
|
|
||||||
if (!this.worldObj.isRemote && this.enabled)
|
|
||||||
{
|
|
||||||
this.consumeFuel();
|
|
||||||
if (this.isFunctioning())
|
|
||||||
{
|
|
||||||
this.produce();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void produce()
|
|
||||||
{
|
|
||||||
for (ForgeDirection direction : this.getOutputDirections())
|
|
||||||
{
|
|
||||||
if (direction != ForgeDirection.UNKNOWN)
|
|
||||||
{
|
|
||||||
TileEntity entity = VectorHelper.getTileEntityFromSide(this.worldObj, new Vector3(this), direction);
|
|
||||||
if (CompatibilityModule.canConnect(entity, direction.getOpposite()))
|
|
||||||
{
|
|
||||||
CompatibilityModule.receiveEnergy(entity, direction.getOpposite(), this.JOULES_PER_TICK, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long onExtractEnergy(ForgeDirection from, long receive, boolean doReceive)
|
|
||||||
{
|
|
||||||
if (this.canConnect(from) && this.getOutputDirections().contains(from))
|
|
||||||
{
|
|
||||||
return Math.min(receive, this.JOULES_PER_TICK);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canFunction()
|
|
||||||
{
|
|
||||||
return this.enabled && this.hasFuel();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Does this generator have fuel time left to burn */
|
|
||||||
public abstract boolean hasFuel();
|
|
||||||
|
|
||||||
/** Called each tick to handle anything fuel related */
|
|
||||||
public abstract void consumeFuel();
|
|
||||||
|
|
||||||
/* ********************************************
|
|
||||||
* Electricity reception logic - all of which is set to zero to prevent input from wires
|
|
||||||
* *********************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getEnergy(ForgeDirection from)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getEnergyCapacity(ForgeDirection from)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package resonantinduction.core.render;
|
|
||||||
|
|
||||||
import codechicken.lib.vec.Matrix4;
|
|
||||||
import codechicken.lib.vec.Transformation;
|
|
||||||
import codechicken.lib.vec.VariableTransformation;
|
|
||||||
|
|
||||||
public class InvertX extends VariableTransformation
|
|
||||||
{
|
|
||||||
public InvertX()
|
|
||||||
{
|
|
||||||
super(new Matrix4(1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Transformation inverse()
|
|
||||||
{
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply(codechicken.lib.vec.Vector3 vec)
|
|
||||||
{
|
|
||||||
vec.x = -vec.x;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,196 +0,0 @@
|
||||||
package resonantinduction.core.resource;
|
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.material.MapColor;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.block.material.MaterialTransparent;
|
|
||||||
import net.minecraft.client.renderer.texture.IconRegister;
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
|
||||||
import net.minecraft.util.Icon;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
import net.minecraftforge.fluids.Fluid;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
import net.minecraftforge.fluids.IFluidBlock;
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import resonantinduction.core.Settings;
|
|
||||||
import resonantinduction.mechanical.fluid.EnumGas;
|
|
||||||
import universalelectricity.api.vector.Vector3;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gas that is designed to generate underground in the same way as an ore
|
|
||||||
*
|
|
||||||
* TODO code actual gas behavior such as expanding to fill an area but at the same time losing
|
|
||||||
* volume
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public class BlockGasOre extends Block implements IFluidBlock
|
|
||||||
{
|
|
||||||
public static final int[] volumePerMeta = new int[] { 10, 35, 75, 125, 250, 500, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 12800, 256000, 512000 };
|
|
||||||
public static final Material gas = new MaterialTransparent(MapColor.airColor).setReplaceable();
|
|
||||||
|
|
||||||
public BlockGasOre()
|
|
||||||
{
|
|
||||||
super(Settings.config.getBlock("GasBlock", Settings.getNextBlockID()).getInt(), gas);
|
|
||||||
this.setUnlocalizedName("BlockGas");
|
|
||||||
this.setTickRandomly(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int tickRate(World par1World)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateTick(World world, int x, int y, int z, Random rand)
|
|
||||||
{
|
|
||||||
if (!world.isRemote)
|
|
||||||
{
|
|
||||||
|
|
||||||
final Vector3 vec = new Vector3(x, y, z);
|
|
||||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
|
||||||
{
|
|
||||||
int meta = world.getBlockMetadata(x, y, z);
|
|
||||||
|
|
||||||
Vector3 sVec = vec.clone().modifyPositionFromSide(dir);
|
|
||||||
int sMeta = sVec.getBlockMetadata(world);
|
|
||||||
int blockID = sVec.getBlockID(world);
|
|
||||||
Block block = Block.blocksList[blockID];
|
|
||||||
|
|
||||||
if (blockID == 0 || block == null || block != null && block.isAirBlock(world, x, y, z) && blockID != this.blockID)
|
|
||||||
{
|
|
||||||
if (meta == 0)
|
|
||||||
{
|
|
||||||
world.setBlockToAir(x, y, z);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
world.setBlock(x, y, z, this.blockID, meta / 2, 2);
|
|
||||||
sVec.setBlock(world, this.blockID, meta / 2, 2);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (blockID == this.blockID && meta > sMeta)
|
|
||||||
{
|
|
||||||
meta += sMeta;
|
|
||||||
world.setBlock(x, y, z, this.blockID, meta / 2, 2);
|
|
||||||
sVec.setBlock(world, this.blockID, meta / 2, 2);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* IFluidBlock */
|
|
||||||
@Override
|
|
||||||
public FluidStack drain(World world, int x, int y, int z, boolean doDrain)
|
|
||||||
{
|
|
||||||
int meta = world.getBlockMetadata(x, y, z);
|
|
||||||
FluidStack fluid = new FluidStack(EnumGas.NATURAL_GAS.getGas(), volumePerMeta[meta]);
|
|
||||||
if (doDrain || fluid == null)
|
|
||||||
{
|
|
||||||
world.setBlockToAir(x, y, z);
|
|
||||||
}
|
|
||||||
return fluid;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canDrain(World world, int x, int y, int z)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Fluid getFluid()
|
|
||||||
{
|
|
||||||
return EnumGas.NATURAL_GAS.getGas();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int idDropped(int par1, Random par2Random, int par3)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCollidable()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Icon getIcon(int par1, int par2)
|
|
||||||
{
|
|
||||||
return this.blockIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerIcons(IconRegister par1IconRegister)
|
|
||||||
{
|
|
||||||
this.blockIcon = par1IconRegister.registerIcon(Reference.PREFIX + "gas");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getRenderBlockPass()
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOpaqueCube()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean renderAsNormalBlock()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public int getBlockColor()
|
|
||||||
{
|
|
||||||
return Color.yellow.getRGB();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public int getRenderColor(int par1)
|
|
||||||
{
|
|
||||||
// TODO make the color darker as the meta value goes higher
|
|
||||||
return this.getBlockColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@Override
|
|
||||||
public int colorMultiplier(IBlockAccess world, int x, int y, int z)
|
|
||||||
{
|
|
||||||
return this.getRenderColor(world.getBlockMetadata(x, y, z));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getSubBlocks(int blockID, CreativeTabs tab, List creativeTabList)
|
|
||||||
{
|
|
||||||
creativeTabList.add(new ItemStack(blockID, 1, 15));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,167 +0,0 @@
|
||||||
package resonantinduction.core.resource;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.client.renderer.texture.IconRegister;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.Icon;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.Configuration;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import resonantinduction.core.Settings;
|
|
||||||
import resonantinduction.old.core.recipe.RecipeLoader;
|
|
||||||
import calclavia.lib.ore.OreGenReplaceStone;
|
|
||||||
|
|
||||||
import com.builtbroken.common.Pair;
|
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import dark.lib.EnumMaterial;
|
|
||||||
import dark.lib.IExtraInfo.IExtraBlockInfo;
|
|
||||||
|
|
||||||
public class BlockOre extends Block implements IExtraBlockInfo
|
|
||||||
{
|
|
||||||
Icon[] icons = new Icon[EnumMaterial.values().length];
|
|
||||||
|
|
||||||
public BlockOre()
|
|
||||||
{
|
|
||||||
super(Settings.config.getBlock("Ore", Settings.getNextBlockID()).getInt(), Material.rock);
|
|
||||||
this.setCreativeTab(CreativeTabs.tabBlock);
|
|
||||||
this.setUnlocalizedName(Reference.PREFIX + "Ore");
|
|
||||||
this.setHardness(2.5f);
|
|
||||||
this.setResistance(5.0f);
|
|
||||||
|
|
||||||
for (OreData data : OreData.values())
|
|
||||||
{
|
|
||||||
data.stack = new ItemStack(this.blockID, 1, data.ordinal());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int damageDropped(int par1)
|
|
||||||
{
|
|
||||||
return par1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
|
||||||
{
|
|
||||||
for (OreData data : OreData.values())
|
|
||||||
{
|
|
||||||
par3List.add(data.stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void registerIcons(IconRegister par1IconRegister)
|
|
||||||
{
|
|
||||||
for (OreData data : OreData.values())
|
|
||||||
{
|
|
||||||
data.oreIcon = par1IconRegister.registerIcon(Reference.PREFIX + data.name + "Ore");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public Icon getIcon(int side, int metadata)
|
|
||||||
{
|
|
||||||
if (metadata < OreData.values().length)
|
|
||||||
{
|
|
||||||
return OreData.values()[metadata].oreIcon;
|
|
||||||
}
|
|
||||||
return Block.stone.getIcon(side, metadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadOreNames()
|
|
||||||
{
|
|
||||||
for (OreData data : OreData.values())
|
|
||||||
{
|
|
||||||
OreDictionary.registerOre(data.oreName, data.stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum OreData
|
|
||||||
{
|
|
||||||
TIN(EnumMaterial.TIN, "tin", "oreTin", 20, 8, 128),
|
|
||||||
COPPER(EnumMaterial.COPPER, "copper", "copperOre", 20, 8, 128),
|
|
||||||
SILVER(EnumMaterial.SILVER, "silver", "silverOre", 3, 8, 45),
|
|
||||||
LEAD(EnumMaterial.LEAD, "lead", "leadOre", 1, 6, 30),
|
|
||||||
Bauxite(EnumMaterial.ALUMINIUM, "bauxite", "bauxiteOre", 4, 6, 128);
|
|
||||||
|
|
||||||
public String name, oreName;
|
|
||||||
public ItemStack stack;
|
|
||||||
public EnumMaterial mat;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public Icon oreIcon;
|
|
||||||
|
|
||||||
/* ORE GENERATOR OPTIONS */
|
|
||||||
public boolean doWorldGen = true;
|
|
||||||
public int ammount, branch, maxY;
|
|
||||||
|
|
||||||
private OreData(EnumMaterial mat, String name, String oreName, int ammount, int branch, int maxY)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
this.oreName = oreName;
|
|
||||||
this.mat = mat;
|
|
||||||
|
|
||||||
this.maxY = maxY;
|
|
||||||
this.ammount = ammount;
|
|
||||||
this.branch = branch;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OreGenReplaceStone getGeneratorSettings()
|
|
||||||
{
|
|
||||||
if (this.doWorldGen)
|
|
||||||
{
|
|
||||||
ItemStack stack = new ItemStack(RecipeLoader.blockOre, 1, this.ordinal());
|
|
||||||
return (OreGenReplaceStone) new OreGenReplaceStone(this.name, this.name + "Ore", stack, this.maxY, this.ammount, this.branch).enable(Settings.config);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasExtraConfigs()
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadExtraConfigs(Configuration config)
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createNewTileEntity(World world)
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getTileEntities(int blockID, Set<Pair<String, Class<? extends TileEntity>>> list)
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getClientTileEntityRenderers(List<Pair<Class<? extends TileEntity>, TileEntitySpecialRenderer>> list)
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,128 +0,0 @@
|
||||||
package resonantinduction.core.resource;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraft.world.chunk.IChunkProvider;
|
|
||||||
import net.minecraft.world.gen.ChunkProviderEnd;
|
|
||||||
import net.minecraft.world.gen.ChunkProviderHell;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
import resonantinduction.old.core.recipe.RecipeLoader;
|
|
||||||
import cpw.mods.fml.common.IWorldGenerator;
|
|
||||||
|
|
||||||
public class GasOreGenerator implements IWorldGenerator
|
|
||||||
{
|
|
||||||
|
|
||||||
public int minGenerateLevel = 6;
|
|
||||||
public int maxGenerateLevel = 50;
|
|
||||||
public int amountPerChunk = 3;
|
|
||||||
public int amountPerBranch = 15;
|
|
||||||
public int replaceID = 1;
|
|
||||||
|
|
||||||
public FluidStack stack;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generate(Random rand, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
|
|
||||||
{
|
|
||||||
chunkX = chunkX << 4;
|
|
||||||
chunkZ = chunkZ << 4;
|
|
||||||
|
|
||||||
if (this.isOreGeneratedInWorld(world, chunkGenerator))
|
|
||||||
{
|
|
||||||
this.generate(world, rand, chunkX, chunkZ);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void generate(World world, Random random, int varX, int varZ)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// TODO get the biome of the chunk and generate more gas in swamp biomes
|
|
||||||
// chunk = world.getChunkFromChunkCoords(varX, varZ);
|
|
||||||
for (int i = 0; i < this.amountPerChunk; i++)
|
|
||||||
{
|
|
||||||
int x = varX + random.nextInt(16);
|
|
||||||
int z = varZ + random.nextInt(16);
|
|
||||||
int y = random.nextInt(Math.max(this.maxGenerateLevel - this.minGenerateLevel, 0)) + this.minGenerateLevel;
|
|
||||||
this.generateReplace(world, random, x, y, z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
System.out.println("[CoreMachine]Error generating natural gas");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean generateReplace(World world, Random random, int par3, int par4, int par5)
|
|
||||||
{
|
|
||||||
float var6 = random.nextFloat() * (float) Math.PI;
|
|
||||||
double var7 = par3 + 8 + MathHelper.sin(var6) * this.amountPerBranch / 8.0F;
|
|
||||||
double var9 = par3 + 8 - MathHelper.sin(var6) * this.amountPerBranch / 8.0F;
|
|
||||||
double var11 = par5 + 8 + MathHelper.cos(var6) * this.amountPerBranch / 8.0F;
|
|
||||||
double var13 = par5 + 8 - MathHelper.cos(var6) * this.amountPerBranch / 8.0F;
|
|
||||||
double var15 = par4 + random.nextInt(3) - 2;
|
|
||||||
double var17 = par4 + random.nextInt(3) - 2;
|
|
||||||
|
|
||||||
for (int oreCount = 0; oreCount <= this.amountPerBranch; ++oreCount)
|
|
||||||
{
|
|
||||||
double var20 = var7 + (var9 - var7) * oreCount / this.amountPerBranch;
|
|
||||||
double var22 = var15 + (var17 - var15) * oreCount / this.amountPerBranch;
|
|
||||||
double var24 = var11 + (var13 - var11) * oreCount / this.amountPerBranch;
|
|
||||||
double var26 = random.nextDouble() * this.amountPerBranch / 16.0D;
|
|
||||||
double var28 = (MathHelper.sin(oreCount * (float) Math.PI / this.amountPerBranch) + 1.0F) * var26 + 1.0D;
|
|
||||||
double var30 = (MathHelper.sin(oreCount * (float) Math.PI / this.amountPerBranch) + 1.0F) * var26 + 1.0D;
|
|
||||||
int var32 = MathHelper.floor_double(var20 - var28 / 2.0D);
|
|
||||||
int var33 = MathHelper.floor_double(var22 - var30 / 2.0D);
|
|
||||||
int var34 = MathHelper.floor_double(var24 - var28 / 2.0D);
|
|
||||||
int var35 = MathHelper.floor_double(var20 + var28 / 2.0D);
|
|
||||||
int var36 = MathHelper.floor_double(var22 + var30 / 2.0D);
|
|
||||||
int var37 = MathHelper.floor_double(var24 + var28 / 2.0D);
|
|
||||||
|
|
||||||
for (int x = var32; x <= var35; ++x)
|
|
||||||
{
|
|
||||||
double var39 = (x + 0.5D - var20) / (var28 / 2.0D);
|
|
||||||
|
|
||||||
if (var39 * var39 < 1.0D)
|
|
||||||
{
|
|
||||||
for (int y = var33; y <= var36; ++y)
|
|
||||||
{
|
|
||||||
double var42 = (y + 0.5D - var22) / (var30 / 2.0D);
|
|
||||||
|
|
||||||
if (var39 * var39 + var42 * var42 < 1.0D)
|
|
||||||
{
|
|
||||||
for (int z = var34; z <= var37; ++z)
|
|
||||||
{
|
|
||||||
double var45 = (z + 0.5D - var24) / (var28 / 2.0D);
|
|
||||||
|
|
||||||
int blockid = world.getBlockId(x, y, z);
|
|
||||||
Block block = Block.blocksList[blockid];
|
|
||||||
if (var39 * var39 + var42 * var42 + var45 * var45 < 1.0D && (block == null || block.isAirBlock(world, x, y, z) || block.canBeReplacedByLeaves(world, x, y, z) || blockid == this.replaceID))
|
|
||||||
{
|
|
||||||
world.setBlock(x, y, z, RecipeLoader.blockGas.blockID, 10 + world.rand.nextInt(5), 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOreGeneratedInWorld(World world, IChunkProvider chunkGenerator)
|
|
||||||
{
|
|
||||||
if (chunkGenerator instanceof ChunkProviderHell)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (chunkGenerator instanceof ChunkProviderEnd)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,151 +0,0 @@
|
||||||
package resonantinduction.core.resource;
|
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.Icon;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
|
||||||
import net.minecraftforge.event.ForgeSubscribe;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary.OreRegisterEvent;
|
|
||||||
import resonantinduction.api.recipe.MachineRecipes;
|
|
||||||
import resonantinduction.api.recipe.MachineRecipes.RecipeType;
|
|
||||||
import resonantinduction.api.recipe.OreDetectionBlackList;
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import resonantinduction.core.ResonantInduction;
|
|
||||||
import resonantinduction.core.resource.item.ItemDust;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ResourceGenerator
|
|
||||||
{
|
|
||||||
public static final ResourceGenerator INSTANCE = new ResourceGenerator();
|
|
||||||
public static final Set<String> materialNames = new HashSet<String>();
|
|
||||||
public static final HashMap<String, Integer> materialColors = new HashMap<String, Integer>();
|
|
||||||
|
|
||||||
@ForgeSubscribe
|
|
||||||
public void oreRegisterEvent(OreRegisterEvent evt)
|
|
||||||
{
|
|
||||||
if (evt.Name.startsWith("ingot"))
|
|
||||||
{
|
|
||||||
String ingotName = evt.Name.replace("ingot", "");
|
|
||||||
|
|
||||||
if (OreDetectionBlackList.isIngotBlackListed("ingot" + ingotName) || OreDetectionBlackList.isOreBlackListed("ore" + ingotName))
|
|
||||||
return;
|
|
||||||
|
|
||||||
ResourceGenerator.materialNames.add(ingotName.toLowerCase());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void generateDusts()
|
|
||||||
{
|
|
||||||
for (String materialName : materialNames)
|
|
||||||
{
|
|
||||||
String name = materialName.substring(0, 1).toUpperCase() + materialName.substring(1);
|
|
||||||
|
|
||||||
if (OreDictionary.getOres("ore" + name).size() > 0)
|
|
||||||
{
|
|
||||||
// if (OreDictionary.getOres("dust" + name).size() == 0)
|
|
||||||
{
|
|
||||||
ItemDust.dusts.add(ResonantInduction.itemDust.getStackFromDust(materialName));
|
|
||||||
OreDictionary.registerOre("dust" + name, ResonantInduction.itemDust.getStackFromDust(materialName));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add to machine recipes
|
|
||||||
ItemStack dust = OreDictionary.getOres("dust" + name).get(0).copy();
|
|
||||||
dust.stackSize = 2;
|
|
||||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.GRINDER, "ore" + name, dust);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ForgeSubscribe
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void reloadTextures(TextureStitchEvent.Post e)
|
|
||||||
{
|
|
||||||
computeColors();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public static void computeColors()
|
|
||||||
{
|
|
||||||
for (String ingotName : materialNames)
|
|
||||||
{
|
|
||||||
// Compute color
|
|
||||||
int totalR = 0;
|
|
||||||
int totalG = 0;
|
|
||||||
int totalB = 0;
|
|
||||||
|
|
||||||
int colorCount = 0;
|
|
||||||
|
|
||||||
for (ItemStack ingotStack : OreDictionary.getOres("ingot" + ingotName.substring(0, 1).toUpperCase() + ingotName.substring(1)))
|
|
||||||
{
|
|
||||||
Item theIngot = ingotStack.getItem();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Icon icon = theIngot.getIconIndex(ingotStack);
|
|
||||||
String iconString = icon.getIconName();
|
|
||||||
|
|
||||||
if (iconString != null && !iconString.contains("MISSING_ICON_ITEM"))
|
|
||||||
{
|
|
||||||
iconString = (iconString.contains(":") ? iconString.replace(":", ":" + Reference.ITEM_TEXTURE_DIRECTORY) : Reference.ITEM_TEXTURE_DIRECTORY + iconString) + ".png";
|
|
||||||
ResourceLocation textureLocation = new ResourceLocation(iconString);
|
|
||||||
|
|
||||||
InputStream inputstream = Minecraft.getMinecraft().getResourceManager().getResource(textureLocation).getInputStream();
|
|
||||||
BufferedImage bufferedimage = ImageIO.read(inputstream);
|
|
||||||
|
|
||||||
int width = bufferedimage.getWidth();
|
|
||||||
int height = bufferedimage.getWidth();
|
|
||||||
|
|
||||||
for (int x = 0; x < width; x++)
|
|
||||||
{
|
|
||||||
for (int y = 0; y < height; y++)
|
|
||||||
{
|
|
||||||
Color rgb = new Color(bufferedimage.getRGB(x, y));
|
|
||||||
totalR += rgb.getRed();
|
|
||||||
totalG += rgb.getGreen();
|
|
||||||
totalB += rgb.getBlue();
|
|
||||||
colorCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
System.out.println("Failed to compute colors for: " + theIngot);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (colorCount > 0)
|
|
||||||
{
|
|
||||||
totalR /= colorCount;
|
|
||||||
totalG /= colorCount;
|
|
||||||
totalB /= colorCount;
|
|
||||||
int resultantColor = new Color(totalR, totalG, totalB).brighter().getRGB();
|
|
||||||
materialColors.put(ingotName, resultantColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!materialColors.containsKey(ingotName))
|
|
||||||
{
|
|
||||||
materialColors.put(ingotName, 0xFFFFFF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
package resonantinduction.core.resource.fluid;
|
|
||||||
|
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.fluids.BlockFluidFinite;
|
|
||||||
import net.minecraftforge.fluids.Fluid;
|
|
||||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
import resonantinduction.core.ResonantInduction;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class BlockFluidMixture extends BlockFluidFinite implements ITileEntityProvider
|
|
||||||
{
|
|
||||||
public BlockFluidMixture(int id, Fluid fluid)
|
|
||||||
{
|
|
||||||
super(id, fluid, Material.water);
|
|
||||||
this.setTextureName("water_flow");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
|
|
||||||
{
|
|
||||||
// If this item can be smelted into another fluid, add it to the mixture.
|
|
||||||
}
|
|
||||||
|
|
||||||
/* IFluidBlock */
|
|
||||||
@Override
|
|
||||||
public FluidStack drain(World world, int x, int y, int z, boolean doDrain)
|
|
||||||
{
|
|
||||||
TileFluidMixture tileFluid = (TileFluidMixture) world.getBlockTileEntity(x, y, z);
|
|
||||||
FluidStack stack = new FluidStack(ResonantInduction.MIXTURE, (int) (FluidContainerRegistry.BUCKET_VOLUME * this.getFilledPercentage(world, x, y, z)));
|
|
||||||
tileFluid.writeFluidToNBT(stack.tag);
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canDrain(World world, int x, int y, int z)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createNewTileEntity(World world)
|
|
||||||
{
|
|
||||||
return new TileFluidMixture();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,90 +0,0 @@
|
||||||
package resonantinduction.core.resource.fluid;
|
|
||||||
|
|
||||||
import java.util.TreeSet;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.nbt.NBTTagList;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
import calclavia.lib.prefab.tile.TileAdvanced;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class TileFluidMixture extends TileAdvanced
|
|
||||||
{
|
|
||||||
public final TreeSet<FluidStack> fluids = new TreeSet<FluidStack>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUpdate()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void mix(FluidStack fluid)
|
|
||||||
{
|
|
||||||
if (fluids.contains(fluid))
|
|
||||||
{
|
|
||||||
for (FluidStack checkFluid : fluids)
|
|
||||||
{
|
|
||||||
if (fluid.equals(checkFluid))
|
|
||||||
{
|
|
||||||
checkFluid.amount += fluid.amount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fluids.add(fluid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return The color of the liquid based on the fluidStacks stored.
|
|
||||||
*/
|
|
||||||
public int getColor()
|
|
||||||
{
|
|
||||||
return 0xFFFFFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFromNBT(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
super.readFromNBT(nbt);
|
|
||||||
readFluidFromNBT(nbt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToNBT(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
super.writeToNBT(nbt);
|
|
||||||
writeFluidToNBT(nbt);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void readFluidFromNBT(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
fluids.clear();
|
|
||||||
|
|
||||||
NBTTagList nbtList = nbt.getTagList("fluids");
|
|
||||||
|
|
||||||
for (int i = 0; i < nbtList.tagCount(); ++i)
|
|
||||||
{
|
|
||||||
NBTTagCompound fluidNBT = (NBTTagCompound) nbtList.tagAt(i);
|
|
||||||
fluids.add(FluidStack.loadFluidStackFromNBT(fluidNBT));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeFluidToNBT(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
NBTTagList nbtList = new NBTTagList();
|
|
||||||
|
|
||||||
for (FluidStack fluid : fluids)
|
|
||||||
{
|
|
||||||
NBTTagCompound nbtElement = new NBTTagCompound();
|
|
||||||
fluid.writeToNBT(nbtElement);
|
|
||||||
nbtList.appendTag(nbtElement);
|
|
||||||
}
|
|
||||||
|
|
||||||
nbt.setTag("fluids", nbtList);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
package resonantinduction.core.resource.item;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemBlock;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import resonantinduction.core.resource.BlockOre.OreData;
|
|
||||||
|
|
||||||
public class ItemBlockOre extends ItemBlock
|
|
||||||
{
|
|
||||||
|
|
||||||
public ItemBlockOre(int par1)
|
|
||||||
{
|
|
||||||
super(par1);
|
|
||||||
this.setMaxDamage(0);
|
|
||||||
this.setHasSubtypes(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetadata(int damage)
|
|
||||||
{
|
|
||||||
return damage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUnlocalizedName(ItemStack par1ItemStack)
|
|
||||||
{
|
|
||||||
if (par1ItemStack != null && par1ItemStack.getItemDamage() < OreData.values().length)
|
|
||||||
{
|
|
||||||
return "tile." + Reference.PREFIX + OreData.values()[par1ItemStack.getItemDamage()].name + "Ore";
|
|
||||||
}
|
|
||||||
return super.getUnlocalizedName();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,90 +0,0 @@
|
||||||
package resonantinduction.core.resource.item;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import resonantinduction.core.prefab.item.ItemBase;
|
|
||||||
import resonantinduction.core.resource.ResourceGenerator;
|
|
||||||
import calclavia.lib.utility.LanguageUtility;
|
|
||||||
import calclavia.lib.utility.NBTUtility;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An item used for auto-generated dusts based on registered ingots in the OreDict.
|
|
||||||
*
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ItemDust extends ItemBase
|
|
||||||
{
|
|
||||||
public static final Set<ItemStack> dusts = new HashSet<ItemStack>();
|
|
||||||
|
|
||||||
public ItemDust(int id)
|
|
||||||
{
|
|
||||||
super("dust", id);
|
|
||||||
this.setTextureName(Reference.PREFIX + "dust");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getItemDisplayName(ItemStack is)
|
|
||||||
{
|
|
||||||
String dustName = getDustFromStack(is);
|
|
||||||
ItemStack type = OreDictionary.getOres("ingot" + dustName.substring(0, 1).toUpperCase() + dustName.substring(1)).get(0);
|
|
||||||
|
|
||||||
String name = type.getDisplayName().replace(LanguageUtility.getLocal("misc.resonantinduction.ingot"), "");
|
|
||||||
return (LanguageUtility.getLocal(this.getUnlocalizedName() + ".name")).replace("%v", name).replace(" ", " ");
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getStackFromDust(String name)
|
|
||||||
{
|
|
||||||
ItemStack itemStack = new ItemStack(this);
|
|
||||||
NBTTagCompound nbt = NBTUtility.getNBTTagCompound(itemStack);
|
|
||||||
nbt.setString("name", name);
|
|
||||||
return itemStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getDustFromStack(ItemStack itemStack)
|
|
||||||
{
|
|
||||||
NBTTagCompound nbt = NBTUtility.getNBTTagCompound(itemStack);
|
|
||||||
|
|
||||||
if (nbt.hasKey("name"))
|
|
||||||
{
|
|
||||||
return nbt.getString("name");
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
|
||||||
{
|
|
||||||
for (ItemStack dust : dusts)
|
|
||||||
{
|
|
||||||
par3List.add(dust);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public int getColorFromItemStack(ItemStack itemStack, int par2)
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Auto-color based on the texture of the ingot.
|
|
||||||
*/
|
|
||||||
String name = ItemDust.getDustFromStack(itemStack);
|
|
||||||
|
|
||||||
if (ResourceGenerator.materialColors.containsKey(name))
|
|
||||||
{
|
|
||||||
return ResourceGenerator.materialColors.get(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 16777215;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,130 +0,0 @@
|
||||||
package resonantinduction.core.resource.item;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.texture.IconRegister;
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.Icon;
|
|
||||||
import net.minecraftforge.common.Configuration;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import resonantinduction.core.Settings;
|
|
||||||
import resonantinduction.core.prefab.item.ItemBase;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import dark.lib.IExtraInfo.IExtraItemInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A meta data item containing parts of various crafting recipes. These parts do not do anything but
|
|
||||||
* allow new crafting recipes to be created.
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public class ItemParts extends ItemBase implements IExtraItemInfo
|
|
||||||
{
|
|
||||||
public ItemParts()
|
|
||||||
{
|
|
||||||
super("DMParts", Settings.getNextItemID());
|
|
||||||
this.setHasSubtypes(true);
|
|
||||||
this.setMaxDamage(0);
|
|
||||||
this.setMaxStackSize(64);
|
|
||||||
this.setCreativeTab(CreativeTabs.tabMaterials);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUnlocalizedName(ItemStack itemStack)
|
|
||||||
{
|
|
||||||
if (itemStack != null && itemStack.getItemDamage() < Parts.values().length)
|
|
||||||
{
|
|
||||||
return "item." + Parts.values()[itemStack.getItemDamage()].name;
|
|
||||||
}
|
|
||||||
return super.getUnlocalizedName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public Icon getIconFromDamage(int meta)
|
|
||||||
{
|
|
||||||
if (meta < Parts.values().length)
|
|
||||||
{
|
|
||||||
return Parts.values()[meta].icon;
|
|
||||||
}
|
|
||||||
return this.itemIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void registerIcons(IconRegister iconRegister)
|
|
||||||
{
|
|
||||||
super.registerIcons(iconRegister);
|
|
||||||
for (Parts part : Parts.values())
|
|
||||||
{
|
|
||||||
part.icon = iconRegister.registerIcon(Reference.PREFIX + "part." + part.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetadata(int meta)
|
|
||||||
{
|
|
||||||
return meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getSubItems(int blockID, CreativeTabs tab, List itemStackList)
|
|
||||||
{
|
|
||||||
for (Parts part : Parts.values())
|
|
||||||
{
|
|
||||||
if (part.show)
|
|
||||||
{
|
|
||||||
itemStackList.add(new ItemStack(this, 1, part.ordinal()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum Parts
|
|
||||||
{
|
|
||||||
Seal("leatherSeal"), GasSeal("gasSeal"), Tank("unfinishedTank"), Valve("valvePart"),
|
|
||||||
MiningIcon("miningIcon", false), CircuitBasic("circuitBasic"),
|
|
||||||
CircuitAdvanced("circuitAdvanced"), CircuitElite("circuitElite"), Motor("motor"),
|
|
||||||
IC("ic_chip"), COIL("coilCopper"), LASER("diodeLaser");
|
|
||||||
|
|
||||||
public String name;
|
|
||||||
public Icon icon;
|
|
||||||
boolean show = true;
|
|
||||||
|
|
||||||
private Parts(String name)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Parts(String name, boolean show)
|
|
||||||
{
|
|
||||||
this(name);
|
|
||||||
this.show = show;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasExtraConfigs()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadExtraConfigs(Configuration config)
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadOreNames()
|
|
||||||
{
|
|
||||||
for (Parts part : Parts.values())
|
|
||||||
{
|
|
||||||
OreDictionary.registerOre(part.name, new ItemStack(this, 1, part.ordinal()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
package resonantinduction.core.tilenetwork;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used on tiles that can contain more than one tile network. Currently WIP so don't use unless you
|
|
||||||
* know what your doing. When using this use networks like items and store them in slots.
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public interface INetworkContainer
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Gets a list of all networks slots and their connected networks. Used both to see the max
|
|
||||||
* limit of networks this tile may contain, and if there are networks currently in use
|
|
||||||
*/
|
|
||||||
public ITileNetwork[] getContainedNetworks();
|
|
||||||
|
|
||||||
/** Sets the network in the given slot */
|
|
||||||
public boolean setNetwork(int slot, ITileNetwork network);
|
|
||||||
|
|
||||||
/** Gets the network in the slot */
|
|
||||||
public ITileNetwork getNetwork(int slot);
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
package resonantinduction.core.tilenetwork;
|
|
||||||
|
|
||||||
import universalelectricity.api.energy.IEnergyContainer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tiles that use NetworkSharedPower class should implements this. All methods in IElectricalStorage
|
|
||||||
* should point to the network instead of the tile. This is why more energy methods are added to
|
|
||||||
* this interface
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public interface INetworkEnergyPart extends INetworkPart, IEnergyContainer
|
|
||||||
{
|
|
||||||
/** Gets the energy stored in the part */
|
|
||||||
public long getPartEnergy();
|
|
||||||
|
|
||||||
/** Gets the max energy storage limit of the part */
|
|
||||||
public long getPartMaxEnergy();
|
|
||||||
|
|
||||||
/** Sets the energy stored in the part */
|
|
||||||
public void setPartEnergy(long energy);
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package resonantinduction.core.tilenetwork;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
|
|
||||||
public interface INetworkPart extends ITileConnector
|
|
||||||
{
|
|
||||||
/** Array of connections this tile has to other tiles */
|
|
||||||
public List<TileEntity> getNetworkConnections();
|
|
||||||
|
|
||||||
/** Update the connection this tile has to other tiles */
|
|
||||||
public void refresh();
|
|
||||||
|
|
||||||
/** Gets the networkPart's primary network */
|
|
||||||
public ITileNetwork getTileNetwork();
|
|
||||||
|
|
||||||
/** Sets the networkPart's primary network */
|
|
||||||
public void setTileNetwork(ITileNetwork network);
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
package resonantinduction.core.tilenetwork;
|
|
||||||
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used on tiles that want control over what can connect to there device. It is suggest that other
|
|
||||||
* interfaces for connection be routed threw this to reduce the need to change things
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public interface ITileConnector
|
|
||||||
{
|
|
||||||
/** Can this tile connect on the given side */
|
|
||||||
public boolean canTileConnect(Connection type, ForgeDirection dir);
|
|
||||||
|
|
||||||
/** Types of connections */
|
|
||||||
public static enum Connection
|
|
||||||
{
|
|
||||||
/** Energy from BC, UE, IC2 */
|
|
||||||
Eletricity(),
|
|
||||||
/** Fluids from anything including BC pipes, DM pipes, Mek pipes */
|
|
||||||
FLUIDS(),
|
|
||||||
/** Force mainly from rotating rods */
|
|
||||||
FORCE(),
|
|
||||||
/** Hydraulic pressure from DM pipe */
|
|
||||||
FLUID_PRESSURE(), AIR_PRESSURE(),
|
|
||||||
/** Item pipe */
|
|
||||||
ITEMS(),
|
|
||||||
/** Data line input */
|
|
||||||
DATA(),
|
|
||||||
/** Another tile entity */
|
|
||||||
TILE(),
|
|
||||||
/** Network of tile entities */
|
|
||||||
NETWORK(),
|
|
||||||
/** Thermal connection */
|
|
||||||
HEAT(),
|
|
||||||
/** Wire containing several wires of unknown color */
|
|
||||||
MULTI_WIRE(),
|
|
||||||
/** Bundle of pipes containing several colored pipes */
|
|
||||||
MULTI_PIPE(),
|
|
||||||
/** Device that contains several networks that can be of any type */
|
|
||||||
MULTI_NETWORK();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,68 +0,0 @@
|
||||||
package resonantinduction.core.tilenetwork;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies to objects that act as a collection of tile entities.
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public interface ITileNetwork
|
|
||||||
{
|
|
||||||
/** Gets the name of the network */
|
|
||||||
public String getName();
|
|
||||||
|
|
||||||
/** Gets a list of all tiles that are part of this network */
|
|
||||||
public Set<INetworkPart> getMembers();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when something want the network to add the tile
|
|
||||||
*
|
|
||||||
* @param entity - tile in question
|
|
||||||
* @param member - add it as a member if true
|
|
||||||
* @return true if added without issue
|
|
||||||
*/
|
|
||||||
public boolean addTile(TileEntity ent, boolean member);
|
|
||||||
|
|
||||||
/** Removes a tile from all parts of the network */
|
|
||||||
public boolean removeTile(TileEntity ent);
|
|
||||||
|
|
||||||
/** Called when this network is just created */
|
|
||||||
public void onCreated();
|
|
||||||
|
|
||||||
/** How many ticks should base between updates, return 0 or bellow for no ticks */
|
|
||||||
public int getUpdateRate();
|
|
||||||
|
|
||||||
/** Called every so many ticks so the network has a chance to update */
|
|
||||||
public void updateTick();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called every so many mins when the networks needs to refresh and repair. Each part should
|
|
||||||
* still handle there own refresh when edited, or updated. This is more for the network to do
|
|
||||||
* house cleaning
|
|
||||||
*/
|
|
||||||
public void refreshTick();
|
|
||||||
|
|
||||||
/** Called when two networks try to merge together */
|
|
||||||
public void mergeNetwork(ITileNetwork network, INetworkPart mergePoint);
|
|
||||||
|
|
||||||
/** Called when a peace of the network is removed and might need to split in two */
|
|
||||||
public void splitNetwork(INetworkPart splitPoint);
|
|
||||||
|
|
||||||
/** Check by the network handle if this network is invalid or no longer functional */
|
|
||||||
public boolean isInvalid();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is called when your network is considered invalid. You should cut all ties in the
|
|
||||||
* network to its object so GC will delete it
|
|
||||||
*/
|
|
||||||
public void invalidate();
|
|
||||||
|
|
||||||
/** Called when the network needs to save */
|
|
||||||
public void save();
|
|
||||||
|
|
||||||
/** Called when the network needs to load */
|
|
||||||
public void load();
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue