Removed Magnetic Miner

This commit is contained in:
Ellpeck 2015-10-30 23:24:49 +01:00
parent 96581ba7cf
commit e404bbf783
16 changed files with 2 additions and 582 deletions

View file

@ -1,91 +0,0 @@
/*
* This file ("BlockOreMagnet.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.ActuallyAdditions;
import ellpeck.actuallyadditions.inventory.GuiHandler;
import ellpeck.actuallyadditions.tile.TileEntityOreMagnet;
import ellpeck.actuallyadditions.util.IActAddItemOrBlock;
import ellpeck.actuallyadditions.util.ModUtil;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class BlockOreMagnet extends BlockContainerBase implements IActAddItemOrBlock{
@SideOnly(Side.CLIENT)
private IIcon topIcon;
@SideOnly(Side.CLIENT)
private IIcon bottomIcon;
public BlockOreMagnet(){
super(Material.rock);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityOreMagnet();
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta){
return (side == 1 ? this.topIcon : (side == 0 ? this.bottomIcon : this.blockIcon));
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityOreMagnet magnet = (TileEntityOreMagnet)world.getTileEntity(x, y, z);
if(magnet != null){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.ORE_MAGNET.ordinal(), world, x, y, z);
}
return true;
}
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName());
this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName()+"Top");
this.bottomIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName()+"Bottom");
}
@Override
public String getName(){
return "blockOreMagnet";
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.epic;
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6){
this.dropInventory(world, x, y, z);
super.breakBlock(world, x, y, z, block, par6);
}
}

View file

@ -89,7 +89,6 @@ public class InitBlocks{
public static Block blockTreasureChest;
public static Block blockXPSolidifier;
public static Block blockOreMagnet;
public static Block blockSmileyCloud;
@ -117,9 +116,6 @@ public class InitBlocks{
blockSmileyCloud = new BlockSmileyCloud();
BlockUtil.register(blockSmileyCloud);
blockOreMagnet = new BlockOreMagnet();
BlockUtil.register(blockOreMagnet);
blockXPSolidifier = new BlockXPSolidifier();
BlockUtil.register(blockXPSolidifier);

View file

@ -81,8 +81,7 @@ public class InitBooklet{
new BookletChapterCoffee("coffeeMachine", entryFunctionalRF, new ItemStack(InitBlocks.blockCoffeeMachine), new PageTextOnly(1).setStack(new ItemStack(InitItems.itemCoffeeBean)).addTextReplacement("<rf>", ConfigIntValues.COFFEE_MACHINE_ENERGY_USED.getValue()).addTextReplacement("<coffee>", ConfigIntValues.COFFEE_CACHE_USED_PER_ITEM.getValue()).addTextReplacement("<water>", ConfigIntValues.COFFEE_MACHINE_WATER_USED.getValue()), new PageTextOnly(2).setStack(new ItemStack(InitItems.itemCoffee)), new PagePicture(3, "pageCoffeeMachine", 115), new PageCrafting(4, BlockCrafting.recipeCoffeeMachine).setNoText(), new PageCrafting(5, ItemCrafting.recipeCup).setNoText()).setImportant();
new BookletChapter("crusher", entryFunctionalRF, new ItemStack(InitBlocks.blockGrinderDouble), new PageTextOnly(1).addTextReplacement("<rf1>", ConfigIntValues.GRINDER_ENERGY_USED.getValue()).addTextReplacement("<rf2>", ConfigIntValues.GRINDER_DOUBLE_ENERGY_USED.getValue()), new PageCrafting(2, BlockCrafting.recipeCrusher).setNoText(), new PageCrafting(3, BlockCrafting.recipeDoubleCrusher).setNoText(), new PageCrusherRecipe(4, CrusherCrafting.recipeSugar).setNoText(), new PageCrusherRecipe(5, CrusherCrafting.recipeIronHorseArmor).setNoText(), new PageCrusherRecipe(6, CrusherCrafting.recipeGoldHorseArmor).setNoText(), new PageCrusherRecipe(7, CrusherCrafting.recipeDiamondHorseArmor).setNoText());
new BookletChapter("furnaceDouble", entryFunctionalRF, new ItemStack(InitBlocks.blockFurnaceDouble), new PageCrafting(1, BlockCrafting.recipeFurnace).addTextReplacement("<rf>", ConfigIntValues.FURNACE_ENERGY_USED.getValue()));
new BookletChapter("miner", entryFunctionalRF, new ItemStack(InitBlocks.blockOreMagnet), new PageTextOnly(1).addTextReplacement("<rf>", ConfigIntValues.ORE_MAGNET_ENERGY_USE.getValue()).addTextReplacement("<oil>", ConfigIntValues.ORE_MAGNET_OIL_USE.getValue()).addTextReplacement("<range>", ConfigIntValues.ORE_MAGNET_RANGE.getValue()), new PageCrafting(2, BlockCrafting.recipeMiner).setNoText(), new PageCrafting(3, BlockCrafting.recipeCasing).setNoText());
new BookletChapter("lavaFactory", entryFunctionalRF, new ItemStack(InitBlocks.blockLavaFactoryController), new PageTextOnly(1).addTextReplacement("<rf>", ConfigIntValues.LAVA_FACTORY_ENERGY_USED.getValue()), new PagePicture(2, "pageLavaFactory", 0).setNoText(), new PageCrafting(3, BlockCrafting.recipeLavaFactory).setNoText());
new BookletChapter("lavaFactory", entryFunctionalRF, new ItemStack(InitBlocks.blockLavaFactoryController), new PageTextOnly(1).addTextReplacement("<rf>", ConfigIntValues.LAVA_FACTORY_ENERGY_USED.getValue()), new PagePicture(2, "pageLavaFactory", 0).setNoText(), new PageCrafting(3, BlockCrafting.recipeLavaFactory).setNoText(), new PageCrafting(4, BlockCrafting.recipeCasing).setNoText());
new BookletChapter("energizer", entryFunctionalRF, new ItemStack(InitBlocks.blockEnergizer), new PageCrafting(1, BlockCrafting.recipeEnergizer), new PageCrafting(2, BlockCrafting.recipeEnervator));
new BookletChapter("repairer", entryFunctionalRF, new ItemStack(InitBlocks.blockItemRepairer), new PageCrafting(1, BlockCrafting.recipeRepairer).addTextReplacement("<rf>", ConfigIntValues.REPAIRER_ENERGY_USED.getValue()));
new BookletChapter("longRangeBreaker", entryFunctionalRF, new ItemStack(InitBlocks.blockDirectionalBreaker), new PageTextOnly(1).addTextReplacement("<rf>", ConfigIntValues.DIRECTIONAL_BREAKER_RF_PER_BLOCK.getValue()).addTextReplacement("<range>", ConfigIntValues.DIRECTIONAL_BREAKER_RANGE.getValue()), new PageCrafting(2, BlockCrafting.recipeDirectionalBreaker));

View file

@ -26,9 +26,6 @@ public class ConfigValues{
public static String[] crusherRecipeExceptions;
public static String[] mashedFoodCraftingExceptions;
public static String[] oreMagnetExceptions;
public static String[] oreMagnetExtraWhitelist;
public static String[] paxelExtraMiningWhitelist;
public static String[] drillExtraminingWhitelist;
@ -49,8 +46,6 @@ public class ConfigValues{
crusherRecipeExceptions = config.get(ConfigCategories.CRUSHER_RECIPES.name, "Crusher Recipe Exceptions", new String[]{"ingotBrick", "ingotBrickNether"}, "The Ingots, Dusts and Ores blacklisted from being auto-registered to be crushed by the Crusher. This list uses OreDictionary Names of the Inputs only.").getStringList();
mashedFoodCraftingExceptions = config.get(ConfigCategories.ITEMS_CRAFTING.name, "Mashed Food Crafting Exceptions", new String[]{"ActuallyAdditions:itemCoffee"}, "The ItemFood, IGrowable and IPlantable Items that can not be used to craft Mashed Food. These are the actual registered Item Names, the ones you use, for example, when using the /give Command.").getStringList();
oreMagnetExceptions = config.get(ConfigCategories.MACHINE_VALUES.name, "Ore Magnet Exceptions", new String[0], "By default, the Ore Magnet pulls up everything that is registered in the OreDictionary as a String that starts with 'ore'. If you want any Ore not to be pulled up by the Magnet, put its ORE DICTIONARY name here.").getStringList();
oreMagnetExtraWhitelist = config.get(ConfigCategories.MACHINE_VALUES.name, "Ore Magnet Extra Whitelist", new String[]{"rftools:dimensionalShardBlock"}, "By default, the Ore Magnet pulls up everything that is registered in the OreDictionary as a String that starts with 'ore'. If you want anything else to be pulled up by the Magnet, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command.").getStringList();
paxelExtraMiningWhitelist = config.get(ConfigCategories.TOOL_VALUES.name, "AIOT Extra Whitelist", new String[]{"TConstruct:GravelOre"}, "By default, the AIOT can mine certain blocks. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command.").getStringList();
drillExtraminingWhitelist = config.get(ConfigCategories.TOOL_VALUES.name, "Drill Extra Whitelist", new String[]{"TConstruct:GravelOre"}, "By default, the Drill can mine certain blocks. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command.").getStringList();
}

View file

@ -147,7 +147,6 @@ public enum ConfigCrafting{
TELE_STAFF("Tele Staff", ConfigCategories.ITEMS_CRAFTING),
CASING("Casing", ConfigCategories.BLOCKS_CRAFTING),
ORE_MAGNET("Ore Magnet", ConfigCategories.BLOCKS_CRAFTING),
MAGNET_RING("Magnet Ring", ConfigCategories.ITEMS_CRAFTING),
WATER_RING("Water Ring", ConfigCategories.ITEMS_CRAFTING),

View file

@ -51,7 +51,6 @@ public class BlockCrafting{
public static IRecipe recipeDoubleCrusher;
public static IRecipe recipeFurnace;
public static IRecipe recipeSolidifier;
public static IRecipe recipeMiner;
public static IRecipe recipeCasing;
public static IRecipe recipeGlass;
public static IRecipe recipeLavaFactory;
@ -248,17 +247,6 @@ public class BlockCrafting{
recipeCanolaPress = Util.GetRecipes.lastIRecipe();
}
//Ore Magnet
if(ConfigCrafting.ORE_MAGNET.isEnabled()){
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockOreMagnet),
"SSS", "CBC", "ISI",
'S', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.LAVA_FACTORY_CASE.ordinal()),
'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()),
'B', new ItemStack(InitItems.itemBatteryDouble),
'I', new ItemStack(Blocks.iron_block)));
recipeMiner = Util.GetRecipes.lastIRecipe();
}
//Fermenting Barrel
if(ConfigCrafting.FERMENTING_BARREL.isEnabled()){
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockFermentingBarrel),

View file

@ -62,8 +62,6 @@ public class CreativeTab extends CreativeTabs{
add(InitBlocks.blockCoffeeMachine);
add(InitBlocks.blockXPSolidifier);
add(InitBlocks.blockOreMagnet);
add(InitBlocks.blockGreenhouseGlass);
add(InitBlocks.blockGrinder);
add(InitBlocks.blockGrinderDouble);

View file

@ -1,106 +0,0 @@
/*
* This file ("ContainerOreMagnet.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.inventory;
import ellpeck.actuallyadditions.blocks.InitBlocks;
import ellpeck.actuallyadditions.inventory.slot.SlotOutput;
import ellpeck.actuallyadditions.tile.TileEntityBase;
import ellpeck.actuallyadditions.tile.TileEntityOreMagnet;
import invtweaks.api.container.InventoryContainer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
@InventoryContainer
public class ContainerOreMagnet extends Container{
private TileEntityOreMagnet magnet;
public ContainerOreMagnet(InventoryPlayer inventory, TileEntityBase tile){
this.magnet = (TileEntityOreMagnet)tile;
this.addSlotToContainer(new Slot(this.magnet, TileEntityOreMagnet.SLOT_OIL_INPUT, 98, 74));
this.addSlotToContainer(new SlotOutput(this.magnet, TileEntityOreMagnet.SLOT_OIL_OUTPUT, 98, 43));
this.addSlotToContainer(new SlotOutput(this.magnet, TileEntityOreMagnet.SLOT_UPGRADE, 71, 43));
for(int i = 0; i < 3; i++){
for(int j = 0; j < 9; j++){
this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18));
}
}
for(int i = 0; i < 9; i++){
this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
final int inventoryStart = 3;
final int inventoryEnd = inventoryStart+26;
final int hotbarStart = inventoryEnd+1;
final int hotbarEnd = hotbarStart+8;
Slot theSlot = (Slot)this.inventorySlots.get(slot);
if(theSlot != null && theSlot.getHasStack()){
ItemStack newStack = theSlot.getStack();
ItemStack currentStack = newStack.copy();
//Other Slots in Inventory excluded
if(slot >= inventoryStart){
//Shift from Inventory
if(FluidContainerRegistry.containsFluid(newStack, new FluidStack(InitBlocks.fluidOil, 1))){
if(!this.mergeItemStack(newStack, TileEntityOreMagnet.SLOT_OIL_INPUT, TileEntityOreMagnet.SLOT_OIL_INPUT+1, false)){
return null;
}
}
//
else if(slot >= inventoryStart && slot <= inventoryEnd){
if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){
return null;
}
}
else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){
return null;
}
}
else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){
return null;
}
if(newStack.stackSize == 0){
theSlot.putStack(null);
}
else{
theSlot.onSlotChanged();
}
if(newStack.stackSize == currentStack.stackSize){
return null;
}
theSlot.onPickupFromSlot(player, newStack);
return currentStack;
}
return null;
}
@Override
public boolean canInteractWith(EntityPlayer player){
return this.magnet.isUseableByPlayer(player);
}
}

View file

@ -78,8 +78,6 @@ public class GuiHandler implements IGuiHandler{
return new ContainerEnervator(entityPlayer, tile);
case XP_SOLIDIFIER:
return new ContainerXPSolidifier(entityPlayer.inventory, tile);
case ORE_MAGNET:
return new ContainerOreMagnet(entityPlayer.inventory, tile);
case CLOUD:
return new ContainerSmileyCloud();
case DIRECTIONAL_BREAKER:
@ -142,8 +140,6 @@ public class GuiHandler implements IGuiHandler{
return new GuiEnervator(entityPlayer, tile);
case XP_SOLIDIFIER:
return new GuiXPSolidifier(entityPlayer.inventory, tile, x, y, z, world);
case ORE_MAGNET:
return new GuiOreMagnet(entityPlayer.inventory, tile);
case CLOUD:
return new GuiSmileyCloud(tile, x, y, z, world);
case BOOK:
@ -180,7 +176,6 @@ public class GuiHandler implements IGuiHandler{
ENERGIZER,
ENERVATOR,
XP_SOLIDIFIER,
ORE_MAGNET,
CLOUD,
BOOK(false),
DIRECTIONAL_BREAKER,

View file

@ -1,82 +0,0 @@
/*
* This file ("GuiOreMagnet.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.inventory.gui;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.inventory.ContainerOreMagnet;
import ellpeck.actuallyadditions.tile.TileEntityBase;
import ellpeck.actuallyadditions.tile.TileEntityOreMagnet;
import ellpeck.actuallyadditions.util.AssetUtil;
import ellpeck.actuallyadditions.util.StringUtil;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import java.util.Arrays;
import java.util.Collections;
@SideOnly(Side.CLIENT)
public class GuiOreMagnet extends GuiContainer{
private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiOreMagnet");
private TileEntityOreMagnet magnet;
public GuiOreMagnet(InventoryPlayer inventory, TileEntityBase tile){
super(new ContainerOreMagnet(inventory, tile));
this.magnet = (TileEntityOreMagnet)tile;
this.xSize = 176;
this.ySize = 93+86;
}
@Override
public void drawScreen(int x, int y, float f){
super.drawScreen(x, y, f);
String text1 = this.magnet.storage.getEnergyStored()+"/"+this.magnet.storage.getMaxEnergyStored()+" RF";
if(x >= guiLeft+43 && y >= guiTop+6 && x <= guiLeft+58 && y <= guiTop+88){
this.func_146283_a(Collections.singletonList(text1), x, y);
}
String text2 = this.magnet.tank.getFluidAmount()+"/"+this.magnet.tank.getCapacity()+" mB "+StringUtil.localize("fluid.oil");
if(x >= guiLeft+117 && y >= guiTop+6 && x <= guiLeft+132 && y <= guiTop+88){
this.func_146283_a(Collections.singletonList(text2), x, y);
}
if(x >= guiLeft+70 && y >= guiTop+42 && x <= guiLeft+70+18 && y <= guiTop+42+18){
this.func_146283_a(Arrays.asList("@SuppressWarnings(\"unused\")", "This slot is currently unused. Ignore it."), x, y);
}
}
@Override
public void drawGuiContainerForegroundLayer(int x, int y){
AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.magnet.getInventoryName());
}
@Override
public void drawGuiContainerBackgroundLayer(float f, int x, int y){
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION);
this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86);
this.mc.getTextureManager().bindTexture(resLoc);
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93);
if(this.magnet.storage.getEnergyStored() > 0){
int i = this.magnet.getEnergyScaled(83);
drawTexturedModalRect(this.guiLeft+43, this.guiTop+89-i, 176, 0, 16, i);
}
if(this.magnet.tank.getFluidAmount() > 0){
int i = this.magnet.getTankScaled(83);
drawTexturedModalRect(this.guiLeft+117, this.guiTop+89-i, 192, 0, 16, i);
}
}
}

View file

@ -57,7 +57,6 @@ public abstract class TileEntityBase extends TileEntity{
GameRegistry.registerTileEntity(TileEntityEnergizer.class, ModUtil.MOD_ID_LOWER+":tileEntityEnergizer");
GameRegistry.registerTileEntity(TileEntityEnervator.class, ModUtil.MOD_ID_LOWER+":tileEntityEnervator");
GameRegistry.registerTileEntity(TileEntityXPSolidifier.class, ModUtil.MOD_ID_LOWER+":tileEntityXPSolidifier");
GameRegistry.registerTileEntity(TileEntityOreMagnet.class, ModUtil.MOD_ID_LOWER+":tileEntityOreMagnet");
GameRegistry.registerTileEntity(TileEntitySmileyCloud.class, ModUtil.MOD_ID_LOWER+":tileEntityCloud");
GameRegistry.registerTileEntity(TileEntityLeafGenerator.class, ModUtil.MOD_ID_LOWER+":tileEntityLeafGenerator");
GameRegistry.registerTileEntity(TileEntityDirectionalBreaker.class, ModUtil.MOD_ID_LOWER+":tileEntityDirectionalBreaker");

View file

@ -1,265 +0,0 @@
/*
* This file ("TileEntityOreMagnet.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.tile;
import cofh.api.energy.EnergyStorage;
import cofh.api.energy.IEnergyReceiver;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.blocks.InitBlocks;
import ellpeck.actuallyadditions.blocks.metalists.TheMiscBlocks;
import ellpeck.actuallyadditions.config.ConfigValues;
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
import ellpeck.actuallyadditions.util.WorldPos;
import ellpeck.actuallyadditions.util.WorldUtil;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.*;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
public class TileEntityOreMagnet extends TileEntityInventoryBase implements IEnergyReceiver, IFluidHandler{
public static final int SLOT_OIL_INPUT = 0;
public static final int SLOT_OIL_OUTPUT = 1;
@SuppressWarnings("unused")
public static final int SLOT_UPGRADE = 2;
public EnergyStorage storage = new EnergyStorage(2000000);
public FluidTank tank = new FluidTank(16*FluidContainerRegistry.BUCKET_VOLUME);
private int lastEnergy;
private int lastTankAmount;
private int currentWorkTimer;
public TileEntityOreMagnet(){
super(3, "oreMagnet");
}
@Override
@SuppressWarnings("unchecked")
public void updateEntity(){
if(!worldObj.isRemote){
if(this.storage.getEnergyStored() >= ConfigIntValues.ORE_MAGNET_ENERGY_USE.getValue() && this.tank.getFluid() != null && this.tank.getFluid().getFluid() == InitBlocks.fluidOil && this.tank.getFluidAmount() >= ConfigIntValues.ORE_MAGNET_OIL_USE.getValue() && !worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
if(this.currentWorkTimer > 0){
currentWorkTimer--;
if(currentWorkTimer <= 0){
this.mine();
}
}
else{
this.currentWorkTimer = ConfigIntValues.ORE_MAGNET_MAX_TIMER.getValue()+MathHelper.getRandomIntegerInRange(worldObj.rand, 0, ConfigIntValues.ORE_MAGNET_MAX_TIMER.getValue());
}
//Extract energy
this.storage.extractEnergy(ConfigIntValues.ORE_MAGNET_ENERGY_USE.getValue(), false);
}
//Update Clients
if(this.lastEnergy != this.storage.getEnergyStored() || this.lastTankAmount != this.tank.getFluidAmount()){
this.lastEnergy = this.storage.getEnergyStored();
this.lastTankAmount = this.tank.getFluidAmount();
this.sendUpdate();
}
//Empty Oil Bucket
WorldUtil.emptyBucket(this.tank, this.slots, SLOT_OIL_INPUT, SLOT_OIL_OUTPUT, InitBlocks.fluidOil);
}
}
private void mine(){
//The possible positions where ores can be mined up in RELATIVE COORDINATES!!
ArrayList<WorldPos> possiblePlacingPositions = new ArrayList<WorldPos>();
for(int x = -ConfigIntValues.ORE_MAGNET_RANGE.getValue()/2; x <= ConfigIntValues.ORE_MAGNET_RANGE.getValue()/2; x++){
for(int z = -ConfigIntValues.ORE_MAGNET_RANGE.getValue()/2; z <= ConfigIntValues.ORE_MAGNET_RANGE.getValue()/2; z++){
//Check if there is a casing below the Block to mine
if(WorldUtil.hasBlocksInPlacesGiven(new int[][]{{x, -1, z}}, InitBlocks.blockMisc, TheMiscBlocks.LAVA_FACTORY_CASE.ordinal(), worldObj, xCoord, yCoord, zCoord)){
//Can the block at the top be replaced?
for(int toPlaceY = 0; toPlaceY < 5; toPlaceY++){
Block block = worldObj.getBlock(xCoord+x, yCoord+toPlaceY, zCoord+z);
//Check if the Block is okay to be replaced
if(block.isAir(worldObj, xCoord+x, yCoord+toPlaceY, zCoord+z) || block.isReplaceable(worldObj, xCoord+x, yCoord+toPlaceY, zCoord+z)){
//Add it to the possible positions
possiblePlacingPositions.add(new WorldPos(worldObj, x, toPlaceY, z));
//Only add the lowest Block, you don't want to make random floating towers, duh!
break;
}
}
}
}
}
if(!possiblePlacingPositions.isEmpty()){
//Get a random placing Position
WorldPos randomPlacingPos = possiblePlacingPositions.get(worldObj.rand.nextInt(possiblePlacingPositions.size()));
int x = randomPlacingPos.getX();
int z = randomPlacingPos.getZ();
int toPlaceY = randomPlacingPos.getY();
//Find the first available block
for(int y = this.yCoord-2; y > 0; y--){
Block block = worldObj.getBlock(xCoord+x, y, zCoord+z);
int meta = worldObj.getBlockMetadata(xCoord+x, y, zCoord+z);
if(block != null && !block.isAir(worldObj, xCoord+x, y, zCoord+z) && !block.hasTileEntity(meta) && block.getBlockHardness(worldObj, xCoord+x, y, zCoord+z) >= 0.0F && ((block.getMaterial() != null && block.getMaterial().isToolNotRequired()) || (block.getHarvestTool(meta) == null || (block.getHarvestTool(meta).equals("pickaxe") && block.getHarvestLevel(meta) <= 3)))){
//Check Whitelist
if(this.hasExtraWhitelist(block)){
this.removeBlock(x, y, z, block, meta, toPlaceY);
return;
}
//Check Ores
int[] oreIDs = OreDictionary.getOreIDs(new ItemStack(block, 1, meta));
for(int ID : oreIDs){
String oreName = OreDictionary.getOreName(ID);
//Is the block an ore according to the OreDictionary?
if(oreName.substring(0, 3).equals("ore") && !this.hasException(oreName)){
this.removeBlock(x, y, z, block, meta, toPlaceY);
return;
}
}
}
}
}
}
private boolean hasExtraWhitelist(Block block){
String name = Block.blockRegistry.getNameForObject(block);
if(name != null){
for(String list : ConfigValues.oreMagnetExtraWhitelist){
if(list.equals(name)){
return true;
}
}
}
return false;
}
private void removeBlock(int x, int y, int z, Block block, int meta, int toPlaceY){
//Remove the Block
worldObj.setBlockToAir(xCoord+x, y, zCoord+z);
worldObj.playAuxSFX(2001, xCoord+x, y, zCoord+z, Block.getIdFromBlock(block)+(meta << 12));
//Set the Block at the Top again
worldObj.setBlock(xCoord+x, yCoord+toPlaceY, zCoord+z, block, meta, 2);
worldObj.playSoundEffect((double)xCoord+x+0.5D, (double)yCoord+toPlaceY+0.5D, (double)zCoord+z+0.5D, block.stepSound.func_150496_b(), (block.stepSound.getVolume()+1.0F)/2.0F, block.stepSound.getPitch()*0.8F);
//Extract oil
this.tank.drain(ConfigIntValues.ORE_MAGNET_OIL_USE.getValue(), true);
}
private boolean hasException(String name){
for(String except : ConfigValues.oreMagnetExceptions){
if(except.equals(name)){
return true;
}
}
return false;
}
@SideOnly(Side.CLIENT)
public int getEnergyScaled(int i){
return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored();
}
@SideOnly(Side.CLIENT)
public int getTankScaled(int i){
return this.tank.getFluidAmount()*i/this.tank.getCapacity();
}
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
this.storage.writeToNBT(compound);
this.tank.writeToNBT(compound);
compound.setInteger("CurrentWorkTimer", this.currentWorkTimer);
super.writeSyncableNBT(compound, sync);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.storage.readFromNBT(compound);
this.tank.readFromNBT(compound);
this.currentWorkTimer = compound.getInteger("CurrentWorkTimer");
super.readSyncableNBT(compound, sync);
}
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return FluidContainerRegistry.containsFluid(stack, new FluidStack(InitBlocks.fluidOil, 1)) && i == SLOT_OIL_INPUT;
}
@Override
public boolean canInsertItem(int slot, ItemStack stack, int side){
return this.isItemValidForSlot(slot, stack);
}
@Override
public boolean canExtractItem(int slot, ItemStack stack, int side){
return slot == SLOT_OIL_OUTPUT;
}
@Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){
return this.storage.receiveEnergy(maxReceive, simulate);
}
@Override
public int getEnergyStored(ForgeDirection from){
return this.storage.getEnergyStored();
}
@Override
public int getMaxEnergyStored(ForgeDirection from){
return this.storage.getMaxEnergyStored();
}
@Override
public boolean canConnectEnergy(ForgeDirection from){
return true;
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill){
if(this.canFill(from, resource.getFluid())){
return this.tank.fill(resource, doFill);
}
return 0;
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain){
return null;
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain){
return null;
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid){
return from != ForgeDirection.DOWN && fluid == InitBlocks.fluidOil;
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid){
return false;
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from){
return new FluidTankInfo[]{this.tank.getInfo()};
}
}

View file

@ -64,7 +64,6 @@ tile.actuallyadditions.blockColoredLampLime.name=Lime Lamp
tile.actuallyadditions.blockColoredLampPink.name=Pink Lamp
tile.actuallyadditions.blockColoredLampCyan.name=Cyan Lamp
tile.actuallyadditions.blockColoredLampPurple.name=Purple Lamp
tile.actuallyadditions.blockOreMagnet.name=Magnetic Miner
tile.actuallyadditions.blockPhantomface.name=Phantomface
tile.actuallyadditions.blockPhantomEnergyface.name=Phantom Energyface
tile.actuallyadditions.blockPhantomLiquiface.name=Phantom Liquiface
@ -362,7 +361,6 @@ container.actuallyadditions.drill.name=Drill
container.actuallyadditions.energizer.name=Energizer
container.actuallyadditions.enervator.name=Enervator
container.actuallyadditions.xpSolidifier.name=Experience Solidifier
container.actuallyadditions.oreMagnet.name=Magnetic Miner
container.actuallyadditions.cloud.name=Smiley Cloud
container.actuallyadditions.directionalBreaker.name=Long-Range Breaker
container.actuallyadditions.rangedCollector.name=Ranged Collector
@ -504,11 +502,8 @@ booklet.actuallyadditions.chapter.crusher.text.1=The <item>Crusher<r> turns ever
booklet.actuallyadditions.chapter.furnaceDouble.name=Double Furnace
booklet.actuallyadditions.chapter.furnaceDouble.text.1=The <item>Double Furnace<r> works like a furnace, however, it uses <rf> RF/t and can smelt <imp>two items at a time<r>.
booklet.actuallyadditions.chapter.miner.name=Magnetic Miner
booklet.actuallyadditions.chapter.miner.text.1=The <item>Magnetic Miner<r> pulls ore blocks out of the ground using <rf> RF/t and <oil> of Oil/block mined. <n>Every place where an ore should be pulled up must have a <item>Casing Block<r> one block lower than the miner. <n>It has a range of <range> blocks.
booklet.actuallyadditions.chapter.lavaFactory.name=Lava Factory
booklet.actuallyadditions.chapter.lavaFactory.text.1=The <item>Lava Factory<r> can produce blocks of lava given <imp><rf> RF/block<r>. <n>The Block above it has to be surrounded with 4 Casing Blocks (which can be found on the Magnetic Miner Page!), otherwise it won't be able to produce Lava. <n>Right-Clicking on the <item>Lava Factory<r> will show you if it's able to produce Lava in its current setup. <n><n><i>Lava, for a fact. <n> ory
booklet.actuallyadditions.chapter.lavaFactory.text.1=The <item>Lava Factory<r> can produce blocks of lava given <imp><rf> RF/block<r>. <n>The Block above it has to be surrounded with 4 Casing Blocks, otherwise it won't be able to produce Lava. <n>Right-Clicking on the <item>Lava Factory<r> will show you if it's able to produce Lava in its current setup. <n><n><i>Lava, for a fact. <n> ory
booklet.actuallyadditions.chapter.energizer.name=Energizer and Enervator
booklet.actuallyadditions.chapter.energizer.text.1=The <item>Energizer<r> <imp>charges items that hold RF<r> using its energy supply.