mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-23 03:49:22 +01:00
Made the Ore Magnet need Casing Blocks below the places where it should mine
This commit is contained in:
parent
f1dda0c171
commit
24812ab53f
7 changed files with 73 additions and 46 deletions
|
@ -5,9 +5,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
import ellpeck.actuallyadditions.ActuallyAdditions;
|
||||
import ellpeck.actuallyadditions.inventory.GuiHandler;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityOreMagnet;
|
||||
import ellpeck.actuallyadditions.util.BlockUtil;
|
||||
import ellpeck.actuallyadditions.util.INameableItem;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.*;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
@ -44,14 +42,15 @@ public class BlockOreMagnet extends BlockContainerBase implements INameableItem{
|
|||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconReg){
|
||||
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName());
|
||||
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName());
|
||||
}
|
||||
|
||||
@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);
|
||||
if(magnet != null)
|
||||
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.ORE_MAGNET.ordinal(), world, x, y, z);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
|
@ -92,9 +91,12 @@ public class BlockOreMagnet extends BlockContainerBase implements INameableItem{
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){
|
||||
BlockUtil.addInformation(theBlock, list, 1, "");
|
||||
//TODO Energy stuffs
|
||||
BlockUtil.addPowerUsageInfo(list, TileEntityOreMagnet.energyUsePerTick);
|
||||
if(KeyUtil.isShiftPressed()){
|
||||
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".uses.desc")+" "+TileEntityOreMagnet.oilUsePerTick+" mB/t");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -128,7 +128,8 @@ public enum ConfigCrafting{
|
|||
NICKEL("Nickel Ore -> Nickel Dust + Platinum Dust", ConfigCategories.CRUSHER_RECIPES, "Crusher"),
|
||||
IRON("Iron Ore -> Iron Dust + Gold Dust", ConfigCategories.CRUSHER_RECIPES, "Crusher"),
|
||||
|
||||
TELE_STAFF("Tele Staff", ConfigCategories.ITEMS_CRAFTING);
|
||||
TELE_STAFF("Tele Staff", ConfigCategories.ITEMS_CRAFTING),
|
||||
CASING("Casing", ConfigCategories.BLOCKS_CRAFTING);
|
||||
|
||||
public final String name;
|
||||
public final String category;
|
||||
|
|
|
@ -90,7 +90,7 @@ public class BlockCrafting{
|
|||
'A', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.STONE_CASING.ordinal())));
|
||||
|
||||
//Lava Factory
|
||||
if(ConfigCrafting.LAVA_FACTORY.isEnabled()){
|
||||
if(ConfigCrafting.LAVA_FACTORY.isEnabled())
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockLavaFactoryController),
|
||||
" C ", "ISI", " L ",
|
||||
'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.STONE_CASING.ordinal()),
|
||||
|
@ -98,11 +98,12 @@ public class BlockCrafting{
|
|||
'I', "blockIron",
|
||||
'L', Items.lava_bucket));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockMisc, 4, TheMiscBlocks.LAVA_FACTORY_CASE.ordinal()),
|
||||
//Casing
|
||||
if(ConfigCrafting.CASING.isEnabled())
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockMisc, 16, TheMiscBlocks.LAVA_FACTORY_CASE.ordinal()),
|
||||
"ICI",
|
||||
'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.STONE_CASING.ordinal()),
|
||||
'I', "blockIron"));
|
||||
}
|
||||
|
||||
//Canola Press
|
||||
if(ConfigCrafting.CANOLA_PRESS.isEnabled())
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package ellpeck.actuallyadditions.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import ellpeck.actuallyadditions.config.values.ConfigBoolValues;
|
||||
import ellpeck.actuallyadditions.util.KeyUtil;
|
||||
|
@ -15,7 +14,7 @@ public class TooltipEvent{
|
|||
private static final String TEXT_PRE = StringUtil.GRAY+" ";
|
||||
private static final String HEADER_PRE = StringUtil.LIGHT_GRAY+" -";
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
@SubscribeEvent
|
||||
public void onTooltipEvent(ItemTooltipEvent event){
|
||||
if(event.itemStack.getItem() != null){
|
||||
if(KeyUtil.isControlPressed()){
|
||||
|
|
|
@ -61,7 +61,6 @@ public class ContainerEnergizer extends Container{
|
|||
return this.energizer.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
//TODO Armor Shift-Clicking
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
|
||||
final int inventoryStart = 2;
|
||||
|
|
|
@ -5,8 +5,10 @@ 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.network.sync.IPacketSyncerToClient;
|
||||
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -16,6 +18,8 @@ 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, IPacketSyncerToClient{
|
||||
|
||||
public static final int SLOT_OIL_INPUT = 0;
|
||||
|
@ -33,8 +37,8 @@ public class TileEntityOreMagnet extends TileEntityInventoryBase implements IEne
|
|||
|
||||
private int maxWorkTimer = 15;
|
||||
private int range = 10;
|
||||
private int oilUsePerTick = 50;
|
||||
private int energyUsePerTick = 400;
|
||||
public static int oilUsePerTick = 50;
|
||||
public static int energyUsePerTick = 400;
|
||||
|
||||
public TileEntityOreMagnet(){
|
||||
super(3, "oreMagnet");
|
||||
|
@ -45,48 +49,69 @@ public class TileEntityOreMagnet extends TileEntityInventoryBase implements IEne
|
|||
public void updateEntity(){
|
||||
if(!worldObj.isRemote){
|
||||
|
||||
if(this.storage.getEnergyStored() >= this.energyUsePerTick && this.tank.getFluid() != null && this.tank.getFluid().getFluid() == InitBlocks.fluidOil && this.tank.getFluidAmount() >= this.oilUsePerTick && !worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
if(this.storage.getEnergyStored() >= energyUsePerTick && this.tank.getFluid() != null && this.tank.getFluid().getFluid() == InitBlocks.fluidOil && this.tank.getFluidAmount() >= oilUsePerTick && !worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
if(this.currentWorkTimer > 0){
|
||||
currentWorkTimer--;
|
||||
|
||||
if(currentWorkTimer <= 0){
|
||||
int x = MathHelper.getRandomIntegerInRange(worldObj.rand, -range, range);
|
||||
int z = MathHelper.getRandomIntegerInRange(worldObj.rand, -range, range);
|
||||
//Can the block at the top be replaced?
|
||||
for(int toPlaceY = 0; toPlaceY < 5; toPlaceY++){
|
||||
if(worldObj.isAirBlock(xCoord+x, yCoord+toPlaceY, zCoord+z) || worldObj.getBlock(xCoord+x, yCoord+toPlaceY, zCoord+z).isReplaceable(worldObj, xCoord+x, yCoord+toPlaceY, zCoord+z)){
|
||||
//Find the first available block
|
||||
for(int y = this.yCoord-1; y > 0; y--){
|
||||
Block block = worldObj.getBlock(xCoord+x, y, zCoord+z);
|
||||
int meta = worldObj.getBlockMetadata(xCoord+x, y, zCoord+z);
|
||||
//The possible positions where ores can be mined up in RELATIVE COORDINATES!!
|
||||
ArrayList<WorldPos> possiblePlacingPositions = new ArrayList<WorldPos>();
|
||||
|
||||
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")){
|
||||
//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(this.oilUsePerTick, true);
|
||||
return;
|
||||
for(int x = -range; x <= range; x++){
|
||||
for(int z = -range; z <= range; 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-1; y > 0; y--){
|
||||
Block block = worldObj.getBlock(xCoord+x, y, zCoord+z);
|
||||
int meta = worldObj.getBlockMetadata(xCoord+x, y, zCoord+z);
|
||||
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")){
|
||||
//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(oilUsePerTick, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else this.currentWorkTimer = maxWorkTimer+MathHelper.getRandomIntegerInRange(worldObj.rand, 0, maxWorkTimer);
|
||||
|
||||
//Extract energy
|
||||
this.storage.extractEnergy(this.energyUsePerTick, false);
|
||||
this.storage.extractEnergy(energyUsePerTick, false);
|
||||
}
|
||||
|
||||
//Update Clients
|
||||
|
|
|
@ -118,12 +118,12 @@ tooltip.actuallyadditions.blockPhantomBreaker.desc.1=Breaks Blocks from a distan
|
|||
tooltip.actuallyadditions.blockPhantomBreaker.desc.2=Sneak-Right-Click with an empty hand to see its Connections!
|
||||
|
||||
tile.actuallyadditions.blockLavaFactoryController.name=Lava Factory Controller
|
||||
tooltip.actuallyadditions.blockLavaFactoryController.desc.1=Place Lava Factory Casings around in the right way to produce Lava:
|
||||
tooltip.actuallyadditions.blockLavaFactoryController.desc.1=Place Casings around in the right way to produce Lava:
|
||||
tooltip.actuallyadditions.blockLavaFactoryController.desc.2=Go one block up above the Controller, that's where Lava is going to land
|
||||
tooltip.actuallyadditions.blockLavaFactoryController.desc.3=Place 4 Casings around that empty space so that it is encased
|
||||
|
||||
tile.actuallyadditions.blockMiscLavaFactoryCase.name=Lava Factory Casing
|
||||
tooltip.actuallyadditions.blockMiscLavaFactoryCase.desc=Helps the Lava Factory Controller generate Lava
|
||||
tile.actuallyadditions.blockMiscLavaFactoryCase.name=Casing
|
||||
tooltip.actuallyadditions.blockMiscLavaFactoryCase.desc=A Casing for the Lava Factory and more.
|
||||
|
||||
tile.actuallyadditions.blockFluidPlacer.name=Fluid Placer
|
||||
tooltip.actuallyadditions.blockFluidPlacer.desc=Places Fluids stored inside it
|
||||
|
|
Loading…
Reference in a new issue