This commit is contained in:
EnderProyects committed 2023-03-06 23:23:19 +01:00
1 parent 17454c4993
commit 8e0818be4a
150 files changed
+13246 -12429

No files matched your search

+134 -139
View File
@@ -1,19 +1,11 @@
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;
@@ -27,146 +19,149 @@ 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;
import ab.AdvancedBotany;
import ab.common.block.tile.TileABSpreader;
import ab.common.lib.register.BlockListAB;
import ab.common.lib.register.RecipeListAB;
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() {
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 int getLightValue(IBlockAccess world, int x, int y, int z) {
return 12;
}
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 TileEntity createNewTileEntity(World world, int meta) {
return new TileABSpreader();
}
public LexiconEntry getEntry(World arg0, int arg1, int arg2, int arg3, EntityPlayer arg4, ItemStack arg5) {
return RecipeListAB.lebethronSpreader;
}
}
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;
}
}
@@ -2,9 +2,6 @@ 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;
@@ -14,41 +11,44 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import ab.AdvancedBotany;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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;
}
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;
}
}
@@ -2,61 +2,74 @@ 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;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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) {
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 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 onNeighborBlockChange(World world, int x, int y, int z, Block block) {
if(world.isAirBlock(x, y + 1, z))
world.setBlockToAir(x, y, z);
if (world.isAirBlock(x, y + 1, z)) 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);
}
}
}
@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);
}
}
}
+131 -138
View File
@@ -2,12 +2,6 @@ package ab.common.block;
import java.util.List;
import ab.AdvancedBotany;
import ab.common.block.tile.TileBoardFate;
import ab.common.block.tile.TileGameBoard;
import ab.common.block.tile.TileInventory;
import ab.common.lib.register.AchievementRegister;
import ab.common.lib.register.RecipeListAB;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@@ -23,143 +17,142 @@ import net.minecraft.stats.Achievement;
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.IWandable;
import vazkii.botania.common.achievement.IPickupAchievement;
import vazkii.botania.common.core.handler.ConfigHandler;
import ab.AdvancedBotany;
import ab.common.block.tile.TileBoardFate;
import ab.common.block.tile.TileGameBoard;
import ab.common.block.tile.TileInventory;
import ab.common.lib.register.AchievementRegister;
import ab.common.lib.register.RecipeListAB;
public class BlockBoardFate extends BlockContainer implements IPickupAchievement, ILexiconable {
protected IIcon[] iconsFate;
protected IIcon[] iconsBoard;
public BlockBoardFate() {
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("boardFate");
}
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List list) {
for(int i = 0; i < 2; i++)
list.add(new ItemStack(par1, 1, i));
}
public void registerBlockIcons(IIconRegister ir) {
this.iconsFate = new IIcon[3];
this.iconsBoard = new IIcon[3];
for(int i = 0; i < iconsFate.length; i++)
this.iconsFate[i] = ir.registerIcon("ab:boardFate_" + i);
for(int i = 0; i < iconsBoard.length; i++)
this.iconsBoard[i] = ir.registerIcon("ab:gameBoard_" + i);
}
public IIcon getIcon(int side, int meta) {
if(meta == 0)
return this.iconsBoard[Math.min(2, side)];
else
return this.iconsFate[Math.min(2, side)];
}
public boolean isOpaqueCube() {
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
public int damageDropped(int par1) {
return par1;
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7, float par8, float par9) {
int meta = world.getBlockMetadata(x, y, z);
if(meta == 0) {
TileGameBoard tile = (TileGameBoard)world.getTileEntity(x, y, z);
if(player.isSneaking() && !tile.hasGame()) {
tile.isSingleGame = !tile.isSingleGame;
if(!world.isRemote)
world.playSoundAtEntity((Entity)player, "botania:ding", 0.11F, 0.8F);
return true;
}
if(!tile.hasGame())
tile.setPlayer(player);
else if(!tile.isSingleGame && tile.playersName[1].isEmpty() && !tile.playersName[0].equals(player.getCommandSenderName()))
tile.setPlayer(player);
else {
return tile.dropDice(player);
}
return false;
} else {
if(!player.isSneaking()) {
ItemStack heldItem = player.getCurrentEquippedItem();
TileBoardFate tile = (TileBoardFate)world.getTileEntity(x, y, z);
if(heldItem != null && tile != null && tile.isDice(heldItem)) {
for(int i = 0; i < tile.getSizeInventory(); i++) {
ItemStack slotStack = tile.getStackInSlot(i);
if(slotStack != null)
continue;
heldItem.stackSize--;
if(heldItem.stackSize == 0)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
if(!world.isRemote) {
ItemStack copy = heldItem.copy();
copy.stackSize = 1;
tile.setInventorySlotContents(i, copy);
tile.slotChance[i] = (byte)(world.rand.nextInt(6) + 1);
tile.requestUpdate = true;
world.playSoundEffect(x, y, z, "ab:boardCube", 0.6F, 1.0F);
}
return true;
}
}
return false;
} else {
TileBoardFate tile = (TileBoardFate)world.getTileEntity(x, y, z);
return tile.spawnRelic(player);
}
}
}
public TileEntity createNewTileEntity(World world, int meta) {
return meta == 0 ? new TileGameBoard() : new TileBoardFate();
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if(!world.isRemote && meta == 1) {
TileInventory inv = (TileInventory)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);
}
protected IIcon[] iconsFate;
protected IIcon[] iconsBoard;
public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) {
return stack.getItemDamage() == 1 ? AchievementRegister.fateBoard : null;
}
public BlockBoardFate() {
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("boardFate");
}
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack stack) {
return world.getBlockMetadata(x, y, z) == 0 ? RecipeListAB.gameBoard : RecipeListAB.fateBoard;
}
}
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List list) {
for (int i = 0; i < 2; i++) list.add(new ItemStack(par1, 1, i));
}
public void registerBlockIcons(IIconRegister ir) {
this.iconsFate = new IIcon[3];
this.iconsBoard = new IIcon[3];
for (int i = 0; i < iconsFate.length; i++) this.iconsFate[i] = ir.registerIcon("ab:boardFate_" + i);
for (int i = 0; i < iconsBoard.length; i++) this.iconsBoard[i] = ir.registerIcon("ab:gameBoard_" + i);
}
public IIcon getIcon(int side, int meta) {
if (meta == 0) return this.iconsBoard[Math.min(2, side)];
else return this.iconsFate[Math.min(2, side)];
}
public boolean isOpaqueCube() {
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
public int damageDropped(int par1) {
return par1;
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7,
float par8, float par9) {
int meta = world.getBlockMetadata(x, y, z);
if (meta == 0) {
TileGameBoard tile = (TileGameBoard) world.getTileEntity(x, y, z);
if (player.isSneaking() && !tile.hasGame()) {
tile.isSingleGame = !tile.isSingleGame;
if (!world.isRemote) world.playSoundAtEntity((Entity) player, "botania:ding", 0.11F, 0.8F);
return true;
}
if (!tile.hasGame()) tile.setPlayer(player);
else if (!tile.isSingleGame && tile.playersName[1].isEmpty()
&& !tile.playersName[0].equals(player.getCommandSenderName()))
tile.setPlayer(player);
else {
return tile.dropDice(player);
}
return false;
} else {
if (!player.isSneaking()) {
ItemStack heldItem = player.getCurrentEquippedItem();
TileBoardFate tile = (TileBoardFate) world.getTileEntity(x, y, z);
if (heldItem != null && tile != null && tile.isDice(heldItem)) {
for (int i = 0; i < tile.getSizeInventory(); i++) {
ItemStack slotStack = tile.getStackInSlot(i);
if (slotStack != null) continue;
heldItem.stackSize--;
if (heldItem.stackSize == 0)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
if (!world.isRemote) {
ItemStack copy = heldItem.copy();
copy.stackSize = 1;
tile.setInventorySlotContents(i, copy);
tile.slotChance[i] = (byte) (world.rand.nextInt(6) + 1);
tile.requestUpdate = true;
world.playSoundEffect(x, y, z, "ab:boardCube", 0.6F, 1.0F);
}
return true;
}
}
return false;
} else {
TileBoardFate tile = (TileBoardFate) world.getTileEntity(x, y, z);
return tile.spawnRelic(player);
}
}
}
public TileEntity createNewTileEntity(World world, int meta) {
return meta == 0 ? new TileGameBoard() : new TileBoardFate();
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if (!world.isRemote && meta == 1) {
TileInventory inv = (TileInventory) 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 Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) {
return stack.getItemDamage() == 1 ? AchievementRegister.fateBoard : null;
}
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack stack) {
return world.getBlockMetadata(x, y, z) == 0 ? RecipeListAB.gameBoard : RecipeListAB.fateBoard;
}
}
@@ -1,110 +1,101 @@
package ab.common.block;
import java.util.List;
import ab.AdvancedBotany;
import ab.common.block.tile.TileEngineerHopper;
import ab.common.block.tile.TileInventory;
import ab.common.lib.register.BlockListAB;
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.BlockContainer;
import net.minecraft.block.BlockHopper;
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.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.AxisAlignedBB;
import net.minecraft.util.Facing;
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.common.block.ModBlocks;
import ab.AdvancedBotany;
import ab.common.block.tile.TileEngineerHopper;
import ab.common.block.tile.TileInventory;
import ab.common.lib.register.BlockListAB;
import ab.common.lib.register.RecipeListAB;
public class BlockEngineerHopper extends BlockContainer implements IWandable, IWandHUD, ILexiconable {
private static IIcon[] icons = new IIcon[3];
public BlockEngineerHopper() {
super(Material.iron);
this.setCreativeTab(AdvancedBotany.tabAB);
this.setBlockName("engineerHopper");
float offset = 0.125F;
this.setBlockBounds(offset, offset / 2.0f, offset, 1.0F - offset, 1.0F - (offset / 2.0f), 1.0F - offset);
}
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return RecipeListAB.engineerHopper;
}
public IIcon getIcon(int par1, int par2) {
return ModBlocks.blazeBlock.getIcon(0, 0);
}
private static IIcon[] icons = new IIcon[3];
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if(!world.isRemote) {
TileInventory inv = (TileInventory)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 TileEntity createNewTileEntity(World world, int meta) {
public BlockEngineerHopper() {
super(Material.iron);
this.setCreativeTab(AdvancedBotany.tabAB);
this.setBlockName("engineerHopper");
float offset = 0.125F;
this.setBlockBounds(offset, offset / 2.0f, offset, 1.0F - offset, 1.0F - (offset / 2.0f), 1.0F - offset);
}
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return RecipeListAB.engineerHopper;
}
public IIcon getIcon(int par1, int par2) {
return ModBlocks.blazeBlock.getIcon(0, 0);
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if (!world.isRemote) {
TileInventory inv = (TileInventory) 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 TileEntity createNewTileEntity(World world, int meta) {
return new TileEngineerHopper();
}
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) {
((TileEngineerHopper)world.getTileEntity(x, y, z)).renderHUD(mc, res);
}
public int getRenderType() {
return BlockListAB.blockEngineerHopperRI;
}
public boolean isOpaqueCube() {
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) {
((TileEngineerHopper) world.getTileEntity(x, y, z)).renderHUD(mc, res);
}
public int getRenderType() {
return BlockListAB.blockEngineerHopperRI;
}
public boolean isOpaqueCube() {
return false;
}
public boolean renderAsNormalBlock() {
public boolean renderAsNormalBlock() {
return false;
}
public boolean onUsedByWand(EntityPlayer player, ItemStack wand, World world, int x, int y, int z, int meta) {
if(!player.isSneaking()) {
TileEngineerHopper tile = (TileEngineerHopper)world.getTileEntity(x, y, z);
tile.changeBindType();
if(!world.isRemote)
world.playSoundAtEntity((Entity)player, "botania:ding", 0.11F, 1.0F);
}
return true;
}
}
public boolean onUsedByWand(EntityPlayer player, ItemStack wand, World world, int x, int y, int z, int meta) {
if (!player.isSneaking()) {
TileEngineerHopper tile = (TileEngineerHopper) world.getTileEntity(x, y, z);
tile.changeBindType();
if (!world.isRemote) world.playSoundAtEntity((Entity) player, "botania:ding", 0.11F, 1.0F);
}
return true;
}
}
@@ -2,9 +2,6 @@ package ab.common.block;
import java.util.Random;
import ab.common.core.CommonHelper;
import ab.common.lib.register.BlockListAB;
import ab.common.lib.register.RecipeListAB;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBush;
import net.minecraft.block.IGrowable;
@@ -15,66 +12,72 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import ab.common.core.CommonHelper;
import ab.common.lib.register.BlockListAB;
import ab.common.lib.register.RecipeListAB;
public class BlockFreyrLiana extends BlockBush implements ILexiconable {
public BlockFreyrLiana() {
super(Material.plants);
this.setBlockName("BlockFreyrLiana");
this.setStepSound(soundTypeGrass);
this.setBlockTextureName("ab:freyrLiana");
}
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return RecipeListAB.freyrSlingshot;
}
public BlockFreyrLiana() {
super(Material.plants);
this.setBlockName("BlockFreyrLiana");
this.setStepSound(soundTypeGrass);
this.setBlockTextureName("ab:freyrLiana");
}
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;
}
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return RecipeListAB.freyrSlingshot;
}
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 < 5; i1++) {
Block block = world.getBlock(x, y - i1, z);
if(block instanceof IGrowable) {
CommonHelper.fertilizer(world, block, x, y - i1, z, 18, null);
if(world.getBlock(x, y - i1 - 1, z) == BlockListAB.blockTerraFarmland)
world.getBlock(x, y - i1 - 1, z).updateTick(world, x, y - i1 - 1, z, rand);
break;
}
}
}
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;
}
protected void checkAndDropBlock(World world, int x, int y, int z) {
if (!this.canBlockStay(world, x, y, z)) {
this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
world.setBlock(x, y, z, getBlockById(0), 0, 3);
}
}
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 < 5; i1++) {
Block block = world.getBlock(x, y - i1, z);
if (block instanceof IGrowable) {
CommonHelper.fertilizer(world, block, x, y - i1, z, 18, null);
if (world.getBlock(x, y - i1 - 1, z) == BlockListAB.blockTerraFarmland)
world.getBlock(x, y - i1 - 1, z).updateTick(world, x, y - i1 - 1, z, rand);
break;
}
}
}
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
return null;
}
protected void checkAndDropBlock(World world, int x, int y, int z) {
if (!this.canBlockStay(world, x, y, z)) {
this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
world.setBlock(x, y, z, getBlockById(0), 0, 3);
}
}
public boolean canBlockStay(World world, int x, int y, int z) {
return this.canPlaceBlockAt(world, x, y, z);
}
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
return null;
}
public int getFlammability(final IBlockAccess world, final int x, final int y, final int z, final ForgeDirection face) {
return 100;
}
public boolean canBlockStay(World world, int x, int y, int z) {
return this.canPlaceBlockAt(world, x, y, z);
}
public int getFireSpreadSpeed(final IBlockAccess world, final int x, final int y, final int z, final ForgeDirection face) {
return 60;
}
}
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;
}
}
@@ -2,11 +2,6 @@ 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;
@@ -14,7 +9,6 @@ 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;
@@ -23,113 +17,117 @@ 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;
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;
public class BlockLebethronWood extends Block implements ILexiconable, ITileEntityProvider {
private static IIcon[] icon = new IIcon[5];
public static IIcon iconPortal;
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) {
TileLebethronCore core = (TileLebethronCore)world.getTileEntity(x, y, z);
ItemStack heldItem = player.getCurrentEquippedItem();
if(heldItem == null)
return false;
Block block = Block.getBlockFromItem(heldItem.getItem());
if(block.getMaterial() == Material.leaves && !heldItem.hasTagCompound()) {
if(!world.isRemote) {
core.updateStructure();
if(core.getValidTree()) {
if(core.setBlock(player, 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);
iconPortal = ir.registerIcon("ab:portalAlphirine");
}
@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;
}
private static IIcon[] icon = new IIcon[5];
public static IIcon iconPortal;
public TileEntity createNewTileEntity(World world, int meta) {
return meta == 4 ? new TileLebethronCore() : null;
}
}
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) {
TileLebethronCore core = (TileLebethronCore) world.getTileEntity(x, y, z);
ItemStack heldItem = player.getCurrentEquippedItem();
if (heldItem == null) return false;
Block block = Block.getBlockFromItem(heldItem.getItem());
if (block.getMaterial() == Material.leaves && !heldItem.hasTagCompound()) {
if (!world.isRemote) {
core.updateStructure();
if (core.getValidTree()) {
if (core.setBlock(player, 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);
iconPortal = ir.registerIcon("ab:portalAlphirine");
}
@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;
}
}
@@ -2,48 +2,57 @@ 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;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockLuminousFreyrLiana extends BlockFreyrLiana {
public BlockLuminousFreyrLiana() {
this.setBlockName("BlockLuminousFreyrLiana");
this.setBlockTextureName("ab:freyrLuminousLiana");
this.setTickRandomly(true);
}
public BlockLuminousFreyrLiana() {
this.setBlockName("BlockLuminousFreyrLiana");
this.setBlockTextureName("ab:freyrLuminousLiana");
this.setTickRandomly(true);
}
public int getLightValue() {
return 11;
}
public int getLightValue() {
return 11;
}
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);
}
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);
}
@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);
}
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;
}
}
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;
}
}
@@ -1,12 +1,5 @@
package ab.common.block;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import ab.AdvancedBotany;
import ab.common.block.tile.TileMagicCraftCrate;
import ab.common.item.ItemCraftingPattern;
import ab.common.lib.register.RecipeListAB;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
@@ -25,6 +18,10 @@ import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.client.lib.UtilsFX;
@@ -35,241 +32,280 @@ import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.wand.IWandHUD;
import vazkii.botania.api.wand.IWandable;
import vazkii.botania.common.block.BlockModContainer;
import ab.AdvancedBotany;
import ab.common.block.tile.TileMagicCraftCrate;
import ab.common.item.ItemCraftingPattern;
import ab.common.lib.register.RecipeListAB;
public class BlockMagicCraftCrate extends BlockModContainer implements IWandable, IWandHUD, ILexiconable {
public static final Aspect[] primals = new Aspect[] { Aspect.AIR, Aspect.WATER, Aspect.EARTH, Aspect.FIRE, Aspect.ORDER, Aspect.ENTROPY };
public static final Aspect[] primals = new Aspect[] { Aspect.AIR, Aspect.WATER, Aspect.EARTH, Aspect.FIRE,
Aspect.ORDER, Aspect.ENTROPY };
IIcon iconSide;
IIcon iconBottom;
IIcon iconTop;
public IIcon nothing;
IIcon iconSide;
IIcon iconBottom;
IIcon iconTop;
public IIcon nothing;
public BlockMagicCraftCrate() {
super(Material.wood);
this.setHardness(2.0F);
this.setStepSound(soundTypeWood);
this.setBlockName("magicThaumCrafter");
this.setCreativeTab(AdvancedBotany.tabAB);
}
public LexiconEntry getEntry(World arg0, int arg1, int arg2, int arg3, EntityPlayer arg4, ItemStack arg5) {
return RecipeListAB.thaumAutoCraft;
}
public BlockMagicCraftCrate() {
super(Material.wood);
this.setHardness(2.0F);
this.setStepSound(soundTypeWood);
this.setBlockName("magicThaumCrafter");
this.setCreativeTab(AdvancedBotany.tabAB);
}
public void registerBlockIcons(IIconRegister ir) {
iconSide = ir.registerIcon("ab:magicCrateSide");
iconTop = ir.registerIcon("ab:magicCrateTop");
iconBottom = ir.registerIcon("ab:magicCrateBottom");
nothing = ir.registerIcon("ab:nothing");
}
public LexiconEntry getEntry(World arg0, int arg1, int arg2, int arg3, EntityPlayer arg4, ItemStack arg5) {
return RecipeListAB.thaumAutoCraft;
}
public boolean hasComparatorInputOverride() {
return true;
}
public void registerBlockIcons(IIconRegister ir) {
iconSide = ir.registerIcon("ab:magicCrateSide");
iconTop = ir.registerIcon("ab:magicCrateTop");
iconBottom = ir.registerIcon("ab:magicCrateBottom");
nothing = ir.registerIcon("ab:nothing");
}
public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) {
TileMagicCraftCrate crate = (TileMagicCraftCrate) par1World.getTileEntity(par2, par3, par4);
return crate.getSignal();
}
public boolean hasComparatorInputOverride() {
return true;
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
TileMagicCraftCrate crate = (TileMagicCraftCrate) world.getTileEntity(x, y, z);
ItemStack stack = player.getHeldItem();
for(int i = 10; i < 12; i++) {
ItemStack item = crate.getStackInSlot(i);
if(player.isSneaking()) {
if(item == null)
continue;
if(!world.isRemote) {
Vec3 vec3 = player.getLook(1.0F).normalize();
EntityItem entityitem = new EntityItem(world, player.posX + vec3.xCoord, player.posY + vec3.yCoord + 0.5f, player.posZ + vec3.zCoord, item.copy());
world.spawnEntityInWorld(entityitem);
}
crate.setInventorySlotContents(i, null);
world.playSoundEffect((double) x, (double) y, (double) z, "random.pop", 0.2f, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7f + 1.0f) * 1.5f);
crate.markDirty();
return true;
} else if(stack != null && crate.isItemValidForSlot(i, stack)) {
if(item != null) {
if(!world.isRemote) {
Vec3 vec3 = player.getLook(1.0F).normalize();
EntityItem entityitem = new EntityItem(world, player.posX + vec3.xCoord, player.posY + vec3.yCoord + 0.5f, player.posZ + vec3.zCoord, item.copy());
world.spawnEntityInWorld(entityitem);
}
}
crate.setInventorySlotContents(i, stack.copy());
if(i == 11)
crate.setPlayer(player);
stack.splitStack(1);
world.playSoundEffect((double) x, (double) y, (double) z, "random.pop", 0.2f, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7f + 1.0f) * 1.5f);
crate.markDirty();
return true;
}
}
if(stack != null && stack.getItem() instanceof ItemCraftingPattern && stack.getItemDamage() != 0) {
boolean[][] pattern = ((ItemCraftingPattern) stack.getItem()).getPattern(stack.getItemDamage());
crate.setPattern(pattern);
stack.splitStack(1);
return true;
}
return false;
}
public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) {
TileMagicCraftCrate crate = (TileMagicCraftCrate) par1World.getTileEntity(par2, par3, par4);
return crate.getSignal();
}
public IIcon getIcon(int side, int meta) {
switch (side) {
case 0:
return iconBottom;
case 1:
return iconTop;
default:
return iconSide;
}
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX,
float hitY, float hitZ) {
TileMagicCraftCrate crate = (TileMagicCraftCrate) world.getTileEntity(x, y, z);
ItemStack stack = player.getHeldItem();
for (int i = 10; i < 12; i++) {
ItemStack item = crate.getStackInSlot(i);
if (player.isSneaking()) {
if (item == null) continue;
if (!world.isRemote) {
Vec3 vec3 = player.getLook(1.0F).normalize();
EntityItem entityitem = new EntityItem(
world,
player.posX + vec3.xCoord,
player.posY + vec3.yCoord + 0.5f,
player.posZ + vec3.zCoord,
item.copy());
world.spawnEntityInWorld(entityitem);
}
crate.setInventorySlotContents(i, null);
world.playSoundEffect(
(double) x,
(double) y,
(double) z,
"random.pop",
0.2f,
((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7f + 1.0f) * 1.5f);
crate.markDirty();
return true;
} else if (stack != null && crate.isItemValidForSlot(i, stack)) {
if (item != null) {
if (!world.isRemote) {
Vec3 vec3 = player.getLook(1.0F).normalize();
EntityItem entityitem = new EntityItem(
world,
player.posX + vec3.xCoord,
player.posY + vec3.yCoord + 0.5f,
player.posZ + vec3.zCoord,
item.copy());
world.spawnEntityInWorld(entityitem);
}
}
crate.setInventorySlotContents(i, stack.copy());
if (i == 11) crate.setPlayer(player);
stack.splitStack(1);
world.playSoundEffect(
(double) x,
(double) y,
(double) z,
"random.pop",
0.2f,
((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7f + 1.0f) * 1.5f);
crate.markDirty();
return true;
}
}
if (stack != null && stack.getItem() instanceof ItemCraftingPattern && stack.getItemDamage() != 0) {
boolean[][] pattern = ((ItemCraftingPattern) stack.getItem()).getPattern(stack.getItemDamage());
crate.setPattern(pattern);
stack.splitStack(1);
return true;
}
return false;
}
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
switch (side) {
case 0:
return iconBottom;
case 1:
return iconTop;
default:
return iconSide;
}
}
public IIcon getIcon(int side, int meta) {
switch (side) {
case 0:
return iconBottom;
case 1:
return iconTop;
default:
return iconSide;
}
}
public TileEntity createNewTileEntity(World world, int meta) {
return new TileMagicCraftCrate();
}
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
switch (side) {
case 0:
return iconBottom;
case 1:
return iconTop;
default:
return iconSide;
}
}
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileMagicCraftCrate) {
TileMagicCraftCrate craft = (TileMagicCraftCrate) tile;
int width = 52;
int height = 52;
int xc = res.getScaledWidth() / 2 + 20;
int yc = res.getScaledHeight() / 2 - height / 2;
public TileEntity createNewTileEntity(World world, int meta) {
return new TileMagicCraftCrate();
}
Gui.drawRect(xc - 6 - 3, yc - 6, xc + width + 3, yc + height + 6, 0x2294178a);
Gui.drawRect(xc - 4 - 3, yc - 4, xc + width + 1, yc + height + 4, 0x2294178a);
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileMagicCraftCrate) {
TileMagicCraftCrate craft = (TileMagicCraftCrate) tile;
int width = 52;
int height = 52;
int xc = res.getScaledWidth() / 2 + 20;
int yc = res.getScaledHeight() / 2 - height / 2;
Gui.drawRect(xc + 60 - 3, yc + 18 - 3, xc + 60 + 16 + 3, yc + 18 + 16 + 3, 0x2294178a);
Gui.drawRect(xc + 60 - 2, yc + 18 - 2, xc + 60 + 16 + 2, yc + 18 + 16 + 2, 0x2294178a);
Gui.drawRect(xc + 60, yc + 18, xc + 60 + 16, yc + 18 + 16, 0x22efd3f4);
Gui.drawRect(xc - 6 - 3, yc - 6, xc + width + 3, yc + height + 6, 0x2294178a);
Gui.drawRect(xc - 4 - 3, yc - 4, xc + width + 1, yc + height + 4, 0x2294178a);
AspectList waitingAspects = null;
if(craft.getWaitingStack() != null && craft.getPlayer() != null) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 0.7f);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, craft.getWaitingStack(), xc + 60, yc + 18);
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
waitingAspects = ThaumcraftCraftingManager.findMatchingArcaneRecipeAspects((IInventory) craft, craft.getPlayer());
}
if(craft.getStackInSlot(10) != null) {
GL11.glEnable(GL11.GL_BLEND);
ItemStack wand = craft.getStackInSlot(10);
ItemWandCasting itemWand = ((ItemWandCasting) wand.getItem());
AspectList aspects = itemWand.getAllVis(wand);
int n = 0;
for (Aspect a : primals) {
float alpha = 1.0f;
if (waitingAspects != null) {
float amt = (float) waitingAspects.getAmount(a);
if (amt > 0) {
amt *= itemWand.getConsumptionModifier(wand, craft.getPlayer(), a, true);
if (amt * 100.0f > itemWand.getVis(wand, a)) {
alpha = 0.5f + (MathHelper.sin((craft.getPlayer().ticksExisted + n * 10) / 2.0f) * 0.2f
- 0.2f);
}
}
}
int xa = (int) (xc - 45 + Math.cos(0.2f * Math.PI * n + Math.PI / 2) * 45);
int ya = (int) (yc + 16 + Math.sin(0.2f * Math.PI * n + Math.PI / 2) * 45);
float amout = aspects.getAmount(a) + 0.000001f;
UtilsFX.drawTag(xa, ya, a, amout / 100f, 0, 0, 771, alpha, false);
n++;
}
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
}
Gui.drawRect(xc + 60 - 3, yc + 18 - 3, xc + 60 + 16 + 3, yc + 18 + 16 + 3, 0x2294178a);
Gui.drawRect(xc + 60 - 2, yc + 18 - 2, xc + 60 + 16 + 2, yc + 18 + 16 + 2, 0x2294178a);
Gui.drawRect(xc + 60, yc + 18, xc + 60 + 16, yc + 18 + 16, 0x22efd3f4);
Gui.drawRect(xc - 28 - 20 - 3, yc + 7 - 3, xc - 28 - 20 + 16 + 3, yc + 7 + 16 + 3, 0x2294178a);
Gui.drawRect(xc - 28 - 20 - 2, yc + 7 - 2, xc - 28 - 20 + 16 + 2, yc + 7 + 16 + 2, 0x2294178a);
Gui.drawRect(xc - 28 - 20, yc + 7, xc - 28 - 20 + 16, yc + 7 + 16, 0x22efd3f4);
net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine,
craft.getStackInSlot(10), xc - 28 - 20, yc + 8);
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
AspectList waitingAspects = null;
Gui.drawRect(xc - 28 - 20 - 3, yc + 29 - 3, xc - 28 - 20 + 16 - 3, yc + 29 + 16 + 3, 0x2294178a);
Gui.drawRect(xc - 28 - 20 - 2, yc + 29 - 2, xc - 28 - 20 + 16 + 2, yc + 29 + 16 + 2, 0x2294178a);
Gui.drawRect(xc - 28 - 20, yc + 29, xc - 28 - 20 + 16, yc + 29 + 16, 0x22efd3f4);
net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine,
craft.getStackInSlot(11), xc - 28 - 20, yc + 29);
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
if (craft.getWaitingStack() != null && craft.getPlayer() != null) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 0.7f);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderItem.getInstance().renderItemAndEffectIntoGUI(
mc.fontRenderer,
mc.renderEngine,
craft.getWaitingStack(),
xc + 60,
yc + 18);
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
waitingAspects = ThaumcraftCraftingManager
.findMatchingArcaneRecipeAspects((IInventory) craft, craft.getPlayer());
}
if (craft.getStackInSlot(10) != null) {
GL11.glEnable(GL11.GL_BLEND);
ItemStack wand = craft.getStackInSlot(10);
ItemWandCasting itemWand = ((ItemWandCasting) wand.getItem());
AspectList aspects = itemWand.getAllVis(wand);
int n = 0;
for (Aspect a : primals) {
float alpha = 1.0f;
if (waitingAspects != null) {
float amt = (float) waitingAspects.getAmount(a);
if (amt > 0) {
amt *= itemWand.getConsumptionModifier(wand, craft.getPlayer(), a, true);
if (amt * 100.0f > itemWand.getVis(wand, a)) {
alpha = 0.5f + (MathHelper.sin((craft.getPlayer().ticksExisted + n * 10) / 2.0f) * 0.2f
- 0.2f);
}
}
}
int xa = (int) (xc - 45 + Math.cos(0.2f * Math.PI * n + Math.PI / 2) * 45);
int ya = (int) (yc + 16 + Math.sin(0.2f * Math.PI * n + Math.PI / 2) * 45);
float amout = aspects.getAmount(a) + 0.000001f;
UtilsFX.drawTag(xa, ya, a, amout / 100f, 0, 0, 771, alpha, false);
n++;
}
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
}
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++) {
int index = i * 3 + j;
int xp = xc + j * 18 - 3;
int yp = yc + i * 18;
Gui.drawRect(xc - 28 - 20 - 3, yc + 7 - 3, xc - 28 - 20 + 16 + 3, yc + 7 + 16 + 3, 0x2294178a);
Gui.drawRect(xc - 28 - 20 - 2, yc + 7 - 2, xc - 28 - 20 + 16 + 2, yc + 7 + 16 + 2, 0x2294178a);
Gui.drawRect(xc - 28 - 20, yc + 7, xc - 28 - 20 + 16, yc + 7 + 16, 0x22efd3f4);
net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderItem.getInstance().renderItemAndEffectIntoGUI(
mc.fontRenderer,
mc.renderEngine,
craft.getStackInSlot(10),
xc - 28 - 20,
yc + 8);
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
boolean enabled = craft.getPattern()[i][j];
Gui.drawRect(xc - 28 - 20 - 3, yc + 29 - 3, xc - 28 - 20 + 16 - 3, yc + 29 + 16 + 3, 0x2294178a);
Gui.drawRect(xc - 28 - 20 - 2, yc + 29 - 2, xc - 28 - 20 + 16 + 2, yc + 29 + 16 + 2, 0x2294178a);
Gui.drawRect(xc - 28 - 20, yc + 29, xc - 28 - 20 + 16, yc + 29 + 16, 0x22efd3f4);
net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderItem.getInstance().renderItemAndEffectIntoGUI(
mc.fontRenderer,
mc.renderEngine,
craft.getStackInSlot(11),
xc - 28 - 20,
yc + 29);
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
Gui.drawRect(xp, yp, xp + 16, yp + 16, enabled ? 0x22efd3f4 : 0x22fb02a6);
for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) {
int index = i * 3 + j;
int xp = xc + j * 18 - 3;
int yp = yc + i * 18;
ItemStack item = craft.getStackInSlot(index);
net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, item, xp, yp);
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
}
}
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if(!world.isRemote) {
TileMagicCraftCrate inv = (TileMagicCraftCrate)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);
}
boolean enabled = craft.getPattern()[i][j];
public boolean renderAsNormalBlock() {
return false;
}
Gui.drawRect(xp, yp, xp + 16, yp + 16, enabled ? 0x22efd3f4 : 0x22fb02a6);
public boolean isOpaqueCube() {
return false;
}
ItemStack item = craft.getStackInSlot(index);
net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, item, xp, yp);
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
}
}
}
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
TileMagicCraftCrate crate = (TileMagicCraftCrate) world.getTileEntity(x, y, z);
crate.ejectAll();
return true;
}
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if (!world.isRemote) {
TileMagicCraftCrate inv = (TileMagicCraftCrate) 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 renderAsNormalBlock() {
return false;
}
public boolean isOpaqueCube() {
return false;
}
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
TileMagicCraftCrate crate = (TileMagicCraftCrate) world.getTileEntity(x, y, z);
crate.ejectAll();
return true;
}
}
@@ -1,10 +1,5 @@
package ab.common.block;
import ab.AdvancedBotany;
import ab.common.block.tile.TileInventory;
import ab.common.block.tile.TileManaCharger;
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.material.Material;
@@ -18,120 +13,132 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.Vec3;
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.api.mana.IManaItem;
import vazkii.botania.api.wand.IWandHUD;
import vazkii.botania.api.wand.IWandable;
import vazkii.botania.common.block.ModBlocks;
import ab.AdvancedBotany;
import ab.common.block.tile.TileInventory;
import ab.common.block.tile.TileManaCharger;
import ab.common.lib.register.BlockListAB;
import ab.common.lib.register.RecipeListAB;
public class BlockManaCharger extends BlockContainer implements IWandHUD, IWandable, ILexiconable {
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 IIcon getIcon(int par1, int par2) {
return ModBlocks.livingrock.getIcon(0, 0);
}
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();
tile.setInventorySlotContents(slotSide, null);
if(!world.isRemote) {
Vec3 vec3 = player.getLook(1.0F).normalize();
EntityItem entityitem = new EntityItem(world, player.posX + vec3.xCoord, player.posY + 1.2f, player.posZ + vec3.zCoord, copy);
world.spawnEntityInWorld(entityitem);
tile.requestUpdate = true;
}
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);
player.inventory.markDirty();
if(!world.isRemote) {
tile.setInventorySlotContents(slotSide, copy);
tile.requestUpdate = true;
}
return true;
}
}
}
return false;
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if(!world.isRemote) {
TileInventory inv = (TileInventory)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() {
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 IIcon getIcon(int par1, int par2) {
return ModBlocks.livingrock.getIcon(0, 0);
}
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();
tile.setInventorySlotContents(slotSide, null);
if (!world.isRemote) {
Vec3 vec3 = player.getLook(1.0F).normalize();
EntityItem entityitem = new EntityItem(
world,
player.posX + vec3.xCoord,
player.posY + 1.2f,
player.posZ + vec3.zCoord,
copy);
world.spawnEntityInWorld(entityitem);
tile.requestUpdate = true;
}
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);
player.inventory.markDirty();
if (!world.isRemote) {
tile.setInventorySlotContents(slotSide, copy);
tile.requestUpdate = true;
}
return true;
}
}
}
return false;
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if (!world.isRemote) {
TileInventory inv = (TileInventory) 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;
}
public TileEntity createNewTileEntity(World world, int meta) {
return new TileManaCharger();
}
public LexiconEntry getEntry(World arg0, int arg1, int arg2, int arg3, EntityPlayer arg4, ItemStack arg5) {
return RecipeListAB.manaCharger;
}
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;
}
public LexiconEntry getEntry(World arg0, int arg1, int arg2, int arg3, EntityPlayer arg4, ItemStack arg5) {
return RecipeListAB.manaCharger;
}
}
@@ -1,13 +1,7 @@
package ab.common.block;
import java.util.List;
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;
@@ -18,66 +12,69 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
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;
import ab.AdvancedBotany;
import ab.common.block.tile.TileManaContainer;
import ab.common.lib.register.BlockListAB;
import ab.common.lib.register.RecipeListAB;
public class BlockManaContainer extends BlockContainer implements IWandHUD, IWandable, ILexiconable {
public BlockManaContainer() {
super(Material.iron);
this.setCreativeTab(AdvancedBotany.tabAB);
this.setHardness(9.0F);
this.setBlockName("ABManaContainer");
float offset = 0.08F;
this.setBlockBounds(offset, offset / 2.0f, offset, 1.0F - offset, 1.0F - (offset / 2.0f), 1.0F - offset);
}
public void getSubBlocks(Item par1, CreativeTabs par2, List par3) {
par3.add(new ItemStack(par1, 1, 0));
par3.add(new ItemStack(par1, 1, 1));
par3.add(new ItemStack(par1, 1, 2));
}
public int damageDropped(int meta) {
return meta;
}
public TileEntity createNewTileEntity(World world, int meta) {
return new TileManaContainer();
}
public boolean isOpaqueCube() {
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
public int getRenderType() {
public BlockManaContainer() {
super(Material.iron);
this.setCreativeTab(AdvancedBotany.tabAB);
this.setHardness(9.0F);
this.setBlockName("ABManaContainer");
float offset = 0.08F;
this.setBlockBounds(offset, offset / 2.0f, offset, 1.0F - offset, 1.0F - (offset / 2.0f), 1.0F - offset);
}
public void getSubBlocks(Item par1, CreativeTabs par2, List par3) {
par3.add(new ItemStack(par1, 1, 0));
par3.add(new ItemStack(par1, 1, 1));
par3.add(new ItemStack(par1, 1, 2));
}
public int damageDropped(int meta) {
return meta;
}
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;
}
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;
}
}
@@ -1,81 +1,77 @@
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;
import ab.AdvancedBotany;
import ab.common.block.tile.TileManaCrystalCube;
import ab.common.lib.register.BlockListAB;
import ab.common.lib.register.RecipeListAB;
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(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() {
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(
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;
}
}
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;
}
}
@@ -1,15 +1,8 @@
package ab.common.block;
import ab.AdvancedBotany;
import ab.common.block.tile.TileNidavellirForge;
import ab.common.block.tile.TileInventory;
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.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
@@ -21,127 +14,148 @@ import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
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.ModBlocks;
import ab.AdvancedBotany;
import ab.common.block.tile.TileInventory;
import ab.common.block.tile.TileNidavellirForge;
import ab.common.lib.register.BlockListAB;
import ab.common.lib.register.RecipeListAB;
public class BlockNidavellirForge extends BlockContainer implements ILexiconable {
public BlockNidavellirForge() {
super(Material.iron);
this.setCreativeTab(AdvancedBotany.tabAB);
this.setHardness(3.0F);
this.setResistance(10.0F);
this.setStepSound(soundTypeMetal);
this.setBlockName("ABPlate");
}
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
float f = 0.1875F;
float f1 = 0.0625F;
switch(world.getBlockMetadata(x, y, z)) {
case 0: this.setBlockBounds(f, 0.0F, f1, 1.0F - f, 0.75F, 1.0F);
break;
case 1: this.setBlockBounds(0.0F, 0.0F, f, 1.0F - f1, 0.75F, 1.0F - f);
break;
case 2: this.setBlockBounds(f, 0.0F, 0.0F, 1.0F - f, 0.75F, 1.0F - f1);
break;
case 3: this.setBlockBounds(f1, 0.0F, f, 1.0F, 0.75F, 1.0F - f);
break;
default: this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase liv, ItemStack stack) {
int meta = MathHelper.floor_double((double)(liv.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
world.setBlockMetadataWithNotify(x, y, z, meta, 3);
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
TileNidavellirForge tile = (TileNidavellirForge)world.getTileEntity(x, y, z);
if(player.isSneaking()) {
if(tile.getStackInSlot(0) != null) {
ItemStack copy = tile.getStackInSlot(0).copy();
if(!world.isRemote) {
Vec3 vec3 = player.getLook(1.0F).normalize();
EntityItem entityitem = new EntityItem(world, player.posX + vec3.xCoord, player.posY + 1.2f, player.posZ + vec3.zCoord, copy);
world.spawnEntityInWorld(entityitem);
tile.requestUpdate = true;
}
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(!world.isRemote) {
Vec3 vec3 = player.getLook(1.0F).normalize();
EntityItem entityitem = new EntityItem(world, player.posX + vec3.xCoord, player.posY + 1.2f, player.posZ + vec3.zCoord, copy);
world.spawnEntityInWorld(entityitem);
tile.requestUpdate = true;
}
tile.setInventorySlotContents(i, null);
world.func_147453_f(x, y, z, (Block)this);
return true;
}
}
}
return false;
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if(!world.isRemote) {
TileInventory inv = (TileInventory)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 int getRenderType() {
return BlockListAB.blockABPlateRI;
}
public IIcon getIcon(int par1, int par2) {
return ModBlocks.storage.getIcon(0, 0);
}
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 TileNidavellirForge();
}
public BlockNidavellirForge() {
super(Material.iron);
this.setCreativeTab(AdvancedBotany.tabAB);
this.setHardness(3.0F);
this.setResistance(10.0F);
this.setStepSound(soundTypeMetal);
this.setBlockName("ABPlate");
}
public LexiconEntry getEntry(World arg0, int arg1, int arg2, int arg3, EntityPlayer arg4, ItemStack arg5) {
return RecipeListAB.advandedAgglomerationPlate;
}
}
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
float f = 0.1875F;
float f1 = 0.0625F;
switch (world.getBlockMetadata(x, y, z)) {
case 0:
this.setBlockBounds(f, 0.0F, f1, 1.0F - f, 0.75F, 1.0F);
break;
case 1:
this.setBlockBounds(0.0F, 0.0F, f, 1.0F - f1, 0.75F, 1.0F - f);
break;
case 2:
this.setBlockBounds(f, 0.0F, 0.0F, 1.0F - f, 0.75F, 1.0F - f1);
break;
case 3:
this.setBlockBounds(f1, 0.0F, f, 1.0F, 0.75F, 1.0F - f);
break;
default:
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase liv, ItemStack stack) {
int meta = MathHelper.floor_double((double) (liv.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
world.setBlockMetadataWithNotify(x, y, z, meta, 3);
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7,
float par8, float par9) {
TileNidavellirForge tile = (TileNidavellirForge) world.getTileEntity(x, y, z);
if (player.isSneaking()) {
if (tile.getStackInSlot(0) != null) {
ItemStack copy = tile.getStackInSlot(0).copy();
if (!world.isRemote) {
Vec3 vec3 = player.getLook(1.0F).normalize();
EntityItem entityitem = new EntityItem(
world,
player.posX + vec3.xCoord,
player.posY + 1.2f,
player.posZ + vec3.zCoord,
copy);
world.spawnEntityInWorld(entityitem);
tile.requestUpdate = true;
}
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 (!world.isRemote) {
Vec3 vec3 = player.getLook(1.0F).normalize();
EntityItem entityitem = new EntityItem(
world,
player.posX + vec3.xCoord,
player.posY + 1.2f,
player.posZ + vec3.zCoord,
copy);
world.spawnEntityInWorld(entityitem);
tile.requestUpdate = true;
}
tile.setInventorySlotContents(i, null);
world.func_147453_f(x, y, z, (Block) this);
return true;
}
}
}
return false;
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if (!world.isRemote) {
TileInventory inv = (TileInventory) 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 int getRenderType() {
return BlockListAB.blockABPlateRI;
}
public IIcon getIcon(int par1, int par2) {
return ModBlocks.storage.getIcon(0, 0);
}
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 TileNidavellirForge();
}
public LexiconEntry getEntry(World arg0, int arg1, int arg2, int arg3, EntityPlayer arg4, ItemStack arg5) {
return RecipeListAB.advandedAgglomerationPlate;
}
}
@@ -1,22 +1,12 @@
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.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
@@ -26,16 +16,21 @@ 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;
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;
public class BlockTerraFarmland extends Block implements ILexiconable {
private IIcon icon;
private IIcon icon;
public BlockTerraFarmland() {
super(Material.ground);
this.setTickRandomly(true);
@@ -44,94 +39,97 @@ public class BlockTerraFarmland extends Block implements ILexiconable {
this.setLightOpacity(255);
this.setStepSound(soundTypeGravel);
}
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) {
List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - 4, y - 4, z - 4, x + 4, y + 4, z + 4));
if(!items.isEmpty() && items.size() > 7)
return;
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 * 2.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 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) {
List<EntityItem> items = world.getEntitiesWithinAABB(
EntityItem.class,
AxisAlignedBB.getBoundingBox(x - 4, y - 4, z - 4, x + 4, y + 4, z + 4));
if (!items.isEmpty() && items.size() > 7) return;
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 * 2.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_);
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);
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");
icon = reg.registerIcon("ab:terraFarmland");
}
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return RecipeListAB.terraHoe;
}
}
return RecipeListAB.terraHoe;
}
}
@@ -8,6 +8,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.subtile.SubTileEntity;
import vazkii.botania.api.subtile.SubTileFunctional;
@@ -18,48 +19,44 @@ 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 unlocalizedName("");
}
private String unlocalizedName(String end) {
return "ab.flower." + this.name + end;
}
public String getUnlocalizedLoreTextForStack(ItemStack stack) {
return unlocalizedName(".reference");
}
public String getType() {
Class<? extends SubTileEntity> clazz = BotaniaAPI.getSubTileMapping(this.name);
if(clazz == null)
return "uwotm8";
if(clazz.getAnnotation(PassiveFlower.class) != null)
return "botania.flowerType.passiveGenerating";
if(SubTileGenerating.class.isAssignableFrom(clazz))
return "botania.flowerType.generating";
if(SubTileFunctional.class.isAssignableFrom(clazz))
return "botania.flowerType.functional";
return "botania.flowerType.misc";
}
public void addTooltip(ItemStack stack, EntityPlayer player, List<String> tooltip) {
tooltip.add(EnumChatFormatting.BLUE + StatCollector.translateToLocal(getType()));
}
}
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 unlocalizedName("");
}
private String unlocalizedName(String end) {
return "ab.flower." + this.name + end;
}
public String getUnlocalizedLoreTextForStack(ItemStack stack) {
return unlocalizedName(".reference");
}
public String getType() {
Class<? extends SubTileEntity> clazz = BotaniaAPI.getSubTileMapping(this.name);
if (clazz == null) return "uwotm8";
if (clazz.getAnnotation(PassiveFlower.class) != null) return "botania.flowerType.passiveGenerating";
if (SubTileGenerating.class.isAssignableFrom(clazz)) return "botania.flowerType.generating";
if (SubTileFunctional.class.isAssignableFrom(clazz)) return "botania.flowerType.functional";
return "botania.flowerType.misc";
}
public void addTooltip(ItemStack stack, EntityPlayer player, List<String> tooltip) {
tooltip.add(EnumChatFormatting.BLUE + StatCollector.translateToLocal(getType()));
}
}
@@ -2,130 +2,127 @@ package ab.common.block.subtile;
import java.util.List;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.subtile.RadiusDescriptor;
import vazkii.botania.api.subtile.SubTileFunctional;
import vazkii.botania.common.item.ItemLexicon;
import ab.api.AdvancedBotanyAPI;
import ab.api.recipe.RecipeAncientAlphirine;
import ab.common.entity.EntityAlphirinePortal;
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.Item;
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.RadiusDescriptor;
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();
float posX = this.supertile.xCoord + 0.5f;
float posY = this.supertile.yCoord;
float posZ = this.supertile.zCoord + 0.5f;
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 && this.mana >= manaRequare) {
label666: for(EntityItem item : items) {
if(item.isDead || !(item.getEntityItem().stackSize >= 1))
continue;
for(RecipeAncientAlphirine recipe : AdvancedBotanyAPI.alphirineRecipes) {
if(recipe.matches(item.getEntityItem())) {
if(world.isRemote) {
spawnParticle(world, item);
} else {
if(item.getEntityItem().stackSize > 1)
item.getEntityItem().stackSize -= 1;
else
item.setDead();
if(world.rand.nextInt(111) <= recipe.getChance()) {
spawnPortal(world, recipe.getOutput().copy(), posX, posY, posZ);
this.mana -= manaRequare;
} else {
this.mana -= manaRequare / 10;
}
this.sync();
}
break label666;
}
}
if(item.getEntityItem().getItem() instanceof ItemLexicon) {
if(!((ItemLexicon)item.getEntityItem().getItem()).isKnowledgeUnlocked(item.getEntityItem(), RecipeListAB.forgotten)) {
if(world.isRemote)
spawnParticle(world, item);
else {
if(item.getEntityItem().stackSize > 1)
item.getEntityItem().stackSize -= 1;
else
item.setDead();
ItemStack lexicon = item.getEntityItem().copy();
((ItemLexicon)lexicon.getItem()).unlockKnowledge(lexicon, RecipeListAB.forgotten);
this.mana -= manaRequare;
spawnPortal(world, lexicon, posX, posY, posZ);
this.sync();
}
break label666;
}
}
}
}
}
public RadiusDescriptor getRadius() {
return new RadiusDescriptor.Square(toChunkCoordinates(), 1);
}
private void spawnPortal(World world, ItemStack stack, float posX, float posY, float posZ) {
EntityAlphirinePortal portal = new EntityAlphirinePortal(world);
float itemX = (float)(posX + (Math.random() * 2.0f - 1.0f));
float itemY = (float)(posY + 1.2f + (Math.random() - 0.5f));
float itemZ = (float)(posZ + (Math.random() * 2.0f - 1.0f));
portal.setPosition(itemX, itemY, itemZ);
portal.setStack(stack);
world.spawnEntityInWorld(portal);
}
private void spawnParticle(World world, EntityItem item) {
ItemStack stack = item.getEntityItem();
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;
if(stack.getItem() instanceof net.minecraft.item.ItemBlock) {
world.spawnParticle("blockcrack_" + Item.getIdFromItem(stack.getItem()) + "_" + stack.getItemDamage(), item.posX, item.posY, item.posZ, mx, my, mz);
} else {
world.spawnParticle("iconcrack_" + Item.getIdFromItem(stack.getItem()) + "_" + stack.getItemDamage(), item.posX, item.posY, item.posZ, mx, my, mz);
}
}
}
public int getMaxMana() {
return 180000;
}
public int getColor() {
return 0xd0bf58;
}
public LexiconEntry getEntry() {
return RecipeListAB.ancientAlphirine;
}
}
protected static int manaRequare = 4500;
public void onUpdate() {
super.onUpdate();
float posX = this.supertile.xCoord + 0.5f;
float posY = this.supertile.yCoord;
float posZ = this.supertile.zCoord + 0.5f;
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 && this.mana >= manaRequare) {
label666: for (EntityItem item : items) {
if (item.isDead || !(item.getEntityItem().stackSize >= 1)) continue;
for (RecipeAncientAlphirine recipe : AdvancedBotanyAPI.alphirineRecipes) {
if (recipe.matches(item.getEntityItem())) {
if (world.isRemote) {
spawnParticle(world, item);
} else {
if (item.getEntityItem().stackSize > 1) item.getEntityItem().stackSize -= 1;
else item.setDead();
if (world.rand.nextInt(111) <= recipe.getChance()) {
spawnPortal(world, recipe.getOutput().copy(), posX, posY, posZ);
this.mana -= manaRequare;
} else {
this.mana -= manaRequare / 10;
}
this.sync();
}
break label666;
}
}
if (item.getEntityItem().getItem() instanceof ItemLexicon) {
if (!((ItemLexicon) item.getEntityItem().getItem())
.isKnowledgeUnlocked(item.getEntityItem(), RecipeListAB.forgotten)) {
if (world.isRemote) spawnParticle(world, item);
else {
if (item.getEntityItem().stackSize > 1) item.getEntityItem().stackSize -= 1;
else item.setDead();
ItemStack lexicon = item.getEntityItem().copy();
((ItemLexicon) lexicon.getItem()).unlockKnowledge(lexicon, RecipeListAB.forgotten);
this.mana -= manaRequare;
spawnPortal(world, lexicon, posX, posY, posZ);
this.sync();
}
break label666;
}
}
}
}
}
public RadiusDescriptor getRadius() {
return new RadiusDescriptor.Square(toChunkCoordinates(), 1);
}
private void spawnPortal(World world, ItemStack stack, float posX, float posY, float posZ) {
EntityAlphirinePortal portal = new EntityAlphirinePortal(world);
float itemX = (float) (posX + (Math.random() * 2.0f - 1.0f));
float itemY = (float) (posY + 1.2f + (Math.random() - 0.5f));
float itemZ = (float) (posZ + (Math.random() * 2.0f - 1.0f));
portal.setPosition(itemX, itemY, itemZ);
portal.setStack(stack);
world.spawnEntityInWorld(portal);
}
private void spawnParticle(World world, EntityItem item) {
ItemStack stack = item.getEntityItem();
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;
if (stack.getItem() instanceof net.minecraft.item.ItemBlock) {
world.spawnParticle(
"blockcrack_" + Item.getIdFromItem(stack.getItem()) + "_" + stack.getItemDamage(),
item.posX,
item.posY,
item.posZ,
mx,
my,
mz);
} else {
world.spawnParticle(
"iconcrack_" + Item.getIdFromItem(stack.getItem()) + "_" + stack.getItemDamage(),
item.posX,
item.posY,
item.posZ,
mx,
my,
mz);
}
}
}
public int getMaxMana() {
return 180000;
}
public int getColor() {
return 0xd0bf58;
}
public LexiconEntry getEntry() {
return RecipeListAB.ancientAlphirine;
}
}
@@ -1,96 +1,91 @@
package ab.common.block.subtile;
import ab.common.block.tile.TileGameBoard;
import ab.common.lib.register.RecipeListAB;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.subtile.RadiusDescriptor;
import vazkii.botania.api.subtile.SubTileGenerating;
import vazkii.botania.common.item.block.ItemBlockSpecialFlower;
import ab.common.block.tile.TileGameBoard;
import ab.common.lib.register.RecipeListAB;
public class SubTileArdentAzarcissus extends SubTileGenerating {
public static final String playerName = "ArdentAzarcissus#21sda2gaj91*21df#111sfq3jrns@#";
public static final ItemStack flowerStack = ItemBlockSpecialFlower.ofType("ardentAzarcissus");
int cooldown;
int workMana = 320;
public void onUpdate() {
super.onUpdate();
World world = this.supertile.getWorldObj();
int posX = this.supertile.xCoord;
int posY = this.supertile.yCoord;
int posZ = this.supertile.zCoord;
if(world.isRemote)
return;
if(cooldown > 0) {
cooldown--;
return;
} else if(this.mana == this.getMaxMana())
return;
boolean needSync = false;
for(int i = -1; i <= 1; i++)
for(int j = -1; j <= 1; j++) {
int x = posX + i;
int z = posZ + j;
TileEntity tile = world.getTileEntity(x, posY, z);
if(tile != null && tile instanceof TileGameBoard) {
TileGameBoard board = (TileGameBoard)tile;
if(board.isSingleGame) {
if(!board.hasGame()) {
board.setPlayer(playerName, true);
cooldown = 120;
} else {
if(!board.playersName[0].equals(playerName))
board.playersName[0] = playerName;
if(!board.isCustomGame)
board.isCustomGame = true;
if(board.endGameTick == 0) {
int winCount = (board.slotChance[0] + board.slotChance[1]) - (board.slotChance[2] + board.slotChance[3]);
if(winCount > 0) {
mana = Math.min(this.getMaxMana(), this.mana + (workMana * winCount));
needSync = true;
}
board.finishGame(false);
} else
board.dropDice(playerName);
cooldown = 120;
}
board.changeCustomStack(flowerStack);
}
}
}
if(needSync)
sync();
}
public RadiusDescriptor getRadius() {
return new RadiusDescriptor.Square(toChunkCoordinates(), 1);
}
public int getMaxMana() {
return 16000;
}
public int getColor() {
return 0xdf3596;
}
public LexiconEntry getEntry() {
return RecipeListAB.azartFlower;
}
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");
}
}
public static final String playerName = "ArdentAzarcissus#21sda2gaj91*21df#111sfq3jrns@#";
public static final ItemStack flowerStack = ItemBlockSpecialFlower.ofType("ardentAzarcissus");
int cooldown;
int workMana = 320;
public void onUpdate() {
super.onUpdate();
World world = this.supertile.getWorldObj();
int posX = this.supertile.xCoord;
int posY = this.supertile.yCoord;
int posZ = this.supertile.zCoord;
if (world.isRemote) return;
if (cooldown > 0) {
cooldown--;
return;
} else if (this.mana == this.getMaxMana()) return;
boolean needSync = false;
for (int i = -1; i <= 1; i++) for (int j = -1; j <= 1; j++) {
int x = posX + i;
int z = posZ + j;
TileEntity tile = world.getTileEntity(x, posY, z);
if (tile != null && tile instanceof TileGameBoard) {
TileGameBoard board = (TileGameBoard) tile;
if (board.isSingleGame) {
if (!board.hasGame()) {
board.setPlayer(playerName, true);
cooldown = 120;
} else {
if (!board.playersName[0].equals(playerName)) board.playersName[0] = playerName;
if (!board.isCustomGame) board.isCustomGame = true;
if (board.endGameTick == 0) {
int winCount = (board.slotChance[0] + board.slotChance[1])
- (board.slotChance[2] + board.slotChance[3]);
if (winCount > 0) {
mana = Math.min(this.getMaxMana(), this.mana + (workMana * winCount));
needSync = true;
}
board.finishGame(false);
} else board.dropDice(playerName);
cooldown = 120;
}
board.changeCustomStack(flowerStack);
}
}
}
if (needSync) sync();
}
public RadiusDescriptor getRadius() {
return new RadiusDescriptor.Square(toChunkCoordinates(), 1);
}
public int getMaxMana() {
return 16000;
}
public int getColor() {
return 0xdf3596;
}
public LexiconEntry getEntry() {
return RecipeListAB.azartFlower;
}
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");
}
}
@@ -2,99 +2,98 @@ package ab.common.block.subtile;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import ab.common.lib.register.RecipeListAB;
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.lexicon.LexiconEntry;
import vazkii.botania.api.subtile.RadiusDescriptor;
import vazkii.botania.api.subtile.SubTileFunctional;
import ab.common.lib.register.RecipeListAB;
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 RadiusDescriptor getRadius() {
return new RadiusDescriptor.Square(toChunkCoordinates(), 1);
}
public int getMaxMana() {
return 15000;
}
public int getColor() {
return 0x8a20dc;
}
public LexiconEntry getEntry() {
return RecipeListAB.aspecolus;
}
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");
}
}
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 RadiusDescriptor getRadius() {
return new RadiusDescriptor.Square(toChunkCoordinates(), 1);
}
public int getMaxMana() {
return 15000;
}
public int getColor() {
return 0x8a20dc;
}
public LexiconEntry getEntry() {
return RecipeListAB.aspecolus;
}
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");
}
}
@@ -2,10 +2,7 @@ package ab.common.block.subtile;
import java.util.List;
import ab.common.core.handler.ConfigABHandler;
import ab.common.lib.register.RecipeListAB;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.player.EntityPlayer;
@@ -16,105 +13,126 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.subtile.RadiusDescriptor;
import vazkii.botania.api.subtile.SubTileGenerating;
import vazkii.botania.common.block.tile.TileSpecialFlower;
import ab.common.core.handler.ConfigABHandler;
import ab.common.lib.register.RecipeListAB;
public class SubTileDictarius extends SubTileGenerating {
private static final int workMana = 480;
int cooldown;
public void onUpdate() {
super.onUpdate();
if(this.supertile.getWorldObj().isRemote)
return;
int posX = this.supertile.xCoord;
int posY = this.supertile.yCoord;
int posZ = this.supertile.zCoord;
World world = this.supertile.getWorldObj();
if(world.getTotalWorldTime() % 1200 == 0)
checkNearDictarius();
if(this.mana != this.getMaxMana() && cooldown == 0) {
List<EntityLivingBase> livs = world.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, (posX + 1), (posY + 1), (posZ + 1)).expand(2, 1, 2));
int workMana = 0;
int villagers = 0;
if(!livs.isEmpty()) {
for(int i = 0; i < Math.min(livs.size(), 16); i++) {
EntityLivingBase liv = livs.get(i);
if(liv instanceof EntityPlayer)
workMana += SubTileDictarius.workMana;
else if(!world.isRemote && liv instanceof EntityVillager) {
workMana += (int)(SubTileDictarius.workMana / 6);
if(villagers > 15 && world.rand.nextInt(100) <= 4)
liv.setDead();
villagers++;
}
}
}
if(workMana > 0) {
this.cooldown = 200;
workMana *= Math.random();
this.mana = Math.min(this.getMaxMana(), this.mana + workMana);
sync();
}
}
if(cooldown > 0)
cooldown -= 1;
}
public RadiusDescriptor getRadius() {
return new RadiusDescriptor.Square(toChunkCoordinates(), 2);
}
public void checkNearDictarius() {
int findedFlower = 0;
for(int z = -4; z < 4; z++) {
for(int x = -4; x < 4; x++) {
for(int y = -4; y < 4; y++) {
int posX = this.supertile.xCoord + x;
int posY = this.supertile.yCoord + y;
int posZ = this.supertile.zCoord + z;
TileEntity tile = this.supertile.getWorldObj().getTileEntity(posX, posY, posZ);
if(tile != null && tile instanceof TileSpecialFlower) {
TileSpecialFlower tileFlower = (TileSpecialFlower)tile;
if(tileFlower.subTileName.equals("dictarius")) {
if(findedFlower >= ConfigABHandler.maxDictariusCount) {
this.supertile.getWorldObj().playAuxSFX(2001, this.supertile.xCoord, this.supertile.yCoord, this.supertile.zCoord, Block.getIdFromBlock(this.supertile.getBlockType()));
if(this.supertile.getWorldObj().getBlock(this.supertile.xCoord, this.supertile.yCoord - 1, this.supertile.zCoord).isSideSolid((IBlockAccess)this.supertile.getWorldObj(), this.supertile.xCoord, this.supertile.yCoord - 1, this.supertile.zCoord, ForgeDirection.UP))
this.supertile.getWorldObj().setBlock(this.supertile.xCoord, this.supertile.yCoord, this.supertile.zCoord, (Block)Blocks.deadbush);
else
this.supertile.getWorldObj().setBlockToAir(this.supertile.xCoord, this.supertile.yCoord, this.supertile.zCoord);
return;
}
findedFlower++;
}
}
}
}
}
}
public int getMaxMana() {
return 8000;
}
public int getColor() {
return 0xd2cdb2;
}
public LexiconEntry getEntry() {
return RecipeListAB.dictarius;
}
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");
}
}
private static final int workMana = 480;
int cooldown;
public void onUpdate() {
super.onUpdate();
if (this.supertile.getWorldObj().isRemote) return;
int posX = this.supertile.xCoord;
int posY = this.supertile.yCoord;
int posZ = this.supertile.zCoord;
World world = this.supertile.getWorldObj();
if (world.getTotalWorldTime() % 1200 == 0) checkNearDictarius();
if (this.mana != this.getMaxMana() && cooldown == 0) {
List<EntityLivingBase> livs = world.getEntitiesWithinAABB(
EntityLivingBase.class,
AxisAlignedBB.getBoundingBox(posX, posY, posZ, (posX + 1), (posY + 1), (posZ + 1)).expand(2, 1, 2));
int workMana = 0;
int villagers = 0;
if (!livs.isEmpty()) {
for (int i = 0; i < Math.min(livs.size(), 16); i++) {
EntityLivingBase liv = livs.get(i);
if (liv instanceof EntityPlayer) workMana += SubTileDictarius.workMana;
else if (!world.isRemote && liv instanceof EntityVillager) {
workMana += (int) (SubTileDictarius.workMana / 6);
if (villagers > 15 && world.rand.nextInt(100) <= 4) liv.setDead();
villagers++;
}
}
}
if (workMana > 0) {
this.cooldown = 200;
workMana *= Math.random();
this.mana = Math.min(this.getMaxMana(), this.mana + workMana);
sync();
}
}
if (cooldown > 0) cooldown -= 1;
}
public RadiusDescriptor getRadius() {
return new RadiusDescriptor.Square(toChunkCoordinates(), 2);
}
public void checkNearDictarius() {
int findedFlower = 0;
for (int z = -4; z < 4; z++) {
for (int x = -4; x < 4; x++) {
for (int y = -4; y < 4; y++) {
int posX = this.supertile.xCoord + x;
int posY = this.supertile.yCoord + y;
int posZ = this.supertile.zCoord + z;
TileEntity tile = this.supertile.getWorldObj().getTileEntity(posX, posY, posZ);
if (tile != null && tile instanceof TileSpecialFlower) {
TileSpecialFlower tileFlower = (TileSpecialFlower) tile;
if (tileFlower.subTileName.equals("dictarius")) {
if (findedFlower >= ConfigABHandler.maxDictariusCount) {
this.supertile.getWorldObj().playAuxSFX(
2001,
this.supertile.xCoord,
this.supertile.yCoord,
this.supertile.zCoord,
Block.getIdFromBlock(this.supertile.getBlockType()));
if (this.supertile.getWorldObj()
.getBlock(
this.supertile.xCoord,
this.supertile.yCoord - 1,
this.supertile.zCoord)
.isSideSolid(
(IBlockAccess) this.supertile.getWorldObj(),
this.supertile.xCoord,
this.supertile.yCoord - 1,
this.supertile.zCoord,
ForgeDirection.UP))
this.supertile.getWorldObj().setBlock(
this.supertile.xCoord,
this.supertile.yCoord,
this.supertile.zCoord,
(Block) Blocks.deadbush);
else this.supertile.getWorldObj().setBlockToAir(
this.supertile.xCoord,
this.supertile.yCoord,
this.supertile.zCoord);
return;
}
findedFlower++;
}
}
}
}
}
}
public int getMaxMana() {
return 8000;
}
public int getColor() {
return 0xd2cdb2;
}
public LexiconEntry getEntry() {
return RecipeListAB.dictarius;
}
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");
}
}
@@ -2,88 +2,93 @@ package ab.common.block.subtile;
import java.util.List;
import ab.common.lib.register.RecipeListAB;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.common.entities.EntityAspectOrb;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.subtile.RadiusDescriptor;
import vazkii.botania.api.subtile.SubTileFunctional;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.ModBlocks;
import ab.common.lib.register.RecipeListAB;
public class SubTilePureGladiolus extends SubTileFunctional {
private static final int MAX_MANA = 10000;
private static final String COOLDOWN_TAG = "Cooldown";
private static final Aspect[] PRIMALS = new Aspect[] { Aspect.AIR, Aspect.WATER, Aspect.EARTH, Aspect.ENTROPY, Aspect.ORDER, Aspect.FIRE };
private static final int MAX_MANA = 10000;
private static final String COOLDOWN_TAG = "Cooldown";
private static final Aspect[] PRIMALS = new Aspect[] { Aspect.AIR, Aspect.WATER, Aspect.EARTH, Aspect.ENTROPY,
Aspect.ORDER, Aspect.FIRE };
private int cooldown = 180;
protected static int manaRequare = 1000;
private int cooldown = 180;
protected static int manaRequare = 1000;
public void onUpdate() {
super.onUpdate();
int tick = 1;
World world = this.supertile.getWorldObj();
int x = this.supertile.xCoord;
int y = this.supertile.yCoord;
int z = this.supertile.zCoord;
List<EntityPlayer> players = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, (x + 1), (y + 1), (z + 1)).expand(1.9f, 1.2f, 1.9f));
if(world.getBlock(x, y + 1, z).getMaterial() != Material.air)
return;
else if(world.getBlock(x, y - 1, z) == ModBlocks.enchantedSoil)
tick = 2;
if(players.isEmpty())
return;
if(cooldown > 0)
cooldown -= tick;
else if(mana >= manaRequare && cooldown <= 0) {
mana -= manaRequare;
cooldown = 180;
spawnAspectOrbs(world, x + 0.5, y + 1.0, z + 0.5);
}
}
public RadiusDescriptor getRadius() {
return new RadiusDescriptor.Square(toChunkCoordinates(), 1);
}
public LexiconEntry getEntry() {
return RecipeListAB.gladious;
}
public void onUpdate() {
super.onUpdate();
int tick = 1;
World world = this.supertile.getWorldObj();
int x = this.supertile.xCoord;
int y = this.supertile.yCoord;
int z = this.supertile.zCoord;
List<EntityPlayer> players = world.getEntitiesWithinAABB(
EntityPlayer.class,
AxisAlignedBB.getBoundingBox(x, y, z, (x + 1), (y + 1), (z + 1)).expand(1.9f, 1.2f, 1.9f));
if (world.getBlock(x, y + 1, z).getMaterial() != Material.air) return;
else if (world.getBlock(x, y - 1, z) == ModBlocks.enchantedSoil) tick = 2;
if (players.isEmpty()) return;
if (cooldown > 0) cooldown -= tick;
else if (mana >= manaRequare && cooldown <= 0) {
mana -= manaRequare;
cooldown = 180;
spawnAspectOrbs(world, x + 0.5, y + 1.0, z + 0.5);
}
}
public void spawnAspectOrbs(World world, double x, double y, double z) {
if(!world.isRemote) {
for (int i = 0; i < 3 + world.rand.nextInt(3); i++) {
EntityAspectOrb orb = new EntityAspectOrb(world, x, y, z, PRIMALS[world.rand.nextInt(6)], 2 + world.rand.nextInt(3));
orb.motionX = 0.05 - Math.random() * 0.1;
orb.motionY = 0.07;
orb.motionZ = 0.05 - Math.random() * 0.1;
world.spawnEntityInWorld(orb);
}
this.sync();
}
}
public RadiusDescriptor getRadius() {
return new RadiusDescriptor.Square(toChunkCoordinates(), 1);
}
public int getColor() {
return 0xFF00FF;
}
public LexiconEntry getEntry() {
return RecipeListAB.gladious;
}
public int getMaxMana() {
return MAX_MANA;
}
public void spawnAspectOrbs(World world, double x, double y, double z) {
if (!world.isRemote) {
for (int i = 0; i < 3 + world.rand.nextInt(3); i++) {
EntityAspectOrb orb = new EntityAspectOrb(
world,
x,
y,
z,
PRIMALS[world.rand.nextInt(6)],
2 + world.rand.nextInt(3));
orb.motionX = 0.05 - Math.random() * 0.1;
orb.motionY = 0.07;
orb.motionZ = 0.05 - Math.random() * 0.1;
world.spawnEntityInWorld(orb);
}
this.sync();
}
}
public void writeToPacketNBT(NBTTagCompound cmp) {
super.writeToPacketNBT(cmp);
cmp.setInteger(COOLDOWN_TAG, this.cooldown);
}
public int getColor() {
return 0xFF00FF;
}
public void readFromPacketNBT(NBTTagCompound cmp) {
super.readFromPacketNBT(cmp);
this.cooldown = cmp.getInteger(COOLDOWN_TAG);
}
}
public int getMaxMana() {
return MAX_MANA;
}
public void writeToPacketNBT(NBTTagCompound cmp) {
super.writeToPacketNBT(cmp);
cmp.setInteger(COOLDOWN_TAG, this.cooldown);
}
public void readFromPacketNBT(NBTTagCompound cmp) {
super.readFromPacketNBT(cmp);
this.cooldown = cmp.getInteger(COOLDOWN_TAG);
}
}
@@ -1,122 +1,130 @@
package ab.common.block.tile;
import java.util.UUID;
import org.lwjgl.opengl.GL11;
import ab.common.core.handler.ConfigABHandler;
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 org.lwjgl.opengl.GL11;
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;
import ab.common.core.handler.ConfigABHandler;
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);
int maxMana = ConfigABHandler.spreaderBurstMana;
int color = 0xcdd419;
int ticksBeforeManaLoss = 35;
float manaLossPerTick = ConfigABHandler.spreaderBurstMana / 4.5f;
float motionModifier = 2.5f;
float gravity = 0.0F;
BurstProperties props = new BurstProperties(maxMana, ticksBeforeManaLoss, manaLossPerTick, gravity, motionModifier, color);
ItemStack lens = getStackInSlot(0);
if(lens != null && lens.getItem() instanceof ILensEffect)
((ILensEffect)lens.getItem()).apply(lens, props);
burst.setSourceLens(lens);
if(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;
}
return null;
}
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);
int maxMana = ConfigABHandler.spreaderBurstMana;
int color = 0xcdd419;
int ticksBeforeManaLoss = 35;
float manaLossPerTick = ConfigABHandler.spreaderBurstMana / 4.5f;
float motionModifier = 2.5f;
float gravity = 0.0F;
BurstProperties props = new BurstProperties(
maxMana,
ticksBeforeManaLoss,
manaLossPerTick,
gravity,
motionModifier,
color);
ItemStack lens = getStackInSlot(0);
if (lens != null && lens.getItem() instanceof ILensEffect) ((ILensEffect) lens.getItem()).apply(lens, props);
burst.setSourceLens(lens);
if (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;
}
return null;
}
public void renderHUD(Minecraft mc, ScaledResolution res) {
String name = StatCollector.translateToLocal("tile.advancedSpreader.name");
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);
}
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() {
public int getMaxMana() {
return ConfigABHandler.spreaderMaxMana;
}
}
}
@@ -2,8 +2,6 @@ package ab.common.block.tile;
import java.util.List;
import ab.api.AdvancedBotanyAPI;
import ab.common.core.handler.ConfigABHandler;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -14,156 +12,164 @@ import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.Vec3;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.api.item.IRelic;
import vazkii.botania.common.item.relic.ItemDice;
import vazkii.botania.common.item.relic.ItemRelic;
import ab.api.AdvancedBotanyAPI;
import ab.common.core.handler.ConfigABHandler;
public class TileBoardFate extends TileInventory {
public byte[] slotChance = new byte[getSizeInventory()];
public int clientTick[] = new int[] { 0, 0, 0, 0 };
public boolean requestUpdate;
public void updateEntity() {
if(!worldObj.isRemote)
updateServer();
else
updateAnimationTicks();
}
public void updateAnimationTicks() {
for(int i = 0; i < getSizeInventory(); i++)
if(getStackInSlot(i) != null)
clientTick[i]++;
else
clientTick[i] = 0;
}
protected void updateServer() {
if(requestUpdate)
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
boolean hasUpdate = false;
if(hasFreeSlot())
hasUpdate = setDiceFate();
requestUpdate = hasUpdate;
}
public boolean spawnRelic(EntityPlayer player) {
int relicCount = 0;
for(int i = 0; i < getSizeInventory(); i++) {
if(getStackInSlot(i) == null)
slotChance[i] = 0;
else if(!ItemRelic.isRightPlayer(player, getStackInSlot(i))) {
if(!worldObj.isRemote)
dropRelic(player, i);
return true;
}
else
setInventorySlotContents(i, null);
relicCount += slotChance[i];
}
if(relicCount < 1)
return false;
else if(!worldObj.isRemote) {
ItemStack relic = AdvancedBotanyAPI.relicList.get(Math.min(relicCount - 1, AdvancedBotanyAPI.relicList.size() - 1)).copy();
worldObj.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (worldObj.rand.nextFloat() * 0.4F + 0.8F));
if(hasRelicAchievement(player, relic) || !ConfigABHandler.fateBoardRelicEnables[relicCount - 1]) {
player.addChatMessage((new ChatComponentTranslation("botaniamisc.dudDiceRoll", new Object[] { Integer.valueOf(relicCount) })).setChatStyle((new ChatStyle()).setColor(EnumChatFormatting.DARK_GREEN)));
} else {
ItemRelic.updateRelic(relic, player);
EntityItem entityItem = new EntityItem(worldObj, xCoord + 0.5f, yCoord + 0.5f, zCoord + 0.5f, relic);
player.addChatMessage((new ChatComponentTranslation("botaniamisc.diceRoll", new Object[] { Integer.valueOf(relicCount) })).setChatStyle((new ChatStyle()).setColor(EnumChatFormatting.DARK_GREEN)));
worldObj.spawnEntityInWorld(entityItem);
}
requestUpdate = true;
}
return true;
}
private void dropRelic(EntityPlayer player, int slot) {
EntityItem entityItem = new EntityItem(worldObj, xCoord + 0.5f, yCoord + 0.8f, zCoord + 0.5f, getStackInSlot(slot).copy());
float f3 = 0.15F;
Vec3 vec = player.getLookVec();
entityItem.motionX = vec.xCoord * f3;
entityItem.motionY = 0.25F;
entityItem.motionZ = vec.zCoord * f3;
setInventorySlotContents(slot, null);
worldObj.spawnEntityInWorld(entityItem);
}
public static boolean hasRelicAchievement(EntityPlayer player, ItemStack rStack) {
EntityPlayerMP mpPlayer = (EntityPlayerMP)player;
IRelic irelic = (IRelic)rStack.getItem();
if(irelic.getBindAchievement() == null)
return false;
return mpPlayer.func_147099_x().hasAchievementUnlocked(irelic.getBindAchievement());
}
protected boolean hasFreeSlot() {
for(int i = 0; i < getSizeInventory(); i++)
if(getStackInSlot(i) == null)
return true;
return false;
}
protected boolean setDiceFate() {
boolean hasUpdate = false;
List<EntityItem> items = this.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord, this.zCoord, (this.xCoord + 1), (this.yCoord + 0.7f), (this.zCoord + 1)));
label666: for(EntityItem item : items) {
if(!item.isDead && item.getEntityItem() != null) {
ItemStack stack = item.getEntityItem();
if(!isDice(stack))
continue;
for(int s = 0; s < getSizeInventory(); s++) {
ItemStack slotStack = getStackInSlot(s);
if(slotStack != null)
continue;
ItemStack copy = stack.copy();
copy.stackSize = 1;
setInventorySlotContents(s, copy);
slotChance[s] = (byte)(worldObj.rand.nextInt(6) + 1);
stack.stackSize--;
if(stack.stackSize == 0)
item.setDead();
hasUpdate = true;
worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "ab:boardCube", 0.6F, 1.0F);
break label666;
}
}
}
return hasUpdate;
}
public static boolean isDice(ItemStack stack) {
for(ItemStack dice : AdvancedBotanyAPI.diceList) {
if(dice.getItem() == stack.getItem() && (dice.getItemDamage() == stack.getItemDamage() || dice.getItemDamage() == 32767))
return true;
}
return false;
}
public void writeCustomNBT(NBTTagCompound cmp) {
super.writeCustomNBT(cmp);
cmp.setByteArray("slotChance", slotChance);
cmp.setBoolean("requestUpdate", requestUpdate);
}
public void readCustomNBT(NBTTagCompound cmp) {
super.readCustomNBT(cmp);
slotChance = cmp.getByteArray("slotChance");
requestUpdate = cmp.getBoolean("requestUpdate");
}
public int getInventoryStackLimit() {
return 1;
}
public byte[] slotChance = new byte[getSizeInventory()];
public int clientTick[] = new int[] { 0, 0, 0, 0 };
public boolean requestUpdate;
public String getInventoryName() {
return "inv.boardFate";
}
public void updateEntity() {
if (!worldObj.isRemote) updateServer();
else updateAnimationTicks();
}
public int getSizeInventory() {
return 2;
}
}
public void updateAnimationTicks() {
for (int i = 0; i < getSizeInventory(); i++) if (getStackInSlot(i) != null) clientTick[i]++;
else clientTick[i] = 0;
}
protected void updateServer() {
if (requestUpdate)
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
boolean hasUpdate = false;
if (hasFreeSlot()) hasUpdate = setDiceFate();
requestUpdate = hasUpdate;
}
public boolean spawnRelic(EntityPlayer player) {
int relicCount = 0;
for (int i = 0; i < getSizeInventory(); i++) {
if (getStackInSlot(i) == null) slotChance[i] = 0;
else if (!ItemRelic.isRightPlayer(player, getStackInSlot(i))) {
if (!worldObj.isRemote) dropRelic(player, i);
return true;
} else setInventorySlotContents(i, null);
relicCount += slotChance[i];
}
if (relicCount < 1) return false;
else if (!worldObj.isRemote) {
ItemStack relic = AdvancedBotanyAPI.relicList
.get(Math.min(relicCount - 1, AdvancedBotanyAPI.relicList.size() - 1)).copy();
worldObj.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (worldObj.rand.nextFloat() * 0.4F + 0.8F));
if (hasRelicAchievement(player, relic) || !ConfigABHandler.fateBoardRelicEnables[relicCount - 1]) {
player.addChatMessage(
(new ChatComponentTranslation(
"botaniamisc.dudDiceRoll",
new Object[] { Integer.valueOf(relicCount) }))
.setChatStyle((new ChatStyle()).setColor(EnumChatFormatting.DARK_GREEN)));
} else {
ItemRelic.updateRelic(relic, player);
EntityItem entityItem = new EntityItem(worldObj, xCoord + 0.5f, yCoord + 0.5f, zCoord + 0.5f, relic);
player.addChatMessage(
(new ChatComponentTranslation(
"botaniamisc.diceRoll",
new Object[] { Integer.valueOf(relicCount) }))
.setChatStyle((new ChatStyle()).setColor(EnumChatFormatting.DARK_GREEN)));
worldObj.spawnEntityInWorld(entityItem);
}
requestUpdate = true;
}
return true;
}
private void dropRelic(EntityPlayer player, int slot) {
EntityItem entityItem = new EntityItem(
worldObj,
xCoord + 0.5f,
yCoord + 0.8f,
zCoord + 0.5f,
getStackInSlot(slot).copy());
float f3 = 0.15F;
Vec3 vec = player.getLookVec();
entityItem.motionX = vec.xCoord * f3;
entityItem.motionY = 0.25F;
entityItem.motionZ = vec.zCoord * f3;
setInventorySlotContents(slot, null);
worldObj.spawnEntityInWorld(entityItem);
}
public static boolean hasRelicAchievement(EntityPlayer player, ItemStack rStack) {
EntityPlayerMP mpPlayer = (EntityPlayerMP) player;
IRelic irelic = (IRelic) rStack.getItem();
if (irelic.getBindAchievement() == null) return false;
return mpPlayer.func_147099_x().hasAchievementUnlocked(irelic.getBindAchievement());
}
protected boolean hasFreeSlot() {
for (int i = 0; i < getSizeInventory(); i++) if (getStackInSlot(i) == null) return true;
return false;
}
protected boolean setDiceFate() {
boolean hasUpdate = false;
List<EntityItem> items = this.worldObj.getEntitiesWithinAABB(
EntityItem.class,
AxisAlignedBB.getBoundingBox(
this.xCoord,
this.yCoord,
this.zCoord,
(this.xCoord + 1),
(this.yCoord + 0.7f),
(this.zCoord + 1)));
label666: for (EntityItem item : items) {
if (!item.isDead && item.getEntityItem() != null) {
ItemStack stack = item.getEntityItem();
if (!isDice(stack)) continue;
for (int s = 0; s < getSizeInventory(); s++) {
ItemStack slotStack = getStackInSlot(s);
if (slotStack != null) continue;
ItemStack copy = stack.copy();
copy.stackSize = 1;
setInventorySlotContents(s, copy);
slotChance[s] = (byte) (worldObj.rand.nextInt(6) + 1);
stack.stackSize--;
if (stack.stackSize == 0) item.setDead();
hasUpdate = true;
worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "ab:boardCube", 0.6F, 1.0F);
break label666;
}
}
}
return hasUpdate;
}
public static boolean isDice(ItemStack stack) {
for (ItemStack dice : AdvancedBotanyAPI.diceList) {
if (dice.getItem() == stack.getItem()
&& (dice.getItemDamage() == stack.getItemDamage() || dice.getItemDamage() == 32767))
return true;
}
return false;
}
public void writeCustomNBT(NBTTagCompound cmp) {
super.writeCustomNBT(cmp);
cmp.setByteArray("slotChance", slotChance);
cmp.setBoolean("requestUpdate", requestUpdate);
}
public void readCustomNBT(NBTTagCompound cmp) {
super.readCustomNBT(cmp);
slotChance = cmp.getByteArray("slotChance");
requestUpdate = cmp.getBoolean("requestUpdate");
}
public int getInventoryStackLimit() {
return 1;
}
public String getInventoryName() {
return "inv.boardFate";
}
public int getSizeInventory() {
return 2;
}
}
@@ -1,333 +1,320 @@
package ab.common.block.tile;
import java.util.List;
import org.lwjgl.opengl.GL11;
import ab.api.IBoundRender;
import ab.client.core.ClientHelper;
import net.minecraft.block.Block;
import net.minecraft.block.BlockChest;
import net.minecraft.block.BlockHopper;
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.command.IEntitySelector;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
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.tileentity.IHopper;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.tileentity.TileEntityHopper;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.Facing;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import vazkii.botania.api.wand.IWandBindable;
import vazkii.botania.client.core.handler.HUDHandler;
import vazkii.botania.common.core.helper.Vector3;
import org.lwjgl.opengl.GL11;
import vazkii.botania.common.item.ModItems;
import ab.api.IBoundRender;
import ab.client.core.ClientHelper;
public class TileEngineerHopper extends TileInventory implements IHopper, IBoundRender {
private int cooldown;
private int[] invPosX = new int[] {0, 0};
private int[] invPosY = new int[] {-1, -1};
private int[] invPosZ = new int[] {0, 0};
private int[] invSide = new int[] {-1, -1};
private boolean bindType;
public int redstoneSignal = 0;
public void updateEntity() {
private int cooldown;
private int[] invPosX = new int[] { 0, 0 };
private int[] invPosY = new int[] { -1, -1 };
private int[] invPosZ = new int[] { 0, 0 };
private int[] invSide = new int[] { -1, -1 };
private boolean bindType;
public int redstoneSignal = 0;
public void updateEntity() {
this.redstoneSignal = 0;
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
int redstoneSide = getWorldObj().getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal());
this.redstoneSignal = Math.max(this.redstoneSignal, redstoneSide);
}
if(redstoneSignal > 0)
return;
else if(this.worldObj != null) {
if(!this.worldObj.isRemote) {
if(cooldown > 0)
--cooldown;
else if(cooldown == 0) {
if(worldObj != null && !worldObj.isRemote) {
boolean hasUpdate = false;
ItemStack stack = getStackInSlot(0);
if(stack != null)
hasUpdate = canExtractStack();
if(stack == null || stack.stackSize != stack.getMaxStackSize())
hasUpdate = canInsertStack() || hasUpdate;
if(hasUpdate)
this.cooldown = 8;
this.markDirty();
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
int redstoneSide = getWorldObj().getIndirectPowerLevelTo(
xCoord + dir.offsetX,
yCoord + dir.offsetY,
zCoord + dir.offsetZ,
dir.ordinal());
this.redstoneSignal = Math.max(this.redstoneSignal, redstoneSide);
}
if (redstoneSignal > 0) return;
else if (this.worldObj != null) {
if (!this.worldObj.isRemote) {
if (cooldown > 0) --cooldown;
else if (cooldown == 0) {
if (worldObj != null && !worldObj.isRemote) {
boolean hasUpdate = false;
ItemStack stack = getStackInSlot(0);
if (stack != null) hasUpdate = canExtractStack();
if (stack == null || stack.stackSize != stack.getMaxStackSize())
hasUpdate = canInsertStack() || hasUpdate;
if (hasUpdate) this.cooldown = 8;
this.markDirty();
}
}
}
}
}
}
public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) {
TileEntity tile = player.getEntityWorld().getTileEntity(x, y, z);
boolean isFar = Math.abs(this.xCoord - x) >= 10 || Math.abs(this.yCoord - y) >= 10 || Math.abs(this.zCoord - z) >= 10;
if(isFar)
return false;
int invCount = bindType ? 0 : 1;
if(tile instanceof TileEngineerHopper)
return false;
else if(tile != null && tile instanceof IInventory) {
setDistantInventory(invCount, x, y, z);
invSide[invCount] = side;
return true;
} else {
setDistantInventory(invCount, 0, -1, 0);
invSide[invCount] = -1;
return false;
}
}
public void changeBindType() {
bindType = !bindType;
}
public void setDistantInventory(int count, int posX, int posY, int posZ) {
invPosX[count] = posX;
invPosY[count] = posY;
invPosZ[count] = posZ;
}
public IInventory getDistantInventory(int count) {
IInventory inv = TileEntityHopper.func_145893_b(this.getWorldObj(), invPosX[count], invPosY[count], invPosZ[count]);
if(inv == null)
setDistantInventory(count, 0, -1, 0);
return inv;
}
public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) {
return true;
}
public ChunkCoordinates[] getBlocksCoord() {
return new ChunkCoordinates[] { new ChunkCoordinates(invPosX[0], invPosY[0], invPosZ[0]), new ChunkCoordinates(invPosX[1], invPosY[1], invPosZ[1]) };
}
public ChunkCoordinates getBinding() {
return null;
}
public void renderHUD(Minecraft mc, ScaledResolution res) {
int x = res.getScaledWidth() / 2 - 7;
int y = res.getScaledHeight() / 2 + 16;
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
ClientHelper.drawArrow(x - 2, y, false);
for(int i = 0; i < 2; i++) {
ItemStack stack = null;
boolean hasInv = false;
int posX = x + (i == 0 ? 32 : -32);
if(getDistantInventory(i) != null && (TileEntity)getDistantInventory(i) != null) {
TileEntity tile = (TileEntity)getDistantInventory(i);
Block block = tile.getWorldObj().getBlock(tile.xCoord, tile.yCoord, tile.zCoord);
int meta = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord);
stack = new ItemStack(block, 1, meta);
hasInv = true;
}
Gui.drawRect(posX - 4, y - 4, posX + 20, y + 20, 1140850688);
Gui.drawRect(posX - 2, y - 2, posX + 18, y + 18, 1140850688);
if(stack != null) {
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(32826);
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, posX, y);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(2929);
}
int invCount = bindType ? 0 : 1;
if(invCount == i) {
GL11.glTranslatef(0.0f, 0.0f, 300.0f);
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(32826);
RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModItems.twigWand), posX + 10, y + 7);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(2929);
GL11.glTranslatef(0.0f, 0.0f, -300.0f);
}
boolean unicode = mc.fontRenderer.getUnicodeFlag();
mc.fontRenderer.setUnicodeFlag(true);
if(!hasInv) {
mc.fontRenderer.drawStringWithShadow("\u2717", posX + 5, y + 6, 4980736);
mc.fontRenderer.drawStringWithShadow("\u2717", posX + 5, y + 5, 13764621);
}
mc.fontRenderer.setUnicodeFlag(unicode);
GL11.glEnable(2929);
}
GL11.glDisable(3042);
}
public void writeCustomNBT(NBTTagCompound nbtt) {
super.writeCustomNBT(nbtt);
nbtt.setInteger("cooldown", this.cooldown);
nbtt.setBoolean("bindType", this.bindType);
nbtt.setIntArray("bindingX", this.invPosX);
nbtt.setIntArray("bindingY", this.invPosY);
nbtt.setIntArray("bindingZ", this.invPosZ);
nbtt.setIntArray("bindingSide", this.invSide);
}
public void readCustomNBT(NBTTagCompound nbtt) {
super.readCustomNBT(nbtt);
this.cooldown = nbtt.getInteger("cooldown");
this.bindType = nbtt.getBoolean("bindType");
this.invPosX = nbtt.getIntArray("bindingX");
this.invPosY = nbtt.getIntArray("bindingY");
this.invPosZ = nbtt.getIntArray("bindingZ");
this.invSide = nbtt.getIntArray("bindingSide");
}
private boolean canExtractStack() {
IInventory inv = getDistantInventory(0);
if(inv == null)
return false;
else {
int side = invSide[0];
int pullCount = getPullCount(inv, side);
System.out.println("canExtractStack " + pullCount);
if(pullCount <= 0)
return false;
else {
if(getStackInSlot(0) != null) {
ItemStack itemstack = getStackInSlot(0).copy();
ItemStack itemstack1 = TileEntityHopper.func_145889_a(inv, decrStackSize(0, pullCount), side);
if(itemstack1 == null || itemstack1.stackSize == 0) {
inv.markDirty();
return true;
}
setInventorySlotContents(0, itemstack);
}
return false;
}
}
}
}
private int getPullCount(IInventory inv, int side) {
if(inv instanceof ISidedInventory && side > -1) {
ISidedInventory sideInv = (ISidedInventory)inv;
int[] slots = sideInv.getAccessibleSlotsFromSide(side);
for(int i = 0; i < slots.length; ++i) {
ItemStack stack = sideInv.getStackInSlot(slots[i]);
if(stack == null)
return inv.getInventoryStackLimit();
else if(inv.getInventoryStackLimit() != stack.stackSize && stack.stackSize != stack.getMaxStackSize() && TileNidavellirForge.isItemEqual(stack, getStackInSlot(0)))
return inv.getInventoryStackLimit() - stack.stackSize;
}
} else {
int size = inv.getSizeInventory();
for(int i = 0; i < size; ++i) {
ItemStack stack = inv.getStackInSlot(i);
if(stack == null)
return inv.getInventoryStackLimit();
else if(inv.getInventoryStackLimit() != stack.stackSize && stack.stackSize != stack.getMaxStackSize() && TileNidavellirForge.isItemEqual(stack, getStackInSlot(0)))
return inv.getInventoryStackLimit() - stack.stackSize;
}
}
return 0;
}
public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) {
TileEntity tile = player.getEntityWorld().getTileEntity(x, y, z);
boolean isFar = Math.abs(this.xCoord - x) >= 10 || Math.abs(this.yCoord - y) >= 10
|| Math.abs(this.zCoord - z) >= 10;
if (isFar) return false;
int invCount = bindType ? 0 : 1;
if (tile instanceof TileEngineerHopper) return false;
else if (tile != null && tile instanceof IInventory) {
setDistantInventory(invCount, x, y, z);
invSide[invCount] = side;
return true;
} else {
setDistantInventory(invCount, 0, -1, 0);
invSide[invCount] = -1;
return false;
}
}
private boolean canInsertStack() {
IInventory inv = getDistantInventory(1);
if(inv != null) {
int side = invSide[1];
int takeCount = getTakeCount(inv, side);
System.out.println("canInsertStack " + takeCount);
if(takeCount <= 0)
return false;
if(inv instanceof ISidedInventory && side > -1) {
ISidedInventory sidedInv = (ISidedInventory)inv;
int[] slots = sidedInv.getAccessibleSlotsFromSide(side);
for(int k = 0; k < slots.length; ++k) {
if(func_145892_a(inv, slots[k], side, takeCount))
return true;
}
} else {
int i = inv.getSizeInventory();
for(int j = 0; j < i; ++j) {
if(func_145892_a(inv, j, side, takeCount))
return true;
}
}
}
return false;
}
public void changeBindType() {
bindType = !bindType;
}
private int getTakeCount(IInventory inv, int side) {
if(inv instanceof ISidedInventory && side > -1) {
ISidedInventory sideInv = (ISidedInventory)inv;
int[] slots = sideInv.getAccessibleSlotsFromSide(side);
for(int i = 0; i < slots.length; ++i) {
ItemStack stack = sideInv.getStackInSlot(slots[i]);
if(stack != null)
if(getStackInSlot(0) == null)
return Math.min(stack.getMaxStackSize(), getInventoryStackLimit());
else if(getInventoryStackLimit() != getStackInSlot(0).stackSize && getStackInSlot(0).stackSize != getStackInSlot(0).getMaxStackSize() && TileNidavellirForge.isItemEqual(stack, getStackInSlot(0)))
return getInventoryStackLimit() - getStackInSlot(0).stackSize;
}
} else {
for(int i = 0; i < inv.getSizeInventory(); ++i) {
ItemStack stack = inv.getStackInSlot(i);
if(stack != null)
if(getStackInSlot(0) == null)
return Math.min(stack.getMaxStackSize(), getInventoryStackLimit());
else if(getInventoryStackLimit() != getStackInSlot(0).stackSize && getStackInSlot(0).stackSize != getStackInSlot(0).getMaxStackSize() && TileNidavellirForge.isItemEqual(stack, getStackInSlot(0)))
return getInventoryStackLimit() - getStackInSlot(0).stackSize;
}
}
return 0;
}
public void setDistantInventory(int count, int posX, int posY, int posZ) {
invPosX[count] = posX;
invPosY[count] = posY;
invPosZ[count] = posZ;
}
private boolean func_145892_a(IInventory inv, int slot, int side, int takeCount) {
ItemStack itemstack = inv.getStackInSlot(slot);
if(itemstack != null && func_145890_b(inv, itemstack, slot, side)) {
ItemStack itemstack1 = itemstack.copy();
ItemStack itemstack2 = TileEntityHopper.func_145889_a(this, inv.decrStackSize(slot, takeCount), side);
if(itemstack2 == null || itemstack2.stackSize == 0) {
inv.markDirty();
return true;
}
inv.setInventorySlotContents(slot, itemstack1);
}
return false;
}
private static boolean func_145890_b(IInventory inv, ItemStack stack, int slot, int side) {
return !(inv instanceof ISidedInventory) || ((ISidedInventory)inv).canExtractItem(slot, stack, side);
}
public int getSizeInventory() {
return 1;
}
public IInventory getDistantInventory(int count) {
IInventory inv = TileEntityHopper
.func_145893_b(this.getWorldObj(), invPosX[count], invPosY[count], invPosZ[count]);
if (inv == null) setDistantInventory(count, 0, -1, 0);
return inv;
}
public String getInventoryName() {
return "engineerHopper";
}
public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) {
return true;
}
public double getXPos() {
return this.xCoord;
}
public ChunkCoordinates[] getBlocksCoord() {
return new ChunkCoordinates[] { new ChunkCoordinates(invPosX[0], invPosY[0], invPosZ[0]),
new ChunkCoordinates(invPosX[1], invPosY[1], invPosZ[1]) };
}
public double getYPos() {
return this.yCoord;
}
public ChunkCoordinates getBinding() {
return null;
}
public double getZPos() {
return this.zCoord;
}
}
public void renderHUD(Minecraft mc, ScaledResolution res) {
int x = res.getScaledWidth() / 2 - 7;
int y = res.getScaledHeight() / 2 + 16;
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
ClientHelper.drawArrow(x - 2, y, false);
for (int i = 0; i < 2; i++) {
ItemStack stack = null;
boolean hasInv = false;
int posX = x + (i == 0 ? 32 : -32);
if (getDistantInventory(i) != null && (TileEntity) getDistantInventory(i) != null) {
TileEntity tile = (TileEntity) getDistantInventory(i);
Block block = tile.getWorldObj().getBlock(tile.xCoord, tile.yCoord, tile.zCoord);
int meta = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord);
stack = new ItemStack(block, 1, meta);
hasInv = true;
}
Gui.drawRect(posX - 4, y - 4, posX + 20, y + 20, 1140850688);
Gui.drawRect(posX - 2, y - 2, posX + 18, y + 18, 1140850688);
if (stack != null) {
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(32826);
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, posX, y);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(2929);
}
int invCount = bindType ? 0 : 1;
if (invCount == i) {
GL11.glTranslatef(0.0f, 0.0f, 300.0f);
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(32826);
RenderItem.getInstance().renderItemIntoGUI(
mc.fontRenderer,
mc.renderEngine,
new ItemStack(ModItems.twigWand),
posX + 10,
y + 7);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(2929);
GL11.glTranslatef(0.0f, 0.0f, -300.0f);
}
boolean unicode = mc.fontRenderer.getUnicodeFlag();
mc.fontRenderer.setUnicodeFlag(true);
if (!hasInv) {
mc.fontRenderer.drawStringWithShadow("\u2717", posX + 5, y + 6, 4980736);
mc.fontRenderer.drawStringWithShadow("\u2717", posX + 5, y + 5, 13764621);
}
mc.fontRenderer.setUnicodeFlag(unicode);
GL11.glEnable(2929);
}
GL11.glDisable(3042);
}
public void writeCustomNBT(NBTTagCompound nbtt) {
super.writeCustomNBT(nbtt);
nbtt.setInteger("cooldown", this.cooldown);
nbtt.setBoolean("bindType", this.bindType);
nbtt.setIntArray("bindingX", this.invPosX);
nbtt.setIntArray("bindingY", this.invPosY);
nbtt.setIntArray("bindingZ", this.invPosZ);
nbtt.setIntArray("bindingSide", this.invSide);
}
public void readCustomNBT(NBTTagCompound nbtt) {
super.readCustomNBT(nbtt);
this.cooldown = nbtt.getInteger("cooldown");
this.bindType = nbtt.getBoolean("bindType");
this.invPosX = nbtt.getIntArray("bindingX");
this.invPosY = nbtt.getIntArray("bindingY");
this.invPosZ = nbtt.getIntArray("bindingZ");
this.invSide = nbtt.getIntArray("bindingSide");
}
private boolean canExtractStack() {
IInventory inv = getDistantInventory(0);
if (inv == null) return false;
else {
int side = invSide[0];
int pullCount = getPullCount(inv, side);
System.out.println("canExtractStack " + pullCount);
if (pullCount <= 0) return false;
else {
if (getStackInSlot(0) != null) {
ItemStack itemstack = getStackInSlot(0).copy();
ItemStack itemstack1 = TileEntityHopper.func_145889_a(inv, decrStackSize(0, pullCount), side);
if (itemstack1 == null || itemstack1.stackSize == 0) {
inv.markDirty();
return true;
}
setInventorySlotContents(0, itemstack);
}
return false;
}
}
}
private int getPullCount(IInventory inv, int side) {
if (inv instanceof ISidedInventory && side > -1) {
ISidedInventory sideInv = (ISidedInventory) inv;
int[] slots = sideInv.getAccessibleSlotsFromSide(side);
for (int i = 0; i < slots.length; ++i) {
ItemStack stack = sideInv.getStackInSlot(slots[i]);
if (stack == null) return inv.getInventoryStackLimit();
else if (inv.getInventoryStackLimit() != stack.stackSize && stack.stackSize != stack.getMaxStackSize()
&& TileNidavellirForge.isItemEqual(stack, getStackInSlot(0)))
return inv.getInventoryStackLimit() - stack.stackSize;
}
} else {
int size = inv.getSizeInventory();
for (int i = 0; i < size; ++i) {
ItemStack stack = inv.getStackInSlot(i);
if (stack == null) return inv.getInventoryStackLimit();
else if (inv.getInventoryStackLimit() != stack.stackSize && stack.stackSize != stack.getMaxStackSize()
&& TileNidavellirForge.isItemEqual(stack, getStackInSlot(0)))
return inv.getInventoryStackLimit() - stack.stackSize;
}
}
return 0;
}
private boolean canInsertStack() {
IInventory inv = getDistantInventory(1);
if (inv != null) {
int side = invSide[1];
int takeCount = getTakeCount(inv, side);
System.out.println("canInsertStack " + takeCount);
if (takeCount <= 0) return false;
if (inv instanceof ISidedInventory && side > -1) {
ISidedInventory sidedInv = (ISidedInventory) inv;
int[] slots = sidedInv.getAccessibleSlotsFromSide(side);
for (int k = 0; k < slots.length; ++k) {
if (func_145892_a(inv, slots[k], side, takeCount)) return true;
}
} else {
int i = inv.getSizeInventory();
for (int j = 0; j < i; ++j) {
if (func_145892_a(inv, j, side, takeCount)) return true;
}
}
}
return false;
}
private int getTakeCount(IInventory inv, int side) {
if (inv instanceof ISidedInventory && side > -1) {
ISidedInventory sideInv = (ISidedInventory) inv;
int[] slots = sideInv.getAccessibleSlotsFromSide(side);
for (int i = 0; i < slots.length; ++i) {
ItemStack stack = sideInv.getStackInSlot(slots[i]);
if (stack != null)
if (getStackInSlot(0) == null) return Math.min(stack.getMaxStackSize(), getInventoryStackLimit());
else if (getInventoryStackLimit() != getStackInSlot(0).stackSize
&& getStackInSlot(0).stackSize != getStackInSlot(0).getMaxStackSize()
&& TileNidavellirForge.isItemEqual(stack, getStackInSlot(0)))
return getInventoryStackLimit() - getStackInSlot(0).stackSize;
}
} else {
for (int i = 0; i < inv.getSizeInventory(); ++i) {
ItemStack stack = inv.getStackInSlot(i);
if (stack != null)
if (getStackInSlot(0) == null) return Math.min(stack.getMaxStackSize(), getInventoryStackLimit());
else if (getInventoryStackLimit() != getStackInSlot(0).stackSize
&& getStackInSlot(0).stackSize != getStackInSlot(0).getMaxStackSize()
&& TileNidavellirForge.isItemEqual(stack, getStackInSlot(0)))
return getInventoryStackLimit() - getStackInSlot(0).stackSize;
}
}
return 0;
}
private boolean func_145892_a(IInventory inv, int slot, int side, int takeCount) {
ItemStack itemstack = inv.getStackInSlot(slot);
if (itemstack != null && func_145890_b(inv, itemstack, slot, side)) {
ItemStack itemstack1 = itemstack.copy();
ItemStack itemstack2 = TileEntityHopper.func_145889_a(this, inv.decrStackSize(slot, takeCount), side);
if (itemstack2 == null || itemstack2.stackSize == 0) {
inv.markDirty();
return true;
}
inv.setInventorySlotContents(slot, itemstack1);
}
return false;
}
private static boolean func_145890_b(IInventory inv, ItemStack stack, int slot, int side) {
return !(inv instanceof ISidedInventory) || ((ISidedInventory) inv).canExtractItem(slot, stack, side);
}
public int getSizeInventory() {
return 1;
}
public String getInventoryName() {
return "engineerHopper";
}
public double getXPos() {
return this.xCoord;
}
public double getYPos() {
return this.yCoord;
}
public double getZPos() {
return this.zCoord;
}
}
@@ -2,258 +2,251 @@ package ab.common.block.tile;
import java.util.List;
import ab.api.IRenderHud;
import ab.common.block.subtile.SubTileArdentAzarcissus;
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.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.EnumChatFormatting;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.common.block.tile.TileMod;
import ab.api.IRenderHud;
public class TileGameBoard extends TileMod implements IRenderHud {
public String[] playersName = new String[] { "", "" };
public byte[] slotChance = new byte[] { 0, 0, 0, 0 };
protected int botTick = -1;
public int endGameTick = -1;
protected boolean requestUpdate;
public boolean isSingleGame = true;
public boolean isCustomGame = false;
public int clientTick[] = new int[] { 0, 0, 0, 0 };
public static final ItemStack headRender = new ItemStack(Items.skull, 1, 3);
private ItemStack customStack;
public void updateEntity() {
if(botTick > 0)
botTick--;
if(endGameTick > 0)
endGameTick--;
if(!worldObj.isRemote)
updateServer();
else
updateAnimationTicks();
}
public void updateAnimationTicks() {
for(int i = 0; i < slotChance.length; i++)
if(slotChance[i] > 0)
clientTick[i]++;
else
clientTick[i] = 0;
}
protected void updateServer() {
if(hasGame() && endGameTick == 0 && !isCustomGame)
finishGame();
if(requestUpdate)
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
if(worldObj.getTotalWorldTime() % 20 == 0 && hasFullDice() && endGameTick == -1)
endGameTick = 28;
boolean hasUpdate = false;
if(isSingleGame) {
if(botTick == 0 && hasGame()) {
for(int i = 2; i < 4; i++) {
if(slotChance[i] == 0) {
slotChance[i] = (byte)(worldObj.rand.nextInt(6) + 1);
botTick = -1;
hasUpdate = true;
worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "ab:boardCube", 0.6F, 1.0F);
break;
}
}
}
} else {
if(botTick == 0 && hasGame())
endGameTick = 0;
}
requestUpdate = hasUpdate;
}
public void setPlayer(String name, boolean isCustomGame) {
this.isCustomGame = isCustomGame;
if(isSingleGame) {
playersName[0] = name;
playersName[1] = "";
requestUpdate = true;
botTick = 8;
} else {
if(playersName[0].isEmpty())
playersName[0] = name;
else if(!playersName[0].equals(name))
playersName[1] = name;
requestUpdate = true;
}
}
public void setPlayer(EntityPlayer player) {
setPlayer(player.getCommandSenderName(), false);
}
public boolean dropDice(String name) {
if(isSingleGame) {
if(name.equals(playersName[0]) && botTick == -1) {
boolean hasDrop = false;
for(int i = 0; i < 2; i++) {
if(slotChance[i] == 0) {
hasDrop = true;
if(!worldObj.isRemote) {
slotChance[i] = (byte)(worldObj.rand.nextInt(6) + 1);
botTick = 18;
worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "ab:boardCube", 0.6F, 1.0F);
requestUpdate = true;
}
break;
}
}
return hasDrop;
}
} else {
for(int i = 0; i < playersName.length; i++) {
if(name.equals(playersName[i])) {
boolean hasDrop = false;
for(int j = i * 2; j < (i + 1) * 2; j++) {
if(slotChance[j] == 0) {
hasDrop = true;
if(!worldObj.isRemote) {
slotChance[j] = (byte)(worldObj.rand.nextInt(6) + 1);
botTick = playersName[1].isEmpty() ? 240 : 1200;
worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "ab:boardCube", 0.6F, 1.0F);
requestUpdate = true;
}
break;
}
}
return hasDrop;
}
}
}
return false;
}
public boolean dropDice(EntityPlayer player) {
return dropDice(player.getCommandSenderName());
}
public boolean hasFullDice() {
boolean hasFull = false;
for(int i = 0; i < slotChance.length; i++) {
if(!(slotChance[i] > 0))
return false;
hasFull = slotChance[i] > 0;
}
return hasFull;
}
public boolean hasGame() {
if(isSingleGame)
return !playersName[0].isEmpty();
else
for(int i = 0; i < playersName.length; i++)
if(!playersName[i].isEmpty())
return true;
return false;
}
public void finishGame(boolean hasChatMessage) {
if(worldObj.isRemote)
return;
else if(!hasChatMessage) {
resetGame();
return;
} else if(!hasFullDice()) {
sendNearMessage("ab.gameBoard.misc.notPlayer", new Object[] {});
resetGame();
return;
}
String str = isSingleGame ? "" : ".mult";
if((slotChance[0] + slotChance[1]) > (slotChance[2] + slotChance[3]))
sendNearMessage("ab.gameBoard.misc.0" + str, new Object[] { playersName[0] });
else if((slotChance[0] + slotChance[1]) == (slotChance[2] + slotChance[3]))
sendNearMessage("ab.gameBoard.misc.1" + str, new Object[] {});
else
sendNearMessage("ab.gameBoard.misc.2" + str, new Object[] { playersName[isSingleGame ? 0 : 1] });
resetGame();
}
public void finishGame() {
finishGame(true);
}
public void sendNearMessage(String text, Object[] obj) {
List<EntityPlayer> players = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord, this.zCoord, (this.xCoord + 1), (this.yCoord + 1), (this.zCoord + 1)).expand(3.5f, 3.5f, 3.5f));
for(EntityPlayer player : players) {
if(player != null)
player.addChatMessage((new ChatComponentTranslation(text, obj)).setChatStyle((new ChatStyle()).setColor(EnumChatFormatting.DARK_GREEN)));
}
}
public boolean changeCustomStack(ItemStack stack) {
if(!isCustomGame)
return false;
else if(customStack == null || !ItemStack.areItemStacksEqual(customStack, stack)) {
customStack = stack;
requestUpdate = true;
return true;
} else
return false;
}
public void resetGame() {
playersName[0] = "";
playersName[1] = "";
for(int i = 0; i < slotChance.length; i++)
slotChance[i] = 0;
botTick = -1;
endGameTick = -1;
isCustomGame = false;
requestUpdate = true;
}
public void renderHud(Minecraft mc, ScaledResolution res) {
int x = res.getScaledWidth() / 2 - 7;
int y = res.getScaledHeight() / 2 + 12;
RenderHelper.enableGUIStandardItemLighting();
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, isCustomGame ? (customStack == null ? headRender : customStack) : headRender, x - (!isSingleGame ? 1 : 0), y - (!isSingleGame ? 1 : 0));
if(!isSingleGame)
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, headRender, x + 3, y + 3);
RenderHelper.disableStandardItemLighting();
}
public void writeCustomNBT(NBTTagCompound cmp) {
super.writeCustomNBT(cmp);
for(int i = 0; i < playersName.length; i++)
cmp.setString("playerName" + i, playersName[i]);
cmp.setByteArray("slotChance", slotChance);
cmp.setInteger("botTick", botTick);
cmp.setInteger("endGameTick", endGameTick);
cmp.setBoolean("requestUpdate", requestUpdate);
cmp.setBoolean("isSingleGame", isSingleGame);
cmp.setBoolean("isAnonimGame", isCustomGame);
if(customStack != null)
customStack.writeToNBT(cmp);
}
public void readCustomNBT(NBTTagCompound cmp) {
super.readCustomNBT(cmp);
for(int i = 0; i < playersName.length; i++)
playersName[i] = cmp.getString("playerName" + i);
botTick = cmp.getInteger("botTick");
endGameTick = cmp.getInteger("endGameTick");
slotChance = cmp.getByteArray("slotChance");
requestUpdate = cmp.getBoolean("requestUpdate");
isSingleGame = cmp.getBoolean("isSingleGame");
isCustomGame = cmp.getBoolean("isAnonimGame");
customStack = ItemStack.loadItemStackFromNBT(cmp);
}
}
public String[] playersName = new String[] { "", "" };
public byte[] slotChance = new byte[] { 0, 0, 0, 0 };
protected int botTick = -1;
public int endGameTick = -1;
protected boolean requestUpdate;
public boolean isSingleGame = true;
public boolean isCustomGame = false;
public int clientTick[] = new int[] { 0, 0, 0, 0 };
public static final ItemStack headRender = new ItemStack(Items.skull, 1, 3);
private ItemStack customStack;
public void updateEntity() {
if (botTick > 0) botTick--;
if (endGameTick > 0) endGameTick--;
if (!worldObj.isRemote) updateServer();
else updateAnimationTicks();
}
public void updateAnimationTicks() {
for (int i = 0; i < slotChance.length; i++) if (slotChance[i] > 0) clientTick[i]++;
else clientTick[i] = 0;
}
protected void updateServer() {
if (hasGame() && endGameTick == 0 && !isCustomGame) finishGame();
if (requestUpdate)
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
if (worldObj.getTotalWorldTime() % 20 == 0 && hasFullDice() && endGameTick == -1) endGameTick = 28;
boolean hasUpdate = false;
if (isSingleGame) {
if (botTick == 0 && hasGame()) {
for (int i = 2; i < 4; i++) {
if (slotChance[i] == 0) {
slotChance[i] = (byte) (worldObj.rand.nextInt(6) + 1);
botTick = -1;
hasUpdate = true;
worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "ab:boardCube", 0.6F, 1.0F);
break;
}
}
}
} else {
if (botTick == 0 && hasGame()) endGameTick = 0;
}
requestUpdate = hasUpdate;
}
public void setPlayer(String name, boolean isCustomGame) {
this.isCustomGame = isCustomGame;
if (isSingleGame) {
playersName[0] = name;
playersName[1] = "";
requestUpdate = true;
botTick = 8;
} else {
if (playersName[0].isEmpty()) playersName[0] = name;
else if (!playersName[0].equals(name)) playersName[1] = name;
requestUpdate = true;
}
}
public void setPlayer(EntityPlayer player) {
setPlayer(player.getCommandSenderName(), false);
}
public boolean dropDice(String name) {
if (isSingleGame) {
if (name.equals(playersName[0]) && botTick == -1) {
boolean hasDrop = false;
for (int i = 0; i < 2; i++) {
if (slotChance[i] == 0) {
hasDrop = true;
if (!worldObj.isRemote) {
slotChance[i] = (byte) (worldObj.rand.nextInt(6) + 1);
botTick = 18;
worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "ab:boardCube", 0.6F, 1.0F);
requestUpdate = true;
}
break;
}
}
return hasDrop;
}
} else {
for (int i = 0; i < playersName.length; i++) {
if (name.equals(playersName[i])) {
boolean hasDrop = false;
for (int j = i * 2; j < (i + 1) * 2; j++) {
if (slotChance[j] == 0) {
hasDrop = true;
if (!worldObj.isRemote) {
slotChance[j] = (byte) (worldObj.rand.nextInt(6) + 1);
botTick = playersName[1].isEmpty() ? 240 : 1200;
worldObj.playSoundEffect(
this.xCoord,
this.yCoord,
this.zCoord,
"ab:boardCube",
0.6F,
1.0F);
requestUpdate = true;
}
break;
}
}
return hasDrop;
}
}
}
return false;
}
public boolean dropDice(EntityPlayer player) {
return dropDice(player.getCommandSenderName());
}
public boolean hasFullDice() {
boolean hasFull = false;
for (int i = 0; i < slotChance.length; i++) {
if (!(slotChance[i] > 0)) return false;
hasFull = slotChance[i] > 0;
}
return hasFull;
}
public boolean hasGame() {
if (isSingleGame) return !playersName[0].isEmpty();
else for (int i = 0; i < playersName.length; i++) if (!playersName[i].isEmpty()) return true;
return false;
}
public void finishGame(boolean hasChatMessage) {
if (worldObj.isRemote) return;
else if (!hasChatMessage) {
resetGame();
return;
} else if (!hasFullDice()) {
sendNearMessage("ab.gameBoard.misc.notPlayer", new Object[] {});
resetGame();
return;
}
String str = isSingleGame ? "" : ".mult";
if ((slotChance[0] + slotChance[1]) > (slotChance[2] + slotChance[3]))
sendNearMessage("ab.gameBoard.misc.0" + str, new Object[] { playersName[0] });
else if ((slotChance[0] + slotChance[1]) == (slotChance[2] + slotChance[3]))
sendNearMessage("ab.gameBoard.misc.1" + str, new Object[] {});
else sendNearMessage("ab.gameBoard.misc.2" + str, new Object[] { playersName[isSingleGame ? 0 : 1] });
resetGame();
}
public void finishGame() {
finishGame(true);
}
public void sendNearMessage(String text, Object[] obj) {
List<EntityPlayer> players = this.worldObj.getEntitiesWithinAABB(
EntityPlayer.class,
AxisAlignedBB.getBoundingBox(
this.xCoord,
this.yCoord,
this.zCoord,
(this.xCoord + 1),
(this.yCoord + 1),
(this.zCoord + 1)).expand(3.5f, 3.5f, 3.5f));
for (EntityPlayer player : players) {
if (player != null) player.addChatMessage(
(new ChatComponentTranslation(text, obj))
.setChatStyle((new ChatStyle()).setColor(EnumChatFormatting.DARK_GREEN)));
}
}
public boolean changeCustomStack(ItemStack stack) {
if (!isCustomGame) return false;
else if (customStack == null || !ItemStack.areItemStacksEqual(customStack, stack)) {
customStack = stack;
requestUpdate = true;
return true;
} else return false;
}
public void resetGame() {
playersName[0] = "";
playersName[1] = "";
for (int i = 0; i < slotChance.length; i++) slotChance[i] = 0;
botTick = -1;
endGameTick = -1;
isCustomGame = false;
requestUpdate = true;
}
public void renderHud(Minecraft mc, ScaledResolution res) {
int x = res.getScaledWidth() / 2 - 7;
int y = res.getScaledHeight() / 2 + 12;
RenderHelper.enableGUIStandardItemLighting();
RenderItem.getInstance().renderItemAndEffectIntoGUI(
mc.fontRenderer,
mc.renderEngine,
isCustomGame ? (customStack == null ? headRender : customStack) : headRender,
x - (!isSingleGame ? 1 : 0),
y - (!isSingleGame ? 1 : 0));
if (!isSingleGame) RenderItem.getInstance()
.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, headRender, x + 3, y + 3);
RenderHelper.disableStandardItemLighting();
}
public void writeCustomNBT(NBTTagCompound cmp) {
super.writeCustomNBT(cmp);
for (int i = 0; i < playersName.length; i++) cmp.setString("playerName" + i, playersName[i]);
cmp.setByteArray("slotChance", slotChance);
cmp.setInteger("botTick", botTick);
cmp.setInteger("endGameTick", endGameTick);
cmp.setBoolean("requestUpdate", requestUpdate);
cmp.setBoolean("isSingleGame", isSingleGame);
cmp.setBoolean("isAnonimGame", isCustomGame);
if (customStack != null) customStack.writeToNBT(cmp);
}
public void readCustomNBT(NBTTagCompound cmp) {
super.readCustomNBT(cmp);
for (int i = 0; i < playersName.length; i++) playersName[i] = cmp.getString("playerName" + i);
botTick = cmp.getInteger("botTick");
endGameTick = cmp.getInteger("endGameTick");
slotChance = cmp.getByteArray("slotChance");
requestUpdate = cmp.getBoolean("requestUpdate");
isSingleGame = cmp.getBoolean("isSingleGame");
isCustomGame = cmp.getBoolean("isAnonimGame");
customStack = ItemStack.loadItemStackFromNBT(cmp);
}
}
@@ -6,87 +6,86 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import vazkii.botania.common.block.tile.TileMod;
public abstract class TileInventory extends TileMod implements IInventory {
ItemStack[] inventorySlots = new ItemStack[getSizeInventory()];
public void readCustomNBT(NBTTagCompound par1NBTTagCompound) {
NBTTagList var2 = par1NBTTagCompound.getTagList("Items", 10);
this.inventorySlots = new ItemStack[getSizeInventory()];
for(int var3 = 0; var3 < var2.tagCount(); var3++) {
NBTTagCompound var4 = var2.getCompoundTagAt(var3);
byte var5 = var4.getByte("Slot");
if(var5 >= 0 && var5 < this.inventorySlots.length)
this.inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
public void writeCustomNBT(NBTTagCompound par1NBTTagCompound) {
NBTTagList var2 = new NBTTagList();
for(int var3 = 0; var3 < this.inventorySlots.length; var3++) {
if (this.inventorySlots[var3] != null) {
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
this.inventorySlots[var3].writeToNBT(var4);
var2.appendTag((NBTBase)var4);
}
}
par1NBTTagCompound.setTag("Items", (NBTBase)var2);
}
public ItemStack getStackInSlot(int i) {
return this.inventorySlots[i];
}
public ItemStack decrStackSize(int i, int j) {
if(this.inventorySlots[i] != null) {
if(!this.worldObj.isRemote)
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
if((this.inventorySlots[i]).stackSize <= j) {
ItemStack itemStack = this.inventorySlots[i];
this.inventorySlots[i] = null;
markDirty();
return itemStack;
}
ItemStack stackAt = this.inventorySlots[i].splitStack(j);
if((this.inventorySlots[i]).stackSize == 0)
this.inventorySlots[i] = null;
markDirty();
return stackAt;
}
return null;
}
public ItemStack getStackInSlotOnClosing(int i) {
return getStackInSlot(i);
}
public void setInventorySlotContents(int i, ItemStack itemstack) {
this.inventorySlots[i] = itemstack;
markDirty();
if (!this.worldObj.isRemote)
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
public int getInventoryStackLimit() {
return 64;
}
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
return (this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this) ? false : ((entityplayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D));
}
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
return true;
}
public boolean hasCustomInventoryName() {
return false;
}
public void openInventory() {}
public void closeInventory() {}
}
ItemStack[] inventorySlots = new ItemStack[getSizeInventory()];
public void readCustomNBT(NBTTagCompound par1NBTTagCompound) {
NBTTagList var2 = par1NBTTagCompound.getTagList("Items", 10);
this.inventorySlots = new ItemStack[getSizeInventory()];
for (int var3 = 0; var3 < var2.tagCount(); var3++) {
NBTTagCompound var4 = var2.getCompoundTagAt(var3);
byte var5 = var4.getByte("Slot");
if (var5 >= 0 && var5 < this.inventorySlots.length)
this.inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
public void writeCustomNBT(NBTTagCompound par1NBTTagCompound) {
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < this.inventorySlots.length; var3++) {
if (this.inventorySlots[var3] != null) {
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte) var3);
this.inventorySlots[var3].writeToNBT(var4);
var2.appendTag((NBTBase) var4);
}
}
par1NBTTagCompound.setTag("Items", (NBTBase) var2);
}
public ItemStack getStackInSlot(int i) {
return this.inventorySlots[i];
}
public ItemStack decrStackSize(int i, int j) {
if (this.inventorySlots[i] != null) {
if (!this.worldObj.isRemote) this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
if ((this.inventorySlots[i]).stackSize <= j) {
ItemStack itemStack = this.inventorySlots[i];
this.inventorySlots[i] = null;
markDirty();
return itemStack;
}
ItemStack stackAt = this.inventorySlots[i].splitStack(j);
if ((this.inventorySlots[i]).stackSize == 0) this.inventorySlots[i] = null;
markDirty();
return stackAt;
}
return null;
}
public ItemStack getStackInSlotOnClosing(int i) {
return getStackInSlot(i);
}
public void setInventorySlotContents(int i, ItemStack itemstack) {
this.inventorySlots[i] = itemstack;
markDirty();
if (!this.worldObj.isRemote) this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
public int getInventoryStackLimit() {
return 64;
}
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
return (this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this) ? false
: ((entityplayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D));
}
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
return true;
}
public boolean hasCustomInventoryName() {
return false;
}
public void openInventory() {}
public void closeInventory() {}
}
@@ -1,9 +1,5 @@
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;
@@ -14,201 +10,212 @@ import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
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.util.Vec3;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
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;
import vazkii.botania.common.core.handler.ConfigHandler;
import ab.api.IRenderHud;
import ab.common.lib.register.BlockListAB;
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(!worldObj.isRemote) {
if(tick <= 0) {
updateStructure();
if(validTree && getBlock() != null) {
spawnLeaves();
tick = 40;
}
} else
tick--;
} else if(worldObj.rand.nextBoolean())
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(EntityPlayer player, 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;
else if(!worldObj.isRemote) {
Vec3 vec3 = player.getLook(1.0F).normalize();
EntityItem entityitem = new EntityItem(worldObj, player.posX + vec3.xCoord, player.posY + 1.2f, player.posZ + vec3.zCoord, new ItemStack(this.block, 1, this.meta));
worldObj.spawnEntityInWorld(entityitem);
}
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.rand.nextInt(10) <= 8)
return;
else if(world.getBlock(x, y, z).getMaterial() == Material.air && y < 256)
world.setBlock(x, y, z, this.block, this.meta, 3);
}
protected int tick;
protected Block block;
protected int meta;
protected boolean validTree;
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();
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 (!worldObj.isRemote) {
if (tick <= 0) {
updateStructure();
if (validTree && getBlock() != null) {
spawnLeaves();
tick = 40;
}
} else tick--;
} else if (worldObj.rand.nextBoolean()) 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(EntityPlayer player, 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;
else if (!worldObj.isRemote) {
Vec3 vec3 = player.getLook(1.0F).normalize();
EntityItem entityitem = new EntityItem(
worldObj,
player.posX + vec3.xCoord,
player.posY + 1.2f,
player.posZ + vec3.zCoord,
new ItemStack(this.block, 1, this.meta));
worldObj.spawnEntityInWorld(entityitem);
}
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.rand.nextInt(10) <= 8) return;
else 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);
}
}
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);
}
}
@@ -1,6 +1,5 @@
package ab.common.block.tile;
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
@@ -14,7 +13,7 @@ import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.common.items.relics.ItemThaumonomicon;
import thaumcraft.common.items.wands.ItemWandCasting;
@@ -22,312 +21,295 @@ import thaumcraft.common.lib.crafting.ThaumcraftCraftingManager;
import thaumcraft.common.tiles.TileMagicWorkbench;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.common.item.ModItems;
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
public class TileMagicCraftCrate extends TileMagicWorkbench implements ISidedInventory, IInventory {
private static final String WAITING_TAG = "waitingStack";
private static final String PATTERN_TAG = "pattern";
private static final int[] ACCESSIBLE_SLOTS = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
private static final String WAITING_TAG = "waitingStack";
private static final String PATTERN_TAG = "pattern";
private static final int[] ACCESSIBLE_SLOTS = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
private boolean[][] pattern;
private EntityPlayer player;
int signal = 0;
private ItemStack waitingStack;
private boolean[][] pattern;
private EntityPlayer player;
int signal = 0;
private ItemStack waitingStack;
public TileMagicCraftCrate() {
pattern = new boolean[][] { new boolean[] { true, true, true }, new boolean[] { true, true, true }, new boolean[] { true, true, true } };
}
public TileMagicCraftCrate() {
pattern = new boolean[][] { new boolean[] { true, true, true }, new boolean[] { true, true, true },
new boolean[] { true, true, true } };
}
public void updateEntity() {
if(!worldObj.isRemote && (craft(true) && canEject() || isFull() && !isWaiting()))
ejectAll();
int newSignal = 0;
for(; newSignal < 9; newSignal++)
if(!isLocked(newSignal) && getStackInSlot(newSignal) == null)
break;
if(isWaiting())
newSignal = 14;
if(newSignal != signal) {
signal = newSignal;
worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
}
}
public void updateEntity() {
if (!worldObj.isRemote && (craft(true) && canEject() || isFull() && !isWaiting())) ejectAll();
int newSignal = 0;
for (; newSignal < 9; newSignal++) if (!isLocked(newSignal) && getStackInSlot(newSignal) == null) break;
if (isWaiting()) newSignal = 14;
if (newSignal != signal) {
signal = newSignal;
worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
}
}
boolean craft(boolean fullCheck) {
if(fullCheck && !isFull())
return false;
if(player == null)
return false;
TileMagicWorkbench craft = new TileMagicWorkbench() {
public void setInventorySlotContents(int par1, ItemStack par2ItemStack) {
this.stackList[par1] = par2ItemStack;
}
boolean craft(boolean fullCheck) {
if (fullCheck && !isFull()) return false;
if (player == null) return false;
TileMagicWorkbench craft = new TileMagicWorkbench() {
public ItemStack decrStackSize(int par1, int par2) {
if(this.stackList[par1] == null) {
return null;
}
if(this.stackList[par1].stackSize <= par2) {
final ItemStack var3 = this.stackList[par1];
this.stackList[par1] = null;
return var3;
}
final ItemStack var3 = this.stackList[par1].splitStack(par2);
if(this.stackList[par1].stackSize == 0) {
this.stackList[par1] = null;
}
return var3;
}
};
for(int i = 0; i < 10; i++) {
ItemStack stack = getStackInSlot(i);
if(stack == null || isLocked(i) || stack.getItem() == ModItems.manaResource && stack.getItemDamage() == 11)
continue;
craft.setInventorySlotContents(i, stack.copy());
}
ItemStack result = ThaumcraftCraftingManager.findMatchingArcaneRecipe(craft, player);
if(result != null) {
final AspectList aspects = ThaumcraftCraftingManager.findMatchingArcaneRecipeAspects(craft, player);
if(aspects.size() > 0 && this.getStackInSlot(10) != null) {
final ItemWandCasting wand = (ItemWandCasting) this.getStackInSlot(10).getItem();
if (wand.consumeAllVisCrafting(this.getStackInSlot(10), player, aspects, true)) {
for(int var2 = 0; var2 < 9; ++var2) {
final ItemStack var3 = craft.getStackInSlot(var2);
if(var3 != null)
craft.decrStackSize(var2, 1);
}
for(int i = 0; i < 9; i++)
setInventorySlotContents(i, craft.getStackInSlot(i));
setInventorySlotContents(9, result);
MinecraftForge.EVENT_BUS.post(new ItemCraftedEvent(player, result, craft));
waitingStack = null;
return true;
} else {
waitingStack = result;
markDirty();
}
}
} else
waitingStack = null;
return false;
}
public void setInventorySlotContents(int par1, ItemStack par2ItemStack) {
this.stackList[par1] = par2ItemStack;
}
boolean isFull() {
for (int i = 0; i < 9; i++)
if (!isLocked(i) && getStackInSlot(i) == null)
return false;
public ItemStack decrStackSize(int par1, int par2) {
if (this.stackList[par1] == null) {
return null;
}
if (this.stackList[par1].stackSize <= par2) {
final ItemStack var3 = this.stackList[par1];
this.stackList[par1] = null;
return var3;
}
final ItemStack var3 = this.stackList[par1].splitStack(par2);
if (this.stackList[par1].stackSize == 0) {
this.stackList[par1] = null;
}
return var3;
}
};
for (int i = 0; i < 10; i++) {
ItemStack stack = getStackInSlot(i);
if (stack == null || isLocked(i) || stack.getItem() == ModItems.manaResource && stack.getItemDamage() == 11)
continue;
craft.setInventorySlotContents(i, stack.copy());
}
ItemStack result = ThaumcraftCraftingManager.findMatchingArcaneRecipe(craft, player);
if (result != null) {
final AspectList aspects = ThaumcraftCraftingManager.findMatchingArcaneRecipeAspects(craft, player);
if (aspects.size() > 0 && this.getStackInSlot(10) != null) {
final ItemWandCasting wand = (ItemWandCasting) this.getStackInSlot(10).getItem();
if (wand.consumeAllVisCrafting(this.getStackInSlot(10), player, aspects, true)) {
for (int var2 = 0; var2 < 9; ++var2) {
final ItemStack var3 = craft.getStackInSlot(var2);
if (var3 != null) craft.decrStackSize(var2, 1);
}
for (int i = 0; i < 9; i++) setInventorySlotContents(i, craft.getStackInSlot(i));
setInventorySlotContents(9, result);
MinecraftForge.EVENT_BUS.post(new ItemCraftedEvent(player, result, craft));
waitingStack = null;
return true;
} else {
waitingStack = result;
markDirty();
}
}
} else waitingStack = null;
return false;
}
return true;
}
boolean isFull() {
for (int i = 0; i < 9; i++) if (!isLocked(i) && getStackInSlot(i) == null) return false;
public boolean[][] getPattern() {
return pattern;
}
return true;
}
public void setPattern(boolean[][] pattern) {
this.pattern = pattern;
}
public boolean[][] getPattern() {
return pattern;
}
public int getSizeInventory() {
return 12;
}
public void setPattern(boolean[][] pattern) {
this.pattern = pattern;
}
public EntityPlayer getPlayer() {
return player;
}
public int getSizeInventory() {
return 12;
}
public void setPlayer(EntityPlayer player) {
this.player = player;
}
public EntityPlayer getPlayer() {
return player;
}
public int getSignal() {
return signal;
}
public void setPlayer(EntityPlayer player) {
this.player = player;
}
public ItemStack getWaitingStack() {
return waitingStack;
}
public int getSignal() {
return signal;
}
private boolean isWaiting() {
return waitingStack != null;
}
public ItemStack getWaitingStack() {
return waitingStack;
}
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
if (i < 9 && !isLocked(i))
return true;
if (i == 9)
return false;
if (i == 10) {
if (!(itemstack.getItem() instanceof ItemWandCasting)) {
return false;
}
final ItemWandCasting wand = (ItemWandCasting) itemstack.getItem();
return !wand.isStaff(itemstack);
}
return itemstack.getItem() instanceof ItemThaumonomicon;
}
private boolean isWaiting() {
return waitingStack != null;
}
private boolean isLocked(int slot) {
return pattern != null && !pattern[slot / 3][slot % 3];
}
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
if (i < 9 && !isLocked(i)) return true;
if (i == 9) return false;
if (i == 10) {
if (!(itemstack.getItem() instanceof ItemWandCasting)) {
return false;
}
final ItemWandCasting wand = (ItemWandCasting) itemstack.getItem();
return !wand.isStaff(itemstack);
}
return itemstack.getItem() instanceof ItemThaumonomicon;
}
public void readCustomNBT(NBTTagCompound nbtt) {
super.readCustomNBT(nbtt);
NBTTagList var2 = nbtt.getTagList("Items", 10);
inventorySlots = new ItemStack[getSizeInventory()];
for(int var3 = 0; var3 < var2.tagCount(); ++var3) {
NBTTagCompound var4 = var2.getCompoundTagAt(var3);
byte var5 = var4.getByte("Slot");
if(var5 >= 0 && var5 < inventorySlots.length)
inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4);
}
for(int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++)
pattern[i][j] = nbtt.getBoolean(PATTERN_TAG + i * 3 + j);
NBTTagCompound nbtt1 = nbtt.getCompoundTag(WAITING_TAG);
if(nbtt1 != null)
waitingStack = ItemStack.loadItemStackFromNBT(nbtt1);
}
private boolean isLocked(int slot) {
return pattern != null && !pattern[slot / 3][slot % 3];
}
public void writeCustomNBT(NBTTagCompound nbtt) {
super.writeCustomNBT(nbtt);
NBTTagList var2 = new NBTTagList();
for(int var3 = 0; var3 < inventorySlots.length; ++var3) {
if(inventorySlots[var3] != null) {
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte) var3);
inventorySlots[var3].writeToNBT(var4);
var2.appendTag(var4);
}
}
nbtt.setTag("Items", var2);
for(int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++)
nbtt.setBoolean(PATTERN_TAG + i * 3 + j, pattern[i][j]);
NBTTagCompound nbtt1 = new NBTTagCompound();
if(waitingStack != null) {
waitingStack.writeToNBT(nbtt1);
nbtt.setTag(WAITING_TAG, nbtt1);
}
}
public void readCustomNBT(NBTTagCompound nbtt) {
super.readCustomNBT(nbtt);
NBTTagList var2 = nbtt.getTagList("Items", 10);
inventorySlots = new ItemStack[getSizeInventory()];
for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
NBTTagCompound var4 = var2.getCompoundTagAt(var3);
byte var5 = var4.getByte("Slot");
if (var5 >= 0 && var5 < inventorySlots.length) inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4);
}
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++) pattern[i][j] = nbtt.getBoolean(PATTERN_TAG + i * 3 + j);
NBTTagCompound nbtt1 = nbtt.getCompoundTag(WAITING_TAG);
if (nbtt1 != null) waitingStack = ItemStack.loadItemStackFromNBT(nbtt1);
}
public void markDirty() {
super.markDirty();
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
}
public void writeCustomNBT(NBTTagCompound nbtt) {
super.writeCustomNBT(nbtt);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < inventorySlots.length; ++var3) {
if (inventorySlots[var3] != null) {
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte) var3);
inventorySlots[var3].writeToNBT(var4);
var2.appendTag(var4);
}
}
nbtt.setTag("Items", var2);
for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) nbtt.setBoolean(PATTERN_TAG + i * 3 + j, pattern[i][j]);
NBTTagCompound nbtt1 = new NBTTagCompound();
if (waitingStack != null) {
waitingStack.writeToNBT(nbtt1);
nbtt.setTag(WAITING_TAG, nbtt1);
}
}
public void onDataPacket(NetworkManager manager, S35PacketUpdateTileEntity packet) {
super.onDataPacket(manager, packet);
worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
}
public void markDirty() {
super.markDirty();
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
}
public Packet getDescriptionPacket() {
final NBTTagCompound compound = new NBTTagCompound();
this.writeToNBT(compound);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 10, compound);
}
public void onDataPacket(NetworkManager manager, S35PacketUpdateTileEntity packet) {
super.onDataPacket(manager, packet);
worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
}
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
return i == 9;
}
public Packet getDescriptionPacket() {
final NBTTagCompound compound = new NBTTagCompound();
this.writeToNBT(compound);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 10, compound);
}
public int[] getAccessibleSlotsFromSide(int side) {
return ACCESSIBLE_SLOTS;
}
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
return i == 9;
}
public boolean canInsertItem(int i, ItemStack stack, int j) {
return i < 9;
}
public int[] getAccessibleSlotsFromSide(int side) {
return ACCESSIBLE_SLOTS;
}
public int getInventoryStackLimit() {
return 1;
}
public boolean canInsertItem(int i, ItemStack stack, int j) {
return i < 9;
}
public int onWandRightClick(World world, ItemStack wandstack, EntityPlayer player, int x, int y, int z, int side, int md) {
return 0;
}
public int getInventoryStackLimit() {
return 1;
}
public ItemStack onWandRightClick(final World world, final ItemStack wandstack, final EntityPlayer player) {
this.player = player;
return wandstack;
}
public int onWandRightClick(World world, ItemStack wandstack, EntityPlayer player, int x, int y, int z, int side,
int md) {
return 0;
}
public void onUsingWandTick(ItemStack wandstack, EntityPlayer player, int count) {}
public ItemStack onWandRightClick(final World world, final ItemStack wandstack, final EntityPlayer player) {
this.player = player;
return wandstack;
}
public void onWandStoppedUsing(ItemStack wandstack, World world, EntityPlayer player, int count) {}
public void onUsingWandTick(ItemStack wandstack, EntityPlayer player, int count) {}
public void ejectAll() {
for(int i = 0; i < 10; ++i) {
ItemStack stack = getStackInSlot(i);
if(stack != null)
eject(stack, false);
setInventorySlotContents(i, null);
}
this.waitingStack = null;
markDirty();
}
public void onWandStoppedUsing(ItemStack wandstack, World world, EntityPlayer player, int count) {}
public void eject(ItemStack stack, boolean redstone) {
EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord - 0.5, zCoord + 0.5, stack);
item.motionX = 0;
item.motionY = 0;
item.motionZ = 0;
if(redstone)
item.age = -200;
setInventorySlotContents(0, null);
if(!worldObj.isRemote)
worldObj.spawnEntityInWorld(item);
}
public void ejectAll() {
for (int i = 0; i < 10; ++i) {
ItemStack stack = getStackInSlot(i);
if (stack != null) eject(stack, false);
setInventorySlotContents(i, null);
}
this.waitingStack = null;
markDirty();
}
public boolean canEject() {
Block blockBelow = worldObj.getBlock(xCoord, yCoord - 1, zCoord);
return blockBelow.isAir(worldObj, xCoord, yCoord - 1, zCoord) || blockBelow.getCollisionBoundingBoxFromPool(worldObj, xCoord, yCoord - 1, zCoord) == null;
}
public void eject(ItemStack stack, boolean redstone) {
EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord - 0.5, zCoord + 0.5, stack);
item.motionX = 0;
item.motionY = 0;
item.motionZ = 0;
if (redstone) item.age = -200;
setInventorySlotContents(0, null);
if (!worldObj.isRemote) worldObj.spawnEntityInWorld(item);
}
ItemStack[] inventorySlots = new ItemStack[getSizeInventory()];
public boolean canEject() {
Block blockBelow = worldObj.getBlock(xCoord, yCoord - 1, zCoord);
return blockBelow.isAir(worldObj, xCoord, yCoord - 1, zCoord)
|| blockBelow.getCollisionBoundingBoxFromPool(worldObj, xCoord, yCoord - 1, zCoord) == null;
}
@Override
public ItemStack getStackInSlot(int i) {
return inventorySlots[i];
}
ItemStack[] inventorySlots = new ItemStack[getSizeInventory()];
public ItemStack decrStackSize(int i, int j) {
if(inventorySlots[i] != null) {
ItemStack stackAt;
if (inventorySlots[i].stackSize <= j) {
stackAt = inventorySlots[i];
inventorySlots[i] = null;
return stackAt;
} else {
stackAt = inventorySlots[i].splitStack(j);
if(inventorySlots[i].stackSize == 0)
inventorySlots[i] = null;
return stackAt;
}
}
return null;
}
@Override
public ItemStack getStackInSlot(int i) {
return inventorySlots[i];
}
// Copied from vazkii.botania.common.block.tile.TileSimpleInventory
public ItemStack decrStackSize(int i, int j) {
if (inventorySlots[i] != null) {
ItemStack stackAt;
if (inventorySlots[i].stackSize <= j) {
stackAt = inventorySlots[i];
inventorySlots[i] = null;
return stackAt;
} else {
stackAt = inventorySlots[i].splitStack(j);
if (inventorySlots[i].stackSize == 0) inventorySlots[i] = null;
return stackAt;
}
}
return null;
}
public ItemStack getStackInSlotOnClosing(int i) {
return getStackInSlot(i);
}
// Copied from vazkii.botania.common.block.tile.TileSimpleInventory
public void setInventorySlotContents(int i, ItemStack itemstack) {
inventorySlots[i] = itemstack;
}
public ItemStack getStackInSlotOnClosing(int i) {
return getStackInSlot(i);
}
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
return worldObj.getTileEntity(xCoord, yCoord, zCoord) != this ? false : entityplayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64;
}
public void setInventorySlotContents(int i, ItemStack itemstack) {
inventorySlots[i] = itemstack;
}
public boolean hasCustomInventoryName() {
return false;
}
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
return worldObj.getTileEntity(xCoord, yCoord, zCoord) != this ? false
: entityplayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64;
}
public void openInventory() {}
public boolean hasCustomInventoryName() {
return false;
}
public void closeInventory() {}
}
public void openInventory() {}
public void closeInventory() {}
}
@@ -1,279 +1,274 @@
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 ab.common.core.handler.ConfigABHandler;
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 org.lwjgl.opengl.GL11;
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;
import ab.api.IRenderHud;
import ab.client.core.ClientHelper;
import ab.common.core.handler.ConfigABHandler;
public class TileManaCharger extends TileInventory implements ISidedInventory, IRenderHud, IWandBindable {
private static final int MANA_SPEED = 11240;
public boolean requestUpdate;
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() {
boolean hasUpdate = false;
if(!this.worldObj.isRemote && requestUpdate)
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
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);
if(this.worldObj.getTotalWorldTime() % 15 == 0)
hasUpdate = 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);
if(this.worldObj.getTotalWorldTime() % 15 == 0)
hasUpdate = true;
} else {
if(ConfigABHandler.useManaChargerAnimation)
clientTick[i]++;
}
receiver.recieveMana(-manaVal);
}
}
}
requestUpdate = hasUpdate;
}
public ISparkAttachable getReceiver() {
ISparkAttachable receiver = null;
if(this.worldObj != null && this.receiverPosY != -1) {
TileEntity tile = this.worldObj.getTileEntity(receiverPosX, receiverPosY, receiverPosZ);
if(tile != null && tile instanceof ISparkAttachable) {
receiver = (ISparkAttachable)tile;
}
}
if(receiver == null) {
receiverPosX = -1;
receiverPosY = -1;
receiverPosZ = -1;
}
return receiver;
}
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) >= 10 || Math.abs(this.yCoord - y) >= 10 || Math.abs(this.zCoord - z) >= 10;
if(isFar)
return false;
else if(tile instanceof ISparkAttachable && ((ISparkAttachable)tile).canRecieveManaFromBursts()) {
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;
}
private static final int MANA_SPEED = 11240;
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.requestUpdate);
}
public void readFromNBT(NBTTagCompound nbtt) {
super.readFromNBT(nbtt);
this.requestUpdate = 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 boolean requestUpdate;
int clientMana = -1;
int receiverPosX = -1;
int receiverPosY = -1;
int receiverPosZ = -1;
public int clientTick[] = new int[] { 0, 0, 3, 12, 6 };
public int[] getAccessibleSlotsFromSide(int side) {
return new int[] {1, 2, 3, 4};
}
public void updateEntity() {
boolean hasUpdate = false;
if (!this.worldObj.isRemote && requestUpdate)
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
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);
if (this.worldObj.getTotalWorldTime() % 15 == 0) hasUpdate = 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);
if (this.worldObj.getTotalWorldTime() % 15 == 0) hasUpdate = true;
} else {
if (ConfigABHandler.useManaChargerAnimation) clientTick[i]++;
}
receiver.recieveMana(-manaVal);
}
}
}
requestUpdate = hasUpdate;
}
public boolean canInsertItem(int slot, ItemStack stack, int side) {
boolean isManaItem = false;
if(stack != null && stack.getItem() instanceof IManaItem) {
IManaItem mana = (IManaItem)stack.getItem();
ISparkAttachable receiver = this.getReceiver();
if(receiver == null)
return false;
isManaItem = mana.getMana(stack) < mana.getMaxMana(stack) && mana.canReceiveManaFromPool(stack, (TileEntity)receiver);
}
return side == 1 && slot != 0 && isManaItem;
}
public ISparkAttachable getReceiver() {
ISparkAttachable receiver = null;
if (this.worldObj != null && this.receiverPosY != -1) {
TileEntity tile = this.worldObj.getTileEntity(receiverPosX, receiverPosY, receiverPosZ);
if (tile != null && tile instanceof ISparkAttachable) {
receiver = (ISparkAttachable) tile;
}
}
if (receiver == null) {
receiverPosX = -1;
receiverPosY = -1;
receiverPosZ = -1;
}
return receiver;
}
public boolean canExtractItem(int slot, ItemStack stack, int side) {
boolean isManaItem = false;
if(stack != null && stack.getItem() instanceof IManaItem) {
IManaItem mana = (IManaItem)stack.getItem();
ISparkAttachable receiver = this.getReceiver();
if(receiver == null)
return false;
isManaItem = mana.getMana(stack) == mana.getMaxMana(stack);
}
return side == 0 && slot != 0 && isManaItem;
}
}
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) >= 10 || Math.abs(this.yCoord - y) >= 10
|| Math.abs(this.zCoord - z) >= 10;
if (isFar) return false;
else if (tile instanceof ISparkAttachable && ((ISparkAttachable) tile).canRecieveManaFromBursts()) {
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.requestUpdate);
}
public void readFromNBT(NBTTagCompound nbtt) {
super.readFromNBT(nbtt);
this.requestUpdate = 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[] { 1, 2, 3, 4 };
}
public boolean canInsertItem(int slot, ItemStack stack, int side) {
boolean isManaItem = false;
if (stack != null && stack.getItem() instanceof IManaItem) {
IManaItem mana = (IManaItem) stack.getItem();
ISparkAttachable receiver = this.getReceiver();
if (receiver == null) return false;
isManaItem = mana.getMana(stack) < mana.getMaxMana(stack)
&& mana.canReceiveManaFromPool(stack, (TileEntity) receiver);
}
return side == 1 && slot != 0 && isManaItem;
}
public boolean canExtractItem(int slot, ItemStack stack, int side) {
boolean isManaItem = false;
if (stack != null && stack.getItem() instanceof IManaItem) {
IManaItem mana = (IManaItem) stack.getItem();
ISparkAttachable receiver = this.getReceiver();
if (receiver == null) return false;
isManaItem = mana.getMana(stack) == mana.getMaxMana(stack);
}
return side == 0 && slot != 0 && isManaItem;
}
}
@@ -3,128 +3,139 @@ package ab.common.block.tile;
import java.awt.Color;
import java.util.List;
import org.lwjgl.opengl.GL11;
import ab.client.core.ClientHelper;
import ab.common.core.handler.ConfigABHandler;
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.Botania;
import vazkii.botania.common.block.tile.TileMod;
import ab.client.core.ClientHelper;
import ab.common.core.handler.ConfigABHandler;
public class TileManaContainer extends TileMod implements IManaPool, ISparkAttachable {
protected int mana = 0;
int knownMana = -1;
protected int mana = 0;
int knownMana = -1;
public boolean canUpdate() {
return true;
}
public void updateEntity() {
if(this.worldObj.isRemote) {
double particleChance = 1.0D - getCurrentMana() / getMaxMana() * 0.1D;
Color color = new Color(50943);
if(Math.random() > particleChance)
Botania.proxy.wispFX(this.worldObj, this.xCoord + 0.5f + (Math.random() - 0.5) * 0.4f, this.yCoord + 0.81D + (Math.random() * 0.05D), this.zCoord + 0.5f + (Math.random() - 0.5) * 0.4f, color.getRed() / 255.0F, color.getGreen() / 255.0F, color.getBlue() / 255.0F, (float)Math.random() / 4.2F, (float)-Math.random() / 50.0F, 2.0F);
}
}
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." + worldObj.getBlockMetadata(xCoord, yCoord, zCoord) + ".hud");
int color = 0x30ead1;
ClientHelper.drawPoolManaHUD(res, name, this.knownMana, getMaxMana(), color);
}
public int getCurrentMana() {
return this.mana;
}
public boolean canRecieveManaFromBursts() {
return true;
}
public int getMaxMana() {
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
return ConfigABHandler.maxContainerMana[Math.min(Math.max(meta, 0), ConfigABHandler.maxContainerMana.length)];
}
public boolean isFull() {
return this.mana == getMaxMana();
}
public void updateEntity() {
if (this.worldObj.isRemote) {
double particleChance = 1.0D - getCurrentMana() / getMaxMana() * 0.1D;
Color color = new Color(50943);
if (Math.random() > particleChance) Botania.proxy.wispFX(
this.worldObj,
this.xCoord + 0.5f + (Math.random() - 0.5) * 0.4f,
this.yCoord + 0.81D + (Math.random() * 0.05D),
this.zCoord + 0.5f + (Math.random() - 0.5) * 0.4f,
color.getRed() / 255.0F,
color.getGreen() / 255.0F,
color.getBlue() / 255.0F,
(float) Math.random() / 4.2F,
(float) -Math.random() / 50.0F,
2.0F);
}
}
public void recieveMana(int mana) {
this.mana = Math.max(0, Math.min(getCurrentMana() + mana, getMaxMana()));
}
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 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 boolean areIncomingTranfersDone() {
return false;
}
public void renderHUD(Minecraft mc, ScaledResolution res) {
String name = StatCollector
.translateToLocal("ab.manaContainer." + worldObj.getBlockMetadata(xCoord, yCoord, zCoord) + ".hud");
int color = 0x30ead1;
ClientHelper.drawPoolManaHUD(res, name, this.knownMana, getMaxMana(), color);
}
public void attachSpark(ISparkEntity entity) {}
public int getCurrentMana() {
return this.mana;
}
public boolean canAttachSpark(ItemStack arg0) {
return true;
}
public boolean canRecieveManaFromBursts() {
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 getMaxMana() {
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
return ConfigABHandler.maxContainerMana[Math.min(Math.max(meta, 0), ConfigABHandler.maxContainerMana.length)];
}
public int getAvailableSpaceForMana() {
return Math.max(0, getMaxMana() - getCurrentMana());
}
public boolean isOutputtingPower() {
return false;
}
}
public boolean isFull() {
return this.mana == getMaxMana();
}
public void recieveMana(int mana) {
this.mana = Math.max(0, Math.min(getCurrentMana() + mana, getMaxMana()));
}
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, getMaxMana() - getCurrentMana());
}
public boolean isOutputtingPower() {
return false;
}
}
@@ -1,64 +1,49 @@
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;
import ab.api.IRenderHud;
import ab.client.core.ClientHelper;
public class TileManaCrystalCube extends TileMod implements IRenderHud {
int knownMana = -1;
int knownMaxMana = -1;
public boolean canUpdate() {
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(worldObj, xCoord, yCoord, zCoord);
for(ISparkEntity spark : allSparks) {
ISparkAttachable tileMana = spark.getAttachedTile();
mana[1] += tileMana.getCurrentMana() + tileMana.getAvailableSpaceForMana();
mana[0] += tileMana.getCurrentMana();
}
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");
}
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(worldObj, xCoord, yCoord, zCoord);
for (ISparkEntity spark : allSparks) {
ISparkAttachable tileMana = spark.getAttachedTile();
mana[1] += tileMana.getCurrentMana() + tileMana.getAvailableSpaceForMana();
mana[0] += tileMana.getCurrentMana();
}
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");
}
}
@@ -4,261 +4,288 @@ import java.awt.Color;
import java.util.List;
import java.util.Random;
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.client.core.handler.ClientTickHandler;
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;
import ab.api.AdvancedBotanyAPI;
import ab.api.recipe.RecipeAdvancedPlate;
public class TileNidavellirForge extends TileInventory implements ISparkAttachable, ISidedInventory {
private int mana;
public int manaToGet;
private RecipeAdvancedPlate currentRecipe;
private int recipeID;
public boolean requestUpdate;
public void updateEntity() {
if(!this.worldObj.isRemote)
updateServer();
else
updateClient();
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;
else if(otherSpark.getAttachedTile() != null && otherSpark.getAttachedTile() instanceof IManaPool)
otherSpark.registerTransfer(spark);
}
}
}
private void updateServer() {
if(requestUpdate)
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
boolean hasUpdate = false;
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.getEntityItem() != null && !item.isDead) {
ItemStack stack = item.getEntityItem();
int splitCount = addItemStack(stack);
stack.stackSize -= splitCount;
if(stack.stackSize <= 0)
item.setDead();
if(splitCount > 0)
hasUpdate = true;
break;
}
}
int wasManaToGet = this.manaToGet;
boolean hasCraft = false;
int recipeID = 0;
for(RecipeAdvancedPlate recipe : AdvancedBotanyAPI.advancedPlateRecipes) {
if(recipe.matches(this)) {
this.recipeID = recipeID;
if(this.mana > 0 && this.isFull()) {
ItemStack 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;
else
this.setInventorySlotContents(i, null);
}
if(this.getStackInSlot(0) != null)
++this.getStackInSlot(0).stackSize;
else
this.setInventorySlotContents(0, output);
hasUpdate = true;
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:terrasteelCraft", 1.0F, 2.0F);
break;
} else {
if(this.getStackInSlot(0) == null) {
this.manaToGet = recipe.getManaUsage();
currentRecipe = recipe;
hasCraft = true;
break;
} else if(isItemEqual(recipe.getOutput(), getStackInSlot(0)) && getStackInSlot(0).stackSize < recipe.getOutput().getMaxStackSize()) {
this.manaToGet = recipe.getManaUsage();
currentRecipe = recipe;
hasCraft = true;
break;
}
}
}
recipeID++;
}
if(!hasCraft) {
currentRecipe = null;
this.mana = 0;
this.manaToGet = 0;
}
if(this.manaToGet != wasManaToGet)
hasUpdate = true;
requestUpdate = hasUpdate;
}
private void updateClient() {
if(this.mana > 0) {
double worldTime = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks;
worldTime += (new Random((this.xCoord ^ this.yCoord ^ this.zCoord))).nextInt(360);
float indetY = (float)(Math.sin(worldTime / 18.0D) / 24.0D);
float ticks = 100.0F * 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) * 0.5D;
double g = Math.sin(wticks * Math.PI / 180.0D * 0.55D);
float size = 0.4f;
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 - indetY + 0.85D + Math.abs(r) * 0.7D;
double z = this.zCoord + Math.cos(wticks * Math.PI / 180.0D) * r + 0.5D;
wticks += tickIncrement;
int color = 0x24cce0;
if(currentRecipe != null)
color = currentRecipe.getColor();
float hsb[] = Color.RGBtoHSB(color & 255, color >> 8 & 255, color >> 16 & 255, null);
int color1 = Color.HSBtoRGB(hsb[0], hsb[1], ticks / 100.0F);
float[] colorsfx = { (color1 & 255) / 255.0f, (color1 >> 8 & 255) / 255.0f, (color1 >> 16 & 255) / 255.0f };
Botania.proxy.wispFX(this.worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], 0.85F * size, (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 * size, (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 < 12; j++)
Botania.proxy.wispFX(this.worldObj, this.xCoord + 0.5D, this.yCoord + 1.1D - indetY, this.zCoord + 0.5D, colorsfx[0], colorsfx[1], colorsfx[2], (float)Math.random() * 0.15F + 0.15F * size, (float)(Math.random() - 0.5D) * 0.125F * size, (float)(Math.random() - 0.5D) * 0.125F * size, (float)(Math.random() - 0.5D) * 0.125F * size, 0.8f);
}
}
}
public static boolean isItemEqual(ItemStack stack, ItemStack stack1) {
return stack.isItemEqual(stack1) && ItemStack.areItemStackTagsEqual(stack, stack1);
}
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(isItemEqual(stack, getStackInSlot(i))) {
if(getStackInSlot(i).stackSize < stack.getMaxStackSize()) {
int count = Math.min(stack.stackSize, stack.getMaxStackSize() - getStackInSlot(i).stackSize);
getStackInSlot(i).stackSize += count;
return count;
}
}
}
return 0;
}
public void writeCustomNBT(NBTTagCompound cmp) {
super.writeCustomNBT(cmp);
cmp.setInteger("mana", mana);
cmp.setInteger("manaToGet", manaToGet);
cmp.setBoolean("requestUpdate", requestUpdate);
cmp.setInteger("recipeID", currentRecipe == null ? -1 : recipeID);
}
public void readCustomNBT(NBTTagCompound cmp) {
super.readCustomNBT(cmp);
this.mana = cmp.getInteger("mana");
this.manaToGet = cmp.getInteger("manaToGet");
this.requestUpdate = cmp.getBoolean("requestUpdate");
int recipeID = cmp.getInteger("recipeID");
if(recipeID == -1)
this.currentRecipe = null;
else
this.currentRecipe = AdvancedBotanyAPI.advancedPlateRecipes.get(recipeID);
}
private int mana;
public int manaToGet;
private RecipeAdvancedPlate currentRecipe;
private int recipeID;
public boolean requestUpdate;
public int getSizeInventory() {
return 4;
}
public void updateEntity() {
if (!this.worldObj.isRemote) updateServer();
else updateClient();
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;
else if (otherSpark.getAttachedTile() != null && otherSpark.getAttachedTile() instanceof IManaPool)
otherSpark.registerTransfer(spark);
}
}
}
public String getInventoryName() {
return "tileAdvancedPlate";
}
private void updateServer() {
if (requestUpdate)
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
boolean hasUpdate = false;
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.getEntityItem() != null && !item.isDead) {
ItemStack stack = item.getEntityItem();
int splitCount = addItemStack(stack);
stack.stackSize -= splitCount;
if (stack.stackSize <= 0) item.setDead();
if (splitCount > 0) hasUpdate = true;
break;
}
}
int wasManaToGet = this.manaToGet;
boolean hasCraft = false;
int recipeID = 0;
for (RecipeAdvancedPlate recipe : AdvancedBotanyAPI.advancedPlateRecipes) {
if (recipe.matches(this)) {
this.recipeID = recipeID;
if (this.mana > 0 && this.isFull()) {
ItemStack 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;
else this.setInventorySlotContents(i, null);
}
if (this.getStackInSlot(0) != null) ++this.getStackInSlot(0).stackSize;
else this.setInventorySlotContents(0, output);
hasUpdate = true;
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:terrasteelCraft", 1.0F, 2.0F);
break;
} else {
if (this.getStackInSlot(0) == null) {
this.manaToGet = recipe.getManaUsage();
currentRecipe = recipe;
hasCraft = true;
break;
} else if (isItemEqual(recipe.getOutput(), getStackInSlot(0))
&& getStackInSlot(0).stackSize < recipe.getOutput().getMaxStackSize()) {
this.manaToGet = recipe.getManaUsage();
currentRecipe = recipe;
hasCraft = true;
break;
}
}
}
recipeID++;
}
if (!hasCraft) {
currentRecipe = null;
this.mana = 0;
this.manaToGet = 0;
}
if (this.manaToGet != wasManaToGet) hasUpdate = true;
requestUpdate = hasUpdate;
}
public int getCurrentMana() {
return this.mana;
}
private void updateClient() {
if (this.mana > 0) {
double worldTime = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks;
worldTime += (new Random((this.xCoord ^ this.yCoord ^ this.zCoord))).nextInt(360);
float indetY = (float) (Math.sin(worldTime / 18.0D) / 24.0D);
float ticks = 100.0F * 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) * 0.5D;
double g = Math.sin(wticks * Math.PI / 180.0D * 0.55D);
float size = 0.4f;
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 - indetY + 0.85D + Math.abs(r) * 0.7D;
double z = this.zCoord + Math.cos(wticks * Math.PI / 180.0D) * r + 0.5D;
wticks += tickIncrement;
int color = 0x24cce0;
if (currentRecipe != null) color = currentRecipe.getColor();
float hsb[] = Color.RGBtoHSB(color & 255, color >> 8 & 255, color >> 16 & 255, null);
int color1 = Color.HSBtoRGB(hsb[0], hsb[1], ticks / 100.0F);
float[] colorsfx = { (color1 & 255) / 255.0f, (color1 >> 8 & 255) / 255.0f,
(color1 >> 16 & 255) / 255.0f };
Botania.proxy.wispFX(
this.worldObj,
x,
y,
z,
colorsfx[0],
colorsfx[1],
colorsfx[2],
0.85F * size,
(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 * size,
(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 < 12; j++) Botania.proxy.wispFX(
this.worldObj,
this.xCoord + 0.5D,
this.yCoord + 1.1D - indetY,
this.zCoord + 0.5D,
colorsfx[0],
colorsfx[1],
colorsfx[2],
(float) Math.random() * 0.15F + 0.15F * size,
(float) (Math.random() - 0.5D) * 0.125F * size,
(float) (Math.random() - 0.5D) * 0.125F * size,
(float) (Math.random() - 0.5D) * 0.125F * size,
0.8f);
}
}
}
public boolean isFull() {
return this.mana >= this.manaToGet;
}
public static boolean isItemEqual(ItemStack stack, ItemStack stack1) {
return stack.isItemEqual(stack1) && ItemStack.areItemStackTagsEqual(stack, stack1);
}
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 side) {
return new int[]{0, 1, 2, 3};
}
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 (isItemEqual(stack, getStackInSlot(i))) {
if (getStackInSlot(i).stackSize < stack.getMaxStackSize()) {
int count = Math.min(stack.stackSize, stack.getMaxStackSize() - getStackInSlot(i).stackSize);
getStackInSlot(i).stackSize += count;
return count;
}
}
}
return 0;
}
public boolean canInsertItem(int slot, ItemStack stack, int side) {
for(int i = 1; i < getSizeInventory(); i++) {
ItemStack slotStack = getStackInSlot(i);
if(slotStack != null && slotStack.stackSize == slotStack.getMaxStackSize() && isItemEqual(stack, slotStack))
return false;
}
return side == 1 && slot != 0;
}
public void writeCustomNBT(NBTTagCompound cmp) {
super.writeCustomNBT(cmp);
cmp.setInteger("mana", mana);
cmp.setInteger("manaToGet", manaToGet);
cmp.setBoolean("requestUpdate", requestUpdate);
cmp.setInteger("recipeID", currentRecipe == null ? -1 : recipeID);
}
public boolean canExtractItem(int slot, ItemStack stack, int side) {
return (side == 0 && slot == 0) || (side != 0 && side != 1 && slot != 0);
}
}
public void readCustomNBT(NBTTagCompound cmp) {
super.readCustomNBT(cmp);
this.mana = cmp.getInteger("mana");
this.manaToGet = cmp.getInteger("manaToGet");
this.requestUpdate = cmp.getBoolean("requestUpdate");
int recipeID = cmp.getInteger("recipeID");
if (recipeID == -1) this.currentRecipe = null;
else this.currentRecipe = AdvancedBotanyAPI.advancedPlateRecipes.get(recipeID);
}
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 side) {
return new int[] { 0, 1, 2, 3 };
}
public boolean canInsertItem(int slot, ItemStack stack, int side) {
for (int i = 1; i < getSizeInventory(); i++) {
ItemStack slotStack = getStackInSlot(i);
if (slotStack != null && slotStack.stackSize == slotStack.getMaxStackSize()
&& isItemEqual(stack, slotStack))
return false;
}
return side == 1 && slot != 0;
}
public boolean canExtractItem(int slot, ItemStack stack, int side) {
return (side == 0 && slot == 0) || (side != 0 && side != 1 && slot != 0);
}
}