no message

This commit is contained in:
Pulxes-9244 committed 2022-02-03 16:48:16 +03:00
1 parent 8c1bd5995b
commit 93f114dceb
645 files changed
+59797

No files matched your search

@@ -0,0 +1,172 @@
package ab.common.block;
import java.util.List;
import ab.AdvancedBotany;
import ab.common.block.tile.TileABSpreader;
import ab.common.lib.register.BlockListAB;
import ab.common.lib.register.RecipeListAB;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.wand.IWandHUD;
import vazkii.botania.api.wand.IWandable;
import vazkii.botania.api.wand.IWireframeAABBProvider;
import vazkii.botania.common.item.ModItems;
public class BlockABSpreader extends BlockContainer implements IWandable, IWandHUD, IWireframeAABBProvider, ILexiconable {
public BlockABSpreader() {
super(Material.wood);
this.setCreativeTab(AdvancedBotany.tabAB);
this.setHardness(7.0F);
this.setStepSound(soundTypeWood);
this.setBlockName("advancedSpreader");
}
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase liv, ItemStack stack) {
int orientation = BlockPistonBase.determineOrientation(world, x, y, z, liv);
TileABSpreader spreader = (TileABSpreader)world.getTileEntity(x, y, z);
world.setBlockMetadataWithNotify(x, y, z, stack.getItemDamage(), 3);
switch (orientation) {
case 0:
spreader.rotationY = -90.0F;
case 1:
spreader.rotationY = 90.0F;
case 2:
spreader.rotationX = 270.0F;
case 3:
spreader.rotationX = 90.0F;
case 4:
return;
}
spreader.rotationX = 180.0F;
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileABSpreader))
return false;
TileABSpreader spreader = (TileABSpreader)tile;
ItemStack lens = spreader.getStackInSlot(0);
ItemStack heldItem = player.getCurrentEquippedItem();
boolean isHeldItemLens = (heldItem != null && heldItem.getItem() instanceof vazkii.botania.api.mana.ILens);
boolean wool = (heldItem != null && heldItem.getItem() == Item.getItemFromBlock(Blocks.wool));
if (heldItem != null && heldItem.getItem() == ModItems.twigWand)
return false;
if (lens == null && isHeldItemLens) {
if (!player.capabilities.isCreativeMode)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
spreader.setInventorySlotContents(0, heldItem.copy());
spreader.markDirty();
} else if (lens != null && !wool) {
ItemStack add = lens.copy();
if (!player.inventory.addItemStackToInventory(add))
player.dropPlayerItemWithRandomChoice(add, false);
spreader.setInventorySlotContents(0, null);
spreader.markDirty();
}
if (wool && spreader.paddingColor == -1) {
spreader.paddingColor = heldItem.getItemDamage();
heldItem.stackSize--;
if (heldItem.stackSize == 0)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
} else if (heldItem == null && spreader.paddingColor != -1 && lens == null) {
ItemStack pad = new ItemStack(Blocks.wool, 1, spreader.paddingColor);
if (!player.inventory.addItemStackToInventory(pad))
player.dropPlayerItemWithRandomChoice(pad, false);
spreader.paddingColor = -1;
spreader.markDirty();
}
return true;
}
public void breakBlock(World world, int x, int y, int z, Block par5, int par6) {
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileABSpreader))
return;
TileABSpreader inv = (TileABSpreader)tile;
if (inv != null) {
for (int i = 0; i < inv.getSizeInventory() + 1; i++) {
ItemStack stack = (i >= inv.getSizeInventory()) ? ((inv.paddingColor == -1) ? null : new ItemStack(Blocks.wool, 1, inv.paddingColor)) : inv.getStackInSlot(i);
if(stack != null) {
float spawnX = x + world.rand.nextFloat();
float spawnY = y + world.rand.nextFloat();
float spawnZ = z + world.rand.nextFloat();
EntityItem droppedItem = new EntityItem(world, spawnX, spawnY, spawnZ, stack);
float mult = 0.05F;
droppedItem.motionX = ((-0.5F + world.rand.nextFloat()) * mult);
droppedItem.motionY = ((4.0F + world.rand.nextFloat()) * mult);
droppedItem.motionZ = ((-0.5F + world.rand.nextFloat()) * mult);
if (stack.hasTagCompound())
droppedItem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy());
world.spawnEntityInWorld((Entity)droppedItem);
}
}
world.func_147453_f(x, y, z, par5);
}
super.breakBlock(world, x, y, z, par5, par6);
}
public IIcon getIcon(int par1, int par2) {
return BlockListAB.blockLebethron.getIcon(par1, 0);
}
public boolean isOpaqueCube() {
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
public int getRenderType() {
return BlockListAB.blockABSpreaderRI;
}
public int getLightValue(IBlockAccess world, int x, int y, int z) {
return 12;
}
public TileEntity createNewTileEntity(World world, int meta) {
return new TileABSpreader();
}
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
((TileABSpreader)world.getTileEntity(x, y, z)).onWanded(player, stack);
return true;
}
public AxisAlignedBB getWireframeAABB(World world, int x, int y, int z) {
float f = 0.0625F;
return AxisAlignedBB.getBoundingBox((x + f), (y + f), (z + f), ((x + 1) - f), ((y + 1) - f), ((z + 1) - f));
}
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) {
((TileABSpreader)world.getTileEntity(x, y, z)).renderHUD(mc, res);
}
public LexiconEntry getEntry(World arg0, int arg1, int arg2, int arg3, EntityPlayer arg4, ItemStack arg5) {
return RecipeListAB.lebethronSpreader;
}
}
@@ -0,0 +1,54 @@
package ab.common.block;
import java.util.List;
import ab.AdvancedBotany;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
public class BlockABStorage extends Block {
private static IIcon[] icon = new IIcon[1];
public BlockABStorage() {
super(Material.iron);
this.setCreativeTab(AdvancedBotany.tabAB);
this.setHardness(3.0F);
this.setResistance(10.0F);
this.setStepSound(soundTypeMetal);
this.setBlockName("abStorage");
}
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List list) {
for(int i = 0; i < icon.length; i++) {
list.add(new ItemStack(par1, 1, i));
}
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister ir) {
for (int i = 0; i < icon.length; i++)
icon[i] = ir.registerIcon("ab:abStorage_" + i);
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return this.icon[meta];
}
public int damageDropped(int par1) {
return par1;
}
public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) {
return true;
}
}
@@ -0,0 +1,118 @@
package ab.common.block;
import ab.AdvancedBotany;
import ab.common.block.tile.TileAgglomerationPlate;
import ab.common.lib.register.RecipeListAB;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.common.block.tile.TileSimpleInventory;
public class BlockAgglomerationPlate extends BlockContainer implements ILexiconable {
private IIcon[] icons;
public BlockAgglomerationPlate() {
super(Material.iron);
this.setCreativeTab(AdvancedBotany.tabAB);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.1875F, 1.0F);
this.setHardness(3.0F);
this.setResistance(10.0F);
this.setStepSound(soundTypeMetal);
this.setBlockName("ABPlate");
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
TileAgglomerationPlate tile = (TileAgglomerationPlate)world.getTileEntity(x, y, z);
if (player.isSneaking()) {
if(tile.getStackInSlot(0) != null) {
ItemStack copy = tile.getStackInSlot(0).copy();
if (!player.inventory.addItemStackToInventory(copy))
player.dropPlayerItemWithRandomChoice(copy, false);
tile.setInventorySlotContents(0, null);
world.func_147453_f(x, y, z, (Block)this);
return true;
}
for(int i = tile.getSizeInventory() - 1; i > 0; i--) {
ItemStack stack = tile.getStackInSlot(i);
if(stack != null) {
ItemStack copy = stack.copy();
if (!player.inventory.addItemStackToInventory(copy))
player.dropPlayerItemWithRandomChoice(copy, false);
tile.setInventorySlotContents(i, null);
world.func_147453_f(x, y, z, (Block)this);
break;
}
}
}
return false;
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if(!world.isRemote) {
TileSimpleInventory inv = (TileSimpleInventory)world.getTileEntity(x, y, z);
if (inv != null) {
for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if (stack != null) {
float f = world.rand.nextFloat() * 0.8F + 0.1F;
float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
float f2 = world.rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityitem = new EntityItem(world, (x + f), (y + f1), (z + f2), stack.copy());
float f3 = 0.05F;
entityitem.motionX = ((float)world.rand.nextGaussian() * f3);
entityitem.motionY = ((float)world.rand.nextGaussian() * f3 + 0.2F);
entityitem.motionZ = ((float)world.rand.nextGaussian() * f3);
if (stack.hasTagCompound())
entityitem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy());
world.spawnEntityInWorld(entityitem);
}
}
}
}
super.breakBlock(world, x, y, z, block, meta);
}
public void registerBlockIcons(IIconRegister ir) {
this.icons = new IIcon[3];
for (int i = 0; i < this.icons.length; i++)
this.icons[i] = ir.registerIcon("ab:advancedPlate_" + i);
}
public IIcon getIcon(int par1, int par2) {
return this.icons[Math.min(2, par1)];
}
public boolean renderAsNormalBlock() {
return false;
}
public boolean isOpaqueCube() {
return false;
}
public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) {
return false;
}
public TileEntity createNewTileEntity(World world, int meta) {
return new TileAgglomerationPlate();
}
public LexiconEntry getEntry(World arg0, int arg1, int arg2, int arg3, EntityPlayer arg4, ItemStack arg5) {
return RecipeListAB.advandedAgglomerationPlate;
}
}
@@ -0,0 +1,61 @@
package ab.common.block;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import vazkii.botania.common.Botania;
public class BlockAntigravitation extends Block {
public BlockAntigravitation() {
super(Material.ground);
this.setHardness(-1.0f);
this.setTickRandomly(true);
this.useNeighborBrightness = false;
}
public boolean isReplaceable(IBlockAccess world, int x, int y, int z) {
return true;
}
public int getRenderType() {
return -1;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
return null;
}
public boolean renderAsNormalBlock() {
return false;
}
public boolean isOpaqueCube() {
return false;
}
public boolean canCollideCheck(int p_149678_1_, boolean p_149678_2_) {
return false;
}
public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) {}
public void updateTick(World world, int x, int y, int z, Random rand) {
world.setBlockToAir(x, y, z);
}
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
if(random.nextBoolean()) {
float r = random.nextInt(128) / 255.0f;
float g = (random.nextInt(128) + 70) / 255.0f;
float b = 200.0f / 255.0f;
Botania.proxy.wispFX(world, x + 0.1f + Math.random() * 0.8f, y - 0.18f + 1.0f, z + 0.1 + Math.random() * 0.8, r, g, b, 0.24F * (float)(Math.random() - 0.5D), 0.0f, (float)(0.001f + Math.random() * 0.01f), 0.0f);
}
}
}
@@ -0,0 +1,129 @@
package ab.common.block;
import java.util.Random;
import ab.AdvancedBotany;
import ab.api.ICorporeaModification;
import ab.common.block.tile.TileCorporeaCatalyst;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.api.wand.IWandable;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.material.ItemRune;
public class BlockCorporeaCatalyst extends Block implements ITileEntityProvider, IWandable {
public IIcon[] icon;
public BlockCorporeaCatalyst() {
super(Material.rock);
this.icon = new IIcon[4];
setHardness(5.5F);
this.setCreativeTab(AdvancedBotany.tabAB);
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister ir) {
// this.icon[0] = ModBlocks.livingrock.getIcon(0, 0);
this.icon[0] = ir.registerIcon("ab:corporeaCatalyst");
this.icon[1] = ir.registerIcon("ab:goodPicture");
this.icon[2] = ir.registerIcon("ab:star_sign");
this.icon[3] = ir.registerIcon("ab:corporea_downside");
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(final int par1, final int par2) {
return ModBlocks.livingrock.getIcon(0, 0);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX,
float hitY, float hitZ) {
int meta = world.getBlockMetadata(x, y, z);
if (player.isSneaking() && meta != 0) {
if (!world.isRemote)
world.spawnEntityInWorld(
new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.rune, 1, meta - 1)));
world.setBlockMetadataWithNotify(x, y, z, 0, 0);
return true;
}
if (player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemRune) {
int damage = player.getHeldItem().getItemDamage();
if (meta == 0 && damage < 4) {
world.setBlockMetadataWithNotify(x, y, z, damage + 1, 1);
player.getHeldItem().stackSize--;
((TileCorporeaCatalyst) world.getTileEntity(x, y, z)).sideRune = side;
return true;
}
}
return false;
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
Random random = world.rand;
if (meta != 0) {
ItemStack itemstack = new ItemStack(ModItems.rune, 1, meta - 1);
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
float f2 = random.nextFloat() * 0.8F + 0.1F;
EntityItem entityitem;
entityitem = new EntityItem(world, x + f, y + f1, z + f2, itemstack);
float f3 = 0.05F;
entityitem.motionX = (float) random.nextGaussian() * f3;
entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) random.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
world.func_147453_f(x, y, z, block);
}
super.breakBlock(world, x, y, z, block, meta);
}
@Override
public void onBlockPreDestroy(World world, int x, int y, int z, int oldMeta) {
TileCorporeaCatalyst tile = (TileCorporeaCatalyst) world.getTileEntity(x, y, z);
for (ChunkCoordinates coords : tile.getBindings()) {
TileEntity target = world.getTileEntity(coords.posX, coords.posY, coords.posZ);
if (target instanceof ICorporeaModification) {
((ICorporeaModification) target).removeModification();
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(target);
}
}
}
@Override
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
return true;
}
public boolean renderAsNormalBlock() {
return false;
}
public boolean isOpaqueCube() {
return false;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileCorporeaCatalyst();
}
}
@@ -0,0 +1,45 @@
package ab.common.block;
import ab.AdvancedBotany;
import ab.common.block.tile.TileCorporeaInterrupter;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import vazkii.botania.common.block.corporea.BlockCorporeaBase;
import vazkii.botania.common.block.tile.corporea.TileCorporeaBase;
public class BlockCorporeaInterrupter extends BlockCorporeaBase {
public IIcon icons[];
public BlockCorporeaInterrupter() {
super(Material.iron, "CorporeaInterrupter");
this.icons = new IIcon[3];
this.setCreativeTab(AdvancedBotany.tabAB);
setHardness(5.5F);
setStepSound(soundTypeMetal);
}
@Override
public TileCorporeaBase createNewTileEntity(World world, int meta) {
return new TileCorporeaInterrupter();
}
@Override
public IIcon getIcon(int side, int meta) {
return icons[side > 1 ? 1 : 0];
}
@Override
public void registerBlockIcons(IIconRegister ir) {
for(int i = 0; i < icons.length; i++) {
this.icons[2] = ir.registerIcon("ab:interrupter_rune");
this.icons[1] = ir.registerIcon("ab:CorporeaInterrupter0");
this.icons[0] = ir.registerIcon("ab:CorporeaInterrupter1");
}
}
}
@@ -0,0 +1,76 @@
package ab.common.block;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBush;
import net.minecraft.block.IGrowable;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockFreyrLiana extends BlockBush {
public BlockFreyrLiana() {
super(Material.plants);
this.setBlockName("BlockFreyrLiana");
this.setStepSound(soundTypeGrass);
this.setBlockTextureName("ab:freyrLiana");
}
@Override
public boolean canPlaceBlockAt(World world, int x, int y, int z) {
return world.getBlock(x, y + 1, z).getMaterial() == Material.leaves
|| world.getBlock(x, y + 1, z).getMaterial() == Material.wood
|| world.getBlock(x, y + 1, z).getMaterial() == Material.ground
|| world.getBlock(x, y + 1, z).getMaterial() == Material.rock
|| world.getBlock(x, y + 1, z).getMaterial() == Material.sand
|| world.getBlock(x, y + 1, z).getMaterial() == Material.grass
|| world.getBlock(x, y + 1, z) instanceof BlockFreyrLiana;
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
this.checkAndDropBlock(world, x, y, z);
world.markBlockForUpdate(x, y, z);
for (int i1 = 1; i1 < 10; i1++) {
Block block = world.getBlock(x, y - i1, z);
if (block instanceof IGrowable || block instanceof BlockBush && !(block instanceof BlockFreyrLiana)) {
for (int i = 0; i < 5 + rand.nextInt(4); i++)
block.updateTick(world, x, y - i1, z, rand);
break;
}
}
}
@Override
protected void checkAndDropBlock(World p_149855_1_, int p_149855_2_, int p_149855_3_, int p_149855_4_) {
if (!this.canBlockStay(p_149855_1_, p_149855_2_, p_149855_3_, p_149855_4_)) {
this.dropBlockAsItem(p_149855_1_, p_149855_2_, p_149855_3_, p_149855_4_,
p_149855_1_.getBlockMetadata(p_149855_2_, p_149855_3_, p_149855_4_), 0);
p_149855_1_.setBlock(p_149855_2_, p_149855_3_, p_149855_4_, getBlockById(0), 0, 3);
}
}
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
return null;
}
@Override
public boolean canBlockStay(World world, int x, int y, int z) {
return this.canPlaceBlockAt(world, x, y, z);
}
public int getFlammability(final IBlockAccess world, final int x, final int y, final int z,
final ForgeDirection face) {
return 100;
}
public int getFireSpreadSpeed(final IBlockAccess world, final int x, final int y, final int z,
final ForgeDirection face) {
return 60;
}
}
@@ -0,0 +1,135 @@
package ab.common.block;
import java.util.List;
import ab.AdvancedBotany;
import ab.common.block.tile.TileLebethronCore;
import ab.common.lib.register.RecipeListAB;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.common.item.ModItems;
public class BlockLebethronWood extends Block implements ILexiconable, ITileEntityProvider {
private static IIcon[] icon = new IIcon[5];
public BlockLebethronWood() {
super(Material.wood);
this.setCreativeTab(AdvancedBotany.tabAB);
this.setHardness(6.0F);
this.setStepSound(soundTypeWood);
this.setBlockName("lebethronWood");
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
int meta = world.getBlockMetadata(x, y, z);
if(meta == 4) {
TileEntity tile = world.getTileEntity(x, y, z);
if(!(tile instanceof TileLebethronCore)) {
return false;
}
TileLebethronCore core = (TileLebethronCore)tile;
ItemStack heldItem = player.getCurrentEquippedItem();
if(heldItem == null)
return false;
Block block = Block.getBlockFromItem(heldItem.getItem());
if(block.getMaterial() == Material.leaves) {
core.updateStructure();
if(core.getValidTree()) {
if(core.setBlock(block, heldItem.getItemDamage())) {
heldItem.stackSize--;
if (heldItem.stackSize == 0)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z);
return true;
}
}
}
}
return false;
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if(!world.isRemote && meta == 4) {
TileLebethronCore tile = (TileLebethronCore)world.getTileEntity(x, y, z);
if(tile != null) {
ItemStack stack = new ItemStack(tile.getBlock(), 1, tile.getMeta());
if (stack != null) {
float f = world.rand.nextFloat() * 0.8F + 0.1F;
float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
float f2 = world.rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityitem = new EntityItem(world, (x + f), (y + f1), (z + f2), stack.copy());
float f3 = 0.05F;
entityitem.motionX = ((float)world.rand.nextGaussian() * f3);
entityitem.motionY = ((float)world.rand.nextGaussian() * f3 + 0.2F);
entityitem.motionZ = ((float)world.rand.nextGaussian() * f3);
if (stack.hasTagCompound())
entityitem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy());
world.spawnEntityInWorld(entityitem);
}
}
}
super.breakBlock(world, x, y, z, block, meta);
}
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List list) {
for(int i = 0; i < icon.length; i++) {
list.add(new ItemStack(par1, 1, i));
}
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister ir) {
for (int i = 0; i < icon.length; i++)
icon[i] = ir.registerIcon("ab:lebethronWood_" + i);
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return this.icon[meta];
}
public int damageDropped(int par1) {
return par1;
}
public int getLightValue(IBlockAccess world, int x, int y, int z) {
return (world.getBlockMetadata(x, y, z) == 3) ? 12 : 0;
}
public boolean canSustainLeaves(IBlockAccess world, int x, int y, int z) {
return (world.getBlockMetadata(x, y, z) == 0);
}
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
return new ItemStack(this, 1, meta);
}
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return RecipeListAB.lebethronWood;
}
public TileEntity createNewTileEntity(World world, int meta) {
return meta == 4 ? new TileLebethronCore() : null;
}
}
@@ -0,0 +1,55 @@
package ab.common.block;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import vazkii.botania.common.Botania;
public class BlockLuminousFreyrLiana extends BlockFreyrLiana {
public BlockLuminousFreyrLiana() {
this.setBlockName("BlockLuminousFreyrLiana");
this.setBlockTextureName("ab:freyrLuminousLiana");
this.setTickRandomly(true);
}
public int getLightValue() {
return 11;
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
super.updateTick(world, x, y, z, rand);
if (rand.nextInt(11) == 0)
world.setBlockMetadataWithNotify(x, y, z, 1, 3);
}
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
if (world.getBlockMetadata(x, y, z) == 1)
if(rand.nextInt(3) == 0)
Botania.proxy.wispFX(world, x + 0.1 + Math.random() * 0.8, y + Math.random() * 0.5,
z + 0.1 + Math.random() * 0.8, 249 / 255f, 230 / 255f, 3 / 255f, 0.14f, -0.04f, 2);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX,
float hitY, float hitZ) {
Random rand = new Random();
if (world.getBlockMetadata(x, y, z) == 1) {
if (!world.isRemote)
(new EntityItem(world, x + 0.5, y, z + 0.5))
.entityDropItem(new ItemStack(Items.gold_nugget, 1 + rand.nextInt(3)), 0.75f);
world.setBlockMetadataWithNotify(x, y, z, 0, 3);
return true;
}
return false;
}
}
@@ -0,0 +1,121 @@
package ab.common.block;
import ab.AdvancedBotany;
import ab.common.block.tile.TileManaCharger;
import ab.common.lib.register.BlockListAB;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.api.mana.IManaItem;
import vazkii.botania.api.wand.IWandHUD;
import vazkii.botania.api.wand.IWandable;
import vazkii.botania.common.block.tile.TileSimpleInventory;
public class BlockManaCharger extends BlockContainer implements IWandHUD, IWandable {
public BlockManaCharger() {
super(Material.iron);
this.setCreativeTab(AdvancedBotany.tabAB);
this.setHardness(6.0F);
float f = 0.0625f;
this.setBlockBounds(f * 3, f * 3, f * 3, 1.0f - f * 3, 1.0f - f * 4 + f * 3, 1.0f - f * 3);
this.setBlockName("ABManaCharger");
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7, float par8, float par9) {
TileManaCharger tile = (TileManaCharger)world.getTileEntity(x, y, z);
if(tile != null) {
int slotSide = side - 1;
if(slotSide < 0)
return false;
ItemStack heldItem = player.getCurrentEquippedItem();
ItemStack stackInSlot = tile.getStackInSlot(slotSide);
if(player.isSneaking()) {
if(stackInSlot != null) {
ItemStack copy = stackInSlot.copy();
if(!player.inventory.addItemStackToInventory(copy))
player.dropPlayerItemWithRandomChoice(copy, false);
if(!world.isRemote) {
tile.setInventorySlotContents(slotSide, null);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z);
}
world.func_147453_f(x, y, z, (Block)this);
return true;
}
} else {
if (heldItem != null && heldItem.getItem() instanceof IManaItem && stackInSlot == null && heldItem.getMaxStackSize() == 1) {
ItemStack copy = heldItem.copy();
copy.stackSize = 1;
heldItem.stackSize--;
if(heldItem.stackSize == 0)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
if(!world.isRemote) {
tile.setInventorySlotContents(slotSide, copy);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z);
}
return true;
}
}
}
return false;
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if(!world.isRemote) {
TileSimpleInventory inv = (TileSimpleInventory)world.getTileEntity(x, y, z);
if (inv != null) {
for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if (stack != null) {
float f = world.rand.nextFloat() * 0.8F + 0.1F;
float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
float f2 = world.rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityitem = new EntityItem(world, (x + f), (y + f1), (z + f2), stack.copy());
float f3 = 0.05F;
entityitem.motionX = ((float)world.rand.nextGaussian() * f3);
entityitem.motionY = ((float)world.rand.nextGaussian() * f3 + 0.2F);
entityitem.motionZ = ((float)world.rand.nextGaussian() * f3);
if (stack.hasTagCompound())
entityitem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy());
world.spawnEntityInWorld(entityitem);
}
}
}
}
super.breakBlock(world, x, y, z, block, meta);
}
public boolean isOpaqueCube() {
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
public int getRenderType() {
return BlockListAB.blockManaChargerRI;
}
public TileEntity createNewTileEntity(World world, int meta) {
return new TileManaCharger();
}
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) {
((TileManaCharger)world.getTileEntity(x, y, z)).renderHUD(mc, res);
}
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
((TileManaCharger)world.getTileEntity(x, y, z)).onWanded(player, stack);
return true;
}
}
@@ -0,0 +1,69 @@
package ab.common.block;
import java.util.Random;
import ab.AdvancedBotany;
import ab.common.block.tile.TileABSpreader;
import ab.common.block.tile.TileManaContainer;
import ab.common.lib.register.BlockListAB;
import ab.common.lib.register.RecipeListAB;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.wand.IWandHUD;
import vazkii.botania.api.wand.IWandable;
import vazkii.botania.common.block.BlockLivingrock;
import vazkii.botania.common.block.ModBlocks;
public class BlockManaContainer extends BlockContainer implements IWandHUD, IWandable, ILexiconable {
public BlockManaContainer() {
super(Material.iron);
this.setCreativeTab(AdvancedBotany.tabAB);
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 1.1875F, 0.9375F);
this.setHardness(9.0F);
this.setBlockName("ABManaContainer");
}
public TileEntity createNewTileEntity(World world, int meta) {
return new TileManaContainer();
}
public boolean isOpaqueCube() {
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
public int getRenderType() {
return BlockListAB.blockManaContainerRI;
}
public IIcon getIcon(int par1, int par2) {
return ModBlocks.livingrock.getIcon(0, 0);
}
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) {
((TileManaContainer)world.getTileEntity(x, y, z)).renderHUD(mc, res);
}
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
((TileManaContainer)world.getTileEntity(x, y, z)).onWanded(player, stack);
return true;
}
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return RecipeListAB.manaContainer;
}
}
@@ -0,0 +1,81 @@
package ab.common.block;
import ab.AdvancedBotany;
import ab.common.block.tile.TileManaCrystalCube;
import ab.common.lib.register.BlockListAB;
import ab.common.lib.register.RecipeListAB;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.wand.IWandHUD;
import vazkii.botania.api.wand.IWandable;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.item.ItemTwigWand;
public class BlockManaCrystalCube extends BlockContainer implements ILexiconable {
public BlockManaCrystalCube() {
super(Material.iron);
this.setCreativeTab(AdvancedBotany.tabAB);
float f = 0.1875F;
this.setBlockBounds(f, 0.0F, f, 1.0F - f, 1.0F, 1.0F - f);
this.setHardness(5.5F);
this.setStepSound(soundTypeMetal);
this.setBlockName("ABManaCrystalCube");
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7, float par8, float par9) {
boolean isWand = player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemTwigWand;
if(isWand)
return false;
TileManaCrystalCube tile = (TileManaCrystalCube)world.getTileEntity(x, y, z);
if(tile != null && !world.isRemote) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
tile.writeCustomNBT(nbttagcompound);
int[] mana = tile.getManaAround();
nbttagcompound.setInteger("knownMana", mana[0]);
nbttagcompound.setInteger("knownMaxMana", mana[1]);
if (player instanceof EntityPlayerMP)
((EntityPlayerMP)player).playerNetServerHandler.sendPacket((Packet)new S35PacketUpdateTileEntity(tile.xCoord, tile.yCoord, tile.zCoord, -999, nbttagcompound));
}
world.playSoundAtEntity((Entity)player, "botania:ding", 0.11F, 1.0F);
return true;
}
public TileEntity createNewTileEntity(World world, int meta) {
return new TileManaCrystalCube();
}
public IIcon getIcon(int par1, int par2) {
return ModBlocks.dreamwood.getIcon(0, 0);
}
public int getRenderType() {
return BlockListAB.blockManaCrystalCubeRI;
}
public boolean isOpaqueCube() {
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return RecipeListAB.manaCrystalCube;
}
}
@@ -0,0 +1,66 @@
package ab.common.block;
import java.util.ArrayList;
import java.util.Random;
import ab.AdvancedBotany;
import ab.common.block.tile.TileModifiedCorporeaFunnel;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.corporea.BlockCorporeaBase;
import vazkii.botania.common.block.tile.corporea.TileCorporeaBase;
import vazkii.botania.common.lib.LibBlockNames;
public class BlockModifiedFunnel extends BlockCorporeaBase {
public IIcon[] icons;
public BlockModifiedFunnel() {
super(Material.iron, "CorporeaFunnel");
setHardness(5.5F);
setStepSound(soundTypeMetal);
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister ir) {
icons = new IIcon[1];
this.icons[0] = ir.registerIcon("ab:funnel_rune");
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
boolean power = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z);
int meta = world.getBlockMetadata(x, y, z);
boolean powered = (meta & 8) != 0;
if(power && !powered) {
((TileModifiedCorporeaFunnel) world.getTileEntity(x, y, z)).doRequest();
world.setBlockMetadataWithNotify(x, y, z, meta | 8, 3);
} else if(!power && powered)
world.setBlockMetadataWithNotify(x, y, z, meta & -9, 3);
}
@Override
public Item getItemDropped(int par1, Random random, int par2)
{
return Item.getItemFromBlock(ModBlocks.corporeaFunnel);
}
@Override
public TileCorporeaBase createNewTileEntity(World arg0, int arg1) {
return new TileModifiedCorporeaFunnel();
}
@Override
public IIcon getIcon(int par1, int par2) {
return ModBlocks.corporeaFunnel.getIcon(par1, par2);
}
}
@@ -0,0 +1,70 @@
package ab.common.block;
import java.util.Random;
import ab.common.block.tile.TileModifiedInterceptor;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.corporea.BlockCorporeaBase;
import vazkii.botania.common.block.tile.corporea.TileCorporeaBase;
public class BlockModifiedInterceptor extends BlockCorporeaBase {
public IIcon[] icons;
public BlockModifiedInterceptor() {
super(Material.iron, "CorporeaInterceptor");
setHardness(5.5F);
setStepSound(soundTypeMetal);
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister ir) {
icons = new IIcon[1];
this.icons[0] = ir.registerIcon("ab:interceptor_rune");
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
world.setBlockMetadataWithNotify(x, y, z, 0, 3);
}
@Override
public boolean canProvidePower() {
return true;
}
@Override
public int tickRate(World world) {
return 2;
}
@Override
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) {
return world.getBlockMetadata(x, y, z) != 0 ? 15 : 0;
}
@Override
public TileCorporeaBase createNewTileEntity(World world, int meta) {
return new TileModifiedInterceptor();
}
@Override
public Item getItemDropped(int par1, Random random, int par2)
{
return Item.getItemFromBlock(ModBlocks.corporeaInterceptor);
}
@Override
public IIcon getIcon(int par1, int par2) {
return ModBlocks.corporeaInterceptor.getIcon(par1, par2);
}
}
@@ -0,0 +1,52 @@
package ab.common.block;
import java.util.Random;
import ab.common.block.tile.TileModifiedRetainer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.corporea.BlockCorporeaRetainer;
public class BlockModifiedRetainer extends BlockCorporeaRetainer {
public IIcon[] icons;
public BlockModifiedRetainer() {
super();
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister ir) {
icons = new IIcon[1];
this.icons[0] = ir.registerIcon("ab:retainer_rune");
}
@Override
public int getComparatorInputOverride(World world, int x, int y, int z, int s) {
return ((TileModifiedRetainer) world.getTileEntity(x, y, z)).hasPendingRequest() ? 15 : 0;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileModifiedRetainer();
}
@Override
public Item getItemDropped(int par1, Random random, int par2)
{
return Item.getItemFromBlock(ModBlocks.corporeaRetainer);
}
@Override
public IIcon getIcon(int par1, int par2) {
return ModBlocks.corporeaRetainer.getIcon(par1, par2);
}
}
@@ -0,0 +1,132 @@
package ab.common.block;
import static net.minecraftforge.common.util.ForgeDirection.UP;
import java.util.List;
import java.util.Random;
import ab.api.AdvancedBotanyAPI;
import ab.api.TerraFarmlandList;
import ab.common.lib.register.RecipeListAB;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBush;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.BlockFarmland;
import net.minecraft.block.IGrowable;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.ForgeDirection;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
public class BlockTerraFarmland extends Block implements ILexiconable {
private IIcon icon;
public BlockTerraFarmland() {
super(Material.ground);
this.setTickRandomly(true);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.9375F, 1.0F);
this.setLightOpacity(255);
}
public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) {
Block plant = plantable.getPlant(world, x, y + 1, z);
return plant != Blocks.cactus && plant != Blocks.reeds;
}
public void updateTick(World world, int x, int y, int z, Random rand) {
if(world.isRemote)
return;
Block block = world.getBlock(x, y + 1, z);
int meta = world.getBlockMetadata(x, y + 1, z);
if(block instanceof BlockCrops) {
if(meta == 7) {
refreshSeed(world, x, y, z, block, meta);
return;
}
} else if(block instanceof IPlantable) {
for(TerraFarmlandList fSeed : AdvancedBotanyAPI.farmlandList) {
int meta1 = fSeed.getMeta();
Block block1 = fSeed.getBlock();
if(block != block1)
continue;
if(meta == meta1) {
refreshSeed(world, x, y, z, block1, meta1);
return;
}
}
} else {
world.setBlock(x, y, z, Blocks.dirt);
}
}
private void refreshSeed(World world, int x, int y, int z, Block block, int meta) {
IPlantable seed = (IPlantable)block;
List<ItemStack> list = block.getDrops(world, x, y + 1, z, meta, 0);
for (ItemStack stack : list) {
if(stack == null)
continue;
else if(stack.getItem() == seed) {
if(stack.stackSize > 1)
stack.stackSize -= 1;
} else {
stack.stackSize = Math.min(64, (int)(stack.stackSize * 3.5f));
}
}
for (ItemStack stack : list) {
if(stack == null)
continue;
EntityItem itemEnt = new EntityItem(world, x + 0.5f, y + 1, z + 0.5f, stack);
world.spawnEntityInWorld(itemEnt);
}
world.setBlock(x, y + 1, z, block, 0, 3);
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) {
return AxisAlignedBB.getBoundingBox((double)(p_149668_2_ + 0), (double)(p_149668_3_ + 0), (double)(p_149668_4_ + 0), (double)(p_149668_2_ + 1), (double)(p_149668_3_ + 1), (double)(p_149668_4_ + 1));
}
public boolean isOpaqueCube() {
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
return Blocks.dirt.getItemDropped(0, p_149650_2_, p_149650_3_);
}
@SideOnly(Side.CLIENT)
public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) {
return Item.getItemFromBlock(Blocks.dirt);
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int p_149691_2_) {
return p_149691_1_ == 1 ? icon : Blocks.dirt.getIcon(0, 0);
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
icon = reg.registerIcon("ab:terraFarmland");
}
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return RecipeListAB.terraHoe;
}
}
@@ -0,0 +1,41 @@
package ab.common.block.subtile;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import vazkii.botania.api.subtile.signature.SubTileSignature;
import vazkii.botania.common.block.BlockSpecialFlower;
public class ABSubTileSignature extends SubTileSignature {
String name;
IIcon icon;
public ABSubTileSignature(String name) {
this.name = name;
}
public void registerIcons(IIconRegister reg) {
this.icon = reg.registerIcon("ab:flower_" + this.name);
BlockSpecialFlower.icons.put(name, icon);
}
public IIcon getIconForStack(ItemStack item) {
return this.icon;
}
public String getUnlocalizedNameForStack(ItemStack item) {
return "ab.flower." + this.name;
}
public String getUnlocalizedLoreTextForStack(ItemStack item) {
return "tile.ab.flower." + this.name + ".lore";
}
public void addTooltip(ItemStack stack, EntityPlayer player, List<String> tooltip) {
}
}
@@ -0,0 +1,93 @@
package ab.common.block.subtile;
import java.util.List;
import ab.api.AdvancedBotanyAPI;
import ab.api.recipe.RecipeAncientAlphirine;
import ab.common.lib.register.BlockListAB;
import ab.common.lib.register.RecipeListAB;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.lexicon.multiblock.Multiblock;
import vazkii.botania.api.lexicon.multiblock.MultiblockSet;
import vazkii.botania.api.subtile.SubTileEntity;
import vazkii.botania.api.subtile.SubTileFunctional;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.ModFluffBlocks;
import vazkii.botania.common.item.ItemLexicon;
public class SubTileAncientAlphirine extends SubTileFunctional {
protected static int manaRequare = 4500;
public void onUpdate() {
super.onUpdate();
int posX = this.supertile.xCoord;
int posY = this.supertile.yCoord;
int posZ = this.supertile.zCoord;
World world = this.supertile.getWorldObj();
List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, (posX + 1), (posY + 1), (posZ + 1)).expand(1, 0, 1));
if(this.ticksExisted % 10 == 0) {
label48: for(EntityItem item : items) {
for(RecipeAncientAlphirine recipe : AdvancedBotanyAPI.alphirineRecipes) {
if(recipe.matches(item.getEntityItem())) {
if(this.mana >= manaRequare && item.getEntityItem().stackSize >= 1) {
if(world.isRemote) {
spawnParticle(world, item);
} else {
if(item.getEntityItem().stackSize > 1)
item.getEntityItem().stackSize -= 1;
else
item.setDead();
if(world.rand.nextInt(175) <= recipe.getChance()) {
EntityItem itemResult = new EntityItem(world, item.posX, item.posY, item.posZ);
itemResult.setEntityItemStack(recipe.getOutput().copy());
world.spawnEntityInWorld(itemResult);
}
}
this.mana -= manaRequare;
break label48;
}
}
}
if(item.getEntityItem().getItem() instanceof ItemLexicon) {
if(!((ItemLexicon)item.getEntityItem().getItem()).isKnowledgeUnlocked(item.getEntityItem(), RecipeListAB.forgotten) && this.mana >= 45000) {
((ItemLexicon)item.getEntityItem().getItem()).unlockKnowledge(item.getEntityItem(), RecipeListAB.forgotten);
this.mana -= manaRequare;
if(world.isRemote)
spawnParticle(world, item);
break label48;
}
}
}
}
}
private void spawnParticle(World world, EntityItem item) {
for(int i = 0; i < 12; i++)
Botania.proxy.wispFX(world, item.posX, item.posY, item.posZ, 232 - (int)(Math.random() * 20), 212 - (int)(Math.random() * 20), 82 - (int)(Math.random() * 20), (float)Math.random() * 0.25F, (float)(Math.random() - 0.5D) * 0.0275F, (float)(Math.random() - 0.5D) * 0.0275F, (float)(Math.random() - 0.5D) * 0.0275F);
}
public int getMaxMana() {
return 180000;
}
public int getColor() {
return 0xd0bf58;
}
public LexiconEntry getEntry() {
return RecipeListAB.ancientAlphirine;
}
}
@@ -0,0 +1,94 @@
package ab.common.block.subtile;
import java.util.List;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBook;
import net.minecraft.item.ItemEditableBook;
import net.minecraft.item.ItemEnchantedBook;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import thaumcraft.common.items.ItemResource;
import thaumcraft.common.items.relics.ItemThaumonomicon;
import vazkii.botania.api.subtile.SubTileGenerating;
import vazkii.botania.common.Botania;
import vazkii.botania.common.item.ItemLexicon;
public class SubTileAngryMallos extends SubTileGenerating {
int cooldown = 0;
static int workMana = 360;
public void onUpdate() {
super.onUpdate();
if(this.cooldown > 0)
this.cooldown -= 1;
int posX = this.supertile.xCoord;
int posY = this.supertile.yCoord;
int posZ = this.supertile.zCoord;
World world = this.supertile.getWorldObj();
List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, (posX + 1), (posY + 1), (posZ + 1)).expand(1, 0, 1));
for(EntityItem item : items) {
ItemStack stack = ((EntityItem)item).getEntityItem();
if(this.cooldown > 0)
break;
else if(stack == null)
continue;
else if(searchKnowledge(stack) == 0)
continue;
int mana = searchKnowledge(stack);
if(stack.stackSize > 1)
stack.stackSize -= 1;
else
item.setDead();
this.mana = Math.min(this.getMaxMana(), this.mana + mana);
this.cooldown = 18;
if(world.isRemote)
for (int i = 0; i < 10; i++) {
float m = 0.2F;
float mx = (float)(Math.random() - 0.5D) * m;
float my = (float)(Math.random() - 0.5D) * m;
float mz = (float)(Math.random() - 0.5D) * m;
world.spawnParticle("iconcrack_" + Item.getIdFromItem(stack.getItem()) + "_" + stack.getItemDamage(), item.posX, item.posY, item.posZ, mx, my, mz);
}
break;
}
}
public int getMaxMana() {
return 76800;
}
public int getColor() {
return 0xdbc989;
}
public void writeToPacketNBT(NBTTagCompound cmp) {
super.writeToPacketNBT(cmp);
cmp.setInteger("cooldown", this.cooldown);
}
public void readFromPacketNBT(NBTTagCompound cmp) {
super.readFromPacketNBT(cmp);
this.cooldown = cmp.getInteger("cooldown");
}
static int searchKnowledge(ItemStack stack) {
if(stack.getItem() instanceof ItemBook || stack.getItem() instanceof ItemEditableBook)
return workMana;
else if(stack.getItem() instanceof ItemEnchantedBook)
return (int)(workMana * 2.5f);
else if(stack.getItem() instanceof ItemLexicon)
return workMana * 3;
if(Botania.thaumcraftLoaded) {
if(stack.getItem() instanceof ItemThaumonomicon)
return (int)(workMana * 3.2f);
else if(stack.getItem() instanceof ItemResource && stack.getItemDamage() == 9)
return workMana * 2;
}
return 0;
}
}
@@ -0,0 +1,89 @@
package ab.common.block.subtile;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.common.Thaumcraft;
import thaumcraft.common.lib.network.PacketHandler;
import thaumcraft.common.lib.network.playerdata.PacketAspectPool;
import thaumcraft.common.lib.network.playerdata.PacketSyncAspects;
import vazkii.botania.api.subtile.SubTileFunctional;
public class SubTileAspecolus extends SubTileFunctional {
protected static int manaRequare = 1250;
int cooldown = 0;
public void onUpdate() {
super.onUpdate();
World world = this.supertile.getWorldObj();
if(world.isRemote)
return;
if(this.cooldown > 0)
this.cooldown -= 1;
int posX = this.supertile.xCoord;
int posY = this.supertile.yCoord;
int posZ = this.supertile.zCoord;
List<EntityPlayer> players = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, (posX + 1), (posY + 1), (posZ + 1)));
int countPlayer = 0;
for(EntityPlayer p : players) {
if(!(this.mana >= this.manaRequare))
break;
else if(this.cooldown > 0)
break;
AspectList aspList = Thaumcraft.proxy.playerKnowledge.getAspectsDiscovered(p.getDisplayName());
ArrayList<Aspect> aspects = new ArrayList<Aspect>();
for(Aspect a : aspList.getAspects()) {
if(!Aspect.getPrimalAspects().contains(a) && Thaumcraft.proxy.playerKnowledge.getAspectPoolFor(p.getCommandSenderName(), a) > 0)
aspects.add(a);
}
if(aspects.isEmpty())
continue;
for(int i = 0; i < 8; i++) {
Aspect a = aspects.get(world.rand.nextInt(aspects.size()));
if(!(Thaumcraft.proxy.playerKnowledge.getAspectPoolFor(p.getCommandSenderName(), a) > 0))
continue;
Aspect[] components = a.getComponents();
aspList.reduce(a, 1);
for(int r = 0; r < components.length; r++) {
if(world.rand.nextInt(100) < 70)
continue;
Thaumcraft.proxy.playerKnowledge.addAspectPool(p.getDisplayName(), components[r], (short) 1);
PacketHandler.INSTANCE.sendTo(new PacketAspectPool(components[r].getTag(), (short) 1, Thaumcraft.proxy.playerKnowledge.getAspectPoolFor(p.getCommandSenderName(), components[r])),
(EntityPlayerMP) p);
}
}
this.mana -= this.manaRequare;
this.sync();
++countPlayer;
}
if(countPlayer > 0)
this.cooldown = 75 * countPlayer;
}
public int getMaxMana() {
return 15000;
}
public int getColor() {
return 0xd0bf58;
}
public void writeToPacketNBT(NBTTagCompound cmp) {
super.writeToPacketNBT(cmp);
cmp.setInteger("cooldown", this.cooldown);
}
public void readFromPacketNBT(NBTTagCompound cmp) {
super.readFromPacketNBT(cmp);
this.cooldown = cmp.getInteger("cooldown");
}
}
@@ -0,0 +1,61 @@
package ab.common.block.subtile;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import vazkii.botania.api.subtile.SubTileGenerating;
public class SubTileDictarius extends SubTileGenerating {
int cooldown = 0;
int workMana = 400;
public void onUpdate() {
super.onUpdate();
int posX = this.supertile.xCoord;
int posY = this.supertile.yCoord;
int posZ = this.supertile.zCoord;
World world = this.supertile.getWorldObj();
if(this.cooldown == 0) {
List<EntityLivingBase> livs = world.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, (posX + 1), (posY + 1), (posZ + 1)).expand(4, 3, 4));
int workMana = 0;
for(EntityLivingBase liv : livs) {
if(liv instanceof EntityPlayer)
workMana += this.workMana;
else if(liv instanceof EntityVillager)
workMana += (int)(this.workMana / 8);
}
this.cooldown = 200;
this.mana = Math.min(this.getMaxMana(), this.mana + workMana);
sync();
}
if(this.cooldown > 0) {
this.cooldown -= 1;
}
}
public int getMaxMana() {
return 15000;
}
public int getColor() {
return 0xdbc989;
}
public void writeToPacketNBT(NBTTagCompound cmp) {
super.writeToPacketNBT(cmp);
cmp.setInteger("cooldown", this.cooldown);
}
public void readFromPacketNBT(NBTTagCompound cmp) {
super.readFromPacketNBT(cmp);
this.cooldown = cmp.getInteger("cooldown");
}
}
@@ -0,0 +1,123 @@
package ab.common.block.tile;
import java.util.UUID;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.StatCollector;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.api.mana.BurstProperties;
import vazkii.botania.api.mana.ILensEffect;
import vazkii.botania.api.mana.IManaReceiver;
import vazkii.botania.client.core.handler.HUDHandler;
import vazkii.botania.common.block.tile.mana.TileSpreader;
import vazkii.botania.common.entity.EntityManaBurst;
public class TileABSpreader extends TileSpreader {
protected boolean requestsClientUpdate = false;
protected int knownMana = -1;
protected IManaReceiver receiver = null;
public void readCustomNBT(NBTTagCompound cmp) {
super.readCustomNBT(cmp);
this.requestsClientUpdate = cmp.getBoolean("requestUpdate");
if (cmp.hasKey("knownMana"))
this.knownMana = cmp.getInteger("knownMana");
if (this.requestsClientUpdate && this.worldObj != null) {
int x = cmp.getInteger("forceClientBindingX");
int y = cmp.getInteger("forceClientBindingY");
int z = cmp.getInteger("forceClientBindingZ");
if (y != -1) {
TileEntity tile = this.worldObj.getTileEntity(x, y, z);
if (tile instanceof IManaReceiver) {
this.receiver = (IManaReceiver)tile;
} else {
this.receiver = null;
}
} else {
this.receiver = null;
}
}
}
public EntityManaBurst getBurst(boolean fake) {
EntityManaBurst burst = new EntityManaBurst(this, fake);
if (burst != null) {
int maxMana = 30720;
int color = 0xcdd419;
int ticksBeforeManaLoss = 35;
float manaLossPerTick = 5376;
float motionModifier = 6.5f;
float gravity = 0.0f;
BurstProperties props = new BurstProperties(maxMana, ticksBeforeManaLoss, manaLossPerTick, gravity, motionModifier, color);
ItemStack lens = this.getStackInSlot(0);
if (lens != null && lens.getItem() instanceof ILensEffect) {
((ILensEffect)lens.getItem()).apply(lens, props);
}
burst.setSourceLens(lens);
if (this.getCurrentMana() >= props.maxMana || fake) {
burst.setColor(props.color);
burst.setMana(props.maxMana);
burst.setStartingMana(props.maxMana);
burst.setMinManaLoss(props.ticksBeforeManaLoss);
burst.setManaLossPerTick(props.manaLossPerTick);
burst.setGravity(props.gravity);
burst.setMotion(burst.motionX * props.motionModifier, burst.motionY * props.motionModifier, burst.motionZ * props.motionModifier);
}
}
return burst;
}
public void renderHUD(Minecraft mc, ScaledResolution res) {
String name = StatCollector.translateToLocal("tile.advancedSpreader.name");
int color = 0xcdd419;
HUDHandler.drawSimpleManaHUD(color, this.knownMana, getMaxMana(), name, res);
ItemStack lens = getStackInSlot(0);
if (lens != null) {
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
String lensName = lens.getDisplayName();
int width = 16 + mc.fontRenderer.getStringWidth(lensName) / 2;
int x = res.getScaledWidth() / 2 - width;
int y = res.getScaledHeight() / 2 + 50;
mc.fontRenderer.drawStringWithShadow(lensName, x + 20, y + 5, color);
RenderHelper.enableGUIStandardItemLighting();
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, lens, x, y);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(2896);
GL11.glDisable(3042);
}
if (this.receiver != null) {
TileEntity receiverTile = (TileEntity)this.receiver;
ItemStack recieverStack = new ItemStack(this.worldObj.getBlock(receiverTile.xCoord, receiverTile.yCoord, receiverTile.zCoord), 1, receiverTile.getBlockMetadata());
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
if (recieverStack != null && recieverStack.getItem() != null) {
String stackName = recieverStack.getDisplayName();
int width = 16 + mc.fontRenderer.getStringWidth(stackName) / 2;
int x = res.getScaledWidth() / 2 - width;
int y = res.getScaledHeight() / 2 + 30;
mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, color);
RenderHelper.enableGUIStandardItemLighting();
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recieverStack, x, y);
RenderHelper.disableStandardItemLighting();
}
GL11.glDisable(2896);
GL11.glDisable(3042);
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
public int getMaxMana() {
return 192000;
}
}
@@ -0,0 +1,270 @@
package ab.common.block.tile;
import java.util.List;
import ab.api.AdvancedBotanyAPI;
import ab.api.recipe.RecipeAdvancedPlate;
import ab.common.lib.register.BlockListAB;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import scala.reflect.internal.Trees.This;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.api.lexicon.multiblock.Multiblock;
import vazkii.botania.api.lexicon.multiblock.MultiblockSet;
import vazkii.botania.api.mana.IManaPool;
import vazkii.botania.api.mana.IManaReceiver;
import vazkii.botania.api.mana.spark.ISparkAttachable;
import vazkii.botania.api.mana.spark.ISparkEntity;
import vazkii.botania.api.mana.spark.SparkHelper;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.ModFluffBlocks;
import vazkii.botania.common.block.tile.TileMod;
import vazkii.botania.common.block.tile.TileSimpleInventory;
import vazkii.botania.common.item.ModItems;
public class TileAgglomerationPlate extends TileSimpleInventory implements ISparkAttachable, ISidedInventory {
private static final int[][] MANA_STEEL_BLOCKS = new int[][] { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 } };
private static final int[][] MANA_QUARZ_BLOCKS = new int[][] { { 0, 0 }, { 1, 1 }, { 1, -1 }, { -1, 1 }, { -1, -1 } };
int mana;
public int manaToGet;
public static MultiblockSet makeMultiblockSet() {
Multiblock mb = new Multiblock();
for (int[] l : MANA_STEEL_BLOCKS)
mb.addComponent(l[0], 0, l[1], ModBlocks.storage, 0);
for (int[] l : MANA_QUARZ_BLOCKS)
mb.addComponent(l[0], 0, l[1], ModFluffBlocks.manaQuartz, 0);
mb.addComponent(0, 1, 0, BlockListAB.blockABPlate, 0);
mb.setRenderOffset(0, 1, 0);
return mb.makeSet();
}
public void updateEntity() {
if(!this.worldObj.isRemote) {
updateServer();
} else {
updateClient();
}
if(hasValidPlatform()) {
boolean hasCraft = false;
for(RecipeAdvancedPlate recipe : AdvancedBotanyAPI.advancedPlateRecipes) {
if(recipe.matches(this)) {
if(this.getStackInSlot(0) == null) {
this.manaToGet = recipe.getManaUsage();
hasCraft = true;
break;
} else {
if(this.getStackInSlot(0).isItemEqual(recipe.getOutput()) && this.getStackInSlot(0).stackSize < 64) {
this.manaToGet = recipe.getManaUsage();
hasCraft = true;
break;
}
}
}
}
if(!hasCraft) {
this.mana = 0;
this.manaToGet = 0;
}
}
ISparkEntity spark = getAttachedSpark();
if (spark != null) {
List<ISparkEntity> sparkEntities = SparkHelper.getSparksAround(this.worldObj, this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D);
for (ISparkEntity otherSpark : sparkEntities) {
if (spark == otherSpark)
continue;
if (otherSpark.getAttachedTile() != null && otherSpark.getAttachedTile() instanceof IManaPool)
otherSpark.registerTransfer(spark);
}
}
}
private void updateServer() {
List<EntityItem> items = this.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord, this.zCoord, (this.xCoord + 1), (this.yCoord + 1), (this.zCoord + 1)));
for (EntityItem item : items) {
if (!item.isDead && item.getEntityItem() != null) {
ItemStack stack = item.getEntityItem();
int splitCount = addItemStack(stack);
stack.splitStack(splitCount);
if(splitCount > 0)
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
}
}
if(this.isFull() && this.mana > 0) {
ItemStack output = null;
for(RecipeAdvancedPlate recipe : AdvancedBotanyAPI.advancedPlateRecipes) {
if(recipe.matches(this)) {
output = recipe.getOutput().copy();
this.recieveMana(-recipe.getManaUsage());
this.manaToGet = 0;
for(int i = 1; i < this.getSizeInventory(); i++) {
if(this.getStackInSlot(i).stackSize > 1) {
this.getStackInSlot(i).stackSize -= 1;
} else {
this.setInventorySlotContents(i, null);
}
}
if(this.getStackInSlot(0) != null) {
this.getStackInSlot(0).stackSize += 1;
} else {
this.setInventorySlotContents(0, output);
}
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
break;
}
}
}
}
private void updateClient() {
if(this.mana > 0)
doParticles();
}
private void doParticles() {
if (this.worldObj.isRemote) {
int ticks = (int)(100.0D * getCurrentMana() / this.manaToGet);
int totalSpiritCount = 3;
double tickIncrement = 360.0D / totalSpiritCount;
int speed = 5;
double wticks = (ticks * speed) - tickIncrement;
double r = Math.sin((ticks - 100) / 10.0D) * 2.0D;
double g = Math.sin(wticks * Math.PI / 180.0D * 0.55D);
for (int i = 0; i < totalSpiritCount; i++) {
double x = this.xCoord + Math.sin(wticks * Math.PI / 180.0D) * r + 0.5D;
double y = this.yCoord + 0.25D + Math.abs(r) * 0.7D;
double z = this.zCoord + Math.cos(wticks * Math.PI / 180.0D) * r + 0.5D;
wticks += tickIncrement;
float[] colorsfx = { 0.0F, ticks / 100.0F, ticks / 100.0F };
Botania.proxy.wispFX(this.worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], 0.85F, (float)g * 0.05F, 0.25F);
Botania.proxy.wispFX(this.worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], (float)Math.random() * 0.1F + 0.1F, (float)(Math.random() - 0.5D) * 0.05F, (float)(Math.random() - 0.5D) * 0.05F, (float)(Math.random() - 0.5D) * 0.05F, 0.9F);
if (ticks == 100)
for (int j = 0; j < 15; j++)
Botania.proxy.wispFX(this.worldObj, this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, colorsfx[0], colorsfx[1], colorsfx[2], (float)Math.random() * 0.15F + 0.15F, (float)(Math.random() - 0.5D) * 0.125F, (float)(Math.random() - 0.5D) * 0.125F, (float)(Math.random() - 0.5D) * 0.125F);
}
}
}
private int addItemStack(ItemStack stack) {
for (int i = 1; i < getSizeInventory(); i++) {
if(getStackInSlot(i) == null) {
ItemStack stackToAdd = stack.copy();
setInventorySlotContents(i, stackToAdd);
return stack.stackSize;
} else {
if(getStackInSlot(i).getItem() == stack.getItem() && getStackInSlot(i).getItemDamage() == stack.getItemDamage() && ItemStack.areItemStackTagsEqual(stack, getStackInSlot(i)) && stack.getMaxStackSize() > getStackInSlot(i).stackSize) {
if(getStackInSlot(i).stackSize < 64) {
int count = 64 - getStackInSlot(i).stackSize;
if(stack.stackSize <= count) {
getStackInSlot(i).stackSize += stack.stackSize;
return stack.stackSize;
} else {
getStackInSlot(i).stackSize += count;
return stack.stackSize - count;
}
}
}
}
}
return 0;
}
boolean hasValidPlatform() {
return (checkAll(MANA_STEEL_BLOCKS, ModBlocks.storage, 0, -1) && checkAll(MANA_QUARZ_BLOCKS, ModFluffBlocks.manaQuartz, 0, -1));
}
boolean checkAll(int[][] positions, Block block, int meta, int yOff) {
for (int[] position : positions) {
int[] positions_ = position;
if (!checkPlatform(positions_[0], yOff, positions_[1], block, meta))
return false;
}
return true;
}
boolean checkPlatform(int xOff, int yOff, int zOff, Block block, int meta) {
Block checkBlock = this.worldObj.getBlock(this.xCoord + xOff, this.yCoord + yOff, zOff + this.zCoord);
return checkBlock == block && this.worldObj.getBlockMetadata(this.xCoord + xOff, this.yCoord + yOff, zOff + this.zCoord) == meta;
}
public void writeCustomNBT(NBTTagCompound cmp) {
super.writeCustomNBT(cmp);
cmp.setInteger("mana", this.mana);
cmp.setInteger("manaToGet", this.manaToGet);
}
public void readCustomNBT(NBTTagCompound cmp) {
super.readCustomNBT(cmp);
this.mana = cmp.getInteger("mana");
this.manaToGet = cmp.getInteger("manaToGet");
}
public int getSizeInventory() {
return 4;
}
public String getInventoryName() {
return "tileAdvancedPlate";
}
public int getCurrentMana() {
return this.mana;
}
public boolean isFull() {
return this.mana >= this.manaToGet;
}
public void recieveMana(final int mana) {
this.mana = Math.min(this.mana + mana, this.manaToGet);
}
public boolean canRecieveManaFromBursts() {
return !this.isFull();
}
public boolean canAttachSpark(ItemStack stack) {
return true;
}
public void attachSpark(ISparkEntity entity) {}
public ISparkEntity getAttachedSpark() {
List<ISparkEntity> sparks = this.worldObj.getEntitiesWithinAABB(ISparkEntity.class, AxisAlignedBB.getBoundingBox(this.xCoord, (this.yCoord + 1), this.zCoord, (this.xCoord + 1), (this.yCoord + 2), (this.zCoord + 1)));
if (sparks.size() == 1) {
Entity e = (Entity)sparks.get(0);
return (ISparkEntity)e;
}
return null;
}
public boolean areIncomingTranfersDone() {
return this.isFull();
}
public int getAvailableSpaceForMana() {
return Math.max(0, this.manaToGet - getCurrentMana());
}
public int[] getAccessibleSlotsFromSide(int par1) {
return new int[0];
}
public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) {
return false;
}
public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) {
return false;
}
}
@@ -0,0 +1,162 @@
package ab.common.block.tile;
import java.util.LinkedList;
import java.util.List;
import ab.api.ICorporeaModification;
import ab.common.lib.register.BlockListAB;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChunkCoordinates;
import vazkii.botania.api.wand.IWandBindable;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.tile.corporea.TileCorporeaCrystalCube;
import vazkii.botania.common.block.tile.corporea.TileCorporeaFunnel;
import vazkii.botania.common.block.tile.corporea.TileCorporeaInterceptor;
import vazkii.botania.common.block.tile.corporea.TileCorporeaRetainer;
public class TileCorporeaCatalyst extends TileEntity implements IWandBindable {
public int sideRune;
private List<ChunkCoordinates> bindings = new LinkedList<ChunkCoordinates>();
@Override
public ChunkCoordinates getBinding() {
return new ChunkCoordinates(0, 0, 0);
}
public List<ChunkCoordinates> getBindings() {
return this.bindings;
}
@Override
public void updateEntity() {
List<ChunkCoordinates> bindingsCopy = new LinkedList(bindings);
for (ChunkCoordinates coords : bindingsCopy) {
if (!isModified(coords.posX, coords.posY, coords.posZ)
|| ((ICorporeaModification) this.worldObj.getTileEntity(coords.posX, coords.posY, coords.posZ))
.getCatalystTile() != this) {
bindings.remove(coords);
}
}
}
private boolean isModified(int x, int y, int z) {
return this.worldObj.getTileEntity(x, y, z) instanceof ICorporeaModification
&& ((ICorporeaModification) this.worldObj.getTileEntity(x, y, z)).isModified();
}
public boolean modify(int x, int y, int z) {
Block block = this.worldObj.getBlock(x, y, z);
if (block == ModBlocks.corporeaFunnel)
this.worldObj.setBlock(x, y, z, BlockListAB.blockModifiedCorporeaFunnel);
else if ((block == ModBlocks.corporeaInterceptor))
this.worldObj.setBlock(x, y, z, BlockListAB.blockModifiedInterceptor);
else if ((block == ModBlocks.corporeaRetainer))
this.worldObj.setBlock(x, y, z, BlockListAB.blockModifiedRetainer);
else
return false;
return true;
}
@Override
public boolean canSelect(EntityPlayer player, ItemStack stack, int x, int y, int z, int side) {
return true;
}
public int getRune() {
return this.getBlockMetadata() - 1;
}
@Override
public boolean bindTo(EntityPlayer player, ItemStack stack, int x, int y, int z, int side) {
ChunkCoordinates coords = new ChunkCoordinates(x, y, z);
if (isModified(x, y, z)) {
if (this.bindings.contains(coords)) {
this.bindings.remove(coords);
((ICorporeaModification)worldObj.getTileEntity(x, y, z)).removeModification();
return true;
} else
((ICorporeaModification) this.worldObj.getTileEntity(x, y, z)).getCatalystTile().bindings
.remove(coords);
} else if (Math.abs(x - this.xCoord) < 8 && Math.abs(y - this.yCoord) < 8 && Math.abs(z - this.zCoord) < 8
&& canBeModified(this.worldObj.getTileEntity(x, y, z))) {
modify(x, y, z);
} else
return false;
bindings.add(coords);
((ICorporeaModification) this.worldObj.getTileEntity(x, y, z)).setCatalystCoords(this.xCoord, this.yCoord,
this.zCoord);
return true;
}
@Override
public void readFromNBT(NBTTagCompound nbtt) {
super.readFromNBT(nbtt);
this.sideRune = nbtt.getInteger("sideRune");
int[] xCoords = nbtt.getIntArray("xCoords");
int[] yCoords = nbtt.getIntArray("yCoords");
int[] zCoords = nbtt.getIntArray("zCoords");
int i = 0;
while (i < xCoords.length) {
bindings.add(new ChunkCoordinates(xCoords[i], yCoords[i], zCoords[i]));
i++;
}
}
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox() {
return AxisAlignedBB.getBoundingBox(xCoord - 1, yCoord - 1, zCoord - 1, xCoord + 2, yCoord + 2, zCoord + 2);
}
@Override
public void writeToNBT(NBTTagCompound nbtt) {
super.writeToNBT(nbtt);
nbtt.setInteger("sideRune", sideRune);
int[] xCoords = new int[bindings.size()];
int[] yCoords = new int[bindings.size()];
int[] zCoords = new int[bindings.size()];
int i = 0;
for (ChunkCoordinates coords : bindings) {
xCoords[i] = coords.posX;
yCoords[i] = coords.posY;
zCoords[i] = coords.posZ;
i++;
}
nbtt.setIntArray("xCoords", xCoords);
nbtt.setIntArray("yCoords", yCoords);
nbtt.setIntArray("zCoords", zCoords);
}
@Override
public final void onDataPacket(final NetworkManager manager, final S35PacketUpdateTileEntity paket) {
super.onDataPacket(manager, paket);
this.readFromNBT(paket.func_148857_g());
}
@Override
public Packet getDescriptionPacket() {
final NBTTagCompound compound = new NBTTagCompound();
this.writeToNBT(compound);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 10, compound);
}
private boolean canBeModified(TileEntity tile) {
return tile instanceof TileCorporeaCrystalCube || tile instanceof TileCorporeaFunnel
|| tile instanceof TileCorporeaInterceptor || tile instanceof TileCorporeaRetainer
|| tile instanceof ICorporeaModification;
}
}
@@ -0,0 +1,235 @@
package ab.common.block.tile;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import ab.api.AdvancedCorporeaHelper;
import ab.api.ICorporeaModification;
import ab.common.integration.corporea.ICorporeaInterrupter;
import ab.common.lib.utils.Pair;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import vazkii.botania.api.corporea.CorporeaHelper;
import vazkii.botania.api.corporea.CorporeaRequestEvent;
import vazkii.botania.api.corporea.ICorporeaInterceptor;
import vazkii.botania.api.corporea.ICorporeaSpark;
import vazkii.botania.api.corporea.IWrappedInventory;
import vazkii.botania.common.block.tile.corporea.TileCorporeaBase;
import vazkii.botania.common.core.helper.ItemNBTHelper;
public class TileCorporeaInterrupter extends TileCorporeaBase implements ICorporeaInterrupter, ICorporeaModification {
ChunkCoordinates coords = new ChunkCoordinates();;
boolean hasCatalyst = false;
@Override
public int getSizeInventory() {
return 1;
}
@Override
public String getInventoryName() {
return "CorporeaInterrupter";
}
@Override
public void onInterrupt(CorporeaRequestEvent event) {
if(this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord))
return;
int rune = -1;
if (this.getCatalystTile() != null)
rune = this.getCatalystTile().getRune();
List<ItemStack> stacks = new ArrayList<ItemStack>();
IInventory inv$ = event.spark.getInventory();
List<IInventory> inventories = CorporeaHelper.getInventoriesOnNetwork(event.spark);
List<IWrappedInventory> inventoriesW = AdvancedCorporeaHelper.wrapInventory(inventories);
Map<ICorporeaInterceptor, ICorporeaSpark> interceptors = new HashMap<ICorporeaInterceptor, ICorporeaSpark>();
switch (rune) {
case -1:
if (this.worldObj.getTileEntity(xCoord + 1, yCoord, zCoord) == inv$
|| this.worldObj.getTileEntity(xCoord, yCoord, zCoord + 1) == inv$
|| this.worldObj.getTileEntity(xCoord - 1, yCoord, zCoord) == inv$
|| this.worldObj.getTileEntity(xCoord, yCoord, zCoord - 1) == inv$)
event.setCanceled(true);
case 1:
if (this.worldObj.getTileEntity(xCoord + 1, yCoord, zCoord) == inv$
|| this.worldObj.getTileEntity(xCoord, yCoord, zCoord + 1) == inv$
|| this.worldObj.getTileEntity(xCoord - 1, yCoord, zCoord) == inv$
|| this.worldObj.getTileEntity(xCoord, yCoord, zCoord - 1) == inv$)
for (IWrappedInventory invW : inventoriesW) {
ICorporeaSpark invSpark = invW.getSpark();
Object originalInventory = invW.getWrappedObject();
if (originalInventory instanceof ICorporeaInterceptor) {
ICorporeaInterceptor interceptor = (ICorporeaInterceptor) originalInventory;
interceptor.interceptRequest(event.request, event.count, invSpark, event.spark, stacks,
inventories, event.realRequest);
interceptors.put(interceptor, invSpark);
}
}
break;
case 2:
ItemStack stack = null;
if (event.request instanceof ItemStack)
stack = ((ItemStack) event.request).copy();
if (event.request instanceof Pair) {
Pair pair = (Pair) event.request;
if (pair.getKey() instanceof IInventory && pair.getValue() instanceof Integer)
stack = ((IInventory) pair.getKey()).getStackInSlot((Integer) pair.getValue());
else if (pair.getKey() instanceof String) {
}
}
ItemNBTHelper.initNBT(stack);
String customName = ItemNBTHelper.getNBT(stack).getCompoundTag("display").getString("Name");
if (customName.equals("")) {
return;
}
if (this.worldObj.getTileEntity(xCoord + 1, yCoord, zCoord) == inv$
|| this.worldObj.getTileEntity(xCoord, yCoord, zCoord + 1) == inv$
|| this.worldObj.getTileEntity(xCoord - 1, yCoord, zCoord) == inv$
|| this.worldObj.getTileEntity(xCoord, yCoord, zCoord - 1) == inv$) {
event.setCanceled(true);
for (IWrappedInventory invW : inventoriesW) {
ICorporeaSpark invSpark = invW.getSpark();
Object originalInventory = invW.getWrappedObject();
if (originalInventory instanceof ICorporeaInterceptor) {
ICorporeaInterceptor interceptor = (ICorporeaInterceptor) originalInventory;
interceptor.interceptRequest(event.request, event.count, invSpark, event.spark, stacks,
inventories, event.realRequest);
interceptors.put(interceptor, invSpark);
}
}
}
break;
case 3:
if (this.worldObj.getTileEntity(xCoord + 1, yCoord, zCoord) == inv$
|| this.worldObj.getTileEntity(xCoord, yCoord, zCoord + 1) == inv$
|| this.worldObj.getTileEntity(xCoord - 1, yCoord, zCoord) == inv$
|| this.worldObj.getTileEntity(xCoord, yCoord, zCoord - 1) == inv$) {
event.setCanceled(true);
TileEntity tileI = this.worldObj.getTileEntity(xCoord + 1, yCoord, zCoord);
ICorporeaSpark spark;
if (tileI instanceof ICorporeaInterceptor) {
spark = getSparkForBlock(tileI);
interceptors.put((ICorporeaInterceptor) tileI, spark);
((ICorporeaInterceptor) tileI).interceptRequest(event.request, event.count, spark, event.spark,
stacks, inventories, event.realRequest);
}
tileI = this.worldObj.getTileEntity(xCoord - 1, yCoord, zCoord);
if (tileI instanceof ICorporeaInterceptor) {
spark = getSparkForBlock(tileI);
interceptors.put((ICorporeaInterceptor) tileI, spark);
((ICorporeaInterceptor) tileI).interceptRequest(event.request, event.count, spark, event.spark,
stacks, inventories, event.realRequest);
}
tileI = this.worldObj.getTileEntity(xCoord, yCoord, zCoord - 1);
if (tileI instanceof ICorporeaInterceptor) {
spark = getSparkForBlock(tileI);
interceptors.put((ICorporeaInterceptor) tileI, spark);
((ICorporeaInterceptor) tileI).interceptRequest(event.request, event.count, spark, event.spark,
stacks, inventories, event.realRequest);
}
tileI = this.worldObj.getTileEntity(xCoord, yCoord, zCoord + 1);
if (tileI instanceof ICorporeaInterceptor) {
spark = getSparkForBlock(tileI);
interceptors.put((ICorporeaInterceptor) tileI, spark);
((ICorporeaInterceptor) tileI).interceptRequest(event.request, event.count, spark, event.spark,
stacks, inventories, event.realRequest);
}
tileI = this.worldObj.getTileEntity(xCoord, yCoord + 1, zCoord);
if (tileI instanceof ICorporeaInterceptor) {
spark = getSparkForBlock(tileI);
interceptors.put((ICorporeaInterceptor) tileI, spark);
((ICorporeaInterceptor) tileI).interceptRequest(event.request, event.count, spark, event.spark,
stacks, inventories, event.realRequest);
}
tileI = this.worldObj.getTileEntity(xCoord, yCoord - 1, zCoord);
if (tileI instanceof ICorporeaInterceptor) {
spark = getSparkForBlock(tileI);
interceptors.put((ICorporeaInterceptor) tileI, spark);
((ICorporeaInterceptor) tileI).interceptRequest(event.request, event.count, spark, event.spark,
stacks, inventories, event.realRequest);
}
}
break;
}
if (!interceptors.isEmpty())
for (ICorporeaInterceptor interceptor : interceptors.keySet())
interceptor.interceptRequestLast(event.request, event.count, interceptors.get(interceptor), event.spark,
stacks, inventories, event.realRequest);
}
private ICorporeaSpark getSparkForBlock(TileEntity tile) {
return CorporeaHelper.getSparkForBlock(worldObj, tile.xCoord, tile.yCoord, tile.zCoord);
}
@Override
public void readFromNBT(NBTTagCompound nbtt) {
super.readFromNBT(nbtt);
this.hasCatalyst = nbtt.getBoolean("hasCatalyst");
if (hasCatalyst) {
int coordsX = nbtt.getInteger("coordsX");
int coordsY = nbtt.getInteger("coordsY");
int coordsZ = nbtt.getInteger("coordsZ");
this.coords = new ChunkCoordinates(coordsX, coordsY, coordsZ);
}
}
@Override
public void writeToNBT(NBTTagCompound nbtt) {
super.writeToNBT(nbtt);
nbtt.setInteger("coordsX", this.coords.posX);
nbtt.setInteger("coordsY", this.coords.posY);
nbtt.setInteger("coordsZ", this.coords.posZ);
nbtt.setBoolean("hasCatalyst", hasCatalyst);
}
@Override
public final void onDataPacket(final NetworkManager manager, final S35PacketUpdateTileEntity paket) {
super.onDataPacket(manager, paket);
this.readFromNBT(paket.func_148857_g());
}
@Override
public Packet getDescriptionPacket() {
final NBTTagCompound compound = new NBTTagCompound();
this.writeToNBT(compound);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 10, compound);
}
@Override
public void setCatalystCoords(int x, int y, int z) {
coords.set(x, y, z);
this.hasCatalyst = true;
}
@Override
public TileCorporeaCatalyst getCatalystTile() {
if (this.hasCatalyst)
return (TileCorporeaCatalyst) worldObj.getTileEntity(coords.posX, coords.posY, coords.posZ);
return null;
}
@Override
public boolean isModified() {
return this.hasCatalyst;
}
@Override
public void removeModification() {
coords.set(0, 0, 0);
hasCatalyst = false;
}
}
@@ -0,0 +1,213 @@
package ab.common.block.tile;
import org.lwjgl.opengl.GL11;
import ab.api.IRenderHud;
import ab.common.lib.register.BlockListAB;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.api.lexicon.multiblock.Multiblock;
import vazkii.botania.api.lexicon.multiblock.MultiblockSet;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.ModFluffBlocks;
import vazkii.botania.common.block.tile.TileMod;
public class TileLebethronCore extends TileMod implements IRenderHud {
protected int tick;
protected Block block;
protected int meta;
protected boolean validTree;
public static MultiblockSet makeMultiblockSet() {
Multiblock mb = new Multiblock();
mb.addComponent(0, 1, 0, BlockListAB.blockLebethron, 4);
mb.addComponent(0, 0, 0, BlockListAB.blockLebethron, 0);
mb.addComponent(0, 2, 0, BlockListAB.blockLebethron, 0);
mb.addComponent(0, 3, 0, BlockListAB.blockLebethron, 0);
mb.addComponent(0, 4, 0, BlockListAB.blockLebethron, 0);
mb.addComponent(0, 5, 0, BlockListAB.blockLebethron, 0);
mb.setRenderOffset(0, 1, 0);
return mb.makeSet();
}
public void updateEntity() {
if(!this.worldObj.isRemote) {
++tick;
if(tick >= 100) {
updateStructure();
if(validTree && getBlock() != null) {
spawnLeaves();
tick = 0;
}
}
} else {
if (this.worldObj.rand.nextBoolean() && this.worldObj.isRemote)
Botania.proxy.sparkleFX(this.worldObj, this.xCoord + Math.random(), this.yCoord + Math.random(), this.zCoord + Math.random(), 0.5F, 1.0F, 0.5F, (float)Math.random() * 2, 2);
}
}
public boolean getValidTree() {
return this.validTree;
}
public void updateStructure() {
boolean oldValidTree = validTree;
validTree = hasValidTree();
if(oldValidTree != validTree)
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
}
public void writeCustomNBT(NBTTagCompound nbtt) {
nbtt.setInteger("blockID", Block.getIdFromBlock(block));
nbtt.setInteger("blockMeta", this.meta);
nbtt.setInteger("tick", this.tick);
nbtt.setBoolean("validTree", validTree);
}
public void readCustomNBT(NBTTagCompound nbtt) {
this.block = Block.getBlockById(nbtt.getInteger("blockID"));
this.meta = nbtt.getInteger("blockMeta");
this.tick = nbtt.getInteger("tick");
this.validTree = nbtt.getBoolean("validTree");
}
public boolean setBlock(Block block, int meta) {
if(this.block == null) {
this.block = block;
this.meta = meta;
return true;
} else {
if(Block.isEqualTo(this.block, block) && this.meta == meta) {
return false;
}
if(!this.worldObj.isRemote) {
EntityItem entity = new EntityItem(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
entity.setEntityItemStack(new ItemStack(this.block, 1, this.meta));
this.worldObj.spawnEntityInWorld(entity);
}
this.block = block;
this.meta = meta;
return true;
}
}
public Block getBlock() {
if(!Block.isEqualTo(block, Blocks.air) && block != null)
return this.block;
return null;
}
public int getMeta() {
return this.meta;
}
public boolean hasValidTree() {
if(!checkBlock(this.worldObj.getBlock(this.xCoord, this.yCoord - 1, this.zCoord), this.worldObj.getBlockMetadata(this.xCoord, this.yCoord - 1, this.zCoord))) {
return false;
}
for(int i = 1; i <= 4; i++) {
if(!checkBlock(this.worldObj.getBlock(this.xCoord, this.yCoord + i, this.zCoord), this.worldObj.getBlockMetadata(this.xCoord, this.yCoord + i, this.zCoord))) {
return false;
}
}
return true;
}
boolean checkBlock(Block block, int meta) {
return block == BlockListAB.blockLebethron && meta == 0;
}
private void spawnLeaves() {
for(int x = -1; x <= 1; x++) {
for(int z = -1; z <= 1; z++) {
for(int y = 0; y < 5; y++) {
this.setBlock(worldObj, this.xCoord + x, this.yCoord + y + 2, this.zCoord + z);
}
}
}
this.setBlock(worldObj, this.xCoord + 1, this.yCoord + 1, this.zCoord);
this.setBlock(worldObj, this.xCoord - 1, this.yCoord + 1, this.zCoord);
this.setBlock(worldObj, this.xCoord, this.yCoord + 1, this.zCoord + 1);
this.setBlock(worldObj, this.xCoord, this.yCoord + 1, this.zCoord - 1);
this.setBlock(worldObj, this.xCoord + 1, this.yCoord + 7, this.zCoord);
this.setBlock(worldObj, this.xCoord - 1, this.yCoord + 7, this.zCoord);
this.setBlock(worldObj, this.xCoord, this.yCoord + 7, this.zCoord + 1);
this.setBlock(worldObj, this.xCoord, this.yCoord + 7, this.zCoord - 1);
for(int i = 0; i <= 3; i++)
this.setBlock(worldObj, this.xCoord, this.yCoord + 6 + i, this.zCoord);
this.setBlock(worldObj, this.xCoord, this.yCoord + 2, this.zCoord - 2);
for(int i = -1; i <= 1; i++) {
this.setBlock(worldObj, this.xCoord + i, this.yCoord + 3, this.zCoord - 2);
this.setBlock(worldObj, this.xCoord + i, this.yCoord + 4, this.zCoord - 2);
}
this.setBlock(worldObj, this.xCoord, this.yCoord + 5, this.zCoord - 2);
this.setBlock(worldObj, this.xCoord, this.yCoord + 2, this.zCoord + 2);
for(int i = -1; i <= 1; i++) {
this.setBlock(worldObj, this.xCoord + i, this.yCoord + 3, this.zCoord + 2);
this.setBlock(worldObj, this.xCoord + i, this.yCoord + 4, this.zCoord + 2);
}
this.setBlock(worldObj, this.xCoord, this.yCoord + 5, this.zCoord + 2);
this.setBlock(worldObj, this.xCoord + 2, this.yCoord + 2, this.zCoord);
for(int i = -1; i <= 1; i++) {
this.setBlock(worldObj, this.xCoord + 2, this.yCoord + 3, this.zCoord + i);
this.setBlock(worldObj, this.xCoord + 2, this.yCoord + 4, this.zCoord + i);
}
this.setBlock(worldObj, this.xCoord + 2, this.yCoord + 5, this.zCoord);
this.setBlock(worldObj, this.xCoord - 2, this.yCoord + 2, this.zCoord);
for(int i = -1; i <= 1; i++) {
this.setBlock(worldObj, this.xCoord - 2, this.yCoord + 3, this.zCoord + i);
this.setBlock(worldObj, this.xCoord - 2, this.yCoord + 4, this.zCoord + i);
}
this.setBlock(worldObj, this.xCoord - 2, this.yCoord + 5, this.zCoord);
}
private void setBlock(World world, int x, int y, int z) {
if(world.getBlock(x, y, z).getMaterial() == Material.air && y < 256) {
world.setBlock(x, y, z, this.block, this.meta, 3);
}
}
public void renderHud(Minecraft mc, ScaledResolution res) {
if(!validTree)
return;
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
ItemStack stack = getBlock() != null ? new ItemStack(block, 1, meta) : new ItemStack(Blocks.leaves);
int x = res.getScaledWidth() / 2 - 7;
int y = res.getScaledHeight() / 2 + 12;
Gui.drawRect(x - 2, y - 2, x + 18, y + 18, 1140850688);
Gui.drawRect(x, y, x + 16, y + 16, 1140850688);
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(32826);
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(2929);
boolean unicode = mc.fontRenderer.getUnicodeFlag();
mc.fontRenderer.setUnicodeFlag(true);
if(getBlock() != null) {
mc.fontRenderer.drawStringWithShadow("\u2713", x + 10, y + 9, 19456);
mc.fontRenderer.drawStringWithShadow("\u2713", x + 10, y + 8, 774669);
} else {
mc.fontRenderer.drawStringWithShadow("\u2717", x + 10, y + 9, 4980736);
mc.fontRenderer.drawStringWithShadow("\u2717", x + 10, y + 8, 13764621);
}
mc.fontRenderer.setUnicodeFlag(unicode);
GL11.glEnable(2929);
GL11.glDisable(3042);
}
}
@@ -0,0 +1,255 @@
package ab.common.block.tile;
import java.awt.Color;
import java.util.List;
import java.util.Random;
import org.lwjgl.opengl.GL11;
import ab.api.IRenderHud;
import ab.client.core.ClientHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.StatCollector;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.api.mana.IManaItem;
import vazkii.botania.api.mana.IManaReceiver;
import vazkii.botania.api.mana.spark.ISparkAttachable;
import vazkii.botania.api.mana.spark.ISparkEntity;
import vazkii.botania.api.wand.IWandBindable;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.core.handler.HUDHandler;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.tile.TileSimpleInventory;
import vazkii.botania.common.core.helper.Vector3;
public class TileManaCharger extends TileSimpleInventory implements ISidedInventory, IRenderHud, IWandBindable {
private static final int MANA_SPEED = 11240;
public boolean requestsClientUpdate = false;
int clientMana = -1;
int receiverPosX = -1;
int receiverPosY = -1;
int receiverPosZ = -1;
public int clientTick[] = new int[] {0, 0, 3, 12, 6};
public void updateEntity() {
if(requestsClientUpdate && !this.worldObj.isRemote && this.worldObj.getTotalWorldTime() % 15 == 0) {
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
requestsClientUpdate = false;
}
ISparkAttachable receiver = this.getReceiver();
if(receiver == null)
return;
for(int i = 0; i < this.getSizeInventory(); i++) {
ItemStack stack = this.getStackInSlot(i);
if(stack == null)
continue;
else if(stack.getItem() instanceof IManaItem) {
IManaItem mana = (IManaItem)stack.getItem();
if(i == 0) {
if(mana.getMana(stack) > 0 && !receiver.isFull() && mana.canExportManaToPool(stack, (TileEntity)receiver)) {
int availableMana = ((ISparkAttachable)receiver).getAvailableSpaceForMana();
int manaVal = Math.min(Math.min(mana.getMaxMana(stack) / 256, MANA_SPEED) * 3, Math.min(availableMana, mana.getMana(stack)));
if(!this.worldObj.isRemote) {
mana.addMana(stack, -manaVal);
requestsClientUpdate = true;
} else {
clientTick[i]++;
}
receiver.recieveMana(manaVal);
}
continue;
}
else if(receiver.getCurrentMana() > 0 && mana.getMana(stack) < mana.getMaxMana(stack) && mana.canReceiveManaFromPool(stack, (TileEntity)receiver)) {
int manaVal = Math.min(Math.min(mana.getMaxMana(stack) / 256, MANA_SPEED), Math.min(receiver.getCurrentMana(), mana.getMaxMana(stack) - mana.getMana(stack)));
if(!this.worldObj.isRemote) {
mana.addMana(stack, manaVal);
requestsClientUpdate = true;
} else {
clientTick[i]++;
}
receiver.recieveMana(-manaVal);
}
}
}
}
public ISparkAttachable getReceiver() {
if(this.worldObj != null && this.receiverPosY != -1) {
TileEntity tile = this.worldObj.getTileEntity(receiverPosX, receiverPosY, receiverPosZ);
if(tile != null && tile instanceof ISparkAttachable) {
return (ISparkAttachable)tile;
}
}
return null;
}
public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) {
return true;
}
public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) {
TileEntity tile = this.worldObj.getTileEntity(x, y, z);
boolean isFar = Math.abs(this.xCoord - x) >= 16 || Math.abs(this.yCoord - y) >= 16 || Math.abs(this.zCoord - z) >= 16;
if(isFar)
return false;
else if(tile instanceof ISparkAttachable) {
if(!this.worldObj.isRemote) {
this.receiverPosX = tile.xCoord;
this.receiverPosY = tile.yCoord;
this.receiverPosZ = tile.zCoord;
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
}
return true;
}
return false;
}
public ChunkCoordinates getBinding() {
IManaReceiver receiver = this.getReceiver();
if (receiver == null)
return null;
TileEntity tile = (TileEntity)receiver;
return new ChunkCoordinates(tile.xCoord, tile.yCoord, tile.zCoord);
}
public static float getManaPercent(ItemStack stack) {
if(!(stack.getItem() instanceof IManaItem))
return 0.0f;
IManaItem mana = (IManaItem)stack.getItem();
return (float)mana.getMana(stack) / (mana.getMaxMana(stack) / 100.0f);
}
public void renderHud(Minecraft mc, ScaledResolution res) {
int xc = res.getScaledWidth() / 2;
int yc = res.getScaledHeight() / 2;
int radius = 42;
int amt = 0;
for(int i = 0; i < getSizeInventory(); i++)
if(getStackInSlot(i) != null)
amt++;
float angle = -90.0f;
if(amt >= 0) {
for (int i = 0; i < getSizeInventory(); i++) {
ItemStack stack = getStackInSlot(i);
if(stack == null)
continue;
float anglePer = 360.0F / amt;
double xPos = xc + Math.cos(angle * Math.PI / 180.0D) * radius - 8.0D;
double yPos = yc + Math.sin(angle * Math.PI / 180.0D) * radius - 8.0D;
RenderHelper.enableGUIStandardItemLighting();
GL11.glPushMatrix();
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glTranslated(xPos, yPos, 0.0D);
vazkii.botania.client.core.helper.RenderHelper.renderProgressPie(0, 0, getManaPercent(stack) / 100.0f, stack);
if(i == 0) {
GL11.glScalef(0.75f, 0.75f, 0.75f);
GL11.glTranslated(11.0D, 10.0D, 0.0D);
RenderHelper.enableGUIStandardItemLighting();
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModBlocks.pool), 0, 0);
}
GL11.glDisable(2896);
GL11.glDisable(3042);
GL11.glPopMatrix();
RenderHelper.disableStandardItemLighting();
angle += anglePer;
}
}
}
public void onWanded(EntityPlayer player, ItemStack wand) {
ISparkAttachable reciever = getReceiver();
if(player == null)
return;
if(this.worldObj.isRemote && reciever != null)
clientMana = reciever.getCurrentMana();
this.worldObj.playSoundAtEntity((Entity)player, "botania:ding", 0.11F, 1.0F);
}
public void renderHUD(Minecraft mc, ScaledResolution res) {
ISparkAttachable reciever = getReceiver();
if (reciever != null) {
String name = StatCollector.translateToLocal("ab.manaCharger.wandHud");
TileEntity receiverTile = (TileEntity)reciever;
ItemStack recieverStack = new ItemStack(this.worldObj.getBlock(receiverTile.xCoord, receiverTile.yCoord, receiverTile.zCoord), 1, receiverTile.getBlockMetadata());
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
if (recieverStack != null && recieverStack.getItem() != null) {
String stackName = recieverStack.getDisplayName();
int width = 16 + mc.fontRenderer.getStringWidth(stackName) / 2;
int x = res.getScaledWidth() / 2 - width;
int y = res.getScaledHeight() / 2 + 48;
mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, 0xf4f4f4);
RenderHelper.enableGUIStandardItemLighting();
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recieverStack, x, y);
RenderHelper.disableStandardItemLighting();
}
GL11.glDisable(2896);
GL11.glDisable(3042);
ClientHelper.drawPoolManaHUD(res, name, clientMana, reciever.getAvailableSpaceForMana() + reciever.getCurrentMana(), 0xb9bbae);
}
}
public int getSizeInventory() {
return 5;
}
public int getInventoryStackLimit() {
return 1;
}
public String getInventoryName() {
return "ab.manaCharger";
}
public void writeCustomNBT(NBTTagCompound nbtt) {
super.writeCustomNBT(nbtt);
nbtt.setInteger("bindingX", this.receiverPosX);
nbtt.setInteger("bindingY", this.receiverPosY);
nbtt.setInteger("bindingZ", this.receiverPosZ);
nbtt.setBoolean("requestUpdate", this.requestsClientUpdate);
this.requestsClientUpdate = false;
}
public void readFromNBT(NBTTagCompound nbtt) {
super.readFromNBT(nbtt);
this.requestsClientUpdate = nbtt.getBoolean("requestUpdate");
}
public void readCustomNBT(NBTTagCompound nbtt) {
super.readCustomNBT(nbtt);
this.receiverPosX = nbtt.getInteger("bindingX");
this.receiverPosY = nbtt.getInteger("bindingY");
this.receiverPosZ = nbtt.getInteger("bindingZ");
}
public int[] getAccessibleSlotsFromSide(int side) {
return new int[0];
}
public boolean canInsertItem(int slot, ItemStack stack, int side) {
return false;
}
public boolean canExtractItem(int slot, ItemStack stack, int side) {
return false;
}
}
@@ -0,0 +1,117 @@
package ab.common.block.tile;
import java.util.List;
import org.lwjgl.opengl.GL11;
import ab.client.core.ClientHelper;
import ab.common.lib.register.BlockListAB;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.StatCollector;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.api.mana.IManaPool;
import vazkii.botania.api.mana.IManaReceiver;
import vazkii.botania.api.mana.IThrottledPacket;
import vazkii.botania.api.mana.spark.ISparkAttachable;
import vazkii.botania.api.mana.spark.ISparkEntity;
import vazkii.botania.client.core.handler.HUDHandler;
import vazkii.botania.common.block.tile.TileMod;
public class TileManaContainer extends TileMod implements IManaPool, ISparkAttachable {
private static final int MAX_MANA = 64000000;
protected int mana = 0;
int knownMana = -1;
public boolean canUpdate() {
return false;
}
public void updateEntity() {}
public void onWanded(EntityPlayer player, ItemStack wand) {
if (player == null)
return;
if (!this.worldObj.isRemote) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
writeCustomNBT(nbttagcompound);
nbttagcompound.setInteger("knownMana", getCurrentMana());
if (player instanceof EntityPlayerMP)
((EntityPlayerMP)player).playerNetServerHandler.sendPacket((Packet)new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, -999, nbttagcompound));
}
this.worldObj.playSoundAtEntity((Entity)player, "botania:ding", 0.11F, 1.0F);
}
public void renderHUD(Minecraft mc, ScaledResolution res) {
String name = StatCollector.translateToLocal("ab.manaContainer.hud");
int color = 0x30ead1;
ClientHelper.drawPoolManaHUD(res, name, this.knownMana, MAX_MANA, color);
}
public int getCurrentMana() {
return this.mana;
}
public boolean canRecieveManaFromBursts() {
return true;
}
public boolean isFull() {
return this.mana == MAX_MANA;
}
public void recieveMana(int mana) {
this.mana = Math.max(0, Math.min(getCurrentMana() + mana, MAX_MANA));
}
public void writeCustomNBT(NBTTagCompound nbtt) {
nbtt.setInteger("mana", this.mana);
}
public void readCustomNBT(NBTTagCompound nbtt) {
this.mana = nbtt.getInteger("mana");
if (nbtt.hasKey("knownMana"))
this.knownMana = nbtt.getInteger("knownMana");
}
public boolean areIncomingTranfersDone() {
return false;
}
public void attachSpark(ISparkEntity entity) {}
public boolean canAttachSpark(ItemStack arg0) {
return true;
}
public ISparkEntity getAttachedSpark() {
List<ISparkEntity> sparks = this.worldObj.getEntitiesWithinAABB(ISparkEntity.class, AxisAlignedBB.getBoundingBox(this.xCoord, (this.yCoord + 1), this.zCoord, (this.xCoord + 1), (this.yCoord + 2), (this.zCoord + 1)));
if (sparks.size() == 1) {
Entity e = (Entity)sparks.get(0);
return (ISparkEntity)e;
}
return null;
}
public int getAvailableSpaceForMana() {
return Math.max(0, MAX_MANA - getCurrentMana());
}
public boolean isOutputtingPower() {
return false;
}
}
@@ -0,0 +1,68 @@
package ab.common.block.tile;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.opengl.GL11;
import ab.api.IRenderHud;
import ab.client.core.ClientHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.util.StatCollector;
import vazkii.botania.api.mana.spark.ISparkAttachable;
import vazkii.botania.api.mana.spark.ISparkEntity;
import vazkii.botania.api.mana.spark.SparkHelper;
import vazkii.botania.client.core.handler.HUDHandler;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.tile.TileMod;
public class TileManaCrystalCube extends TileMod implements IRenderHud {
int knownMana = -1;
int knownMaxMana = -1;
public boolean canUpdate() {
return false;
}
public void updateEntity() {}
public void renderHud(Minecraft mc, ScaledResolution res) {
String name = StatCollector.translateToLocal("ab.manaCrystalCube.hud");
int color = 0x30ead1;
ClientHelper.drawPoolManaHUD(res, name, this.knownMana, this.knownMaxMana, color);
}
public int[] getManaAround() {
int[] mana = new int[] { 0, 0 };
List<ISparkEntity> allSparks = SparkHelper.getSparksAround(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
for (ISparkEntity spark : allSparks) {
ISparkAttachable tileMana = spark.getAttachedTile();
if(mana[1] + tileMana.getCurrentMana() + tileMana.getAvailableSpaceForMana() > 0) {
mana[1] += tileMana.getCurrentMana() + tileMana.getAvailableSpaceForMana();
mana[0] += tileMana.getCurrentMana();
}
else
break;
}
return mana;
}
public void readCustomNBT(NBTTagCompound nbtt) {
if (nbtt.hasKey("knownMana"))
this.knownMana = nbtt.getInteger("knownMana");
if (nbtt.hasKey("knownMaxMana"))
this.knownMaxMana = nbtt.getInteger("knownMaxMana");
}
}
@@ -0,0 +1,252 @@
package ab.common.block.tile;
import java.util.ArrayList;
import java.util.List;
import ab.api.AdvancedCorporeaHelper;
import ab.api.ICorporeaModification;
import ab.common.lib.register.BlockListAB;
import ab.common.lib.utils.Pair;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityItemFrame;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChunkCoordinates;
import net.minecraftforge.common.util.ForgeDirection;
import vazkii.botania.api.corporea.CorporeaHelper;
import vazkii.botania.api.corporea.ICorporeaRequestor;
import vazkii.botania.api.corporea.ICorporeaSpark;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.tile.corporea.TileCorporeaBase;
import vazkii.botania.common.block.tile.corporea.TileCorporeaFunnel;
import vazkii.botania.common.core.helper.InventoryHelper;
import vazkii.botania.common.lib.LibMisc;
public class TileModifiedCorporeaFunnel extends TileCorporeaBase implements ICorporeaRequestor, ICorporeaModification {
ChunkCoordinates coords;
public void doRequest() {
ICorporeaSpark spark = getSpark();
if (spark == null || spark.getMaster() == null)
return;
List<ItemStack> filter = getFilter();
if(filter.isEmpty())
return;
ItemStack stack = filter.get(worldObj.rand.nextInt(filter.size()));
int rune = this.getCatalystTile().getRune();
if (filter.isEmpty())
return;
switch (rune) {
case 0:
int count = AdvancedCorporeaHelper.sumStackSizes(filter);
this.doCorporeaRequest(null, count, spark);
break;
case -1:
case 1:
case 2:
case 3:
if (stack != null)
this.doCorporeaRequest(stack, stack.stackSize, spark);
break;
}
}
public List<ItemStack> getFilter() {
List<ItemStack> filter = new ArrayList();
final int[] orientationToDir = new int[] { 3, 4, 2, 5 };
final int[] rotationToStackSize = new int[] { 1, 16, 32, 64 };
for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) {
List<EntityItemFrame> frames = worldObj.getEntitiesWithinAABB(EntityItemFrame.class,
AxisAlignedBB.getBoundingBox(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ,
xCoord + dir.offsetX + 1, yCoord + dir.offsetY + 1, zCoord + dir.offsetZ + 1));
for (EntityItemFrame frame : frames) {
int orientation = frame.hangingDirection;
if (orientationToDir[orientation] == dir.ordinal()) {
ItemStack stack = frame.getDisplayedItem();
if (stack != null) {
ItemStack copy = stack.copy();
copy.stackSize = rotationToStackSize[frame.getRotation()];
filter.add(copy);
}
}
}
}
return filter;
}
@Override
public void doCorporeaRequest(Object request, int count, ICorporeaSpark spark) {
int rune = this.getCatalystTile().getRune();
IInventory inv = InventoryHelper.getInventory(worldObj, xCoord, yCoord - 1, zCoord);
if (inv == null || inv instanceof TileCorporeaFunnel)
inv = InventoryHelper.getInventory(worldObj, xCoord, yCoord - 2, zCoord);
switch (rune) {
case -1:
if (!(request instanceof ItemStack))
return;
if (inv == null || inv instanceof TileCorporeaFunnel)
inv = InventoryHelper.getInventory(worldObj, xCoord, yCoord - 2, zCoord);
List<ItemStack> stacks$ = CorporeaHelper.requestItem(request, count, spark, true, true);
spark.onItemsRequested(stacks$);
for (ItemStack reqStack : stacks$)
if (request != null) {
if (inv != null && !(inv instanceof TileCorporeaFunnel) && reqStack.stackSize == InventoryHelper
.testInventoryInsertion(inv, reqStack, ForgeDirection.UP))
InventoryHelper.insertItemIntoInventory(inv, reqStack);
else {
EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, reqStack);
worldObj.spawnEntityInWorld(item);
}
}
break;
case 0:
List<ItemStack> stacks = AdvancedCorporeaHelper.requestRandomItem(spark, count, true);
spark.onItemsRequested(stacks);
for (ItemStack reqStack : stacks)
if (inv != null && !(inv instanceof TileCorporeaFunnel) && reqStack.stackSize == InventoryHelper
.testInventoryInsertion(inv, reqStack, ForgeDirection.UP))
InventoryHelper.insertItemIntoInventory(inv, reqStack);
else {
EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, reqStack);
worldObj.spawnEntityInWorld(item);
}
break;
case 1:
if (request instanceof ItemStack) {
List<ItemStack> stacks1 = CorporeaHelper.requestItem(request, -1, spark, true, true);
for (ItemStack reqStack : stacks1)
if (inv != null && !(inv instanceof TileCorporeaFunnel) && reqStack.stackSize == InventoryHelper
.testInventoryInsertion(inv, reqStack, ForgeDirection.UP))
InventoryHelper.insertItemIntoInventory(inv, reqStack);
else {
EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, reqStack);
worldObj.spawnEntityInWorld(item);
}
}
break;
case 2:
String name;
List<ItemStack> stacks2;
if (request instanceof ItemStack) {
name = ((ItemStack) request).getDisplayName();
stacks2 = AdvancedCorporeaHelper.requestSameNamedItem(name, (ItemStack) request, spark,
((ItemStack) request).stackSize, true);
} else if (request instanceof String) {
name = (String) request;
stacks2 = AdvancedCorporeaHelper.requestSameNamedItem(name, null, spark, 1, true);
} else
return;
spark.onItemsRequested(stacks2);
for (ItemStack reqStack : stacks2)
if (inv != null && !(inv instanceof TileCorporeaFunnel) && reqStack.stackSize == InventoryHelper
.testInventoryInsertion(inv, reqStack, ForgeDirection.UP))
InventoryHelper.insertItemIntoInventory(inv, reqStack);
else {
EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, reqStack);
worldObj.spawnEntityInWorld(item);
}
break;
case 3:
ItemStack stack = null;
if (request instanceof Pair) {
Pair pair = (Pair) request;
if (pair.getKey() instanceof IInventory && pair.getValue() instanceof Integer) {
stack = AdvancedCorporeaHelper.getStackBySlot((IInventory) pair.getKey(), (Integer) pair.getValue(),
count, spark, true);
}
} else if (request instanceof ItemStack) {
Pair pair = AdvancedCorporeaHelper.getFirstInventoryWithStackByRequest(spark, (ItemStack) request);
if (pair.getKey() != null)
stack = AdvancedCorporeaHelper.getStackBySlot((IInventory) pair.getKey(),
(Integer) pair.getValue() + 1, count, spark, true);
}
if (stack != null)
if (inv != null && !(inv instanceof TileCorporeaFunnel)
&& stack.stackSize == InventoryHelper.testInventoryInsertion(inv, stack, ForgeDirection.UP))
InventoryHelper.insertItemIntoInventory(inv, stack);
else {
EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, stack);
worldObj.spawnEntityInWorld(item);
}
break;
}
}
@Override
public void setCatalystCoords(int x, int y, int z) {
this.coords = new ChunkCoordinates(x, y, z);
}
@Override
public void readFromNBT(NBTTagCompound nbtt) {
super.readFromNBT(nbtt);
int coordsX = nbtt.getInteger("coordsX");
int coordsY = nbtt.getInteger("coordsY");
int coordsZ = nbtt.getInteger("coordsZ");
this.coords = new ChunkCoordinates(coordsX, coordsY, coordsZ);
}
@Override
public void writeToNBT(NBTTagCompound nbtt) {
super.writeToNBT(nbtt);
nbtt.setInteger("coordsX", this.coords.posX);
nbtt.setInteger("coordsY", this.coords.posY);
nbtt.setInteger("coordsZ", this.coords.posZ);
}
@Override
public final void onDataPacket(final NetworkManager manager, final S35PacketUpdateTileEntity paket) {
super.onDataPacket(manager, paket);
this.readFromNBT(paket.func_148857_g());
}
@Override
public Packet getDescriptionPacket() {
final NBTTagCompound compound = new NBTTagCompound();
this.writeToNBT(compound);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 10, compound);
}
@Override
public int getSizeInventory() {
return 1;
}
@Override
public String getInventoryName() {
return "TileModifiedCorporeaFunnel";
}
@Override
public TileCorporeaCatalyst getCatalystTile() {
if (this.coords != null)
return (TileCorporeaCatalyst) this.worldObj.getTileEntity(this.coords.posX, this.coords.posY,
this.coords.posZ);
return null;
}
@Override
public boolean isModified() {
return true;
}
@Override
public void removeModification() {
this.worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.corporeaFunnel);
}
}
@@ -0,0 +1,282 @@
package ab.common.block.tile;
import java.util.ArrayList;
import java.util.List;
import ab.api.AdvancedCorporeaHelper;
import ab.api.ICorporeaModification;
import ab.common.lib.utils.Pair;
import net.minecraft.entity.item.EntityItemFrame;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChunkCoordinates;
import net.minecraftforge.common.util.ForgeDirection;
import vazkii.botania.api.corporea.CorporeaHelper;
import vazkii.botania.api.corporea.ICorporeaInterceptor;
import vazkii.botania.api.corporea.ICorporeaSpark;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.tile.corporea.TileCorporeaBase;
import vazkii.botania.common.block.tile.corporea.TileCorporeaRetainer;
import vazkii.botania.common.lib.LibMisc;
public class TileModifiedInterceptor extends TileCorporeaBase implements ICorporeaInterceptor, ICorporeaModification {
ChunkCoordinates coords = new ChunkCoordinates();
@Override
public void setCatalystCoords(int x, int y, int z) {
coords.set(x, y, z);
}
@Override
public TileCorporeaCatalyst getCatalystTile() {
return (TileCorporeaCatalyst) worldObj.getTileEntity(coords.posX, coords.posY, coords.posZ);
}
@Override
public boolean isModified() {
return true;
}
@Override
public void removeModification() {
worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.corporeaInterceptor);
}
@Override
public void interceptRequest(Object request, int count, ICorporeaSpark spark, ICorporeaSpark source,
List<ItemStack> stacks, List<IInventory> inventories, boolean doit) {
}
@Override
public void interceptRequestLast(Object request, int count, ICorporeaSpark spark, ICorporeaSpark source,
List<ItemStack> stacks, List<IInventory> inventories, boolean doit) {
int rune = this.getCatalystTile().getRune();
Object filter = getFilter();
switch (rune) {
case -1:
if (requestMatches(request, filter)) {
int missing = count;
for (ItemStack stack_ : stacks)
missing -= stack_.stackSize;
if (missing > 0 && getBlockMetadata() == 0) {
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2);
worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, getBlockType(), 2);
TileEntity requestor = (TileEntity) source.getInventory();
for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) {
TileEntity tile = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ);
if (tile != null && tile instanceof TileCorporeaRetainer)
((TileCorporeaRetainer) tile).setPendingRequest(requestor.xCoord, requestor.yCoord,
requestor.zCoord, request, count);
}
return;
}
}
break;
case 0:
if (requestMatches(request, filter)) {
int missing = count;
for (ItemStack stack_ : stacks)
missing -= stack_.stackSize;
if (missing > 0 && getBlockMetadata() == 0) {
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2);
worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, getBlockType(), 2);
TileEntity requestor = (TileEntity) source.getInventory();
for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) {
TileEntity tile = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ);
if (tile != null && tile instanceof TileCorporeaRetainer)
((TileCorporeaRetainer) tile).setPendingRequest(requestor.xCoord, requestor.yCoord,
requestor.zCoord,
AdvancedCorporeaHelper.trasformateRequest(spark, request, ItemStack.class), count);
}
return;
}
}
break;
case 1:
if (!requestMatches(request, filter)) {
int missing = count;
for (ItemStack stack_ : stacks)
missing -= stack_.stackSize;
if (missing > 0 && getBlockMetadata() == 0) {
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2);
worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, getBlockType(), 2);
TileEntity requestor = (TileEntity) source.getInventory();
for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) {
TileEntity tile = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ);
if (tile != null && tile instanceof TileCorporeaRetainer)
((TileCorporeaRetainer) tile).setPendingRequest(requestor.xCoord, requestor.yCoord,
requestor.zCoord, request, count);
}
return;
}
}
break;
case 2:
if (requestMatches(request, filter)) {
int missing = count;
for (ItemStack stack_ : stacks)
missing -= stack_.stackSize;
if (missing > 0 && getBlockMetadata() == 0) {
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2);
worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, getBlockType(), 2);
TileEntity requestor = (TileEntity) source.getInventory();
for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) {
TileEntity tile = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ);
if (tile != null && tile instanceof TileCorporeaRetainer)
((TileCorporeaRetainer) tile).setPendingRequest(requestor.xCoord, requestor.yCoord,
requestor.zCoord,
AdvancedCorporeaHelper.trasformateRequest(spark, request, IInventory.class), count);
}
return;
}
}
break;
case 3:
if (requestMatches(request, filter)) {
int missing = count;
for (ItemStack stack_ : stacks)
missing -= stack_.stackSize;
if (missing > 0 && getBlockMetadata() == 0) {
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2);
worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, getBlockType(), 2);
TileEntity requestor = (TileEntity) source.getInventory();
for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) {
TileEntity tile = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ);
if (tile != null && tile instanceof TileCorporeaRetainer)
((TileCorporeaRetainer) tile).setPendingRequest(requestor.xCoord, requestor.yCoord,
requestor.zCoord,
AdvancedCorporeaHelper.trasformateRequest(spark, request, String.class), count);
}
return;
}
}
break;
}
}
public Object getFilter() {
List<ItemStack> filter = new ArrayList();
final int[] orientationToDir = new int[] { 3, 4, 2, 5 };
for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) {
List<EntityItemFrame> frames = worldObj.getEntitiesWithinAABB(EntityItemFrame.class,
AxisAlignedBB.getBoundingBox(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ,
xCoord + dir.offsetX + 1, yCoord + dir.offsetY + 1, zCoord + dir.offsetZ + 1));
for (EntityItemFrame frame : frames) {
int orientation = frame.hangingDirection;
if (orientationToDir[orientation] == dir.ordinal())
if (frame.getDisplayedItem() == null)
return "anyone";
filter.add(frame.getDisplayedItem());
}
}
return filter;
}
private boolean requestMatches(Object request, Object filter) {
if (filter instanceof String)
return true;
if (filter == null)
return false;
List<ItemStack> list = (List<ItemStack>) filter;
for (ItemStack filter$ : list) {
if (request instanceof ItemStack) {
ItemStack stack = (ItemStack) request;
return stack != null && stack.isItemEqual(filter$) && ItemStack.areItemStackTagsEqual(filter$, stack);
}
if (request instanceof Pair) {
Pair pair = (Pair) request;
Object key = pair.getKey();
Object value = pair.getValue();
if (key instanceof IInventory && value instanceof Integer) {
ItemStack stack = ((IInventory) key).getStackInSlot((Integer) value);
return stack != null && stack.isItemEqual(filter$)
&& ItemStack.areItemStackTagsEqual(filter$, stack);
}
if (key instanceof String)
return filter$.getDisplayName().equals((String) key);
}
String name = (String) request;
return CorporeaHelper.stacksMatch(filter$, name);
}
return false;
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
return false;
}
@Override
public void readFromNBT(NBTTagCompound nbtt) {
super.readFromNBT(nbtt);
int coordsX = nbtt.getInteger("coordsX");
int coordsY = nbtt.getInteger("coordsY");
int coordsZ = nbtt.getInteger("coordsZ");
this.coords = new ChunkCoordinates(coordsX, coordsY, coordsZ);
}
@Override
public void writeToNBT(NBTTagCompound nbtt) {
super.writeToNBT(nbtt);
nbtt.setInteger("coordsX", this.coords.posX);
nbtt.setInteger("coordsY", this.coords.posY);
nbtt.setInteger("coordsZ", this.coords.posZ);
}
@Override
public final void onDataPacket(final NetworkManager manager, final S35PacketUpdateTileEntity paket) {
super.onDataPacket(manager, paket);
this.readFromNBT(paket.func_148857_g());
}
@Override
public Packet getDescriptionPacket() {
final NBTTagCompound compound = new NBTTagCompound();
this.writeToNBT(compound);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 10, compound);
}
@Override
public int getSizeInventory() {
return 1;
}
@Override
public String getInventoryName() {
return "TileModifiedInterceptor";
}
}
@@ -0,0 +1,66 @@
package ab.common.block.tile;
import ab.api.ICorporeaModification;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.util.ChunkCoordinates;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.tile.corporea.TileCorporeaRetainer;
public class TileModifiedRetainer extends TileCorporeaRetainer implements ICorporeaModification {
ChunkCoordinates coords = new ChunkCoordinates();
@Override
public void setCatalystCoords(int x, int y, int z) {
coords.set(x, y, z);
}
@Override
public TileCorporeaCatalyst getCatalystTile() {
return (TileCorporeaCatalyst) worldObj.getTileEntity(coords.posX, coords.posY, coords.posZ);
}
@Override
public boolean isModified() {
return true;
}
@Override
public void removeModification() {
worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.corporeaRetainer);
}
@Override
public void readFromNBT(NBTTagCompound nbtt) {
super.readFromNBT(nbtt);
int coordsX = nbtt.getInteger("coordsX");
int coordsY = nbtt.getInteger("coordsY");
int coordsZ = nbtt.getInteger("coordsZ");
this.coords = new ChunkCoordinates(coordsX, coordsY, coordsZ);
}
@Override
public void writeToNBT(NBTTagCompound nbtt) {
super.writeToNBT(nbtt);
nbtt.setInteger("coordsX", this.coords.posX);
nbtt.setInteger("coordsY", this.coords.posY);
nbtt.setInteger("coordsZ", this.coords.posZ);
}
@Override
public final void onDataPacket(final NetworkManager manager, final S35PacketUpdateTileEntity paket) {
super.onDataPacket(manager, paket);
this.readFromNBT(paket.func_148857_g());
}
@Override
public Packet getDescriptionPacket() {
final NBTTagCompound compound = new NBTTagCompound();
this.writeToNBT(compound);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 10, compound);
}
}