Send bauble update packets if mana is altered in any bauble slots. Closes #1083

This commit is contained in:
Lizbeth Rika committed 2015-08-15 16:20:33 +01:00
1 parent 720ee069ed
commit c8bd8a1bae
7 files changed
+42 -7

No files matched your search

@@ -216,4 +216,9 @@ public class DummyMethodHandler implements IInternalMethodHandler {
return false;
}
@Override
public void sendBaubleUpdatePacket(EntityPlayer player, int slot) {
// NO-OP
}
}
@@ -120,4 +120,6 @@ public interface IInternalMethodHandler {
public boolean isBotaniaFlower(World world, int x, int y, int z);
public void sendBaubleUpdatePacket(EntityPlayer player, int slot);
}
@@ -39,7 +39,8 @@ public final class ManaItemHandler {
for(int i = 0; i < size; i++) {
boolean useBaubles = i >= invSize;
IInventory inv = useBaubles ? baublesInv : mainInv;
ItemStack stackInSlot = inv.getStackInSlot(i - (useBaubles ? invSize : 0));
int slot = i - (useBaubles ? invSize : 0);
ItemStack stackInSlot = inv.getStackInSlot(slot);
if(stackInSlot == stack)
continue;
@@ -53,6 +54,8 @@ public final class ManaItemHandler {
if(remove)
manaItem.addMana(stackInSlot, -mana);
if(useBaubles)
BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot);
return mana;
}
@@ -84,7 +87,8 @@ public final class ManaItemHandler {
for(int i = 0; i < size; i++) {
boolean useBaubles = i >= invSize;
IInventory inv = useBaubles ? baublesInv : mainInv;
ItemStack stackInSlot = inv.getStackInSlot(i - (useBaubles ? invSize : 0));
int slot = i - (useBaubles ? invSize : 0);
ItemStack stackInSlot = inv.getStackInSlot(slot);
if(stackInSlot == stack)
continue;
@@ -96,6 +100,8 @@ public final class ManaItemHandler {
if(remove)
manaItemSlot.addMana(stackInSlot, -manaToGet);
if(useBaubles)
BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot);
return true;
}
@@ -127,7 +133,8 @@ public final class ManaItemHandler {
for(int i = 0; i < size; i++) {
boolean useBaubles = i >= invSize;
IInventory inv = useBaubles ? baublesInv : mainInv;
ItemStack stackInSlot = inv.getStackInSlot(i - (useBaubles ? invSize : 0));
int slot = i - (useBaubles ? invSize : 0);
ItemStack stackInSlot = inv.getStackInSlot(slot);
if(stackInSlot == stack)
continue;
@@ -146,6 +153,8 @@ public final class ManaItemHandler {
if(add)
manaItemSlot.addMana(stackInSlot, manaToSend);
if(useBaubles)
BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot);
return received;
}
@@ -177,7 +186,8 @@ public final class ManaItemHandler {
for(int i = 0; i < size; i++) {
boolean useBaubles = i >= invSize;
IInventory inv = useBaubles ? baublesInv : mainInv;
ItemStack stackInSlot = inv.getStackInSlot(i - (useBaubles ? invSize : 0));
int slot = i - (useBaubles ? invSize : 0);
ItemStack stackInSlot = inv.getStackInSlot(slot);
if(stackInSlot == stack)
continue;
@@ -189,6 +199,8 @@ public final class ManaItemHandler {
if(add)
manaItemSlot.addMana(stackInSlot, manaToSend);
if(useBaubles)
BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot);
return true;
}
@@ -46,6 +46,11 @@ public abstract class BlockModSlab extends BlockSlab implements ILexiconable {
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
return Item.getItemFromBlock(getSingleBlock());
}
@Override
public int quantityDropped(int meta, int fortune, Random random) {
return super.quantityDropped(meta, fortune, random);
}
@Override
public ItemStack createStackedBlock(int par1) {
@@ -168,7 +168,9 @@ public class SubTileHopperhock extends SubTileFunctional {
};
for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) {
List<EntityItemFrame> frames = supertile.getWorldObj().getEntitiesWithinAABB(EntityItemFrame.class, AxisAlignedBB.getBoundingBox(x+ dir.offsetX, y + dir.offsetY, z + dir.offsetZ, x + dir.offsetX + 1, y + dir.offsetY + 1, z + dir.offsetZ + 1));
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, x + dir.offsetX + 1, y + dir.offsetY + 1, z + dir.offsetZ + 1);
List<EntityItemFrame> frames = supertile.getWorldObj().getEntitiesWithinAABB(EntityItemFrame.class, aabb);
System.out.println(aabb + " " + frames);
for(EntityItemFrame frame : frames) {
int orientation = frame.hangingDirection;
if(orientationToDir[orientation] == dir.ordinal())
@@ -16,6 +16,7 @@ import net.minecraft.block.Block;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
@@ -59,6 +60,8 @@ import vazkii.botania.common.lexicon.page.PagePetalRecipe;
import vazkii.botania.common.lexicon.page.PageRuneRecipe;
import vazkii.botania.common.lexicon.page.PageText;
import baubles.common.lib.PlayerHandler;
import baubles.common.network.PacketHandler;
import baubles.common.network.PacketSyncBauble;
import buildcraft.api.transport.IPipeTile;
import cpw.mods.fml.common.Optional;
@@ -244,4 +247,10 @@ public class InternalMethodHandler extends DummyMethodHandler {
Block block = world.getBlock(x, y, z);
return block == ModBlocks.flower || block == ModBlocks.shinyFlower || block == ModBlocks.specialFlower;
}
@Override
public void sendBaubleUpdatePacket(EntityPlayer player, int slot) {
if(player instanceof EntityPlayerMP)
PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player);
}
}
@@ -22,6 +22,7 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.item.ItemTossEvent;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.item.IRelic;
import vazkii.botania.api.mana.IManaItem;
import vazkii.botania.client.core.helper.IconHelper;
@@ -76,8 +77,7 @@ public class ItemMagnetRing extends ItemBauble {
ItemStack stack = inv.getStackInSlot(i);
if(stack != null && stack.getItem() == this) {
setCooldown(stack, 100);
if(event.player instanceof EntityPlayerMP)
PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(event.player, i), (EntityPlayerMP) event.player);
BotaniaAPI.internalHandler.sendBaubleUpdatePacket(event.player, i);
}
}
}