Rest of root package TE

This commit is contained in:
Vincent Lee committed 2015-11-24 00:49:57 -06:00
1 parent b72be67dd7
commit 605e38337a
10 files changed
+207 -209

No files matched your search

@@ -18,6 +18,7 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.gui.IUpdatePlayerListBox;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.MinecraftForge;
@@ -37,7 +38,7 @@ import vazkii.botania.common.lexicon.LexiconData;
import com.google.common.base.Function;
public class TileAlfPortal extends TileMod {
public class TileAlfPortal extends TileMod implements IUpdatePlayerListBox {
private static final int[][] LIVINGWOOD_POSITIONS = {
{ -1, 0, 0}, { 1, 0, 0}, { -2, 1, 0}, { 2, 1, 0}, { -2, 3, 0}, { 2, 3, 0}, { -1, 4, 0}, { 1, 4, 0}
@@ -112,7 +113,7 @@ public class TileAlfPortal extends TileMod {
}
@Override
public void updateEntity() {
public void update() {
int meta = getBlockMetadata();
if(meta == 0) {
ticksOpen = 0;
@@ -178,7 +179,7 @@ public class TileAlfPortal extends TileMod {
pos = CONVERTER_X_Z_FP.apply(pos);
float motionMul = 0.2F;
Botania.proxy.wispFX(getWorld(), xCoord + pos[0], yCoord + pos[1], zCoord + pos[2], (float) (Math.random() * 0.25F), (float) (Math.random() * 0.5F + 0.5F), (float) (Math.random() * 0.25F), (float) (Math.random() * 0.15F + 0.1F), (float) (Math.random() - 0.5F) * motionMul, (float) (Math.random() - 0.5F) * motionMul, (float) (Math.random() - 0.5F) * motionMul);
Botania.proxy.wispFX(getWorld(), getPos().getX() + pos[0], getPos().getY() + pos[1], getPos().getZ() + pos[2], (float) (Math.random() * 0.25F), (float) (Math.random() * 0.5F + 0.5F), (float) (Math.random() * 0.25F), (float) (Math.random() * 0.15F + 0.1F), (float) (Math.random() - 0.5F) * motionMul, (float) (Math.random() - 0.5F) * motionMul, (float) (Math.random() - 0.5F) * motionMul);
}
public boolean onWanded() {
@@ -195,9 +196,9 @@ public class TileAlfPortal extends TileMod {
}
AxisAlignedBB getPortalAABB() {
AxisAlignedBB aabb = new AxisAlignedBB(xCoord - 1, yCoord + 1, zCoord, xCoord + 2, yCoord + 4, zCoord + 1);
AxisAlignedBB aabb = new AxisAlignedBB(pos.add(-1, 1, 0), pos.add(2, 4, 1));
if(getBlockMetadata() == 2)
aabb = new AxisAlignedBB(xCoord, yCoord + 1, zCoord - 1, xCoord + 1, yCoord + 4, zCoord + 2);
aabb = new AxisAlignedBB(pos.add(0, 1, -1), pos.add(1, 4, 2));
return aabb;
}
@@ -232,7 +233,7 @@ public class TileAlfPortal extends TileMod {
}
void spawnItem(ItemStack stack) {
EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, stack);
EntityItem item = new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, stack);
item.getEntityData().setBoolean(TAG_PORTAL_FLAG, true);
worldObj.spawnEntityInWorld(item);
ticksSinceLastItem = 0;
@@ -322,9 +323,7 @@ public class TileAlfPortal extends TileMod {
if(tile instanceof TilePylon) {
TilePylon pylon = (TilePylon) tile;
pylon.activated = true;
pylon.centerX = xCoord;
pylon.centerY = yCoord;
pylon.centerZ = zCoord;
pylon.centerPos = getPos();
}
tile = worldObj.getTileEntity(xCoord + pos[0], yCoord + pos[1] - 1, zCoord + pos[2]);
@@ -25,7 +25,10 @@ import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.gui.IUpdatePlayerListBox;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.api.item.IPetalApothecary;
@@ -34,7 +37,7 @@ import vazkii.botania.api.recipe.RecipePetals;
import vazkii.botania.common.Botania;
import vazkii.botania.common.lib.LibBlockNames;
public class TileAltar extends TileSimpleInventory implements ISidedInventory, IPetalApothecary {
public class TileAltar extends TileSimpleInventory implements ISidedInventory, IPetalApothecary, IUpdatePlayerListBox {
private static final Pattern SEED_PATTERN = Pattern.compile("(?:(?:(?:[A-Z-_.:]|^)seed)|(?:(?:[a-z-_.:]|^)Seed))(?:[sA-Z-_.:]|$)");
@@ -58,23 +61,23 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory, I
if(!isMossy && getBlockMetadata() == 0) {
if(stack.getItem() == Item.getItemFromBlock(Blocks.vine) && !worldObj.isRemote) {
isMossy = true;
worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
worldObj.updateComparatorOutputLevel(pos, worldObj.getBlockState(pos).getBlock());
stack.stackSize--;
if(stack.stackSize == 0)
item.setDead();
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, , xCoord);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, pos);
}
}
if(!hasWater() && !hasLava()) {
if(stack.getItem() == Items.water_bucket && !worldObj.isRemote) {
setWater(true);
worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
stack.func_150996_a(Items.bucket); // Set item
worldObj.updateComparatorOutputLevel(pos, worldObj.getBlockState(pos).getBlock());
stack.setItem(Items.bucket);
} else if(stack.getItem() == Items.lava_bucket && !worldObj.isRemote) {
setLava(true);
worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
stack.func_150996_a(Items.bucket); // Set item
worldObj.updateComparatorOutputLevel(pos, worldObj.getBlockState(pos).getBlock());
stack.setItem(Items.bucket);
} else return false;
}
@@ -118,11 +121,11 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory, I
item.setDead();
ItemStack output = recipe.getOutput().copy();
EntityItem outputItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output);
EntityItem outputItem = new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, output);
worldObj.spawnEntityInWorld(outputItem);
setWater(false);
worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
worldObj.updateComparatorOutputLevel(pos, worldObj.getBlockState(pos).getBlock());
}
craftingFanciness();
@@ -150,7 +153,7 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory, I
public void trySetLastRecipe(EntityPlayer player) {
tryToSetLastRecipe(player, this, lastRecipe);
if(!isEmpty())
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, , xCoord);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, pos);
}
public static void tryToSetLastRecipe(EntityPlayer player, IInventory inv, List<ItemStack> lastRecipe) {
@@ -191,12 +194,12 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory, I
}
public void craftingFanciness() {
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:altarCraft", 1F, 1F);
worldObj.playSoundEffect(pos.getX(), pos.getY(), pos.getZ(), "botania:altarCraft", 1F, 1F);
for(int i = 0; i < 25; i++) {
float red = (float) Math.random();
float green = (float) Math.random();
float blue = (float) Math.random();
Botania.proxy.sparkleFX(worldObj, xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10);
Botania.proxy.sparkleFX(worldObj, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10);
}
}
@@ -209,8 +212,8 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory, I
}
@Override
public void updateEntity() {
List<EntityItem> items = worldObj.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(xCoord, yCoord + 1D / 16D * 20D, zCoord, xCoord + 1, yCoord + 1D / 16D * 21D, zCoord + 1));
public void update() {
List<EntityItem> items = worldObj.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos.add(0, 1D / 16D * 20D, 0), pos.add(1, 1D / 16D * 21D,1)));
boolean didChange = false;
@@ -218,7 +221,7 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory, I
didChange = collideEntityItem(item) || didChange;
if(didChange)
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, , xCoord);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, pos);
for(int i = 0; i < getSizeInventory(); i++) {
ItemStack stackAt = getStackInSlot(i);
@@ -231,16 +234,16 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory, I
float green = color.getGreen() / 255F;
float blue = color.getBlue() / 255F;
if(Math.random() >= 0.75F)
worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "game.neutral.swim.splash", 0.1F, 10F);
Botania.proxy.sparkleFX(worldObj, xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10);
worldObj.playSoundEffect(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, "game.neutral.swim.splash", 0.1F, 10F);
Botania.proxy.sparkleFX(worldObj, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10);
}
}
if(hasLava()) {
isMossy = false;
worldObj.spawnParticle("smoke", xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, 0, 0.05, 0);
worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, 0, 0.05, 0);
if(Math.random() > 0.9)
worldObj.spawnParticle("lava", xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, 0, 0.01, 0);
worldObj.spawnParticle(EnumParticleTypes.LAVA, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, 0, 0.01, 0);
}
if(recipeKeepTicks > 0)
@@ -267,7 +270,7 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory, I
}
@Override
public String getInventoryName() {
public String getCommandSenderName() {
return LibBlockNames.ALTAR;
}
@@ -287,29 +290,29 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory, I
}
@Override
public int[] getAccessibleSlotsFromSide(int var1) {
public int[] getSlotsForFace(EnumFacing var1) {
return new int[0];
}
@Override
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
public boolean canInsertItem(int i, ItemStack itemstack, EnumFacing j) {
return false;
}
@Override
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
public boolean canExtractItem(int i, ItemStack itemstack, EnumFacing j) {
return false;
}
@Override
public void setWater(boolean water) {
hasWater = water;
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, , xCoord);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, pos);
}
public void setLava(boolean lava) {
hasLava = lava;
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, , xCoord);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, pos);
}
@Override
@@ -13,12 +13,13 @@ package vazkii.botania.common.block.tile;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.server.gui.IUpdatePlayerListBox;
import net.minecraft.util.EnumFacing;
import vazkii.botania.api.item.IAvatarTile;
import vazkii.botania.api.item.IAvatarWieldable;
import vazkii.botania.common.lib.LibBlockNames;
public class TileAvatar extends TileSimpleInventory implements IAvatarTile, ISidedInventory {
public class TileAvatar extends TileSimpleInventory implements IAvatarTile, ISidedInventory, IUpdatePlayerListBox {
private static final int MAX_MANA = 6400;
@@ -31,12 +32,11 @@ public class TileAvatar extends TileSimpleInventory implements IAvatarTile, ISid
int mana;
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
enabled = true;
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
int redstoneSide = worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal());
for(EnumFacing dir : EnumFacing.VALUES) {
int redstoneSide = worldObj.getRedstonePower(pos.offset(dir), dir);
if(redstoneSide > 0) {
enabled = false;
break;
@@ -85,22 +85,22 @@ public class TileAvatar extends TileSimpleInventory implements IAvatarTile, ISid
}
@Override
public int[] getAccessibleSlotsFromSide(int p_94128_1_) {
public int[] getSlotsForFace(EnumFacing p_94128_1_) {
return new int[0];
}
@Override
public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) {
public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, EnumFacing p_102007_3_) {
return false;
}
@Override
public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) {
public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, EnumFacing p_102008_3_) {
return false;
}
@Override
public String getInventoryName() {
public String getCommandSenderName() {
return LibBlockNames.AVATAR;
}
@@ -20,7 +20,9 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.gui.IUpdatePlayerListBox;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.EnumFacing;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.brew.IBrewContainer;
import vazkii.botania.api.brew.IBrewItem;
@@ -32,7 +34,7 @@ import vazkii.botania.common.Botania;
import vazkii.botania.common.lib.LibBlockNames;
// This is mostly copypasta from TileRuneAltar
public class TileBrewery extends TileSimpleInventory implements ISidedInventory, IManaReceiver {
public class TileBrewery extends TileSimpleInventory implements ISidedInventory, IManaReceiver, IUpdatePlayerListBox {
private static final String TAG_MANA = "mana";
@@ -64,11 +66,11 @@ public class TileBrewery extends TileSimpleInventory implements ISidedInventory,
}
if(did) {
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, , xCoord);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, pos);
for(RecipeBrew recipe : BotaniaAPI.brewRecipes)
if(recipe.matches(this) && recipe.getOutput(getStackInSlot(0)) != null) {
this.recipe = recipe;
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2);
worldObj.setBlockMetadataWithNotify(pos.getX(), pos.getY(), pos.getZ(), 1, 1 | 2);
}
}
@@ -76,14 +78,13 @@ public class TileBrewery extends TileSimpleInventory implements ISidedInventory,
}
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
if(mana > 0 && recipe == null) {
for(RecipeBrew recipe : BotaniaAPI.brewRecipes)
if(recipe.matches(this)) {
this.recipe = recipe;
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2);
worldObj.setBlockMetadataWithNotify(pos.getX(), pos.getY(), pos.getZ(), 1, 1 | 2);
}
if(recipe == null)
@@ -94,7 +95,7 @@ public class TileBrewery extends TileSimpleInventory implements ISidedInventory,
recieveMana(0);
if(!worldObj.isRemote && recipe == null) {
List<EntityItem> items = worldObj.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1));
List<EntityItem> items = worldObj.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1));
for(EntityItem item : items)
if(!item.isDead && item.getEntityItem() != null) {
ItemStack stack = item.getEntityItem();
@@ -106,7 +107,7 @@ public class TileBrewery extends TileSimpleInventory implements ISidedInventory,
if(recipe != null) {
if(!recipe.matches(this)) {
recipe = null;
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 1 | 2);
worldObj.setBlockMetadataWithNotify(pos.getX(), pos.getY(), pos.getZ(), 0, 1 | 2);
}
if(recipe != null) {
@@ -116,9 +117,9 @@ public class TileBrewery extends TileSimpleInventory implements ISidedInventory,
float g = color.getGreen() / 255F;
float b = color.getBlue() / 255F;
for(int i = 0; i < 5; i++) {
Botania.proxy.wispFX(worldObj, xCoord + 0.7 - Math.random() * 0.4, yCoord + 0.9 - Math.random() * 0.2, zCoord + 0.7 - Math.random() * 0.4, r, g, b, 0.1F + (float) Math.random() * 0.05F, 0.03F - (float) Math.random() * 0.06F, 0.03F + (float) Math.random() * 0.015F, 0.03F - (float) Math.random() * 0.06F);
Botania.proxy.wispFX(worldObj, pos.getX() + 0.7 - Math.random() * 0.4, pos.getY() + 0.9 - Math.random() * 0.2, pos.getZ() + 0.7 - Math.random() * 0.4, r, g, b, 0.1F + (float) Math.random() * 0.05F, 0.03F - (float) Math.random() * 0.06F, 0.03F + (float) Math.random() * 0.015F, 0.03F - (float) Math.random() * 0.06F);
for(int j = 0; j < 2; j++)
Botania.proxy.wispFX(worldObj, xCoord + 0.7 - Math.random() * 0.4, yCoord + 0.9 - Math.random() * 0.2, zCoord + 0.7 - Math.random() * 0.4, 0.2F, 0.2F, 0.2F, 0.1F + (float) Math.random() * 0.2F, 0.03F - (float) Math.random() * 0.06F, 0.03F + (float) Math.random() * 0.015F, 0.03F - (float) Math.random() * 0.06F);
Botania.proxy.wispFX(worldObj, pos.getX() + 0.7 - Math.random() * 0.4, pos.getY() + 0.9 - Math.random() * 0.2, pos.getZ() + 0.7 - Math.random() * 0.4, 0.2F, 0.2F, 0.2F, 0.1F + (float) Math.random() * 0.2F, 0.03F - (float) Math.random() * 0.06F, 0.03F + (float) Math.random() * 0.015F, 0.03F - (float) Math.random() * 0.06F);
}
}
@@ -127,7 +128,7 @@ public class TileBrewery extends TileSimpleInventory implements ISidedInventory,
recieveMana(-mana);
if(!worldObj.isRemote) {
ItemStack output = recipe.getOutput(getStackInSlot(0));
EntityItem outputItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output);
EntityItem outputItem = new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, output);
worldObj.spawnEntityInWorld(outputItem);
}
@@ -145,7 +146,7 @@ public class TileBrewery extends TileSimpleInventory implements ISidedInventory,
if(newSignal != signal) {
signal = newSignal;
worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
worldObj.updateComparatorOutputLevel(pos, worldObj.getBlockState(pos).getBlock());
}
manaLastTick = mana;
@@ -160,15 +161,15 @@ public class TileBrewery extends TileSimpleInventory implements ISidedInventory,
}
public void craftingFanciness() {
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:potionCreate", 1F, 1.5F + (float) Math.random() * 0.25F);
worldObj.playSoundEffect(pos.getX(), pos.getY(), pos.getZ(), "botania:potionCreate", 1F, 1.5F + (float) Math.random() * 0.25F);
for(int i = 0; i < 25; i++) {
Color color = new Color(recipe.getBrew().getColor(getStackInSlot(0)));
float r = color.getRed() / 255F;
float g = color.getGreen() / 255F;
float b = color.getBlue() / 255F;
Botania.proxy.sparkleFX(worldObj, xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, r, g, b, (float) Math.random() * 2F + 0.5F, 10);
Botania.proxy.sparkleFX(worldObj, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, r, g, b, (float) Math.random() * 2F + 0.5F, 10);
for(int j = 0; j < 2; j++)
Botania.proxy.wispFX(worldObj, xCoord + 0.7 - Math.random() * 0.4, yCoord + 0.9 - Math.random() * 0.2, zCoord + 0.7 - Math.random() * 0.4, 0.2F, 0.2F, 0.2F, 0.1F + (float) Math.random() * 0.2F, 0.05F - (float) Math.random() * 0.1F, 0.05F + (float) Math.random() * 0.03F, 0.05F - (float) Math.random() * 0.1F);
Botania.proxy.wispFX(worldObj, pos.getX() + 0.7 - Math.random() * 0.4, pos.getY() + 0.9 - Math.random() * 0.2, pos.getZ() + 0.7 - Math.random() * 0.4, 0.2F, 0.2F, 0.2F, 0.1F + (float) Math.random() * 0.2F, 0.05F - (float) Math.random() * 0.1F, 0.05F + (float) Math.random() * 0.03F, 0.05F - (float) Math.random() * 0.1F);
}
}
@@ -197,7 +198,7 @@ public class TileBrewery extends TileSimpleInventory implements ISidedInventory,
}
@Override
public String getInventoryName() {
public String getCommandSenderName() {
return LibBlockNames.RUNE_ALTAR;
}
@@ -207,7 +208,7 @@ public class TileBrewery extends TileSimpleInventory implements ISidedInventory,
}
@Override
public int[] getAccessibleSlotsFromSide(int var1) {
public int[] getSlotsForFace(EnumFacing var1) {
int accessibleSlot = -1;
for(int i = 0; i < getSizeInventory(); i++)
if(getStackInSlot(i) != null)
@@ -217,12 +218,12 @@ public class TileBrewery extends TileSimpleInventory implements ISidedInventory,
}
@Override
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
public boolean canInsertItem(int i, ItemStack itemstack, EnumFacing j) {
return true;
}
@Override
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
public boolean canExtractItem(int i, ItemStack itemstack, EnumFacing j) {
return mana == 0;
}
@@ -25,6 +25,7 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.server.gui.IUpdatePlayerListBox;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
@@ -42,7 +43,7 @@ import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.ModBlocks;
public class TileEnchanter extends TileMod implements ISparkAttachable {
public class TileEnchanter extends TileMod implements ISparkAttachable, IUpdatePlayerListBox {
private static final String TAG_STAGE = "stage";
private static final String TAG_STAGE_TICKS = "stageTicks";
@@ -63,37 +64,37 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
public ItemStack itemToEnchant = null;
List<EnchantmentData> enchants = new ArrayList();
private static final int[][] OBSIDIAN_LOCATIONS = new int[][] {
{ 0, -1, 0 },
{ 0, -1, 1 }, { 0, -1, -1 }, { 1, -1, 0 }, { -1, -1, 0 },
{ 0, -1, 2 }, { -1, -1, 2 }, { 1, -1, 2 },
{ 0, -1, -2 }, { -1, -1, -2 }, { 1, -1, -2 },
{ 2, -1, 0 }, { 2, -1, 1 }, { 2, -1, -1 },
{ -2, -1, 0 }, { -2, -1, 1 }, { -2, -1, -1 }
private static final BlockPos[] OBSIDIAN_LOCATIONS = {
new BlockPos(0, -1, 0),
new BlockPos(0, -1, 1), new BlockPos(0, -1, -1), new BlockPos(1, -1, 0), new BlockPos(-1, -1, 0),
new BlockPos(0, -1, 2), new BlockPos(-1, -1, 2), new BlockPos(1, -1, 2),
new BlockPos(0, -1, -2), new BlockPos(-1, -1, -2), new BlockPos(1, -1, -2),
new BlockPos(2, -1, 0), new BlockPos(2, -1, 1), new BlockPos(2, -1, -1 ),
new BlockPos(-2, -1, 0), new BlockPos(-2, -1, 1), new BlockPos(-2, -1, -1)
};
private static final int[][][] PYLON_LOCATIONS = new int[][][] {
{ { -5, 1, 0 }, { 5, 1, 0 }, { -4, 1, 3 }, { 4, 1, 3 }, { -4, 1, -3 }, { 4, 1, -3 } },
{ { 0, 1, -5 }, { 0, 1, 5 }, { 3, 1, -4 }, { 3, 1, 4 }, { -3, 1, -4 }, { -3, 1, 4 } }
private static final BlockPos[][] PYLON_LOCATIONS = {
{ new BlockPos(-5, 1, 0), new BlockPos(5, 1, 0), new BlockPos(-4, 1, 3), new BlockPos(4, 1, 3), new BlockPos(-4, 1, -3 ), new BlockPos(4, 1, -3) },
{ new BlockPos(0, 1, -5), new BlockPos(0, 1, 5), new BlockPos(3, 1, -4), new BlockPos(3, 1, 4), new BlockPos(-3, 1, -4 ), new BlockPos(-3, 1, 4) }
};
private static final int[][] FLOWER_LOCATIONS = new int[][] {
{ -1, 0, -1 }, { 1, 0, -1 }, { -1, 0, 1 }, { 1, 0, 1 }
private static final BlockPos[] FLOWER_LOCATIONS = {
new BlockPos(-1, 0, -1), new BlockPos(1, 0, -1), new BlockPos(-1, 0, 1), new BlockPos(1, 0, 1)
};
public static MultiblockSet makeMultiblockSet() {
Multiblock mb = new Multiblock();
for(int[] o : OBSIDIAN_LOCATIONS)
mb.addComponent(, o[0], Blocks.obsidian, 0);
for(int[] p : PYLON_LOCATIONS[0]) {
mb.addComponent(, p[0], ModBlocks.pylon, 0);
mb.addComponent(new FlowerComponent(new BlockPos(p[0], p[1], p[2]), ModBlocks.flower));
for(BlockPos o : OBSIDIAN_LOCATIONS)
mb.addComponent(o, Blocks.obsidian, 0);
for(BlockPos p : PYLON_LOCATIONS[0]) {
mb.addComponent(p, ModBlocks.pylon, 0);
mb.addComponent(new FlowerComponent(p, ModBlocks.flower));
}
for(int[] f : FLOWER_LOCATIONS)
mb.addComponent(new FlowerComponent(new BlockPos(f[0], f[1] + 1, f[2]), ModBlocks.flower));
for(BlockPos f : FLOWER_LOCATIONS)
mb.addComponent(new FlowerComponent(f, ModBlocks.flower));
mb.addComponent(, 0, Blocks.lapis_block, 0);
mb.addComponent(BlockPos.ORIGIN, Blocks.lapis_block, 0); // todo 1.8 recheck
return mb.makeSet();
}
@@ -102,14 +103,14 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
if(stage != 0 || itemToEnchant == null || !itemToEnchant.isItemEnchantable())
return;
List<EntityItem> items = worldObj.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(xCoord - 2, yCoord, zCoord - 2, xCoord + 3, yCoord + 1, zCoord + 3));
List<EntityItem> items = worldObj.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos.getX() - 2, pos.getY(), pos.getZ() - 2, pos.getX() + 3, pos.getY() + 1, pos.getZ() + 3));
int count = items.size();
if(count > 0 && !worldObj.isRemote) {
for(EntityItem entity : items) {
ItemStack item = entity.getEntityItem();
if(item.getItem() == Items.enchanted_book) {
NBTTagList enchants = Items.enchanted_book.func_92110_g(item);
NBTTagList enchants = Items.enchanted_book.getEnchantments(item);
if(enchants != null && enchants.tagCount() > 0) {
NBTTagCompound enchant = enchants.getCompoundTagAt(0);
short id = enchant.getShort("id");
@@ -124,30 +125,30 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
}
@Override
public void updateEntity() {
public void update() {
if(getBlockMetadata() < PYLON_LOCATIONS.length)
for(int[] pylon : PYLON_LOCATIONS[getBlockMetadata()]) {
TileEntity tile = worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2]);
for(BlockPos pylon : PYLON_LOCATIONS[getBlockMetadata()]) {
TileEntity tile = worldObj.getTileEntity(pos.add(pylon));
if(tile != null && tile instanceof TilePylon)
((TilePylon) tile).activated = false;
}
if(!canEnchanterExist(worldObj, xCoord, yCoord, zCoord, getBlockMetadata())) {
if(!canEnchanterExist(worldObj, pos, getBlockMetadata())) {
worldObj.setBlock(xCoord, yCoord, zCoord, Blocks.lapis_block, 0, 1 | 2);
worldObj.setBlockState(pos, Blocks.lapis_block.getDefaultState(), 1 | 2);
for(int i = 0; i < 50; i++) {
float red = (float) Math.random();
float green = (float) Math.random();
float blue = (float) Math.random();
Botania.proxy.wispFX(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, red, green, blue, (float) Math.random() * 0.15F + 0.15F, (float) (Math.random() - 0.5F) * 0.25F, (float) (Math.random() - 0.5F) * 0.25F, (float) (Math.random() - 0.5F) * 0.25F);
Botania.proxy.wispFX(worldObj, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, red, green, blue, (float) Math.random() * 0.15F + 0.15F, (float) (Math.random() - 0.5F) * 0.25F, (float) (Math.random() - 0.5F) * 0.25F, (float) (Math.random() - 0.5F) * 0.25F);
}
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:enchanterBlock", 0.5F, 10F);
worldObj.playSoundEffect(pos.getX(), pos.getY(), pos.getZ(), "botania:enchanterBlock", 0.5F, 10F);
}
switch(stage) {
case 1 : { // Get books
if(stageTicks % 20 == 0) {
List<EntityItem> items = worldObj.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(xCoord - 2, yCoord, zCoord - 2, xCoord + 3, yCoord + 1, zCoord + 3));
List<EntityItem> items = worldObj.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos.getX() - 2, pos.getY(), pos.getZ() - 2, pos.getX() + 3, pos.getY() + 1, pos.getZ() + 3));
int count = items.size();
boolean addedEnch = false;
@@ -155,14 +156,14 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
for(EntityItem entity : items) {
ItemStack item = entity.getEntityItem();
if(item.getItem() == Items.enchanted_book) {
NBTTagList enchants = Items.enchanted_book.func_92110_g(item);
NBTTagList enchants = Items.enchanted_book.getEnchantments(item);
if(enchants != null && enchants.tagCount() > 0) {
NBTTagCompound enchant = enchants.getCompoundTagAt(0);
short enchantId = enchant.getShort("id");
short enchantLvl = enchant.getShort("lvl");
if(!hasEnchantAlready(enchantId) && isEnchantmentValid(enchantId)) {
this.enchants.add(new EnchantmentData(enchantId, enchantLvl));
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:ding", 1F, 1F);
worldObj.playSoundEffect(pos.getX(), pos.getY(), pos.getZ(), "botania:ding", 1F, 1F);
addedEnch = true;
break;
}
@@ -180,32 +181,30 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
break;
}
case 2 : { // Get Mana
for(int[] pylon : PYLON_LOCATIONS[getBlockMetadata()]) {
TilePylon pylonTile = (TilePylon) worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2]);
for(BlockPos pylon : PYLON_LOCATIONS[getBlockMetadata()]) {
TilePylon pylonTile = (TilePylon) worldObj.getTileEntity(pos.add(pylon));
if(pylonTile != null) {
pylonTile.activated = true;
pylonTile.centerX = xCoord;
pylonTile.centerY = yCoord;
pylonTile.centerZ = zCoord;
pylonTile .centerPos = pos;
}
}
if(manaRequired == -1) {
manaRequired = 0;
for(EnchantmentData data : enchants) {
Enchantment ench = Enchantment.enchantmentsList[data.enchant];
Enchantment ench = Enchantment.getEnchantmentById(data.enchant);
manaRequired += (int) (5000F * ((15 - Math.min(15, ench.getWeight())) * 1.05F) * ((3F + data.level * data.level) * 0.25F) * (0.9F + enchants.size() * 0.05F));
}
} else if(mana >= manaRequired) {
manaRequired = 0;
for(int[] pylon : PYLON_LOCATIONS[getBlockMetadata()])
((TilePylon) worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2])).activated = false;
for(BlockPos pylon : PYLON_LOCATIONS[getBlockMetadata()])
((TilePylon) worldObj.getTileEntity(pos.add(pylon))).activated = false;
advanceStage();
} else {
ISparkEntity spark = getAttachedSpark();
if(spark != null) {
List<ISparkEntity> sparkEntities = SparkHelper.getSparksAround(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5);
List<ISparkEntity> sparkEntities = SparkHelper.getSparksAround(worldObj, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
for(ISparkEntity otherSpark : sparkEntities) {
if(spark == otherSpark)
continue;
@@ -222,7 +221,7 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
if(stageTicks >= 100) {
for(EnchantmentData data : enchants)
if(EnchantmentHelper.getEnchantmentLevel(data.enchant, itemToEnchant) == 0)
itemToEnchant.addEnchantment(Enchantment.enchantmentsList[data.enchant], data.level);
itemToEnchant.addEnchantment(Enchantment.getEnchantmentById(data.enchant), data.level);
enchants.clear();
manaRequired = -1;
@@ -260,12 +259,12 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
}
public void craftingFanciness() {
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:enchanterEnchant", 1F, 1F);
worldObj.playSoundEffect(pos.getX(), pos.getY(), pos.getZ(), "botania:enchanterEnchant", 1F, 1F);
for(int i = 0; i < 25; i++) {
float red = (float) Math.random();
float green = (float) Math.random();
float blue = (float) Math.random();
Botania.proxy.sparkleFX(worldObj, xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10);
Botania.proxy.sparkleFX(worldObj, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10);
}
}
@@ -295,7 +294,7 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
}
public void sync() {
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, , xCoord);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, pos);
}
@Override
@@ -350,12 +349,12 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
}
public boolean isEnchantmentValid(short id) {
Enchantment ench = Enchantment.enchantmentsList[id];
Enchantment ench = Enchantment.getEnchantmentById(id);
if(!ench.canApply(itemToEnchant) || !ench.type.canEnchantItem(itemToEnchant.getItem()))
return false;
for(EnchantmentData data : enchants) {
Enchantment otherEnch = Enchantment.enchantmentsList[data.enchant];
Enchantment otherEnch = Enchantment.getEnchantmentById(data.enchant);
if(!otherEnch.canApplyTogether(ench) || !ench.canApplyTogether(otherEnch))
return false;
}
@@ -363,17 +362,17 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
return true;
}
public static boolean canEnchanterExist(World world, int x, int y, int z, int meta) {
for(int[] obsidian : OBSIDIAN_LOCATIONS)
if(world.getBlock(obsidian[0] + x, obsidian[1] + y, obsidian[2] + z) != Blocks.obsidian)
public static boolean canEnchanterExist(World world, BlockPos pos, int meta) {
for(BlockPos obsidian : OBSIDIAN_LOCATIONS)
if(world.getBlockState(pos.add(obsidian)).getBlock() != Blocks.obsidian)
return false;
for(int[] pylon : PYLON_LOCATIONS[meta])
if(world.getBlock(pylon[0] + x, pylon[1] + y, pylon[2] + z) != ModBlocks.pylon || !BotaniaAPI.internalHandler.isBotaniaFlower(, world, , pylon[0] + x))
for(BlockPos pylon : PYLON_LOCATIONS[meta])
if(world.getBlockState(pos.add(pylon)).getBlock() != ModBlocks.pylon || !BotaniaAPI.internalHandler.isBotaniaFlower(world, pos.add(pylon)))
return false;
for(int[] flower : FLOWER_LOCATIONS)
if(!BotaniaAPI.internalHandler.isBotaniaFlower(, world, , flower[0] + x))
for(BlockPos flower : FLOWER_LOCATIONS)
if(!BotaniaAPI.internalHandler.isBotaniaFlower(world, pos.add(flower)))
return false;
return true;
@@ -391,7 +390,7 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
@Override
public ISparkEntity getAttachedSpark() {
List<ISparkEntity> sparks = worldObj.getEntitiesWithinAABB(ISparkEntity.class, new AxisAlignedBB(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1));
List<ISparkEntity> sparks = worldObj.getEntitiesWithinAABB(ISparkEntity.class, new AxisAlignedBB(pos.getX(), pos.getY() + 1, pos.getZ(), pos.getX() + 1, pos.getY() + 2, pos.getZ() + 1));
if(sparks.size() == 1) {
Entity e = (Entity) sparks.get(0);
return (ISparkEntity) e;
@@ -12,6 +12,7 @@ package vazkii.botania.common.block.tile;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import vazkii.botania.common.block.subtile.functional.SubTileBubbell;
public class TileFakeAir extends TileMod {
@@ -20,32 +21,32 @@ public class TileFakeAir extends TileMod {
private static final String TAG_FLOWER_Y = "flowerY";
private static final String TAG_FLOWER_Z = "flowerZ";
int flowerX, flowerY, flowerZ;
BlockPos flowerPos;
public void setFlower(TileEntity tile) {
flowerX = tile.xCoord;
flowerY = tile.yCoord;
flowerZ = tile.zCoord;
flowerPos = tile.getPos();
}
public boolean canStay() {
return SubTileBubbell.isValidBubbell(worldObj, flowerX, flowerY, flowerZ);
return SubTileBubbell.isValidBubbell(worldObj, flowerPos);
}
@Override
public void writeToNBT(NBTTagCompound par1nbtTagCompound) {
super.writeToNBT(par1nbtTagCompound);
par1nbtTagCompound.setInteger(TAG_FLOWER_X, flowerX);
par1nbtTagCompound.setInteger(TAG_FLOWER_Y, flowerY);
par1nbtTagCompound.setInteger(TAG_FLOWER_Z, flowerZ);
par1nbtTagCompound.setInteger(TAG_FLOWER_X, flowerPos.getX());
par1nbtTagCompound.setInteger(TAG_FLOWER_Y, flowerPos.getY());
par1nbtTagCompound.setInteger(TAG_FLOWER_Z, flowerPos.getZ());
}
@Override
public void readFromNBT(NBTTagCompound par1nbtTagCompound) {
super.readFromNBT(par1nbtTagCompound);
flowerX = par1nbtTagCompound.getInteger(TAG_FLOWER_X);
flowerY = par1nbtTagCompound.getInteger(TAG_FLOWER_Y);
flowerZ = par1nbtTagCompound.getInteger(TAG_FLOWER_Z);
flowerPos = new BlockPos(
par1nbtTagCompound.getInteger(TAG_FLOWER_X),
par1nbtTagCompound.getInteger(TAG_FLOWER_Y),
par1nbtTagCompound.getInteger(TAG_FLOWER_Z)
);
}
}
@@ -18,6 +18,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.gui.IUpdatePlayerListBox;
import net.minecraft.util.StatCollector;
import net.minecraft.util.StringUtils;
@@ -27,7 +28,7 @@ import org.lwjgl.opengl.GL12;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.common.lib.LibBlockNames;
public class TileHourglass extends TileSimpleInventory {
public class TileHourglass extends TileSimpleInventory implements IUpdatePlayerListBox {
private static final String TAG_TIME = "time";
private static final String TAG_TIME_FRACTION = "timeFraction";
@@ -44,8 +45,7 @@ public class TileHourglass extends TileSimpleInventory {
public boolean move = true;
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
int totalTime = getTotalTime();
if(totalTime > 0) {
@@ -56,7 +56,7 @@ public class TileHourglass extends TileSimpleInventory {
flip = !flip;
flipTicks = 4;
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2);
worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, getBlockType(), getBlockType().tickRate(worldObj));
worldObj.scheduleUpdate(pos, getBlockType(), getBlockType().tickRate(worldObj));
}
timeFraction = (float) time / (float) totalTime;
} else {
@@ -149,8 +149,8 @@ public class TileHourglass extends TileSimpleInventory {
if(stack != null) {
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y);
RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y);
mc.getRenderItem().renderItemIntoGUI(stack, x, y);
mc.getRenderItem().renderItemOverlayIntoGUI(mc.fontRendererObj, stack, x, y, "");
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
RenderHelper.disableStandardItemLighting();
@@ -170,7 +170,7 @@ public class TileHourglass extends TileSimpleInventory {
}
@Override
public String getInventoryName() {
public String getCommandSenderName() {
return LibBlockNames.HOURGLASS;
}
@@ -19,7 +19,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.server.gui.IUpdatePlayerListBox;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.EnumFacing;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.brew.Brew;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
@@ -28,7 +30,7 @@ import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.brew.ItemIncenseStick;
import vazkii.botania.common.lib.LibBlockNames;
public class TileIncensePlate extends TileSimpleInventory implements ISidedInventory {
public class TileIncensePlate extends TileSimpleInventory implements ISidedInventory, IUpdatePlayerListBox {
private static final String TAG_TIME_LEFT = "timeLeft";
private static final String TAG_BURNING = "burning";
@@ -40,7 +42,7 @@ public class TileIncensePlate extends TileSimpleInventory implements ISidedInven
public int comparatorOutput = 0;
@Override
public void updateEntity() {
public void update() {
ItemStack stack = getStackInSlot(0);
if(stack != null && burning) {
Brew brew = ((ItemIncenseStick) ModItems.incenseStick).getBrew(stack);
@@ -48,22 +50,22 @@ public class TileIncensePlate extends TileSimpleInventory implements ISidedInven
if(timeLeft > 0) {
timeLeft--;
if(!worldObj.isRemote) {
List<EntityPlayer> players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(xCoord + 0.5 - RANGE, yCoord + 0.5 - RANGE, zCoord + 0.5 - RANGE, xCoord + 0.5 + RANGE, yCoord + 0.5 + RANGE, zCoord + 0.5 + RANGE));
List<EntityPlayer> players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(pos.getX() + 0.5 - RANGE, pos.getY() + 0.5 - RANGE, pos.getZ() + 0.5 - RANGE, pos.getX() + 0.5 + RANGE, pos.getY() + 0.5 + RANGE, pos.getZ() + 0.5 + RANGE));
for(EntityPlayer player : players) {
PotionEffect currentEffect = player.getActivePotionEffect(Potion.potionTypes[effect.getPotionID()]);
boolean nightVision = effect.getPotionID() == Potion.nightVision.id;
if(currentEffect == null || currentEffect.getDuration() < (nightVision ? 205 : 3)) {
PotionEffect applyEffect = new PotionEffect(effect.getPotionID(), nightVision ? 285 : 80, effect.getAmplifier(), true);
PotionEffect applyEffect = new PotionEffect(effect.getPotionID(), nightVision ? 285 : 80, effect.getAmplifier(), true, true);
player.addPotionEffect(applyEffect);
}
}
if(worldObj.rand.nextInt(20) == 0)
worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.1, zCoord + 0.5, "fire.fire", 0.1F, 1F);
worldObj.playSoundEffect(pos.getX() + 0.5, pos.getY() + 0.1, pos.getZ() + 0.5, "fire.fire", 0.1F, 1F);
} else {
double x = xCoord + 0.5;
double y = yCoord + 0.5;
double z = zCoord + 0.5;
double x = pos.getX() + 0.5;
double y = pos.getY() + 0.5;
double z = pos.getZ() + 0.5;
Color color = new Color(brew.getColor(stack));
float r = color.getRed() / 255F;
float g = color.getGreen() / 255F;
@@ -85,7 +87,7 @@ public class TileIncensePlate extends TileSimpleInventory implements ISidedInven
newComparator = 2;
if(comparatorOutput != newComparator) {
comparatorOutput = newComparator;
worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
worldObj.updateComparatorOutputLevel(pos, worldObj.getBlockState(pos).getBlock());
}
}
@@ -105,7 +107,7 @@ public class TileIncensePlate extends TileSimpleInventory implements ISidedInven
}
@Override
public String getInventoryName() {
public String getCommandSenderName() {
return LibBlockNames.INCENSE_PLATE;
}
@@ -129,17 +131,17 @@ public class TileIncensePlate extends TileSimpleInventory implements ISidedInven
}
@Override
public int[] getAccessibleSlotsFromSide(int side) {
public int[] getSlotsForFace(EnumFacing side) {
return new int[] { 0 };
}
@Override
public boolean canInsertItem(int slot, ItemStack stack, int side) {
public boolean canInsertItem(int slot, ItemStack stack, EnumFacing side) {
return isItemValidForSlot(slot, stack);
}
@Override
public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) {
public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, EnumFacing p_102008_3_) {
return false;
}
@@ -21,10 +21,10 @@ 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.server.gui.IUpdatePlayerListBox;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.BlockPos;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@@ -35,7 +35,7 @@ import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.core.helper.MathHelper;
import vazkii.botania.common.core.helper.Vector3;
public class TileLightRelay extends TileMod implements IWandBindable {
public class TileLightRelay extends TileMod implements IWandBindable, IUpdatePlayerListBox {
private static final int MAX_DIST = 20;
@@ -43,14 +43,14 @@ public class TileLightRelay extends TileMod implements IWandBindable {
private static final String TAG_BIND_Y = "bindY";
private static final String TAG_BIND_Z = "bindZ";
int bindX, bindY = -1, bindZ;
BlockPos bindPos = new BlockPos(0, -1, 0);
int ticksElapsed = 0;
public void mountEntity(Entity e) {
if(e.ridingEntity != null || worldObj.isRemote || bindY == -1 || !isValidBinding())
if(e.ridingEntity != null || worldObj.isRemote || bindPos.getY() == -1 || !isValidBinding())
return;
EntityPlayerMover mover = new EntityPlayerMover(worldObj, xCoord, yCoord, zCoord, bindX, bindY, bindZ);
EntityPlayerMover mover = new EntityPlayerMover(worldObj, pos, bindPos);
worldObj.spawnEntityInWorld(mover);
e.mountEntity(mover);
if(!(e instanceof EntityItem)) {
@@ -61,10 +61,10 @@ public class TileLightRelay extends TileMod implements IWandBindable {
}
@Override
public void updateEntity() {
public void update() {
ticksElapsed++;
if(bindY > -1 && isValidBinding()) {
if(bindPos.getY() > -1 && isValidBinding()) {
Vector3 vec = getMovementVector();
double dist = 0.1;
@@ -73,7 +73,7 @@ public class TileLightRelay extends TileMod implements IWandBindable {
int start = ticksElapsed % size;
Vector3 vecMag = vec.copy().normalize().multiply(dist);
Vector3 vecTip = vecMag.copy().multiply(start).add(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5);
Vector3 vecTip = vecMag.copy().multiply(start).add(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
double radPer = Math.PI / 16.0;
float mul = 0.5F;
@@ -90,18 +90,18 @@ public class TileLightRelay extends TileMod implements IWandBindable {
BlockPos endpoint = getEndpoint();
if(endpoint != null && !worldObj.isRemote) {
float range = 0.5F;
List<EntityEnderPearl> enderPearls = worldObj.getEntitiesWithinAABB(EntityEnderPearl.class, new AxisAlignedBB(xCoord - range, yCoord - range, zCoord - range, xCoord + 1 + range, yCoord + 1 + range, zCoord + 1 + range));
List<EntityEnderPearl> enderPearls = worldObj.getEntitiesWithinAABB(EntityEnderPearl.class, new AxisAlignedBB(pos.add(-range, -range, -range), pos.add(1 + range, 1 + range, 1 + range)));
for(EntityEnderPearl pearl : enderPearls) {
pearl.posX = endpoint.posX + pearl.posX - xCoord;
pearl.posY = endpoint.posY + pearl.posY - yCoord;
pearl.posZ = endpoint.posZ + pearl.posZ - zCoord;
pearl.posX = endpoint.getX() + pearl.posX - pos.getX();
pearl.posY = endpoint.getY() + pearl.posY - pos.getY();
pearl.posZ = endpoint.getZ() + pearl.posZ - pos.getZ();
}
}
}
}
public boolean isValidBinding() {
Block block = worldObj.getBlock(bindX, bindY, bindZ);
Block block = worldObj.getBlockState(bindPos).getBlock();
return block == ModBlocks.lightRelay;
}
@@ -121,7 +121,7 @@ public class TileLightRelay extends TileMod implements IWandBindable {
if(coords == null)
return lastCoords;
TileEntity tile = worldObj.getTileEntity(coords.posX, coords.posY, coords.posZ);
TileEntity tile = worldObj.getTileEntity(coords);
if(tile != null && tile instanceof TileLightRelay)
relay = (TileLightRelay) tile;
else return lastCoords;
@@ -133,12 +133,12 @@ public class TileLightRelay extends TileMod implements IWandBindable {
}
public Vector3 getMovementVector() {
return new Vector3(bindX - xCoord, bindY - yCoord, bindZ - zCoord);
return new Vector3(bindPos.getX() - pos.getX(), bindPos.getY() - pos.getY(), bindPos.getZ() - pos.getZ());
}
@Override
public BlockPos getBinding() {
return bindY == -1 ? null : new BlockPos(bindX, bindY, bindZ);
return bindPos.getY() == -1 ? null : bindPos;
}
@Override
@@ -148,27 +148,27 @@ public class TileLightRelay extends TileMod implements IWandBindable {
@Override
public boolean bindTo(EntityPlayer player, ItemStack wand, BlockPos pos, EnumFacing side) {
if(player.worldObj.getBlock(x, y, z) != ModBlocks.lightRelay || MathHelper.pointDistanceSpace(x, y, z, xCoord, yCoord, zCoord) > MAX_DIST)
if(player.worldObj.getBlockState(pos).getBlock() != ModBlocks.lightRelay || MathHelper.pointDistanceSpace(pos, getPos()) > MAX_DIST)
return false;
bindX = x;
bindY = y;
bindZ = z;
bindPos = pos;
return true;
}
@Override
public void readCustomNBT(NBTTagCompound cmp) {
bindX = cmp.getInteger(TAG_BIND_X);
bindY = cmp.getInteger(TAG_BIND_Y);
bindZ = cmp.getInteger(TAG_BIND_Z);
bindPos = new BlockPos(
cmp.getInteger(TAG_BIND_X),
cmp.getInteger(TAG_BIND_Y),
cmp.getInteger(TAG_BIND_Z)
);
}
@Override
public void writeCustomNBT(NBTTagCompound cmp) {
cmp.setInteger(TAG_BIND_X, bindX);
cmp.setInteger(TAG_BIND_Y, bindY);
cmp.setInteger(TAG_BIND_Z, bindZ);
cmp.setInteger(TAG_BIND_X, bindPos.getX());
cmp.setInteger(TAG_BIND_Y, bindPos.getY());
cmp.setInteger(TAG_BIND_Z, bindPos.getZ());
}
public static class EntityPlayerMover extends Entity {
@@ -181,10 +181,10 @@ public class TileLightRelay extends TileMod implements IWandBindable {
super(world);
}
public EntityPlayerMover(World world, int x, int y, int z, int exitX, int exitY, int exitZ) {
public EntityPlayerMover(World world, BlockPos pos, BlockPos exitPos) {
this(world);
setPosition(x + 0.5, y + 0.5, z + 0.5);
setExit(exitX, exitY, exitZ);
setPosition(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
setExit(exitPos);
}
@Override
@@ -213,25 +213,21 @@ public class TileLightRelay extends TileMod implements IWandBindable {
if(!isItem && ticksExisted % 30 == 0)
worldObj.playSoundAtEntity(this, "botania:lightRelay", 0.05F, (float) Math.random() * 0.3F + 0.7F);
int exitX = getExitX();
int exitY = getExitY();
int exitZ = getExitZ();
BlockPos pos = new BlockPos(this);
BlockPos exitPos = getExitPos();
int x = net.minecraft.util.MathHelper.floor_double(posX);
int y = net.minecraft.util.MathHelper.floor_double(posY);
int z = net.minecraft.util.MathHelper.floor_double(posZ);
if(x == exitX && y == exitY && z == exitZ) {
TileEntity tile = worldObj.getTileEntity(x, y, z);
if(pos.equals(exitPos)) {
TileEntity tile = worldObj.getTileEntity(pos);
if(tile != null && tile instanceof TileLightRelay) {
int meta = worldObj.getBlockMetadata(x, y, z);
if(meta > 0) {
worldObj.setBlockMetadataWithNotify(x, y, z, meta | 8, 1 | 2);
worldObj.scheduleBlockUpdate(x, y, z, tile.getBlockType(), tile.getBlockType().tickRate(worldObj));
worldObj.scheduleUpdate(pos, tile.getBlockType(), tile.getBlockType().tickRate(worldObj));
}
BlockPos bind = ((TileLightRelay) tile).getBinding();
if(bind != null) {
setExit(bind.posX, bind.posY, bind.posZ);
setExit(bind);
return;
}
}
@@ -240,7 +236,7 @@ public class TileLightRelay extends TileMod implements IWandBindable {
setDead();
} else {
Vector3 thisVec = Vector3.fromEntity(this);
Vector3 motVec = thisVec.negate().add(exitX + 0.5, exitY + 0.5, exitZ + 0.5).normalize().multiply(0.5);
Vector3 motVec = thisVec.negate().add(exitPos.getX() + 0.5, exitPos.getY() + 0.5, exitPos.getZ() + 0.5).normalize().multiply(0.5);
Color color;
@@ -273,32 +269,29 @@ public class TileLightRelay extends TileMod implements IWandBindable {
@Override
protected void readEntityFromNBT(NBTTagCompound cmp) {
setExit(cmp.getInteger(TAG_EXIT_X), cmp.getInteger(TAG_EXIT_Y), cmp.getInteger(TAG_EXIT_Z));
setExit(new BlockPos(cmp.getInteger(TAG_EXIT_X), cmp.getInteger(TAG_EXIT_Y), cmp.getInteger(TAG_EXIT_Z)));
}
@Override
protected void writeEntityToNBT(NBTTagCompound cmp) {
cmp.setInteger(TAG_EXIT_X, getExitX());
cmp.setInteger(TAG_EXIT_Y, getExitY());
cmp.setInteger(TAG_EXIT_Z, getExitZ());
BlockPos exit = getExitPos();
cmp.setInteger(TAG_EXIT_X, exit.getX());
cmp.setInteger(TAG_EXIT_Y, exit.getY());
cmp.setInteger(TAG_EXIT_Z, exit.getZ());
}
public int getExitX() {
return dataWatcher.getWatchableObjectInt(20);
public BlockPos getExitPos() {
return new BlockPos(
dataWatcher.getWatchableObjectInt(20),
dataWatcher.getWatchableObjectInt(21),
dataWatcher.getWatchableObjectInt(22)
);
}
public int getExitY() {
return dataWatcher.getWatchableObjectInt(21);
}
public int getExitZ() {
return dataWatcher.getWatchableObjectInt(22);
}
public void setExit(int x, int y, int z) {
dataWatcher.updateObject(20, x);
dataWatcher.updateObject(21, y);
dataWatcher.updateObject(22, z);
public void setExit(BlockPos pos) {
dataWatcher.updateObject(20, pos.getX());
dataWatcher.updateObject(21, pos.getY());
dataWatcher.updateObject(22, pos.getZ());
}
}
@@ -65,7 +65,7 @@ public class TilePylon extends TileEntity implements IUpdatePlayerListBox {
Vector3 ourCoords = Vector3.fromTileEntityCenter(this).add(0, 1 + (Math.random() - 0.5 * 0.25), 0);
Vector3 movementVector = centerBlock.sub(ourCoords).normalize().multiply(0.2);
Block block = worldObj.getBlockState(pos.down());
Block block = worldObj.getBlockState(pos.down()).getBlock();
if(block == ModBlocks.flower || block == ModBlocks.shinyFlower) {
int fmeta = worldObj.getBlockMetadata(xCoord, yCoord - 1, zCoord);
float[] color = EntitySheep.fleeceColorTable[fmeta];