Updated to use the new RE resource generator replacing the old built in one
This commit is contained in:
parent
a322b95d38
commit
e50b502335
33 changed files with 30 additions and 1586 deletions
|
@ -42,16 +42,14 @@ import resonant.lib.network.handle.IPacketReceiver;
|
|||
import resonant.lib.render.RenderItemOverlayUtility;
|
||||
import resonant.lib.type.Pair;
|
||||
import resonant.lib.utility.LanguageUtility;
|
||||
import resonant.lib.utility.WorldUtility;
|
||||
import resonant.lib.utility.inventory.AutoCraftingManager;
|
||||
import resonant.lib.utility.inventory.AutoCraftingManager.IAutoCrafter;
|
||||
import resonant.lib.utility.inventory.InventoryUtility;
|
||||
import resonantinduction.core.RecipeType;
|
||||
import resonant.content.factory.resources.RecipeType;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.archaic.blocks.ItemImprint;
|
||||
import universalelectricity.core.transform.region.Cuboid;
|
||||
import universalelectricity.core.transform.rotation.Quaternion;
|
||||
import universalelectricity.core.transform.vector.Vector2;
|
||||
import universalelectricity.core.transform.vector.Vector3;
|
||||
import codechicken.multipart.ControlKeyModifer;
|
||||
|
|
|
@ -10,18 +10,13 @@ import net.minecraft.init.Blocks;
|
|||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import resonant.content.spatial.block.SpatialBlock;
|
||||
import resonant.engine.grid.thermal.BoilEvent;
|
||||
import resonant.engine.grid.thermal.ThermalPhysics;
|
||||
import resonant.lib.network.discriminator.PacketAnnotation;
|
||||
import resonant.lib.network.discriminator.PacketTile;
|
||||
import resonant.lib.network.discriminator.PacketType;
|
||||
import resonant.lib.network.handle.IPacketReceiver;
|
||||
import resonant.lib.utility.FluidUtility;
|
||||
import resonantinduction.archaic.Archaic;
|
||||
import resonantinduction.archaic.fluid.gutter.TileGutter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -40,12 +35,8 @@ import net.minecraftforge.fluids.IFluidHandler;
|
|||
import resonant.lib.network.Synced;
|
||||
import resonantinduction.core.CoreContent;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.resource.ResourceGenerator;
|
||||
import resonantinduction.core.resource.TileMaterial;
|
||||
import universalelectricity.core.transform.vector.Vector3;
|
||||
import resonant.lib.content.prefab.java.TileElectricInventory;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -133,35 +124,7 @@ public class TileFirebox extends TileElectricInventory implements IPacketReceive
|
|||
heatEnergy += POWER / 20;
|
||||
boolean usedHeat = false;
|
||||
|
||||
if (block == CoreContent.blockDust()|| block == CoreContent.blockRefinedDust())
|
||||
{
|
||||
usedHeat = true;
|
||||
|
||||
TileEntity dustTile = worldObj.getTileEntity(xCoord, yCoord + 1, zCoord);
|
||||
|
||||
if (dustTile instanceof TileMaterial)
|
||||
{
|
||||
String name = ((TileMaterial) dustTile).name();
|
||||
int meta = worldObj.getBlockMetadata(xCoord, yCoord + 1, zCoord);
|
||||
|
||||
if (heatEnergy >= getMeltIronEnergy(((meta + 1) / 7f) * 1000))
|
||||
{
|
||||
int volumeMeta = block == CoreContent.blockRefinedDust() ? meta : meta / 2;
|
||||
|
||||
worldObj.setBlock(xCoord, yCoord + 1, zCoord, ResourceGenerator.getMolten(name), volumeMeta, 3);
|
||||
|
||||
TileEntity tile = worldObj.getTileEntity(xCoord, yCoord + 1, zCoord);
|
||||
|
||||
if (tile instanceof TileMaterial)
|
||||
{
|
||||
((TileMaterial) tile).name_$eq(name);
|
||||
}
|
||||
|
||||
heatEnergy = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (block == Blocks.water)
|
||||
if (block == Blocks.water)
|
||||
{
|
||||
usedHeat = true;
|
||||
int volume = 100;
|
||||
|
|
|
@ -24,11 +24,9 @@ import resonant.lib.render.RenderUtility;
|
|||
import resonant.lib.utility.FluidUtility;
|
||||
import resonant.lib.utility.WorldUtility;
|
||||
import resonant.lib.utility.inventory.InventoryUtility;
|
||||
import resonantinduction.core.RecipeType;
|
||||
import resonant.content.factory.resources.RecipeType;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.prefab.node.NodePressure;
|
||||
import resonantinduction.core.prefab.node.TilePressureNode;
|
||||
import resonantinduction.core.prefab.node.TileTankNode;
|
||||
import universalelectricity.core.transform.region.Cuboid;
|
||||
import universalelectricity.core.transform.vector.Vector3;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
|
|
@ -6,8 +6,6 @@ import net.minecraft.block.material.Material;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
|
@ -22,12 +20,10 @@ import resonant.lib.network.discriminator.PacketType;
|
|||
import resonant.lib.network.handle.IPacketReceiver;
|
||||
import resonant.lib.utility.FluidUtility;
|
||||
import resonant.lib.utility.inventory.InventoryUtility;
|
||||
import resonantinduction.core.RecipeType;
|
||||
import resonant.content.factory.resources.RecipeType;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import universalelectricity.core.transform.vector.Vector3;
|
||||
import resonant.lib.content.prefab.java.TileInventory;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
/**
|
||||
* Turns molten fuilds into ingots.
|
||||
|
|
|
@ -9,9 +9,7 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import resonant.api.recipe.MachineRecipes;
|
||||
import resonant.api.recipe.RecipeResource;
|
||||
|
@ -21,12 +19,10 @@ import resonant.lib.network.discriminator.PacketType;
|
|||
import resonant.lib.network.handle.IPacketReceiver;
|
||||
import resonant.lib.utility.inventory.InventoryUtility;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.RecipeType;
|
||||
import resonant.content.factory.resources.RecipeType;
|
||||
import resonantinduction.mechanical.gear.ItemHandCrank;
|
||||
import universalelectricity.core.transform.vector.Vector3;
|
||||
import resonant.lib.content.prefab.java.TileInventory;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class TileMillstone extends TileInventory implements IPacketReceiver
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@ package resonantinduction.compatibility.nei;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import resonant.engine.ResonantEngine;
|
||||
import resonantinduction.core.CoreContent;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import codechicken.nei.api.API;
|
||||
|
@ -28,14 +29,14 @@ public class NEIResonantInductionConfig implements IConfigureNEI
|
|||
API.registerRecipeHandler(new RISmelterRecipeHandler());
|
||||
API.registerUsageHandler(new RISmelterRecipeHandler());
|
||||
|
||||
for (Block block : CoreContent.blockMixtureFluids().values())
|
||||
for (Block block : ResonantEngine.resourceFactory.mixtureFactory.blockMixtureFluids.values())
|
||||
API.hideItem(new ItemStack(block));
|
||||
|
||||
for (Block block : CoreContent.blockMoltenFluid().values())
|
||||
for (Block block : ResonantEngine.resourceFactory.moltenFactory.blockMoltenFluids.values())
|
||||
API.hideItem(new ItemStack(block));
|
||||
|
||||
API.hideItem(new ItemStack(CoreContent.blockDust()));
|
||||
API.hideItem(new ItemStack(CoreContent.blockRefinedDust()));
|
||||
//API.hideItem(new ItemStack(CoreContent.blockDust()));
|
||||
//API.hideItem(new ItemStack(CoreContent.blockRefinedDust()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package resonantinduction.compatibility.nei;
|
||||
|
||||
import resonant.lib.utility.LanguageUtility;
|
||||
import resonantinduction.core.RecipeType;
|
||||
import resonant.content.factory.resources.RecipeType;
|
||||
|
||||
public class RICrusherRecipeHandler extends RITemplateRecipeHandler
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package resonantinduction.compatibility.nei;
|
||||
|
||||
import resonant.lib.utility.LanguageUtility;
|
||||
import resonantinduction.core.RecipeType;
|
||||
import resonant.content.factory.resources.RecipeType;
|
||||
|
||||
public class RIGrinderRecipeHandler extends RITemplateRecipeHandler
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package resonantinduction.compatibility.nei;
|
||||
|
||||
import resonant.lib.utility.LanguageUtility;
|
||||
import resonantinduction.core.RecipeType;
|
||||
import resonant.content.factory.resources.RecipeType;
|
||||
|
||||
public class RIMixerRecipeHandler extends RITemplateRecipeHandler
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package resonantinduction.compatibility.nei;
|
||||
|
||||
import resonant.lib.utility.LanguageUtility;
|
||||
import resonantinduction.core.RecipeType;
|
||||
import resonant.content.factory.resources.RecipeType;
|
||||
|
||||
public class RISawmillRecipeHandler extends RITemplateRecipeHandler
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package resonantinduction.compatibility.nei;
|
||||
|
||||
import resonant.lib.utility.LanguageUtility;
|
||||
import resonantinduction.core.RecipeType;
|
||||
import resonant.content.factory.resources.RecipeType;
|
||||
|
||||
public class RISmelterRecipeHandler extends RITemplateRecipeHandler
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@ import resonant.api.recipe.RecipeResource.FluidStackResource;
|
|||
import resonant.api.recipe.RecipeResource.ItemStackResource;
|
||||
import resonant.api.recipe.RecipeResource.OreDictResource;
|
||||
import resonant.lib.utility.LanguageUtility;
|
||||
import resonantinduction.core.RecipeType;
|
||||
import resonant.content.factory.resources.RecipeType;
|
||||
import resonantinduction.core.Reference;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
package resonantinduction.core
|
||||
|
||||
import java.util.HashMap
|
||||
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.init.{Blocks, Items}
|
||||
import net.minecraft.item.{Item, ItemStack}
|
||||
import net.minecraftforge.fluids.BlockFluidFinite
|
||||
import resonant.content.loader.{ContentHolder, ExplicitContentName}
|
||||
import resonant.lib.ore.OreGenerator
|
||||
import net.minecraft.item.ItemStack
|
||||
import resonant.content.loader.ContentHolder
|
||||
import resonantinduction.core.content.BlockDecoration
|
||||
import resonantinduction.core.resource.fluid.ItemResourceBucket
|
||||
import resonantinduction.core.resource.{ItemResourceDust, TileDust}
|
||||
|
||||
/**
|
||||
* The core contents of Resonant Induction
|
||||
|
@ -18,57 +12,7 @@ import resonantinduction.core.resource.{ItemResourceDust, TileDust}
|
|||
*/
|
||||
object CoreContent extends ContentHolder
|
||||
{
|
||||
final val blockMixtureFluids: HashMap[Integer, BlockFluidFinite] = new HashMap[Integer, BlockFluidFinite]
|
||||
final val blockMoltenFluid: HashMap[Integer, BlockFluidFinite] = new HashMap[Integer, BlockFluidFinite]
|
||||
|
||||
/**
|
||||
* Blocks
|
||||
*/
|
||||
var blockOreCopper: Block = null
|
||||
var blockOreTin: Block = null
|
||||
|
||||
/**
|
||||
* Items
|
||||
*/
|
||||
var itemMotor: Item = null
|
||||
var itemCircuitBasic: Item = null
|
||||
var itemCircuitAdvanced: Item = null
|
||||
var itemCircuitElite: Item = null
|
||||
|
||||
var itemPlateCopper: Item = null
|
||||
var itemPlateTin: Item = null
|
||||
var itemPlateBronze: Item = null
|
||||
var itemPlateSteel: Item = null
|
||||
var itemPlateIron: Item = null
|
||||
var itemPlateGold: Item = null
|
||||
|
||||
var itemIngotSteel: Item = null
|
||||
var itemIngotBronze: Item = null
|
||||
var itemDustSteel: Item = null
|
||||
var itemDustBronze: Item = null
|
||||
|
||||
var generationOreCopper: OreGenerator = null
|
||||
var generationOreTin: OreGenerator = null
|
||||
|
||||
val decoration: Block = new BlockDecoration()
|
||||
@ExplicitContentName("dust")
|
||||
val blockDust: Block = new TileDust().setCreativeTab(null)
|
||||
@ExplicitContentName("refinedDust")
|
||||
val blockRefinedDust: Block = new TileDust().setCreativeTab(null)
|
||||
|
||||
/**
|
||||
* Items
|
||||
*/
|
||||
@ExplicitContentName
|
||||
val rubble = new ItemResourceDust
|
||||
@ExplicitContentName
|
||||
val dust = new ItemResourceDust
|
||||
@ExplicitContentName
|
||||
val refinedDust = new ItemResourceDust
|
||||
@ExplicitContentName
|
||||
val bucketMixture = new ItemResourceBucket(false)
|
||||
@ExplicitContentName
|
||||
val bucketMolten = new ItemResourceBucket(true)
|
||||
|
||||
manager.setTab(ResonantTab).setPrefix(Reference.prefix)
|
||||
|
||||
|
@ -77,14 +21,6 @@ object CoreContent extends ContentHolder
|
|||
*/
|
||||
override def postInit()
|
||||
{
|
||||
/**
|
||||
* Resources
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Decoration
|
||||
*/
|
||||
recipes += shaped(new ItemStack(decoration, 8, 3), "XXX", "XCX", "XXX", 'X', Blocks.cobblestone, 'C', new ItemStack(Items.coal, 1, 1))
|
||||
recipes += (new ItemStack(decoration, 3), new ItemStack(decoration, 1, 5), 5)
|
||||
recipes += (decoration, new ItemStack(decoration, 1, 4), 5)
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
package resonantinduction.core;
|
||||
|
||||
/**
|
||||
* Created by robert on 8/11/2014.
|
||||
*/
|
||||
public enum RecipeType {
|
||||
CRUSHER, GRINDER, MIXER, SMELTER, SAWMILL
|
||||
}
|
|
@ -12,7 +12,6 @@ import resonant.engine.{References, ResonantEngine}
|
|||
import resonant.lib.config.ConfigHandler
|
||||
import resonant.lib.loadable.LoadableHandler
|
||||
import resonantinduction.core.handler.TextureHookHandler
|
||||
import resonantinduction.core.resource.ResourceGenerator
|
||||
|
||||
import scala.collection.convert.wrapAll._
|
||||
|
||||
|
@ -45,7 +44,6 @@ object ResonantInduction
|
|||
Settings.config = new Configuration(evt.getSuggestedConfigurationFile)
|
||||
ConfigHandler.sync(Settings, Settings.config)
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(ResourceGenerator)
|
||||
MinecraftForge.EVENT_BUS.register(new TextureHookHandler)
|
||||
|
||||
loadables.applyModule(proxy)
|
||||
|
@ -70,7 +68,7 @@ object ResonantInduction
|
|||
ResonantInduction.metadata.autogenerated = false
|
||||
}
|
||||
|
||||
ResourceGenerator.generateOreResources()
|
||||
ResonantEngine.resourceFactory.generateAll();
|
||||
proxy.init()
|
||||
}
|
||||
|
||||
|
|
|
@ -2,15 +2,12 @@ package resonantinduction.core.handler;
|
|||
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.fluids.BlockFluidFinite;
|
||||
import resonant.lib.render.RenderUtility;
|
||||
import resonantinduction.core.CoreContent;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.prefab.FluidColored;
|
||||
import resonantinduction.core.resource.ResourceGenerator;
|
||||
import resonant.lib.prefab.block.FluidColored;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -37,21 +34,4 @@ public class TextureHookHandler
|
|||
RenderUtility.registerIcon(Reference.prefix() + "tankEdge", event.map);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void postTextureHook(TextureStitchEvent.Post event)
|
||||
{
|
||||
for (BlockFluidFinite block : CoreContent.blockMixtureFluids().values())
|
||||
{
|
||||
block.getFluid().setIcons(RenderUtility.getIcon(Reference.prefix() + "mixture_flow"));
|
||||
((FluidColored) block.getFluid()).setColor(ResourceGenerator.getColor(ResourceGenerator.mixtureToMaterial(block.getFluid().getName())));
|
||||
}
|
||||
|
||||
for (BlockFluidFinite block : CoreContent.blockMoltenFluid().values())
|
||||
{
|
||||
block.getFluid().setIcons(RenderUtility.getIcon(Reference.prefix() + "molten_flow"));
|
||||
((FluidColored) block.getFluid()).setColor(ResourceGenerator.getColor(ResourceGenerator.moltenToMaterial(block.getFluid().getName())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
package resonantinduction.core.prefab;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
public class FluidColored extends Fluid
|
||||
{
|
||||
private int color = 0xFFFFFF;
|
||||
|
||||
public FluidColored(String fluidName)
|
||||
{
|
||||
super(fluidName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor()
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(int newColor)
|
||||
{
|
||||
color = newColor;
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package resonantinduction.core.prefab;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
|
||||
/**
|
||||
* Version of the fluid tank that restricts input & output amounts
|
||||
* @author Darkguardsman
|
||||
*/
|
||||
public class LimitedTank extends FluidTank
|
||||
{
|
||||
public int maxInput;
|
||||
public int maxOutput;
|
||||
|
||||
public LimitedTank(int capacity)
|
||||
{
|
||||
this(capacity, capacity);
|
||||
}
|
||||
|
||||
public LimitedTank(int capacity, int maxFluidMovement)
|
||||
{
|
||||
this(capacity, maxFluidMovement, maxFluidMovement);
|
||||
}
|
||||
|
||||
public LimitedTank(int capacity, int maxinput, int maxOutput)
|
||||
{
|
||||
super(capacity);
|
||||
this.maxInput = maxinput;
|
||||
this.maxOutput = maxOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(FluidStack resource, boolean doFill)
|
||||
{
|
||||
if(resource != null)
|
||||
{
|
||||
FluidStack fluid = resource.copy();
|
||||
fluid.amount = Math.max(fluid.amount, maxInput);
|
||||
return super.fill(resource, doFill);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, boolean doDrain)
|
||||
{
|
||||
return super.drain(Math.max(maxDrain, maxOutput),doDrain);
|
||||
}
|
||||
}
|
|
@ -11,8 +11,7 @@ import resonant.lib.network.discriminator.PacketTile;
|
|||
import resonant.lib.network.discriminator.PacketType;
|
||||
import resonant.lib.network.handle.IPacketIDReceiver;
|
||||
import resonant.lib.utility.WorldUtility;
|
||||
import resonant.lib.wrapper.ObjectOrWrapper;
|
||||
import resonantinduction.core.prefab.LimitedTank;
|
||||
import resonant.lib.prefab.fluid.LimitedTank;
|
||||
import universalelectricity.api.core.grid.INodeProvider;
|
||||
import universalelectricity.api.core.grid.ISave;
|
||||
import universalelectricity.core.grid.node.NodeConnector;
|
||||
|
@ -181,14 +180,10 @@ public class NodeTank extends NodeConnector implements IFluidTank, IFluidHandler
|
|||
{
|
||||
if(obj != null)
|
||||
{
|
||||
if(obj.getClass().isAssignableFrom(getClass()))
|
||||
if(obj.getClass().isAssignableFrom(getParent().getClass()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(obj instanceof INodeProvider)
|
||||
{
|
||||
return ((INodeProvider) obj).getNode(getClass(), dir) != null;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,186 +0,0 @@
|
|||
package resonantinduction.core.resource;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
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.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import resonant.lib.utility.LanguageUtility;
|
||||
import resonantinduction.core.CoreContent;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import scala.collection.Iterator;
|
||||
|
||||
/**
|
||||
* An item used for auto-generated dusts based on registered ingots in the OreDict.
|
||||
*
|
||||
* @author Calclavia
|
||||
*/
|
||||
public class ItemResourceDust extends Item
|
||||
{
|
||||
public ItemResourceDust()
|
||||
{
|
||||
setHasSubtypes(true);
|
||||
setMaxDamage(0);
|
||||
}
|
||||
|
||||
public static String getMaterialFromStack(ItemStack itemStack)
|
||||
{
|
||||
return ResourceGenerator.getName(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack is)
|
||||
{
|
||||
String material = getMaterialFromStack(is);
|
||||
|
||||
if (material != null)
|
||||
{
|
||||
List<ItemStack> list = OreDictionary.getOres("ingot" + material.substring(0, 1).toUpperCase() + material.substring(1));
|
||||
|
||||
if (list.size() > 0)
|
||||
{
|
||||
ItemStack type = list.get(0);
|
||||
|
||||
String name = type.getDisplayName().replace(LanguageUtility.getLocal("misc.resonantinduction.ingot"), "").replaceAll("^ ", "").replaceAll(" $", "");
|
||||
return (LanguageUtility.getLocal(getUnlocalizedName() + ".name")).replace("%v", name).replace(" ", " ");
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
/**
|
||||
* Allow refined dust to be placed down.
|
||||
*/
|
||||
if (itemStack.getItem() == CoreContent.dust() || itemStack.getItem() == CoreContent.refinedDust())
|
||||
{
|
||||
Block block = itemStack.getItem() == CoreContent.dust() ? CoreContent.blockDust() : CoreContent.blockRefinedDust();
|
||||
|
||||
if (itemStack.stackSize == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!player.canPlayerEdit(x, y, z, side, itemStack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if (world.getBlock(x, y, z) == block && tile instanceof TileMaterial)
|
||||
{
|
||||
if (getMaterialFromStack(itemStack).equals(((TileMaterial) tile).name()))
|
||||
{
|
||||
int j1 = world.getBlockMetadata(x, y, z);
|
||||
int k1 = j1 & 7;
|
||||
|
||||
if (k1 <= 6 && world.checkNoEntityCollision(block.getCollisionBoundingBoxFromPool(world, x, y, z)) && world.setBlockMetadataWithNotify(x, y, z, k1 + 1 | j1 & -8, 2))
|
||||
{
|
||||
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.func_150496_b(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
|
||||
--itemStack.stackSize;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (side == 0)
|
||||
{
|
||||
--y;
|
||||
}
|
||||
|
||||
if (side == 1)
|
||||
{
|
||||
++y;
|
||||
}
|
||||
|
||||
if (side == 2)
|
||||
{
|
||||
--z;
|
||||
}
|
||||
|
||||
if (side == 3)
|
||||
{
|
||||
++z;
|
||||
}
|
||||
|
||||
if (side == 4)
|
||||
{
|
||||
--x;
|
||||
}
|
||||
|
||||
if (side == 5)
|
||||
{
|
||||
++x;
|
||||
}
|
||||
|
||||
if (world.canPlaceEntityOnSide(block, x, y, z, false, side, player, itemStack))
|
||||
{
|
||||
int j1 = this.getMetadata(itemStack.getItemDamage());
|
||||
int k1 = block.onBlockPlaced(world, x, y, z, side, hitX, hitY, hitZ, j1);
|
||||
|
||||
if (placeBlockAt(itemStack, player, world, x, y, z, side, hitX, hitY, hitZ, k1))
|
||||
{
|
||||
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.func_150496_b(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
|
||||
--itemStack.stackSize;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
|
||||
{
|
||||
Block block = stack.getItem() == CoreContent.refinedDust() ? CoreContent.blockRefinedDust() : CoreContent.blockDust();
|
||||
|
||||
if (!world.setBlock(x, y, z, block, metadata, 3))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world.getBlock(x, y, z) == block)
|
||||
{
|
||||
block.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
block.onPostBlockPlaced(world, x, y, z, metadata);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemStack getStackFromMaterial(String name)
|
||||
{
|
||||
return ResourceGenerator.getRefinedDust(name, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
Iterator<String> it = ResourceGenerator.materials().iterator();
|
||||
while(it.hasNext())
|
||||
{
|
||||
par3List.add(it.next());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getColorFromItemStack(ItemStack itemStack, int par2)
|
||||
{
|
||||
return ResourceGenerator.getColor(ItemResourceDust.getMaterialFromStack(itemStack));
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package resonantinduction.core.resource;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
/**
|
||||
* A general item class that does nothing but act as recipe resource item.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class ItemResourcePart extends Item
|
||||
{
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package resonantinduction.core.resource;
|
||||
|
||||
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,370 +0,0 @@
|
|||
package resonantinduction.core.resource
|
||||
|
||||
import java.awt.Color
|
||||
import javax.imageio.ImageIO
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent
|
||||
import cpw.mods.fml.common.registry.GameRegistry
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.init.{Blocks, Items}
|
||||
import net.minecraft.item.{Item, ItemStack}
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.util.{IIcon, ResourceLocation}
|
||||
import net.minecraftforge.client.event.TextureStitchEvent
|
||||
import net.minecraftforge.fluids.{BlockFluidFinite, FluidContainerRegistry, FluidRegistry, FluidStack}
|
||||
import net.minecraftforge.oredict.OreDictionary
|
||||
import resonant.api.recipe.MachineRecipes
|
||||
import resonant.lib.config.Config
|
||||
import resonant.lib.recipe.Recipes
|
||||
import resonant.lib.utility.LanguageUtility
|
||||
import resonant.lib.utility.nbt.NBTUtility
|
||||
import resonant.lib.wrapper.StringWrapper._
|
||||
import resonantinduction.core.prefab.FluidColored
|
||||
import resonantinduction.core.resource.fluid.{BlockFluidMaterial, BlockFluidMixture}
|
||||
import resonantinduction.core.{RecipeType, CoreContent, Reference, Settings}
|
||||
|
||||
import scala.collection.JavaConversions._
|
||||
import scala.collection.mutable
|
||||
|
||||
/**
|
||||
* Generates the resources based on available ores in Resonant Induction
|
||||
* @author Calclavia
|
||||
*/
|
||||
object ResourceGenerator
|
||||
{
|
||||
final val materials = mutable.Set.empty[String]
|
||||
final val materialColorCache = mutable.HashMap.empty[String, Integer]
|
||||
final val iconColorCache = mutable.HashMap.empty[IIcon, Integer]
|
||||
|
||||
final val category = "resource-generator"
|
||||
|
||||
@Config(category = category)
|
||||
var enableAll: Boolean = true
|
||||
@Config(category = category)
|
||||
var enableAllFluids: Boolean = true
|
||||
|
||||
/**
|
||||
* A list of material names. They are all camelCase reference of ore dictionary names without
|
||||
* the "ore" or "ingot" prefix.
|
||||
* <p/>
|
||||
* Name, ID
|
||||
*/
|
||||
private[resource] var maxID: Int = 0
|
||||
@Config(category = "resource-generator", comment = "Allow the Resource Generator to make ore dictionary compatible recipes?")
|
||||
private val allowOreDictCompatibility: Boolean = true
|
||||
|
||||
/**
|
||||
* Automatically generate resources from available ingots
|
||||
*/
|
||||
def generateOreResources()
|
||||
{
|
||||
OreDictionary.registerOre("ingotGold", Items.gold_ingot)
|
||||
OreDictionary.registerOre("ingotIron", Items.iron_ingot)
|
||||
OreDictionary.registerOre("oreGold", Blocks.gold_ore)
|
||||
OreDictionary.registerOre("oreIron", Blocks.iron_ore)
|
||||
OreDictionary.registerOre("oreLapis", Blocks.lapis_ore)
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.SMELTER.name, new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(Blocks.stone))
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.CRUSHER.name, Blocks.cobblestone, Blocks.gravel)
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.CRUSHER.name, Blocks.stone, Blocks.cobblestone)
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.CRUSHER.name, Blocks.chest, new ItemStack(Blocks.planks, 7, 0))
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.GRINDER.name, Blocks.cobblestone, Blocks.sand)
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.GRINDER.name, Blocks.gravel, Blocks.sand)
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.GRINDER.name, Blocks.glass, Blocks.sand)
|
||||
|
||||
materials filter (name => OreDictionary.getOres("ore" + name.capitalizeFirst).size > 0) foreach (generate)
|
||||
}
|
||||
|
||||
def generate(materialName: String)
|
||||
{
|
||||
val nameCaps = materialName.capitalizeFirst
|
||||
var localizedName = materialName
|
||||
|
||||
val list = OreDictionary.getOres("ingot" + nameCaps)
|
||||
|
||||
if (list.size > 0)
|
||||
{
|
||||
localizedName = list.get(0).getDisplayName.trim
|
||||
if (LanguageUtility.getLocal(localizedName) != null && LanguageUtility.getLocal(localizedName) != "")
|
||||
{
|
||||
localizedName = LanguageUtility.getLocal(localizedName)
|
||||
}
|
||||
|
||||
localizedName.replace(LanguageUtility.getLocal("misc.resonantinduction.ingot"), "").replaceAll("^ ", "").replaceAll(" #", "")
|
||||
}
|
||||
|
||||
if (enableAllFluids)
|
||||
{
|
||||
/**
|
||||
* Generate molten fluid
|
||||
*/
|
||||
val fluidMolten = new FluidColored(materialNameToMolten(materialName)).setDensity(7).setViscosity(5000).setTemperature(273 + 1538)
|
||||
FluidRegistry.registerFluid(fluidMolten)
|
||||
val blockFluidMaterial = new BlockFluidMaterial(fluidMolten)
|
||||
CoreContent.manager.newBlock("molten" + nameCaps, blockFluidMaterial)
|
||||
FluidContainerRegistry.registerFluidContainer(fluidMolten, setMaterial(new ItemStack(CoreContent.bucketMolten), materialName))
|
||||
|
||||
/**
|
||||
* Generate mixture fluid
|
||||
*/
|
||||
val fluidMixture = new FluidColored(materialNameToMixture(materialName))
|
||||
FluidRegistry.registerFluid(fluidMixture)
|
||||
val blockFluidMixture = new BlockFluidMixture(fluidMixture)
|
||||
GameRegistry.registerBlock(blockFluidMixture, "mixture" + nameCaps)
|
||||
FluidContainerRegistry.registerFluidContainer(fluidMixture, setMaterial(new ItemStack(CoreContent.bucketMixture), materialName))
|
||||
|
||||
if (allowOreDictCompatibility)
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.SMELTER.name, new FluidStack(fluidMolten, FluidContainerRegistry.BUCKET_VOLUME), "ingot" + nameCaps)
|
||||
else
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.SMELTER.name, new FluidStack(fluidMolten, FluidContainerRegistry.BUCKET_VOLUME), "ingot" + nameCaps)
|
||||
|
||||
}
|
||||
|
||||
val dust: ItemStack = CoreContent.dust.getStackFromMaterial(materialName)
|
||||
val rubble: ItemStack = CoreContent.rubble.getStackFromMaterial(materialName)
|
||||
val refinedDust: ItemStack = CoreContent.refinedDust.getStackFromMaterial(materialName)
|
||||
|
||||
if (allowOreDictCompatibility)
|
||||
{
|
||||
OreDictionary.registerOre("rubble" + nameCaps, CoreContent.rubble.getStackFromMaterial(materialName))
|
||||
OreDictionary.registerOre("dirtyDust" + nameCaps, CoreContent.dust.getStackFromMaterial(materialName))
|
||||
OreDictionary.registerOre("dust" + nameCaps, CoreContent.refinedDust.getStackFromMaterial(materialName))
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.GRINDER.name, "rubble" + nameCaps, dust, dust)
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.MIXER.name, "dirtyDust" + nameCaps, refinedDust)
|
||||
}
|
||||
else
|
||||
{
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.GRINDER.name, rubble, dust, dust)
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.MIXER.name, dust, refinedDust)
|
||||
}
|
||||
|
||||
Recipes +=(dust.copy, OreDictionary.getOres("ingot" + nameCaps).get(0).copy, 0.7f)
|
||||
val smeltResult = OreDictionary.getOres("ingot" + nameCaps).get(0).copy
|
||||
Recipes +=(refinedDust.copy, smeltResult, 0.7f)
|
||||
|
||||
if (OreDictionary.getOres("ore" + nameCaps).size > 0)
|
||||
{
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.CRUSHER.name, "ore" + nameCaps, "rubble" + nameCaps)
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
def computeColors
|
||||
{
|
||||
for (material <- materials)
|
||||
{
|
||||
val totalR: Int = 0
|
||||
val totalG: Int = 0
|
||||
val totalB: Int = 0
|
||||
val colorCount: Int = 0
|
||||
for (ingotStack <- OreDictionary.getOres("ingot" + LanguageUtility.capitalizeFirst(material)))
|
||||
{
|
||||
val theIngot: Item = ingotStack.getItem
|
||||
val color: Int = getAverageColor(ingotStack)
|
||||
materialColorCache.put(material, color)
|
||||
}
|
||||
if (!materialColorCache.containsKey(material))
|
||||
{
|
||||
materialColorCache.put(material, 0xFFFFFF)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the average color of this item.
|
||||
*
|
||||
* @param itemStack
|
||||
* @return The RGB hexadecimal color code.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
def getAverageColor(itemStack: ItemStack): Int =
|
||||
{
|
||||
var totalR: Int = 0
|
||||
var totalG: Int = 0
|
||||
var totalB: Int = 0
|
||||
var colorCount: Int = 0
|
||||
val item: Item = itemStack.getItem
|
||||
try
|
||||
{
|
||||
val icon: IIcon = item.getIconIndex(itemStack)
|
||||
|
||||
if (iconColorCache.contains(icon))
|
||||
{
|
||||
return iconColorCache(icon)
|
||||
}
|
||||
|
||||
var iconString: String = icon.getIconName
|
||||
if (iconString != null && !iconString.contains("MISSING_ICON_ITEM"))
|
||||
{
|
||||
iconString = (if (iconString.contains(":")) iconString.replace(":", ":" + Reference.itemTextureDirectory) else Reference.itemTextureDirectory + iconString) + ".png"
|
||||
val textureLocation = new ResourceLocation(iconString)
|
||||
val inputStream = Minecraft.getMinecraft.getResourceManager.getResource(textureLocation).getInputStream
|
||||
val bufferedImage = ImageIO.read(inputStream)
|
||||
val width: Int = bufferedImage.getWidth
|
||||
val height: Int = bufferedImage.getWidth
|
||||
|
||||
/**
|
||||
* Read every single pixel of the texture.
|
||||
*/
|
||||
for (x <- 0 until width; y <- 0 until height)
|
||||
{
|
||||
val rgb: Color = new Color(bufferedImage.getRGB(x, y))
|
||||
val luma: Double = 0.2126 * rgb.getRed + 0.7152 * rgb.getGreen + 0.0722 * rgb.getBlue
|
||||
|
||||
if (luma > 40)
|
||||
{
|
||||
totalR += rgb.getRed
|
||||
totalG += rgb.getGreen
|
||||
totalB += rgb.getBlue
|
||||
colorCount += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
if (colorCount > 0)
|
||||
{
|
||||
totalR /= colorCount
|
||||
totalG /= colorCount
|
||||
totalB /= colorCount
|
||||
val averageColor: Int = new Color(totalR, totalG, totalB).brighter.getRGB
|
||||
iconColorCache.put(icon, averageColor)
|
||||
return averageColor
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
case e: Exception =>
|
||||
{
|
||||
Reference.logger.fine("Failed to compute colors for: " + item)
|
||||
}
|
||||
}
|
||||
return 0xFFFFFF
|
||||
}
|
||||
|
||||
def moltenToMaterial(fluidName: String): String =
|
||||
{
|
||||
return fluidNameToMaterial(fluidName, "molten")
|
||||
}
|
||||
|
||||
def materialNameToMolten(fluidName: String): String =
|
||||
{
|
||||
return materialNameToFluid(fluidName, "molten")
|
||||
}
|
||||
|
||||
def mixtureToMaterial(fluidName: String): String =
|
||||
{
|
||||
return fluidNameToMaterial(fluidName, "mixture")
|
||||
}
|
||||
|
||||
def materialNameToMixture(fluidName: String): String =
|
||||
{
|
||||
return materialNameToFluid(fluidName, "mixture")
|
||||
}
|
||||
|
||||
def fluidNameToMaterial(fluidName: String, `type`: String): String =
|
||||
{
|
||||
return LanguageUtility.decapitalizeFirst(LanguageUtility.underscoreToCamel(fluidName).replace(`type`, ""))
|
||||
}
|
||||
|
||||
def materialNameToFluid(materialName: String, `type`: String): String =
|
||||
{
|
||||
return `type` + "_" + LanguageUtility.camelToLowerUnderscore(materialName)
|
||||
}
|
||||
|
||||
def getMixture(name: String): BlockFluidFinite =
|
||||
{
|
||||
return Block.blockRegistry.getObject("mixture" + name).asInstanceOf[BlockFluidFinite]
|
||||
}
|
||||
|
||||
def getMolten(name: String): BlockFluidFinite =
|
||||
{
|
||||
return Block.blockRegistry.getObject("molten" + LanguageUtility.capitalizeFirst(name)).asInstanceOf[BlockFluidFinite]
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ItemStack of the ore dust with this material name.
|
||||
*/
|
||||
def getDust(name: String, quantity: Int = 1): ItemStack =
|
||||
{
|
||||
val itemStack = new ItemStack(CoreContent.dust, quantity)
|
||||
val nbt = new NBTTagCompound
|
||||
nbt.setString("material", name)
|
||||
itemStack.setTagCompound(nbt)
|
||||
return itemStack
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ItemStack of the refined ore dust with this material name.
|
||||
*/
|
||||
def getRefinedDust(name: String, quantity: Int = 1): ItemStack =
|
||||
{
|
||||
val itemStack = new ItemStack(CoreContent.refinedDust, quantity)
|
||||
val nbt = new NBTTagCompound
|
||||
nbt.setString("material", name)
|
||||
itemStack.setTagCompound(nbt)
|
||||
return itemStack
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the material of this ItemStack
|
||||
*/
|
||||
def getMaterial(stack: ItemStack): String =
|
||||
{
|
||||
return NBTUtility.getNBTTagCompound(stack).getString("material")
|
||||
}
|
||||
|
||||
def setMaterial(stack: ItemStack, material: String): ItemStack =
|
||||
{
|
||||
NBTUtility.getNBTTagCompound(stack).setString("material", material)
|
||||
return stack
|
||||
}
|
||||
|
||||
def getName(itemStack: ItemStack): String =
|
||||
{
|
||||
return LanguageUtility.decapitalizeFirst(OreDictionary.getOreName(OreDictionary.getOreID(itemStack)).replace("dirtyDust", "").replace("dust", "").replace("ore", "").replace("ingot", ""))
|
||||
}
|
||||
|
||||
def getColor(name: String): Int =
|
||||
{
|
||||
assert(name != null, "getColor(name) received a null name!")
|
||||
|
||||
if (name != null && materialColorCache.contains(name))
|
||||
{
|
||||
return materialColorCache(name)
|
||||
}
|
||||
|
||||
return 0xFFFFFF
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
def oreRegisterEvent(evt: OreDictionary.OreRegisterEvent)
|
||||
{
|
||||
if (evt.Name.startsWith("ingot"))
|
||||
{
|
||||
val oreDictName = evt.Name.replace("ingot", "")
|
||||
val materialName = oreDictName.decapitalizeFirst
|
||||
|
||||
if (!materials.contains(materialName))
|
||||
{
|
||||
Settings.config.load()
|
||||
val allowMaterial = Settings.config.get(category, "Enable " + oreDictName, true).getBoolean(true)
|
||||
Settings.config.save()
|
||||
|
||||
if (!allowMaterial || OreDetectionBlackList.isIngotBlackListed("ingot" + oreDictName) || OreDetectionBlackList.isOreBlackListed("ore" + oreDictName))
|
||||
{
|
||||
return
|
||||
}
|
||||
|
||||
materials += materialName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
def reloadTextures(e: TextureStitchEvent.Post)
|
||||
{
|
||||
computeColors
|
||||
}
|
||||
|
||||
}
|
|
@ -1,179 +0,0 @@
|
|||
package resonantinduction.core.resource
|
||||
|
||||
import java.util
|
||||
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.material.Material
|
||||
import net.minecraft.entity.EntityLivingBase
|
||||
import net.minecraft.init.Blocks
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.util.{AxisAlignedBB, MovingObjectPosition}
|
||||
import net.minecraft.world.{IBlockAccess, World}
|
||||
import resonantinduction.core.CoreContent
|
||||
import universalelectricity.core.transform.region.Cuboid
|
||||
|
||||
/**
|
||||
* @author Calclavia
|
||||
*/
|
||||
class TileDust extends TileMaterial(Material.sand)
|
||||
{
|
||||
private[resource] var nextDropMaterialID: Int = 0
|
||||
|
||||
bounds = new Cuboid(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F)
|
||||
setBlockBoundsForDepth(0)
|
||||
blockHardness = 0.5f
|
||||
textureName = "material_sand"
|
||||
stepSound = Block.soundTypeGravel
|
||||
normalRender = false
|
||||
isOpaqueCube = false
|
||||
|
||||
def canFallBelow(world: World, x: Int, y: Int, z: Int): Boolean =
|
||||
{
|
||||
val block = world.getBlock(x, y, z)
|
||||
|
||||
if (world.isAirBlock(x, y, z))
|
||||
{
|
||||
return true
|
||||
}
|
||||
else if (block == Blocks.fire)
|
||||
{
|
||||
return true
|
||||
}
|
||||
else
|
||||
{
|
||||
val material = block.getMaterial
|
||||
return if (material == Material.water) true else material == Material.lava
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def colorMultiplier: Int = getColor
|
||||
|
||||
override def onPlaced(entityLiving: EntityLivingBase, itemStack: ItemStack)
|
||||
{
|
||||
materialName = ItemResourceDust.getMaterialFromStack(itemStack)
|
||||
}
|
||||
|
||||
override def onPostPlaced(metadata: Int)
|
||||
{
|
||||
tryToFall()
|
||||
}
|
||||
|
||||
/**
|
||||
* Block events
|
||||
*/
|
||||
override def onAdded()
|
||||
{
|
||||
tryToFall()
|
||||
}
|
||||
|
||||
override def onNeighborChanged(block: Block)
|
||||
{
|
||||
tryToFall()
|
||||
}
|
||||
|
||||
private def tryToFall()
|
||||
{
|
||||
var y = this.y
|
||||
|
||||
val tile: TileEntity = world.getTileEntity(x, y, z)
|
||||
if (tile.isInstanceOf[TileMaterial])
|
||||
{
|
||||
val materialName: String = (tile.asInstanceOf[TileMaterial]).materialName
|
||||
if (materialName != null)
|
||||
{
|
||||
val metadata: Int = world.getBlockMetadata(x, y, z)
|
||||
if (canFallBelow(world, x, y - 1, z) && y >= 0)
|
||||
{
|
||||
world.setBlockToAir(x, y, z)
|
||||
while (canFallBelow(world, x, y - 1, z) && y > 0)
|
||||
{
|
||||
y -= 1
|
||||
}
|
||||
if (y > 0)
|
||||
{
|
||||
world.setBlock(x, y, z, block, metadata, 3)
|
||||
|
||||
val newTile: TileEntity = world.getTileEntity(x, y, z)
|
||||
if (newTile.isInstanceOf[TileMaterial])
|
||||
{
|
||||
(newTile.asInstanceOf[TileMaterial]).materialName = materialName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bounding box from the pool of bounding boxes (this means this box can change after
|
||||
* the pool has been
|
||||
* cleared to be reused)
|
||||
*/
|
||||
def getCollisionBoundingBoxFromPool(par1World: World, par2: Int, par3: Int, par4: Int): AxisAlignedBB =
|
||||
{
|
||||
val l: Int = par1World.getBlockMetadata(par2, par3, par4) & 7
|
||||
val f: Float = 0.125F
|
||||
return AxisAlignedBB.getBoundingBox(par2 + bounds.min.x, par3 + bounds.min.y, par4 + bounds.min.z, par2 + bounds.max.x, par3 + l * f, par4 + bounds.max.z)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the block's bounds for rendering it as an item
|
||||
*/
|
||||
override def setBlockBoundsForItemRender
|
||||
{
|
||||
this.setBlockBoundsForDepth(0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon bounds raytrace. World data given.
|
||||
*/
|
||||
override def setBlockBoundsBasedOnState()
|
||||
{
|
||||
setBlockBoundsForDepth(metadata)
|
||||
}
|
||||
|
||||
/**
|
||||
* calls setBlockBounds based on the depth of the snow. Int is any values 0x0-0x7, usually this
|
||||
* blocks metadata.
|
||||
*/
|
||||
protected def setBlockBoundsForDepth(meta: Int)
|
||||
{
|
||||
val j: Int = meta & 7
|
||||
val f: Float = 2 * (1 + j) / 16.0F
|
||||
bounds = new Cuboid(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F)
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops
|
||||
*/
|
||||
override def getDrops(metadata: Int, fortune: Int): util.ArrayList[ItemStack] =
|
||||
{
|
||||
val list = new util.ArrayList[ItemStack]
|
||||
|
||||
if (block == CoreContent.blockRefinedDust)
|
||||
list.add(ResourceGenerator.getRefinedDust(materialName, quantityDropped(metadata, fortune)))
|
||||
else
|
||||
list.add(ResourceGenerator.getDust(materialName, quantityDropped(metadata, fortune)))
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
override def getPickBlock(target: MovingObjectPosition): ItemStack =
|
||||
{
|
||||
if (block == CoreContent.blockRefinedDust)
|
||||
return ResourceGenerator.getRefinedDust(materialName)
|
||||
else
|
||||
return ResourceGenerator.getDust(materialName)
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def shouldSideBeRendered(access: IBlockAccess, x: Int, y: Int, z: Int, side: Int): Boolean =
|
||||
{
|
||||
if (side == 1) true else super.shouldSideBeRendered(access, x, y, z, side)
|
||||
}
|
||||
|
||||
override def quantityDropped(meta: Int, fortune: Int): Int = (meta & 7) + 1
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
package resonantinduction.core.resource
|
||||
|
||||
import io.netty.buffer.ByteBuf
|
||||
import net.minecraft.block.material.Material
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.network.Packet
|
||||
import resonant.content.spatial.block.SpatialTile
|
||||
import resonant.lib.network.ByteBufWrapper.ByteBufWrapper
|
||||
import resonant.lib.network.discriminator.{PacketTile, PacketType}
|
||||
import resonant.lib.network.handle.TPacketReceiver
|
||||
import resonantinduction.core.ResonantInduction
|
||||
|
||||
/**
|
||||
* A tile that stores the material name.
|
||||
*
|
||||
* @author Calclavia
|
||||
*/
|
||||
abstract class TileMaterial(material: Material) extends SpatialTile(material) with TPacketReceiver
|
||||
{
|
||||
var materialName: String = null
|
||||
|
||||
def getColor: Int =
|
||||
{
|
||||
return ResourceGenerator.getColor(materialName)
|
||||
}
|
||||
|
||||
override def canUpdate: Boolean =
|
||||
{
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a packet
|
||||
* @param buf - data encoded into the packet
|
||||
* @param player - player that is receiving the packet
|
||||
* @param packet - The packet instance that was sending this packet.
|
||||
*/
|
||||
override def read(buf: ByteBuf, player: EntityPlayer, packet: PacketType)
|
||||
{
|
||||
materialName = buf.readString()
|
||||
markRender()
|
||||
}
|
||||
|
||||
override def getDescriptionPacket: Packet =
|
||||
{
|
||||
if (materialName != null)
|
||||
{
|
||||
return ResonantInduction.packetHandler.toMCPacket(new PacketTile(this) <<< materialName)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
override def readFromNBT(nbt: NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(nbt)
|
||||
materialName = nbt.getString("name")
|
||||
}
|
||||
|
||||
override def writeToNBT(nbt: NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(nbt)
|
||||
if (materialName != null)
|
||||
{
|
||||
nbt.setString("name", materialName)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package resonantinduction.core.resource.fluid;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
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.Reference;
|
||||
import resonantinduction.core.Settings;
|
||||
import resonantinduction.core.resource.ResourceGenerator;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Fluid class uses for molten materials.
|
||||
*
|
||||
* @author Calclavia
|
||||
*/
|
||||
public class BlockFluidMaterial extends BlockFluidFinite
|
||||
{
|
||||
public BlockFluidMaterial(Fluid fluid)
|
||||
{
|
||||
super(fluid, Material.lava);
|
||||
}
|
||||
|
||||
public void setQuanta(World world, int x, int y, int z, int quanta)
|
||||
{
|
||||
if (quanta > 0)
|
||||
world.setBlockMetadataWithNotify(x, y, z, quanta, 3);
|
||||
else
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
|
||||
/* IFluidBlock */
|
||||
@Override
|
||||
public FluidStack drain(World world, int x, int y, int z, boolean doDrain)
|
||||
{
|
||||
FluidStack stack = new FluidStack(getFluid(), (int) (FluidContainerRegistry.BUCKET_VOLUME * this.getFilledPercentage(world, x, y, z)));
|
||||
if (doDrain)
|
||||
world.setBlockToAir(x, y, z);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int colorMultiplier(IBlockAccess access, int x, int y, int z)
|
||||
{
|
||||
return ResourceGenerator.getColor(ResourceGenerator.moltenToMaterial(getFluid().getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(World world, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
package resonantinduction.core.resource.fluid
|
||||
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import net.minecraft.block.material.Material
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.world.{IBlockAccess, World}
|
||||
import net.minecraftforge.fluids.{BlockFluidFinite, Fluid, FluidContainerRegistry, FluidStack}
|
||||
import resonant.api.recipe.MachineRecipes
|
||||
import resonantinduction.core.RecipeType
|
||||
import resonantinduction.core.resource.ResourceGenerator
|
||||
|
||||
/**
|
||||
* @author Calclavia
|
||||
*/
|
||||
class BlockFluidMixture(fluid: Fluid) extends BlockFluidFinite(fluid, Material.water)
|
||||
{
|
||||
def setQuanta(world: World, x: Int, y: Int, z: Int, quanta: Int)
|
||||
{
|
||||
if (quanta > 0 && quanta <= quantaPerBlock)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, quanta, 3)
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setBlockToAir(x, y, z)
|
||||
}
|
||||
}
|
||||
|
||||
override def drain(world: World, x: Int, y: Int, z: Int, doDrain: Boolean): FluidStack =
|
||||
{
|
||||
val stack: FluidStack = new FluidStack(getFluid, (FluidContainerRegistry.BUCKET_VOLUME * this.getFilledPercentage(world, x, y, z)).asInstanceOf[Int])
|
||||
if (doDrain)
|
||||
{
|
||||
world.setBlockToAir(x, y, z)
|
||||
}
|
||||
return stack
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT) override def colorMultiplier(access: IBlockAccess, x: Int, y: Int, z: Int): Int =
|
||||
{
|
||||
return ResourceGenerator.getColor(ResourceGenerator.mixtureToMaterial(getFluid.getName))
|
||||
}
|
||||
|
||||
def mix(world: World, x: Int, y: Int, z: Int, stack: ItemStack): Boolean =
|
||||
{
|
||||
if (MachineRecipes.INSTANCE.getOutput(RecipeType.MIXER.name, stack).length > 0 && getQuantaValue(world, x, y, z) < quantaPerBlock)
|
||||
{
|
||||
if (getQuantaValue(world, x, y, z) < quantaPerBlock)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, getQuantaValue(world, x, y, z) + 1, 3)
|
||||
world.markBlockForUpdate(x, y, z)
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override def canDrain(world: World, x: Int, y: Int, z: Int): Boolean =
|
||||
{
|
||||
return true
|
||||
}
|
||||
|
||||
def getQuantaPerBlock: Int =
|
||||
{
|
||||
return quantaPerBlock
|
||||
}
|
||||
}
|
|
@ -1,222 +0,0 @@
|
|||
package resonantinduction.core.resource.fluid
|
||||
|
||||
import java.util.List
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.material.Material
|
||||
import net.minecraft.creativetab.CreativeTabs
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.init.Items
|
||||
import net.minecraft.item.{Item, ItemStack}
|
||||
import net.minecraft.util.MovingObjectPosition
|
||||
import net.minecraft.world.World
|
||||
import net.minecraftforge.common.MinecraftForge
|
||||
import net.minecraftforge.event.entity.player.FillBucketEvent
|
||||
import net.minecraftforge.fluids.{BlockFluidFinite, FluidRegistry}
|
||||
import resonant.lib.utility.LanguageUtility
|
||||
import resonant.lib.wrapper.WrapList._
|
||||
import resonantinduction.core.resource.ResourceGenerator
|
||||
|
||||
/** Modified version of the MC bucket to meet the needs of a dynamic fluid registry system
|
||||
*
|
||||
* @author Calclavia
|
||||
*/
|
||||
class ItemResourceBucket(isMolten: Boolean) extends Item
|
||||
{
|
||||
setMaxStackSize(1)
|
||||
setHasSubtypes(true)
|
||||
setMaxDamage(0)
|
||||
|
||||
override def getItemStackDisplayName(stack: ItemStack): String =
|
||||
{
|
||||
val material = ResourceGenerator.getMaterial(stack)
|
||||
if (material != null)
|
||||
{
|
||||
val fluidID: String = if (isMolten) ResourceGenerator.materialNameToMolten(material) else ResourceGenerator.materialNameToMixture(material)
|
||||
if (fluidID != null && FluidRegistry.getFluid(fluidID) != null)
|
||||
{
|
||||
val fluidName: String = FluidRegistry.getFluid(fluidID).getLocalizedName
|
||||
return (LanguageUtility.getLocal(this.getUnlocalizedName + ".name")).replace("%v", fluidName).replace(" ", " ")
|
||||
}
|
||||
return material
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/** Called whenever this item is ==uipped and the right mouse button is pressed. Args: itemStack,
|
||||
* world, entityPlayer */
|
||||
override def onItemRightClick(itemStack: ItemStack, world: World, entityPlayer: EntityPlayer): ItemStack =
|
||||
{
|
||||
val materialName = ResourceGenerator.getMaterial(itemStack)
|
||||
|
||||
if (materialName != null)
|
||||
{
|
||||
val moltenBlock: BlockFluidFinite = ResourceGenerator.getMolten(materialName)
|
||||
val mixBlock: BlockFluidFinite = ResourceGenerator.getMixture(materialName)
|
||||
val fluid: Block = if (isMolten) if (moltenBlock != null) moltenBlock else null else if (mixBlock != null) mixBlock else null
|
||||
if (fluid != null)
|
||||
{
|
||||
val movingobjectposition: MovingObjectPosition = this.getMovingObjectPositionFromPlayer(world, entityPlayer, false)
|
||||
if (movingobjectposition == null)
|
||||
{
|
||||
return itemStack
|
||||
}
|
||||
else
|
||||
{
|
||||
val event: FillBucketEvent = new FillBucketEvent(entityPlayer, itemStack, world, movingobjectposition)
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
return itemStack
|
||||
}
|
||||
if (event.getResult == Event.Result.ALLOW)
|
||||
{
|
||||
if (entityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
return itemStack
|
||||
}
|
||||
if (({itemStack.stackSize -= 1; itemStack.stackSize }) <= 0)
|
||||
{
|
||||
return event.result
|
||||
}
|
||||
if (!entityPlayer.inventory.addItemStackToInventory(event.result))
|
||||
{
|
||||
entityPlayer.dropPlayerItemWithRandomChoice(event.result, false)
|
||||
}
|
||||
return itemStack
|
||||
}
|
||||
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
{
|
||||
var i: Int = movingobjectposition.blockX
|
||||
var j: Int = movingobjectposition.blockY
|
||||
var k: Int = movingobjectposition.blockZ
|
||||
if (!world.canMineBlock(entityPlayer, i, j, k))
|
||||
{
|
||||
return itemStack
|
||||
}
|
||||
if (fluid == null)
|
||||
{
|
||||
if (!entityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, itemStack))
|
||||
{
|
||||
return itemStack
|
||||
}
|
||||
if (world.getBlock(i, j, k).getMaterial == Material.water && world.getBlockMetadata(i, j, k) == 0)
|
||||
{
|
||||
world.setBlockToAir(i, j, k)
|
||||
if (entityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
return itemStack
|
||||
}
|
||||
if (({itemStack.stackSize -= 1; itemStack.stackSize }) <= 0)
|
||||
{
|
||||
return new ItemStack(Items.water_bucket)
|
||||
}
|
||||
if (!entityPlayer.inventory.addItemStackToInventory(new ItemStack(Items.water_bucket)))
|
||||
{
|
||||
entityPlayer.dropPlayerItemWithRandomChoice(new ItemStack(Items.water_bucket, 1, 0), false)
|
||||
}
|
||||
return itemStack
|
||||
}
|
||||
if (world.getBlock(i, j, k).getMaterial == Material.lava && world.getBlockMetadata(i, j, k) == 0)
|
||||
{
|
||||
world.setBlockToAir(i, j, k)
|
||||
if (entityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
return itemStack
|
||||
}
|
||||
if (({itemStack.stackSize -= 1; itemStack.stackSize }) <= 0)
|
||||
{
|
||||
return new ItemStack(Items.lava_bucket)
|
||||
}
|
||||
if (!entityPlayer.inventory.addItemStackToInventory(new ItemStack(Items.lava_bucket)))
|
||||
{
|
||||
entityPlayer.dropPlayerItemWithRandomChoice(new ItemStack(Items.lava_bucket, 1, 0), false)
|
||||
}
|
||||
return itemStack
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fluid != null)
|
||||
{
|
||||
return new ItemStack(Items.bucket)
|
||||
}
|
||||
if (movingobjectposition.sideHit == 0)
|
||||
{
|
||||
j -= 1
|
||||
}
|
||||
if (movingobjectposition.sideHit == 1)
|
||||
{
|
||||
j += 1
|
||||
}
|
||||
if (movingobjectposition.sideHit == 2)
|
||||
{
|
||||
k -= 1
|
||||
}
|
||||
if (movingobjectposition.sideHit == 3)
|
||||
{
|
||||
k += 1
|
||||
}
|
||||
if (movingobjectposition.sideHit == 4)
|
||||
{
|
||||
i -= 1
|
||||
}
|
||||
if (movingobjectposition.sideHit == 5)
|
||||
{
|
||||
i += 1
|
||||
}
|
||||
if (!entityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, itemStack))
|
||||
{
|
||||
return itemStack
|
||||
}
|
||||
if (this.tryPlaceContainedLiquid(world, i, j, k, fluid) && !entityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
return new ItemStack(Items.bucket)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return itemStack
|
||||
}
|
||||
|
||||
/** Attempts to place the liquid contained inside the bucket. */
|
||||
def tryPlaceContainedLiquid(world: World, x: Int, y: Int, z: Int, fluidID: Block): Boolean =
|
||||
{
|
||||
if (fluidID == null)
|
||||
{
|
||||
return false
|
||||
}
|
||||
else
|
||||
{
|
||||
val material: Material = world.getBlock(x, y, z).getMaterial
|
||||
val flag: Boolean = !material.isSolid
|
||||
if (!world.isAirBlock(x, y, z) && !flag)
|
||||
{
|
||||
return false
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!world.isRemote && flag && !material.isLiquid)
|
||||
{
|
||||
world.setBlockToAir(x, y, z)
|
||||
}
|
||||
world.setBlock(x, y, z, fluidID, 8, 3)
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override def getSubItems(item: Item, tabs: CreativeTabs, list: List[_])
|
||||
{
|
||||
ResourceGenerator.materials foreach (m => list.add(ResourceGenerator.setMaterial(new ItemStack(this), m)))
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def getColorFromItemStack(itemStack: ItemStack, par2: Int): Int =
|
||||
{
|
||||
return ResourceGenerator.getColor(ResourceGenerator.getMaterial(itemStack))
|
||||
}
|
||||
}
|
|
@ -1,140 +0,0 @@
|
|||
package resonantinduction.core.resource.fluid;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import resonant.api.recipe.MachineRecipes;
|
||||
import resonantinduction.core.RecipeType;
|
||||
import resonantinduction.core.resource.ResourceGenerator;
|
||||
import resonantinduction.core.resource.TileMaterial;
|
||||
|
||||
/**
|
||||
* NO-OP. Not yet properly implemented. We're not using TEs for now.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class TileFluidMixture extends TileMaterial
|
||||
{
|
||||
public final Set<ItemStack> items = new HashSet<ItemStack>();
|
||||
public final Set<FluidStack> fluids = new HashSet<FluidStack>();
|
||||
|
||||
public TileFluidMixture()
|
||||
{
|
||||
super(Material.water);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean mix(ItemStack itemStack)
|
||||
{
|
||||
if (MachineRecipes.INSTANCE.getOutput(RecipeType.MIXER.name(), itemStack).length > 0 && getBlockMetadata() < 8)
|
||||
{
|
||||
// TODO: Maybe we need to merge the stacks?
|
||||
items.add(itemStack);
|
||||
|
||||
if (name() == null)
|
||||
{
|
||||
name_$eq(ResourceGenerator.getName(itemStack));
|
||||
}
|
||||
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, getBlockMetadata() + 1, 3);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void mix(FluidStack fluid)
|
||||
{
|
||||
if (!fluid.getFluid().isGaseous())
|
||||
{
|
||||
if (fluids.contains(fluid))
|
||||
{
|
||||
for (FluidStack checkFluid : fluids)
|
||||
{
|
||||
if (fluid.equals(checkFluid))
|
||||
{
|
||||
checkFluid.amount += fluid.amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fluids.add(fluid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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();
|
||||
items.clear();
|
||||
|
||||
NBTTagList fluidList = nbt.getTagList("Fluids", 0);
|
||||
|
||||
for (int i = 0; i < fluidList.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound fluidNBT = (NBTTagCompound) fluidList.getCompoundTagAt(i);
|
||||
fluids.add(FluidStack.loadFluidStackFromNBT(fluidNBT));
|
||||
}
|
||||
|
||||
NBTTagList itemList = nbt.getTagList("Items", 0);
|
||||
|
||||
for (int i = 0; i < itemList.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound stackTag = (NBTTagCompound) itemList.getCompoundTagAt(i);
|
||||
items.add(ItemStack.loadItemStackFromNBT(stackTag));
|
||||
}
|
||||
}
|
||||
|
||||
public void writeFluidToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
NBTTagList fluidList = new NBTTagList();
|
||||
|
||||
for (FluidStack fluid : fluids)
|
||||
{
|
||||
NBTTagCompound nbtElement = new NBTTagCompound();
|
||||
fluid.writeToNBT(nbtElement);
|
||||
fluidList.appendTag(nbtElement);
|
||||
}
|
||||
|
||||
nbt.setTag("Fluids", fluidList);
|
||||
|
||||
NBTTagList itemList = new NBTTagList();
|
||||
|
||||
for (ItemStack itemStack : items)
|
||||
{
|
||||
NBTTagCompound var4 = new NBTTagCompound();
|
||||
itemStack.writeToNBT(var4);
|
||||
itemList.appendTag(var4);
|
||||
}
|
||||
|
||||
nbt.setTag("Items", itemList);
|
||||
}
|
||||
}
|
|
@ -7,13 +7,12 @@ import cpw.mods.fml.common.network.NetworkRegistry
|
|||
import cpw.mods.fml.common.registry.GameRegistry
|
||||
import cpw.mods.fml.common.{Mod, ModMetadata, SidedProxy}
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.item.{Item, ItemStack}
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent
|
||||
import net.minecraftforge.oredict.OreDictionary
|
||||
import resonant.content.loader.ModManager
|
||||
import resonant.lib.loadable.LoadableHandler
|
||||
import resonantinduction.atomic.gate.ItemQuantumGlyph
|
||||
import resonantinduction.core.resource.ItemResourcePart
|
||||
import resonantinduction.core.{Reference, ResonantTab, Settings}
|
||||
import resonantinduction.electrical.battery.{ItemBlockBattery, TileBattery}
|
||||
import resonantinduction.electrical.generator.{TileMotor, TileSolarPanel, TileThermopile}
|
||||
|
@ -82,7 +81,7 @@ object Electrical {
|
|||
ElectricalContent.blockTesla = Electrical.contentRegistry.newBlock(classOf[TileTesla])
|
||||
ElectricalContent.blockBattery = Electrical.contentRegistry.newBlock(classOf[TileBattery])
|
||||
ElectricalContent.itemLevitator = Electrical.contentRegistry.newItem(classOf[ItemLevitator])
|
||||
ElectricalContent.itemInsulation = Electrical.contentRegistry.newItem("insulation", classOf[ItemResourcePart])
|
||||
ElectricalContent.itemInsulation = Electrical.contentRegistry.newItem("insulation", classOf[Item])
|
||||
ElectricalContent.blockSolarPanel = Electrical.contentRegistry.newBlock(classOf[TileSolarPanel])
|
||||
ElectricalContent.blockMotor = Electrical.contentRegistry.newBlock(classOf[TileMotor])
|
||||
ElectricalContent.blockThermopile = Electrical.contentRegistry.newBlock(classOf[TileThermopile])
|
||||
|
|
|
@ -2,7 +2,7 @@ package resonantinduction.mechanical.process.crusher;
|
|||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import resonantinduction.core.RecipeType;
|
||||
import resonant.content.factory.resources.RecipeType;
|
||||
import resonantinduction.mechanical.energy.grid.MechanicalNode;
|
||||
import resonantinduction.mechanical.energy.grid.TileMechanical;
|
||||
import net.minecraft.block.Block;
|
||||
|
|
|
@ -13,7 +13,7 @@ import resonant.api.recipe.MachineRecipes;
|
|||
import resonant.api.recipe.RecipeResource;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.RecipeType;
|
||||
import resonant.content.factory.resources.RecipeType;
|
||||
import resonantinduction.core.Timer;
|
||||
import universalelectricity.core.transform.region.Cuboid;
|
||||
import universalelectricity.core.transform.vector.Vector3;
|
||||
|
|
|
@ -5,7 +5,8 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import resonantinduction.core.RecipeType;
|
||||
import resonant.content.factory.resources.RecipeType;
|
||||
import resonant.engine.ResonantEngine;
|
||||
import resonantinduction.mechanical.energy.grid.TileMechanical;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -21,8 +22,7 @@ import resonant.api.recipe.MachineRecipes;
|
|||
import resonant.lib.utility.inventory.InventoryUtility;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.Timer;
|
||||
import resonantinduction.core.resource.ResourceGenerator;
|
||||
import resonantinduction.core.resource.fluid.BlockFluidMixture;
|
||||
import resonant.content.factory.resources.block.BlockFluidMixture;
|
||||
import universalelectricity.core.transform.rotation.Quaternion;
|
||||
import universalelectricity.core.transform.vector.Vector3;
|
||||
|
||||
|
@ -180,7 +180,7 @@ public class TileMixer extends TileMechanical implements IInventory
|
|||
if (mixPosition.getBlock(world()) != getBlockType())
|
||||
{
|
||||
Block block = mixPosition.getBlock(worldObj);
|
||||
Block blockFluidFinite = ResourceGenerator.getMixture(ResourceGenerator.getName(entity.getEntityItem()));
|
||||
Block blockFluidFinite = ResonantEngine.resourceFactory.getMixture(ResonantEngine.resourceFactory.getName(entity.getEntityItem()));
|
||||
|
||||
if (blockFluidFinite != null)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue