mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
Finish off the Bubbell. Recipe/docs remain but I'll do that tomorrow :V
This commit is contained in:
1 parent
55fc93b7ab
commit
94c56e5f02
5 files changed
+181
-51
No files matched your search
@@ -10,57 +10,105 @@
|
||||
*/
|
||||
package vazkii.botania.common.block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.common.block.tile.TileFakeAir;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class BlockFakeAir extends BlockMod {
|
||||
public class BlockFakeAir extends BlockModContainer {
|
||||
|
||||
public BlockFakeAir() {
|
||||
super(Material.air);
|
||||
setBlockName(LibBlockNames.FAKE_AIR);
|
||||
setBlockBounds(0, 0, 0, 0, 0, 0);
|
||||
setTickRandomly(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean registerInCreative() {
|
||||
return false;
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
|
||||
if(shouldRemove(world, x, y, z))
|
||||
world.scheduleBlockUpdate(x, y, z, this, tickRate(world));
|
||||
}
|
||||
|
||||
private boolean shouldRemove(World world, int x, int y, int z) {
|
||||
return !world.isRemote && world.getTileEntity(x, y, z) == null || !(world.getTileEntity(x, y, z) instanceof TileFakeAir) || !((TileFakeAir) world.getTileEntity(x, y, z)).canStay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) {
|
||||
// NO-OP
|
||||
public void updateTick(World world, int x, int y, int z, Random rand) {
|
||||
if(shouldRemove(world, x, y, z))
|
||||
world.setBlock(x, y, z, Blocks.water);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random p_149745_1_) {
|
||||
return 0;
|
||||
public int tickRate(World p_149738_1_) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerInCreative() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockNormalCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCollideCheck(int par1, boolean par2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDropFromExplosion(Explosion par1Explosion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
return new ArrayList(); // Empty List
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAir(IBlockAccess world, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable(IBlockAccess world, int x, int y, int z) {
|
||||
return true;
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileFakeAir();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAir(IBlockAccess world, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -109,6 +109,7 @@ import vazkii.botania.common.block.tile.TileBrewery;
|
||||
import vazkii.botania.common.block.tile.TileCraftCrate;
|
||||
import vazkii.botania.common.block.tile.TileEnchanter;
|
||||
import vazkii.botania.common.block.tile.TileEnderEye;
|
||||
import vazkii.botania.common.block.tile.TileFakeAir;
|
||||
import vazkii.botania.common.block.tile.TileFloatingFlower;
|
||||
import vazkii.botania.common.block.tile.TileFloatingSpecialFlower;
|
||||
import vazkii.botania.common.block.tile.TileForestEye;
|
||||
@@ -354,6 +355,7 @@ public final class ModBlocks {
|
||||
registerTile(TileCorporeaIndex.class, LibBlockNames.CORPOREA_INDEX);
|
||||
registerTile(TileCorporeaFunnel.class, LibBlockNames.CORPOREA_FUNNEL);
|
||||
registerTile(TilePump.class, LibBlockNames.PUMP);
|
||||
registerTile(TileFakeAir.class, LibBlockNames.FAKE_AIR);
|
||||
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_PUREDAISY, SubTilePureDaisy.class);
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MANASTAR, SubTileManastar.class);
|
||||
|
||||
@@ -10,56 +10,96 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.subtile.functional;
|
||||
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.subtile.ISubTileContainer;
|
||||
import vazkii.botania.api.subtile.SubTileFunctional;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.TileFakeAir;
|
||||
import vazkii.botania.common.core.helper.MathHelper;
|
||||
|
||||
public class SubTileBubbell extends SubTileFunctional {
|
||||
|
||||
private static final int RANGE = 12;
|
||||
private static final int COST_PER_TICK = 4;
|
||||
private static final String TAG_RANGE = "range";
|
||||
|
||||
|
||||
int range = 2;
|
||||
|
||||
boolean hadMana = false;
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(ticksExisted % 10 == 0 && range < RANGE)
|
||||
range++;
|
||||
|
||||
// TODO Mana check
|
||||
for(int i = -range; i < range + 1; i++)
|
||||
for(int j = -range; j < range + 1; j++)
|
||||
for(int k = -range; k < range + 1; k++)
|
||||
if(MathHelper.pointDistanceSpace(i, j, k, 0, 0, 0) < range && supertile.getWorldObj().getBlock(supertile.xCoord + i, supertile.yCoord + j, supertile.zCoord + k) instanceof BlockLiquid) {
|
||||
System.out.println("doplace"); // TODO
|
||||
supertile.getWorldObj().setBlock(supertile.xCoord + i, supertile.yCoord + j, supertile.zCoord + k, ModBlocks.fakeAir);
|
||||
}
|
||||
|
||||
if(mana > COST_PER_TICK) {
|
||||
mana -= COST_PER_TICK;
|
||||
hadMana = true;
|
||||
|
||||
if(ticksExisted % 10 == 0 && range < RANGE)
|
||||
range++;
|
||||
|
||||
for(int i = -range; i < range + 1; i++)
|
||||
for(int j = -range; j < range + 1; j++)
|
||||
for(int k = -range; k < range + 1; k++)
|
||||
if(MathHelper.pointDistanceSpace(i, j, k, 0, 0, 0) < range) {
|
||||
Block block = supertile.getWorldObj().getBlock(supertile.xCoord + i, supertile.yCoord + j, supertile.zCoord + k);
|
||||
if(block == Blocks.water || block == Blocks.flowing_water) {
|
||||
supertile.getWorldObj().setBlock(supertile.xCoord + i, supertile.yCoord + j, supertile.zCoord + k, ModBlocks.fakeAir, 0, 2);
|
||||
TileFakeAir air = (TileFakeAir) supertile.getWorldObj().getTileEntity(supertile.xCoord + i, supertile.yCoord + j, supertile.zCoord + k);
|
||||
air.setFlower(supertile);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(hadMana) {
|
||||
for(int i = -range; i < range + 1; i++)
|
||||
for(int j = -range; j < range + 1; j++)
|
||||
for(int k = -range; k < range + 1; k++)
|
||||
if(MathHelper.pointDistanceSpace(i, j, k, 0, 0, 0) < range && supertile.getWorldObj().getBlock(supertile.xCoord + i, supertile.yCoord + j, supertile.zCoord + k) == ModBlocks.fakeAir) {
|
||||
supertile.getWorldObj().setBlock(supertile.xCoord + i, supertile.yCoord + j, supertile.zCoord + k, Blocks.water);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
hadMana = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean isValidBubbell(World world, int x, int y, int z) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile != null && tile instanceof ISubTileContainer) {
|
||||
ISubTileContainer container = (ISubTileContainer) tile;
|
||||
if(container.getSubTile() != null && container.getSubTile() instanceof SubTileBubbell) {
|
||||
SubTileBubbell bubbell = (SubTileBubbell) container.getSubTile();
|
||||
return bubbell.mana > COST_PER_TICK;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToPacketNBT(NBTTagCompound cmp) {
|
||||
super.writeToPacketNBT(cmp);
|
||||
cmp.setInteger(TAG_RANGE, range);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readFromPacketNBT(NBTTagCompound cmp) {
|
||||
super.readFromPacketNBT(cmp);
|
||||
range = cmp.getInteger(TAG_RANGE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getMaxMana() {
|
||||
return 10000;
|
||||
return 2000;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return 0x0DCF89;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -10,6 +10,47 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
public class TileFakeAir {
|
||||
import vazkii.botania.common.block.subtile.functional.SubTileBubbell;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TileFakeAir extends TileMod {
|
||||
|
||||
private static final String TAG_FLOWER_X = "flowerX";
|
||||
private static final String TAG_FLOWER_Y = "flowerY";
|
||||
private static final String TAG_FLOWER_Z = "flowerZ";
|
||||
|
||||
int flowerX, flowerY, flowerZ;
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setFlower(TileEntity tile) {
|
||||
flowerX = tile.xCoord;
|
||||
flowerY = tile.yCoord;
|
||||
flowerZ = tile.zCoord;
|
||||
}
|
||||
|
||||
public boolean canStay() {
|
||||
return SubTileBubbell.isValidBubbell(worldObj, flowerX, flowerY, flowerZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound par1nbtTagCompound) {
|
||||
super.writeToNBT(par1nbtTagCompound);
|
||||
par1nbtTagCompound.setInteger(TAG_FLOWER_X, flowerX);
|
||||
par1nbtTagCompound.setInteger(TAG_FLOWER_Y, flowerY);
|
||||
par1nbtTagCompound.setInteger(TAG_FLOWER_Z, flowerZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound par1nbtTagCompound) {
|
||||
super.readFromNBT(par1nbtTagCompound);
|
||||
flowerX = par1nbtTagCompound.getInteger(TAG_FLOWER_X);
|
||||
flowerY = par1nbtTagCompound.getInteger(TAG_FLOWER_Y);
|
||||
flowerZ = par1nbtTagCompound.getInteger(TAG_FLOWER_Z);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user