Merge branch 'development' of https://bitbucket.org/calclavia/resonant-induction into development

Conflicts:
	src/main/scala/resonantinduction/core/ResonantInduction.java
	src/main/scala/resonantinduction/core/resource/ResourceGenerator.java
This commit is contained in:
Calclavia 2014-03-25 21:10:46 +08:00
commit 5cf5b41dc1
4 changed files with 394 additions and 377 deletions

View file

@ -136,10 +136,10 @@ public class ResonantInduction
e.printStackTrace();
}
Settings.CONFIGURATION.save();
// Generate Resources
ResourceGenerator.generateOreResources();
proxy.postInit();
Settings.CONFIGURATION.save();
}
/**
@ -149,4 +149,5 @@ public class ResonantInduction
{
CRUSHER, GRINDER, MIXER, SMELTER, SAWMILL;
}
}

View file

@ -15,85 +15,85 @@ import cpw.mods.fml.common.ModMetadata;
/** @author Calclavia */
public class Settings
{
public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), Reference.NAME + ".cfg"));
public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), Reference.NAME + ".cfg"));
/** IDs suggested by Jyzarc and Horfius */
public static final IDManager idManager;
/** IDs suggested by Jyzarc and Horfius */
public static final IDManager idManager;
static
{
CONFIGURATION.load();
idManager = new IDManager(CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "BlockIDPrefix", 1200).getInt(1200), CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "ItemIDPrefix", 20150).getInt(20150));
CONFIGURATION.save();
}
static
{
CONFIGURATION.load();
idManager = new IDManager(CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "BlockIDPrefix", 1200).getInt(1200), CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "ItemIDPrefix", 20150).getInt(20150));
CONFIGURATION.save();
}
public static int getNextBlockID()
{
return idManager.getNextBlockID();
}
public static int getNextBlockID()
{
return idManager.getNextBlockID();
}
public static int getNextBlockID(String key)
{
int id = idManager.getNextBlockID();
return Settings.CONFIGURATION.get(Configuration.CATEGORY_BLOCK, key, id).getInt(id);
}
public static int getNextBlockID(String key)
{
int id = idManager.getNextBlockID();
return Settings.CONFIGURATION.get(Configuration.CATEGORY_BLOCK, key, id).getInt(id);
}
public static int getNextItemID()
{
return idManager.getNextItemID();
}
public static int getNextItemID()
{
return idManager.getNextItemID();
}
public static int getNextItemID(String key)
{
int id = idManager.getNextItemID();
return Settings.CONFIGURATION.get(Configuration.CATEGORY_ITEM, key, id).getInt(id);
}
public static int getNextItemID(String key)
{
int id = idManager.getNextItemID();
return Settings.CONFIGURATION.get(Configuration.CATEGORY_ITEM, key, id).getInt(id);
}
@Config(key = "Engineering Table Autocraft")
public static boolean ALLOW_ENGINEERING_AUTOCRAFT = true;
@Config(key = "Tesla Sound FXs")
public static boolean SOUND_FXS = true;
@Config(key = "Shiny silver Wires")
public static boolean SHINY_SILVER = true;
@Config(key = "Max EM Contractor Path")
public static int MAX_LEVITATOR_DISTANCE = 200;
@Config(category = Configuration.CATEGORY_GENERAL, key = "Levitator Max Reach")
public static int LEVITATOR_MAX_REACH = 40;
@Config(category = Configuration.CATEGORY_GENERAL, key = "Levitator Push Delay")
public static int LEVITATOR_PUSH_DELAY = 5;
@Config(category = Configuration.CATEGORY_GENERAL, key = "Levitator Max Speed")
public static double LEVITATOR_MAX_SPEED = .2;
@Config(category = Configuration.CATEGORY_GENERAL, key = "Levitator Acceleration")
public static double LEVITATOR_ACCELERATION = .02;
@Config(key = "Engineering Table Autocraft")
public static boolean ALLOW_ENGINEERING_AUTOCRAFT = true;
@Config(key = "Tesla Sound FXs")
public static boolean SOUND_FXS = true;
@Config(key = "Shiny silver Wires")
public static boolean SHINY_SILVER = true;
@Config(key = "Max EM Contractor Path")
public static int MAX_LEVITATOR_DISTANCE = 200;
@Config(category = Configuration.CATEGORY_GENERAL, key = "Levitator Max Reach")
public static int LEVITATOR_MAX_REACH = 40;
@Config(category = Configuration.CATEGORY_GENERAL, key = "Levitator Push Delay")
public static int LEVITATOR_PUSH_DELAY = 5;
@Config(category = Configuration.CATEGORY_GENERAL, key = "Levitator Max Speed")
public static double LEVITATOR_MAX_SPEED = .2;
@Config(category = Configuration.CATEGORY_GENERAL, key = "Levitator Acceleration")
public static double LEVITATOR_ACCELERATION = .02;
public static void setModMetadata(ModMetadata metadata, String id, String name)
{
setModMetadata(metadata, id, name, "");
}
public static void setModMetadata(ModMetadata metadata, String id, String name)
{
setModMetadata(metadata, id, name, "");
}
public static void setModMetadata(ModMetadata metadata, String id, String name, String parent)
{
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.parent = parent;
metadata.autogenerated = false;
}
public static void setModMetadata(ModMetadata metadata, String id, String name, String parent)
{
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.parent = parent;
metadata.autogenerated = false;
}
public static boolean isOp(String username)
{
MinecraftServer theServer = FMLCommonHandler.instance().getMinecraftServerInstance();
public static boolean isOp(String username)
{
MinecraftServer theServer = FMLCommonHandler.instance().getMinecraftServerInstance();
if (theServer != null)
{
return theServer.getConfigurationManager().getOps().contains(username.trim().toLowerCase());
}
if (theServer != null)
{
return theServer.getConfigurationManager().getOps().contains(username.trim().toLowerCase());
}
return false;
}
return false;
}
}

View file

@ -1,17 +1,16 @@
package resonantinduction.core.resource;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import javax.imageio.ImageIO;
import calclavia.api.recipe.MachineRecipes;
import calclavia.lib.config.Config;
import calclavia.lib.utility.LanguageUtility;
import calclavia.lib.utility.nbt.IVirtualObject;
import calclavia.lib.utility.nbt.NBTUtility;
import calclavia.lib.utility.nbt.SaveManager;
import com.google.common.collect.HashBiMap;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.item.Item;
@ -36,37 +35,25 @@ import resonantinduction.core.Settings;
import resonantinduction.core.fluid.FluidColored;
import resonantinduction.core.resource.fluid.BlockFluidMaterial;
import resonantinduction.core.resource.fluid.BlockFluidMixture;
import calclavia.api.recipe.MachineRecipes;
import calclavia.lib.config.Config;
import calclavia.lib.utility.LanguageUtility;
import calclavia.lib.utility.nbt.IVirtualObject;
import calclavia.lib.utility.nbt.NBTUtility;
import calclavia.lib.utility.nbt.SaveManager;
import com.google.common.collect.HashBiMap;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/** @author Calclavia */
/**
* @author Calclavia
*/
public class ResourceGenerator implements IVirtualObject
{
public static final ResourceGenerator INSTANCE = new ResourceGenerator();
@Config(comment = "Allow the Resource Generator to make ore dictionary compatible recipes?")
private static boolean allowOreDictCompatibility = true;
/**
* A list of material names. They are all camelCase reference of ore dictionary names without
* the "ore" or "ingot" prefix.
*
* Name, ID
*/
static int maxID = 0;
public static final HashBiMap<String, Integer> materials = HashBiMap.create();
static final HashMap<String, Integer> materialColorCache = new HashMap<String, Integer>();
static final HashMap<Icon, Integer> iconColorCache = new HashMap<Icon, Integer>();
@ -78,28 +65,19 @@ public class ResourceGenerator implements IVirtualObject
SaveManager.register(INSTANCE);
}
// TODO: Generate teh resource here instead of elsewhere...
@ForgeSubscribe
public void oreRegisterEvent(OreRegisterEvent evt)
{
if (evt.Name.startsWith("ingot"))
{
String oreDictName = evt.Name.replace("ingot", "");
String materialName = LanguageUtility.decapitalizeFirst(oreDictName);
if (!materials.containsKey(materialName))
{
Settings.CONFIGURATION.load();
boolean allowMaterial = Settings.CONFIGURATION.get("Resource_Generator", "Enable " + oreDictName, true).getBoolean(true);
Settings.CONFIGURATION.save();
if (!allowMaterial || OreDetectionBlackList.isIngotBlackListed("ingot" + oreDictName) || OreDetectionBlackList.isOreBlackListed("ore" + oreDictName))
return;
materials.put(materialName, maxID++);
}
}
}
@Config(category = "Resource_Generator", key = "Enable_All")
public static boolean ENABLED = true;
@Config(category = "Resource_Generator", key = "Enabled_All_Fluids")
public static boolean ENABLE_FLUIDS = true;
/**
* A list of material names. They are all camelCase reference of ore dictionary names without
* the "ore" or "ingot" prefix.
* <p/>
* Name, ID
*/
static int maxID = 0;
@Config(comment = "Allow the Resource Generator to make ore dictionary compatible recipes?")
private static boolean allowOreDictCompatibility = true;
public static void generate(String materialName)
{
@ -121,27 +99,38 @@ public class ResourceGenerator implements IVirtualObject
localizedName.replace(LanguageUtility.getLocal("misc.resonantinduction.ingot"), "").replaceAll("^ ", "").replaceAll(" $", "");
}
if (ENABLE_FLUIDS)
{
/** Generate molten fluids */
FluidColored fluidMolten = new FluidColored(materialNameToMolten(materialName));
fluidMolten.setDensity(7);
fluidMolten.setViscosity(5000);
fluidMolten.setTemperature(273 + 1538);
FluidRegistry.registerFluid(fluidMolten);
LanguageRegistry.instance().addStringLocalization(fluidMolten.getUnlocalizedName(), LanguageUtility.getLocal("tooltip.molten") + " " + localizedName);
BlockFluidMaterial blockFluidMaterial = new BlockFluidMaterial(fluidMolten);
GameRegistry.registerBlock(blockFluidMaterial, "molten" + nameCaps);
ResonantInduction.blockMoltenFluid.put(getID(materialName), blockFluidMaterial);
FluidContainerRegistry.registerFluidContainer(fluidMolten, ResonantInduction.itemBucketMolten.getStackFromMaterial(materialName));
/** Generate molten fluids */
FluidColored fluidMolten = new FluidColored(materialNameToMolten(materialName));
fluidMolten.setDensity(7);
fluidMolten.setViscosity(5000);
fluidMolten.setTemperature(273 + 1538);
FluidRegistry.registerFluid(fluidMolten);
LanguageRegistry.instance().addStringLocalization(fluidMolten.getUnlocalizedName(), LanguageUtility.getLocal("tooltip.molten") + " " + localizedName);
BlockFluidMaterial blockFluidMaterial = new BlockFluidMaterial(fluidMolten);
GameRegistry.registerBlock(blockFluidMaterial, "molten" + nameCaps);
ResonantInduction.blockMoltenFluid.put(getID(materialName), blockFluidMaterial);
FluidContainerRegistry.registerFluidContainer(fluidMolten, ResonantInduction.itemBucketMolten.getStackFromMaterial(materialName));
/** Generate dust mixture fluids */
FluidColored fluidMixture = new FluidColored(materialNameToMixture(materialName));
FluidRegistry.registerFluid(fluidMixture);
BlockFluidMixture blockFluidMixture = new BlockFluidMixture(fluidMixture);
LanguageRegistry.instance().addStringLocalization(fluidMixture.getUnlocalizedName(), localizedName + " " + LanguageUtility.getLocal("tooltip.mixture"));
GameRegistry.registerBlock(blockFluidMixture, "mixture" + nameCaps);
ResonantInduction.blockMixtureFluids.put(getID(materialName), blockFluidMixture);
FluidContainerRegistry.registerFluidContainer(fluidMixture, ResonantInduction.itemBucketMixture.getStackFromMaterial(materialName));
/** Generate dust mixture fluids */
FluidColored fluidMixture = new FluidColored(materialNameToMixture(materialName));
FluidRegistry.registerFluid(fluidMixture);
BlockFluidMixture blockFluidMixture = new BlockFluidMixture(fluidMixture);
LanguageRegistry.instance().addStringLocalization(fluidMixture.getUnlocalizedName(), localizedName + " " + LanguageUtility.getLocal("tooltip.mixture"));
GameRegistry.registerBlock(blockFluidMixture, "mixture" + nameCaps);
ResonantInduction.blockMixtureFluids.put(getID(materialName), blockFluidMixture);
FluidContainerRegistry.registerFluidContainer(fluidMixture, ResonantInduction.itemBucketMixture.getStackFromMaterial(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);
}
}
ItemStack dust = ResonantInduction.itemDust.getStackFromMaterial(materialName);
ItemStack rubble = ResonantInduction.itemRubble.getStackFromMaterial(materialName);
@ -155,13 +144,11 @@ public class ResourceGenerator implements IVirtualObject
MachineRecipes.INSTANCE.addRecipe(RecipeType.GRINDER.name(), "rubble" + nameCaps, dust, dust);
MachineRecipes.INSTANCE.addRecipe(RecipeType.MIXER.name(), "dirtyDust" + nameCaps, refinedDust);
MachineRecipes.INSTANCE.addRecipe(RecipeType.SMELTER.name(), new FluidStack(fluidMolten, FluidContainerRegistry.BUCKET_VOLUME), "ingot" + nameCaps);
}
else
{
MachineRecipes.INSTANCE.addRecipe(RecipeType.GRINDER.name(), rubble, dust, dust);
MachineRecipes.INSTANCE.addRecipe(RecipeType.MIXER.name(), dust, refinedDust);
MachineRecipes.INSTANCE.addRecipe(RecipeType.SMELTER.name(), new FluidStack(fluidMolten, FluidContainerRegistry.BUCKET_VOLUME), "ingot" + nameCaps);
}
FurnaceRecipes.smelting().addSmelting(dust.itemID, dust.getItemDamage(), OreDictionary.getOres("ingot" + nameCaps).get(0).copy(), 0.7f);
@ -203,19 +190,16 @@ public class ResourceGenerator implements IVirtualObject
String nameCaps = LanguageUtility.capitalizeFirst(materialName);
if (OreDictionary.getOres("ore" + nameCaps).size() > 0)
{
generate(materialName);
}
else
{
it.remove();
}
}
}
@ForgeSubscribe
@SideOnly(Side.CLIENT)
public void reloadTextures(TextureStitchEvent.Post e)
{
computeColors();
}
@SideOnly(Side.CLIENT)
public static void computeColors()
{
@ -244,7 +228,7 @@ public class ResourceGenerator implements IVirtualObject
/**
* Gets the average color of this item.
*
*
* @param itemStack
* @return The RGB hexadecimal color code.
*/
@ -402,6 +386,38 @@ public class ResourceGenerator implements IVirtualObject
return returnMaterials;
}
// TODO: Generate teh resource here instead of elsewhere...
@ForgeSubscribe
public void oreRegisterEvent(OreRegisterEvent evt)
{
if (evt.Name.startsWith("ingot"))
{
String oreDictName = evt.Name.replace("ingot", "");
String materialName = LanguageUtility.decapitalizeFirst(oreDictName);
if (!materials.containsKey(materialName))
{
Settings.CONFIGURATION.load();
boolean allowMaterial = Settings.CONFIGURATION.get("Resource_Generator", "Enable " + oreDictName, true).getBoolean(true);
Settings.CONFIGURATION.save();
if (!allowMaterial || OreDetectionBlackList.isIngotBlackListed("ingot" + oreDictName) || OreDetectionBlackList.isOreBlackListed("ore" + oreDictName))
{
return;
}
materials.put(materialName, maxID++);
}
}
}
@ForgeSubscribe
@SideOnly(Side.CLIENT)
public void reloadTextures(TextureStitchEvent.Post e)
{
computeColors();
}
@Override
public void save(NBTTagCompound nbt)
{

View file

@ -13,6 +13,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.Event;
import net.minecraftforge.event.entity.player.FillBucketEvent;
import net.minecraftforge.fluids.BlockFluidFinite;
import net.minecraftforge.fluids.FluidRegistry;
import resonantinduction.core.Reference;
import resonantinduction.core.TabRI;
@ -22,269 +23,268 @@ import calclavia.lib.utility.LanguageUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* Modified version of the MC bucket to meet the needs of a dynamic fluid registry system
/** Modified version of the MC bucket to meet the needs of a dynamic fluid registry system
*
* @author Darkguardsman
*/
* @author Darkguardsman */
public class ItemOreResourceBucket extends Item
{
final boolean isMolten;
final boolean isMolten;
public ItemOreResourceBucket(int id, String name, boolean isMolten)
{
super(id);
this.isMolten = isMolten;
setMaxStackSize(1);
setUnlocalizedName(Reference.PREFIX + name);
setTextureName(Reference.PREFIX + name);
setCreativeTab(TabRI.CORE);
setHasSubtypes(true);
setMaxDamage(0);
}
public ItemOreResourceBucket(int id, String name, boolean isMolten)
{
super(id);
this.isMolten = isMolten;
setMaxStackSize(1);
setUnlocalizedName(Reference.PREFIX + name);
setTextureName(Reference.PREFIX + name);
setCreativeTab(TabRI.CORE);
setHasSubtypes(true);
setMaxDamage(0);
}
@Override
public String getItemDisplayName(ItemStack is)
{
String material = getMaterialFromStack(is);
@Override
public String getItemDisplayName(ItemStack is)
{
String material = getMaterialFromStack(is);
if (material != null)
{
String fluidID = isMolten ? ResourceGenerator.materialNameToMolten(material) : ResourceGenerator.materialNameToMixture(material);
if (material != null)
{
String fluidID = isMolten ? ResourceGenerator.materialNameToMolten(material) : ResourceGenerator.materialNameToMixture(material);
if (fluidID != null && FluidRegistry.getFluid(fluidID) != null)
{
String fluidName = FluidRegistry.getFluid(fluidID).getLocalizedName();
return (LanguageUtility.getLocal(this.getUnlocalizedName() + ".name")).replace("%v", fluidName).replace(" ", " ");
}
if (fluidID != null && FluidRegistry.getFluid(fluidID) != null)
{
String fluidName = FluidRegistry.getFluid(fluidID).getLocalizedName();
return (LanguageUtility.getLocal(this.getUnlocalizedName() + ".name")).replace("%v", fluidName).replace(" ", " ");
}
return material;
}
return material;
}
return null;
}
return null;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack,
* world, entityPlayer
*/
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer)
{
String materialName = ResourceGenerator.getName(itemStack.getItemDamage());
int fluidID = isMolten ? ResourceGenerator.getMolten(materialName).blockID : ResourceGenerator.getMixture(materialName).blockID;
/** Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack,
* world, entityPlayer */
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer)
{
String materialName = ResourceGenerator.getName(itemStack.getItemDamage());
if (materialName != null)
{
BlockFluidFinite molten_block = ResourceGenerator.getMolten(materialName);
BlockFluidFinite mix_block = ResourceGenerator.getMixture(materialName);
int fluidID = isMolten ? molten_block != null ? molten_block.blockID : 0 : mix_block != null ? mix_block.blockID : 0;
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, entityPlayer, false);
if (fluidID > 0)
{
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, entityPlayer, false);
if (movingobjectposition == null)
{
return itemStack;
}
else
{
FillBucketEvent event = new FillBucketEvent(entityPlayer, itemStack, world, movingobjectposition);
if (MinecraftForge.EVENT_BUS.post(event))
{
return itemStack;
}
if (movingobjectposition == null)
{
return itemStack;
}
else
{
FillBucketEvent event = 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 (event.getResult() == Event.Result.ALLOW)
{
if (entityPlayer.capabilities.isCreativeMode)
{
return itemStack;
}
if (--itemStack.stackSize <= 0)
{
return event.result;
}
if (--itemStack.stackSize <= 0)
{
return event.result;
}
if (!entityPlayer.inventory.addItemStackToInventory(event.result))
{
entityPlayer.dropPlayerItem(event.result);
}
if (!entityPlayer.inventory.addItemStackToInventory(event.result))
{
entityPlayer.dropPlayerItem(event.result);
}
return itemStack;
}
return itemStack;
}
if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE)
{
int i = movingobjectposition.blockX;
int j = movingobjectposition.blockY;
int k = movingobjectposition.blockZ;
if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE)
{
int i = movingobjectposition.blockX;
int j = movingobjectposition.blockY;
int k = movingobjectposition.blockZ;
if (!world.canMineBlock(entityPlayer, i, j, k))
{
return itemStack;
}
if (!world.canMineBlock(entityPlayer, i, j, k))
{
return itemStack;
}
if (fluidID == 0)
{
if (!entityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, itemStack))
{
return itemStack;
}
if (fluidID == 0)
{
if (!entityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, itemStack))
{
return itemStack;
}
if (world.getBlockMaterial(i, j, k) == Material.water && world.getBlockMetadata(i, j, k) == 0)
{
world.setBlockToAir(i, j, k);
if (world.getBlockMaterial(i, j, k) == Material.water && world.getBlockMetadata(i, j, k) == 0)
{
world.setBlockToAir(i, j, k);
if (entityPlayer.capabilities.isCreativeMode)
{
return itemStack;
}
if (entityPlayer.capabilities.isCreativeMode)
{
return itemStack;
}
if (--itemStack.stackSize <= 0)
{
return new ItemStack(Item.bucketWater);
}
if (--itemStack.stackSize <= 0)
{
return new ItemStack(Item.bucketWater);
}
if (!entityPlayer.inventory.addItemStackToInventory(new ItemStack(Item.bucketWater)))
{
entityPlayer.dropPlayerItem(new ItemStack(Item.bucketWater.itemID, 1, 0));
}
if (!entityPlayer.inventory.addItemStackToInventory(new ItemStack(Item.bucketWater)))
{
entityPlayer.dropPlayerItem(new ItemStack(Item.bucketWater.itemID, 1, 0));
}
return itemStack;
}
return itemStack;
}
if (world.getBlockMaterial(i, j, k) == Material.lava && world.getBlockMetadata(i, j, k) == 0)
{
world.setBlockToAir(i, j, k);
if (world.getBlockMaterial(i, j, k) == Material.lava && world.getBlockMetadata(i, j, k) == 0)
{
world.setBlockToAir(i, j, k);
if (entityPlayer.capabilities.isCreativeMode)
{
return itemStack;
}
if (entityPlayer.capabilities.isCreativeMode)
{
return itemStack;
}
if (--itemStack.stackSize <= 0)
{
return new ItemStack(Item.bucketLava);
}
if (--itemStack.stackSize <= 0)
{
return new ItemStack(Item.bucketLava);
}
if (!entityPlayer.inventory.addItemStackToInventory(new ItemStack(Item.bucketLava)))
{
entityPlayer.dropPlayerItem(new ItemStack(Item.bucketLava.itemID, 1, 0));
}
if (!entityPlayer.inventory.addItemStackToInventory(new ItemStack(Item.bucketLava)))
{
entityPlayer.dropPlayerItem(new ItemStack(Item.bucketLava.itemID, 1, 0));
}
return itemStack;
}
}
else
{
if (fluidID < 0)
{
return new ItemStack(Item.bucketEmpty);
}
return itemStack;
}
}
else
{
if (fluidID < 0)
{
return new ItemStack(Item.bucketEmpty);
}
if (movingobjectposition.sideHit == 0)
{
--j;
}
if (movingobjectposition.sideHit == 0)
{
--j;
}
if (movingobjectposition.sideHit == 1)
{
++j;
}
if (movingobjectposition.sideHit == 1)
{
++j;
}
if (movingobjectposition.sideHit == 2)
{
--k;
}
if (movingobjectposition.sideHit == 2)
{
--k;
}
if (movingobjectposition.sideHit == 3)
{
++k;
}
if (movingobjectposition.sideHit == 3)
{
++k;
}
if (movingobjectposition.sideHit == 4)
{
--i;
}
if (movingobjectposition.sideHit == 4)
{
--i;
}
if (movingobjectposition.sideHit == 5)
{
++i;
}
if (movingobjectposition.sideHit == 5)
{
++i;
}
if (!entityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, itemStack))
{
return itemStack;
}
if (!entityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, itemStack))
{
return itemStack;
}
if (this.tryPlaceContainedLiquid(world, i, j, k, fluidID) && !entityPlayer.capabilities.isCreativeMode)
{
return new ItemStack(Item.bucketEmpty);
}
}
}
if (this.tryPlaceContainedLiquid(world, i, j, k, fluidID) && !entityPlayer.capabilities.isCreativeMode)
{
return new ItemStack(Item.bucketEmpty);
}
}
}
}
}
}
return itemStack;
}
return itemStack;
}
}
/** Attempts to place the liquid contained inside the bucket. */
public boolean tryPlaceContainedLiquid(World world, int x, int y, int z, int fluidID)
{
if (fluidID <= 0)
{
return false;
}
else
{
Material material = world.getBlockMaterial(x, y, z);
boolean flag = !material.isSolid();
/**
* Attempts to place the liquid contained inside the bucket.
*/
public boolean tryPlaceContainedLiquid(World world, int x, int y, int z, int fluidID)
{
if (fluidID <= 0)
{
return false;
}
else
{
Material material = world.getBlockMaterial(x, y, z);
boolean flag = !material.isSolid();
if (!world.isAirBlock(x, y, z) && !flag)
{
return false;
}
else
{
if (!world.isAirBlock(x, y, z) && !flag)
{
return false;
}
else
{
if (!world.isRemote && flag && !material.isLiquid())
{
world.destroyBlock(x, y, z, true);
}
if (!world.isRemote && flag && !material.isLiquid())
{
world.destroyBlock(x, y, z, true);
}
world.setBlock(x, y, z, fluidID, 8, 3);
world.setBlock(x, y, z, fluidID, 8, 3);
return true;
}
}
}
return true;
}
}
}
public ItemStack getStackFromMaterial(String name)
{
ItemStack itemStack = new ItemStack(this);
itemStack.setItemDamage(ResourceGenerator.getID(name));
return itemStack;
}
public ItemStack getStackFromMaterial(String name)
{
ItemStack itemStack = new ItemStack(this);
itemStack.setItemDamage(ResourceGenerator.getID(name));
return itemStack;
}
public static String getMaterialFromStack(ItemStack itemStack)
{
return ResourceGenerator.getName(itemStack.getItemDamage());
}
public static String getMaterialFromStack(ItemStack itemStack)
{
return ResourceGenerator.getName(itemStack.getItemDamage());
}
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (String materialName : ResourceGenerator.materials.keySet())
{
par3List.add(getStackFromMaterial(materialName));
}
}
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (String materialName : ResourceGenerator.materials.keySet())
{
par3List.add(getStackFromMaterial(materialName));
}
}
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack itemStack, int par2)
{
/**
* Auto-color based on the texture of the ingot.
*/
String name = ItemOreResource.getMaterialFromStack(itemStack);
return ResourceGenerator.getColor(name);
}
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack itemStack, int par2)
{
/** Auto-color based on the texture of the ingot. */
String name = ItemOreResource.getMaterialFromStack(itemStack);
return ResourceGenerator.getColor(name);
}
}