mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 16:58:34 +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.ActuallyAdditions;
|
||||||
import ellpeck.actuallyadditions.inventory.GuiHandler;
|
import ellpeck.actuallyadditions.inventory.GuiHandler;
|
||||||
import ellpeck.actuallyadditions.tile.TileEntityOreMagnet;
|
import ellpeck.actuallyadditions.tile.TileEntityOreMagnet;
|
||||||
import ellpeck.actuallyadditions.util.BlockUtil;
|
import ellpeck.actuallyadditions.util.*;
|
||||||
import ellpeck.actuallyadditions.util.INameableItem;
|
|
||||||
import ellpeck.actuallyadditions.util.ModUtil;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
|
@ -44,14 +42,15 @@ public class BlockOreMagnet extends BlockContainerBase implements INameableItem{
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void registerBlockIcons(IIconRegister iconReg){
|
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
|
@Override
|
||||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
TileEntityOreMagnet magnet = (TileEntityOreMagnet)world.getTileEntity(x, y, z);
|
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;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -92,9 +91,12 @@ public class BlockOreMagnet extends BlockContainerBase implements INameableItem{
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@SideOnly(Side.CLIENT)
|
@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, "");
|
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
|
@Override
|
||||||
|
|
|
@ -128,7 +128,8 @@ public enum ConfigCrafting{
|
||||||
NICKEL("Nickel Ore -> Nickel Dust + Platinum Dust", ConfigCategories.CRUSHER_RECIPES, "Crusher"),
|
NICKEL("Nickel Ore -> Nickel Dust + Platinum Dust", ConfigCategories.CRUSHER_RECIPES, "Crusher"),
|
||||||
IRON("Iron Ore -> Iron Dust + Gold 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 name;
|
||||||
public final String category;
|
public final String category;
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class BlockCrafting{
|
||||||
'A', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.STONE_CASING.ordinal())));
|
'A', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.STONE_CASING.ordinal())));
|
||||||
|
|
||||||
//Lava Factory
|
//Lava Factory
|
||||||
if(ConfigCrafting.LAVA_FACTORY.isEnabled()){
|
if(ConfigCrafting.LAVA_FACTORY.isEnabled())
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockLavaFactoryController),
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockLavaFactoryController),
|
||||||
" C ", "ISI", " L ",
|
" C ", "ISI", " L ",
|
||||||
'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.STONE_CASING.ordinal()),
|
'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.STONE_CASING.ordinal()),
|
||||||
|
@ -98,11 +98,12 @@ public class BlockCrafting{
|
||||||
'I', "blockIron",
|
'I', "blockIron",
|
||||||
'L', Items.lava_bucket));
|
'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",
|
"ICI",
|
||||||
'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.STONE_CASING.ordinal()),
|
'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.STONE_CASING.ordinal()),
|
||||||
'I', "blockIron"));
|
'I', "blockIron"));
|
||||||
}
|
|
||||||
|
|
||||||
//Canola Press
|
//Canola Press
|
||||||
if(ConfigCrafting.CANOLA_PRESS.isEnabled())
|
if(ConfigCrafting.CANOLA_PRESS.isEnabled())
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package ellpeck.actuallyadditions.event;
|
package ellpeck.actuallyadditions.event;
|
||||||
|
|
||||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
import ellpeck.actuallyadditions.config.values.ConfigBoolValues;
|
import ellpeck.actuallyadditions.config.values.ConfigBoolValues;
|
||||||
import ellpeck.actuallyadditions.util.KeyUtil;
|
import ellpeck.actuallyadditions.util.KeyUtil;
|
||||||
|
@ -15,7 +14,7 @@ public class TooltipEvent{
|
||||||
private static final String TEXT_PRE = StringUtil.GRAY+" ";
|
private static final String TEXT_PRE = StringUtil.GRAY+" ";
|
||||||
private static final String HEADER_PRE = StringUtil.LIGHT_GRAY+" -";
|
private static final String HEADER_PRE = StringUtil.LIGHT_GRAY+" -";
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.LOW)
|
@SubscribeEvent
|
||||||
public void onTooltipEvent(ItemTooltipEvent event){
|
public void onTooltipEvent(ItemTooltipEvent event){
|
||||||
if(event.itemStack.getItem() != null){
|
if(event.itemStack.getItem() != null){
|
||||||
if(KeyUtil.isControlPressed()){
|
if(KeyUtil.isControlPressed()){
|
||||||
|
|
|
@ -61,7 +61,6 @@ public class ContainerEnergizer extends Container{
|
||||||
return this.energizer.isUseableByPlayer(player);
|
return this.energizer.isUseableByPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Armor Shift-Clicking
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
|
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
|
||||||
final int inventoryStart = 2;
|
final int inventoryStart = 2;
|
||||||
|
|
|
@ -5,8 +5,10 @@ import cofh.api.energy.IEnergyReceiver;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
||||||
|
import ellpeck.actuallyadditions.blocks.metalists.TheMiscBlocks;
|
||||||
import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient;
|
import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient;
|
||||||
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
|
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
|
||||||
|
import ellpeck.actuallyadditions.util.WorldPos;
|
||||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -16,6 +18,8 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import net.minecraftforge.fluids.*;
|
import net.minecraftforge.fluids.*;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class TileEntityOreMagnet extends TileEntityInventoryBase implements IEnergyReceiver, IFluidHandler, IPacketSyncerToClient{
|
public class TileEntityOreMagnet extends TileEntityInventoryBase implements IEnergyReceiver, IFluidHandler, IPacketSyncerToClient{
|
||||||
|
|
||||||
public static final int SLOT_OIL_INPUT = 0;
|
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 maxWorkTimer = 15;
|
||||||
private int range = 10;
|
private int range = 10;
|
||||||
private int oilUsePerTick = 50;
|
public static int oilUsePerTick = 50;
|
||||||
private int energyUsePerTick = 400;
|
public static int energyUsePerTick = 400;
|
||||||
|
|
||||||
public TileEntityOreMagnet(){
|
public TileEntityOreMagnet(){
|
||||||
super(3, "oreMagnet");
|
super(3, "oreMagnet");
|
||||||
|
@ -45,21 +49,43 @@ public class TileEntityOreMagnet extends TileEntityInventoryBase implements IEne
|
||||||
public void updateEntity(){
|
public void updateEntity(){
|
||||||
if(!worldObj.isRemote){
|
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){
|
if(this.currentWorkTimer > 0){
|
||||||
currentWorkTimer--;
|
currentWorkTimer--;
|
||||||
|
|
||||||
if(currentWorkTimer <= 0){
|
if(currentWorkTimer <= 0){
|
||||||
int x = MathHelper.getRandomIntegerInRange(worldObj.rand, -range, range);
|
//The possible positions where ores can be mined up in RELATIVE COORDINATES!!
|
||||||
int z = MathHelper.getRandomIntegerInRange(worldObj.rand, -range, range);
|
ArrayList<WorldPos> possiblePlacingPositions = new ArrayList<WorldPos>();
|
||||||
|
|
||||||
|
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?
|
//Can the block at the top be replaced?
|
||||||
for(int toPlaceY = 0; toPlaceY < 5; toPlaceY++){
|
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)){
|
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
|
//Find the first available block
|
||||||
for(int y = this.yCoord-1; y > 0; y--){
|
for(int y = this.yCoord-1; y > 0; y--){
|
||||||
Block block = worldObj.getBlock(xCoord+x, y, zCoord+z);
|
Block block = worldObj.getBlock(xCoord+x, y, zCoord+z);
|
||||||
int meta = worldObj.getBlockMetadata(xCoord+x, y, zCoord+z);
|
int meta = worldObj.getBlockMetadata(xCoord+x, y, zCoord+z);
|
||||||
|
|
||||||
int[] oreIDs = OreDictionary.getOreIDs(new ItemStack(block, 1, meta));
|
int[] oreIDs = OreDictionary.getOreIDs(new ItemStack(block, 1, meta));
|
||||||
for(int ID : oreIDs){
|
for(int ID : oreIDs){
|
||||||
String oreName = OreDictionary.getOreName(ID);
|
String oreName = OreDictionary.getOreName(ID);
|
||||||
|
@ -74,7 +100,7 @@ public class TileEntityOreMagnet extends TileEntityInventoryBase implements IEne
|
||||||
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);
|
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
|
//Extract oil
|
||||||
this.tank.drain(this.oilUsePerTick, true);
|
this.tank.drain(oilUsePerTick, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,11 +108,10 @@ public class TileEntityOreMagnet extends TileEntityInventoryBase implements IEne
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else this.currentWorkTimer = maxWorkTimer+MathHelper.getRandomIntegerInRange(worldObj.rand, 0, maxWorkTimer);
|
else this.currentWorkTimer = maxWorkTimer+MathHelper.getRandomIntegerInRange(worldObj.rand, 0, maxWorkTimer);
|
||||||
|
|
||||||
//Extract energy
|
//Extract energy
|
||||||
this.storage.extractEnergy(this.energyUsePerTick, false);
|
this.storage.extractEnergy(energyUsePerTick, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update Clients
|
//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!
|
tooltip.actuallyadditions.blockPhantomBreaker.desc.2=Sneak-Right-Click with an empty hand to see its Connections!
|
||||||
|
|
||||||
tile.actuallyadditions.blockLavaFactoryController.name=Lava Factory Controller
|
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.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
|
tooltip.actuallyadditions.blockLavaFactoryController.desc.3=Place 4 Casings around that empty space so that it is encased
|
||||||
|
|
||||||
tile.actuallyadditions.blockMiscLavaFactoryCase.name=Lava Factory Casing
|
tile.actuallyadditions.blockMiscLavaFactoryCase.name=Casing
|
||||||
tooltip.actuallyadditions.blockMiscLavaFactoryCase.desc=Helps the Lava Factory Controller generate Lava
|
tooltip.actuallyadditions.blockMiscLavaFactoryCase.desc=A Casing for the Lava Factory and more.
|
||||||
|
|
||||||
tile.actuallyadditions.blockFluidPlacer.name=Fluid Placer
|
tile.actuallyadditions.blockFluidPlacer.name=Fluid Placer
|
||||||
tooltip.actuallyadditions.blockFluidPlacer.desc=Places Fluids stored inside it
|
tooltip.actuallyadditions.blockFluidPlacer.desc=Places Fluids stored inside it
|
||||||
|
|
Loading…
Reference in a new issue