Initial stab at 1.11

About halfway.
This commit is contained in:
Nicholas Ignoffo 2016-12-12 19:56:36 -08:00
parent ce52aea512
commit 00d6f8eb46
157 changed files with 1036 additions and 1554 deletions

View file

@ -110,7 +110,7 @@ public class ChatUtil
{
for (ITextComponent c : lines)
{
player.addChatComponentMessage(c);
player.sendMessage(c);
}
}

View file

@ -59,7 +59,7 @@ public class GhostItemHelper
{
newStack.setTagCompound(null);
}
newStack.stackSize = amount;
newStack.setCount(amount);
return newStack;
}

View file

@ -46,9 +46,13 @@ import net.minecraftforge.common.ISpecialArmor.ArmorProperties;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fml.common.discovery.ASMDataTable;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.items.wrapper.InvWrapper;
import net.minecraftforge.items.wrapper.PlayerInvWrapper;
import net.minecraftforge.items.wrapper.PlayerMainInvWrapper;
import net.minecraftforge.items.wrapper.SidedInvWrapper;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.BlockStack;
@ -86,32 +90,6 @@ public class Utils
return added;
}
public static Item getItem(ResourceLocation resource)
{
return Item.REGISTRY.getObject(resource);
}
public static Block getBlock(ResourceLocation resource)
{
return Block.REGISTRY.getObject(resource);
}
public static ResourceLocation getResourceForItem(ItemStack stack)
{
if (stack != null)
{
if (stack.getItem() instanceof ItemBlock)
{
return Block.REGISTRY.getNameForObject(((ItemBlock) stack.getItem()).getBlock());
} else
{
return Item.REGISTRY.getNameForObject(stack.getItem());
}
}
return null;
}
public static boolean isImmuneToFireDamage(EntityLivingBase entity)
{
return entity.isImmuneToFire() || entity.isPotionActive(MobEffects.FIRE_RESISTANCE);
@ -119,7 +97,7 @@ public class Utils
public static boolean isPlayerBesideSolidBlockFace(EntityPlayer player)
{
World world = player.worldObj;
World world = player.getEntityWorld();
double minimumDistanceFromAxis = 0.7;
BlockPos centralPos = player.getPosition();
for (EnumFacing facing : EnumFacing.HORIZONTALS)
@ -142,16 +120,17 @@ public class Utils
public static boolean canPlayerSeeDemonWill(EntityPlayer player)
{
ItemStack[] mainInventory = player.inventory.mainInventory;
IItemHandler inventory = new PlayerMainInvWrapper(player.inventory);
for (ItemStack stack : mainInventory)
for (int i = 0; i < inventory.getSlots(); i++)
{
if (stack == null)
ItemStack stack = inventory.getStackInSlot(i);
if (stack.isEmpty())
{
continue;
}
if (stack.getItem() instanceof IDemonWillViewer && ((IDemonWillViewer) stack.getItem()).canSeeDemonWillAura(player.worldObj, stack, player))
if (stack.getItem() instanceof IDemonWillViewer && ((IDemonWillViewer) stack.getItem()).canSeeDemonWillAura(player.getEntityWorld(), stack, player))
{
return true;
}
@ -165,12 +144,7 @@ public class Utils
Vec3d relativePosition = new Vec3d(entity.posX - pos.getX() - 0.5, entity.posY + (double) entity.getEyeHeight() - pos.getY() - 0.5, entity.posZ - pos.getZ() - 0.5);
EnumFacing dir = EnumFacing.getFacingFromVector((float) relativePosition.xCoord, (float) relativePosition.yCoord, (float) relativePosition.zCoord);
RayTraceResult result = world.rayTraceBlocks(new Vec3d(entity.posX, entity.posY + (double) entity.getEyeHeight(), entity.posZ), new Vec3d(pos.getX() + 0.5 + dir.getFrontOffsetX() * 0.4, pos.getY() + 0.5 + dir.getFrontOffsetY() * 0.4, pos.getZ() + 0.5 + dir.getFrontOffsetZ() * 0.4), false, true, true);
if (result != null)
{
return pos.equals(result.getBlockPos());
}
return result != null;
return result == null || pos.equals(result.getBlockPos());
}
public static int plantSeedsInArea(World world, AxisAlignedBB aabb, int horizontalRadius, int verticalRadius)
@ -188,7 +162,7 @@ public class Utils
public static int plantItemStack(World world, BlockPos centralPos, ItemStack stack, int horizontalRadius, int verticalRadius)
{
if (stack == null || stack.stackSize <= 0)
if (stack.isEmpty())
{
return 0;
}
@ -226,9 +200,9 @@ public class Utils
IBlockState plantState = ((IPlantable) item).getPlant(world, newPos);
world.setBlockState(newPos, plantState, 3);
world.playEvent(2001, newPos, Block.getIdFromBlock(plantState.getBlock()) + (plantState.getBlock().getMetaFromState(plantState) << 12));
stack.stackSize--;
stack.shrink(1);
planted++;
if (stack.stackSize <= 0)
if (stack.isEmpty() || stack.getCount() <= 0)
{
return planted;
}
@ -250,13 +224,13 @@ public class Utils
return 0;
}
World world = itemEntity.worldObj;
World world = itemEntity.getEntityWorld();
BlockPos pos = itemEntity.getPosition();
ItemStack stack = itemEntity.getEntityItem();
int planted = plantItemStack(world, pos, stack, horizontalRadius, verticalRadius);
if (stack.stackSize <= 0)
if (stack.isEmpty())
{
itemEntity.setDead();
}
@ -266,18 +240,19 @@ public class Utils
public static int getDemonWillResolution(EntityPlayer player)
{
ItemStack[] mainInventory = player.inventory.mainInventory;
IItemHandler inventory = new PlayerMainInvWrapper(player.inventory);
for (ItemStack stack : mainInventory)
for (int i = 0; i < inventory.getSlots(); i++)
{
if (stack == null)
ItemStack stack = inventory.getStackInSlot(i);
if (stack.isEmpty())
{
continue;
}
if (stack.getItem() instanceof IDemonWillViewer && ((IDemonWillViewer) stack.getItem()).canSeeDemonWillAura(player.worldObj, stack, player))
if (stack.getItem() instanceof IDemonWillViewer && ((IDemonWillViewer) stack.getItem()).canSeeDemonWillAura(player.getEntityWorld(), stack, player))
{
return ((IDemonWillViewer) stack.getItem()).getDemonWillAuraResolution(player.worldObj, stack, player);
return ((IDemonWillViewer) stack.getItem()).getDemonWillAuraResolution(player.getEntityWorld(), stack, player);
}
}
@ -300,7 +275,7 @@ public class Utils
public static void setPlayerSpeedFromServer(EntityPlayer player, double motionX, double motionY, double motionZ)
{
if (!player.worldObj.isRemote && player instanceof EntityPlayerMP)
if (!player.getEntityWorld().isRemote && player instanceof EntityPlayerMP)
{
BloodMagicPacketHandler.sendTo(new PlayerVelocityPacketProcessor(motionX, motionY, motionZ), (EntityPlayerMP) player);
}
@ -363,19 +338,19 @@ public class Utils
*/
public static boolean insertItemToTile(TileInventory tile, EntityPlayer player, int slot)
{
if (tile.getStackInSlot(slot) == null && player.getHeldItemMainhand() != null)
if (tile.getStackInSlot(slot).isEmpty() && !player.getHeldItemMainhand().isEmpty())
{
ItemStack input = player.getHeldItemMainhand().copy();
input.stackSize = 1;
player.getHeldItemMainhand().stackSize--;
input.setCount(1);
player.getHeldItemMainhand().shrink(1);
tile.setInventorySlotContents(slot, input);
return true;
} else if (tile.getStackInSlot(slot) != null && player.getHeldItemMainhand() == null)
} else if (!tile.getStackInSlot(slot).isEmpty() && player.getHeldItemMainhand().isEmpty())
{
if (!tile.getWorld().isRemote)
{
EntityItem invItem = new EntityItem(tile.getWorld(), player.posX, player.posY + 0.25, player.posZ, tile.getStackInSlot(slot));
tile.getWorld().spawnEntityInWorld(invItem);
tile.getWorld().spawnEntity(invItem);
}
tile.clear();
return false;
@ -523,7 +498,7 @@ public class Utils
return damage;
} else
{
if (attackedEntity.isPotionActive(resistance) && source != DamageSource.outOfWorld)
if (attackedEntity.isPotionActive(resistance) && source != DamageSource.OUT_OF_WORLD)
{
int i = (attackedEntity.getActivePotionEffect(resistance).getAmplifier() + 1) * 5;
int j = 25 - i;
@ -564,20 +539,23 @@ public class Utils
* @param stack2
* Slot content that stack1 is placed into
* @return True if they can be combined
* @deprecated use {@link ItemHandlerHelper#canItemStacksStack(ItemStack, ItemStack)}
*/
@Deprecated
public static boolean canCombine(ItemStack stack1, ItemStack stack2)
{
if (stack1 == null || stack1.isItemStackDamageable() ^ stack2.isItemStackDamageable())
{
return false;
}
if (stack2 == null)
{
return true;
}
return stack1.getItem() == stack2.getItem() && stack1.getItemDamage() == stack2.getItemDamage() && ItemStack.areItemStackTagsEqual(stack1, stack2);
return ItemHandlerHelper.canItemStacksStack(stack1, stack2);
// if (stack1.isEmpty() || stack1.isItemStackDamageable() ^ stack2.isItemStackDamageable())
// {
// return false;
// }
//
// if (stack2.isEmpty())
// {
// return true;
// }
//
// return stack1.getItem() == stack2.getItem() && stack1.getItemDamage() == stack2.getItemDamage() && ItemStack.areItemStackTagsEqual(stack1, stack2);
}
/**
@ -591,18 +569,18 @@ public class Utils
{
ItemStack[] returned = new ItemStack[2];
if (canCombine(stack1, stack2))
if (ItemHandlerHelper.canItemStacksStack(stack1, stack2))
{
int transferedAmount = Math.min(transferMax, stack2 == null ? stack1.stackSize : Math.min(stack2.getMaxStackSize() - stack2.stackSize, stack1.stackSize));
int transferedAmount = Math.min(transferMax, stack2.isEmpty() ? stack1.getCount() : Math.min(stack2.getMaxStackSize() - stack2.getCount(), stack1.getCount()));
if (transferedAmount > 0)
{
ItemStack copyStack = stack1.splitStack(transferedAmount);
if (stack2 == null)
if (stack2.isEmpty())
{
stack2 = copyStack;
} else
{
stack2.stackSize += transferedAmount;
stack2.grow(transferedAmount);
}
}
}
@ -624,18 +602,18 @@ public class Utils
{
ItemStack[] returned = new ItemStack[2];
if (canCombine(stack1, stack2))
if (ItemHandlerHelper.canItemStacksStack(stack1, stack2))
{
int transferedAmount = stack2 == null ? stack1.stackSize : Math.min(stack2.getMaxStackSize() - stack2.stackSize, stack1.stackSize);
int transferedAmount = stack2.isEmpty() ? stack1.getCount() : Math.min(stack2.getMaxStackSize() - stack2.getCount(), stack1.getCount());
if (transferedAmount > 0)
{
ItemStack copyStack = stack1.splitStack(transferedAmount);
if (stack2 == null)
if (stack2.isEmpty())
{
stack2 = copyStack;
} else
{
stack2.stackSize += transferedAmount;
stack2.grow(transferedAmount);
}
}
}
@ -733,9 +711,9 @@ public class Utils
{
ItemStack invStack = handler.getStackInSlot(slot);
if (invStack != null && canCombine(stack, invStack))
if (!invStack.isEmpty() && ItemHandlerHelper.canItemStacksStack(stack, invStack))
{
numberMatching += invStack.stackSize;
numberMatching += invStack.getCount();
}
}
@ -749,23 +727,23 @@ public class Utils
for (int slot = 0; slot < numberOfSlots; slot++)
{
ItemStack newCopyStack = copyStack.copy();
newCopyStack.stackSize = Math.min(copyStack.stackSize, newLimit);
newCopyStack.setCount(Math.min(copyStack.getCount(), newLimit));
newCopyStack = handler.insertItem(slot, newCopyStack, false);
if (newCopyStack == null)
if (newCopyStack.isEmpty())
{
return null;
return ItemStack.EMPTY;
}
newLimit -= (copyStack.stackSize - newCopyStack.stackSize);
newLimit -= (copyStack.getCount() - newCopyStack.getCount());
if (newLimit <= 0)
{
return null; //TODO
return ItemStack.EMPTY; //TODO
}
copyStack.stackSize -= (copyStack.stackSize - newCopyStack.stackSize);
copyStack.shrink(copyStack.getCount() - newCopyStack.getCount());
}
return copyStack;
@ -779,9 +757,9 @@ public class Utils
public static ItemStack insertStackIntoInventory(ItemStack stack, IInventory inventory, EnumFacing dir)
{
if (stack == null)
if (stack.isEmpty())
{
return null;
return ItemStack.EMPTY;
}
boolean[] canBeInserted = new boolean[inventory.getSizeInventory()];
@ -812,9 +790,9 @@ public class Utils
stack = combinedStacks[0];
inventory.setInventorySlotContents(i, combinedStacks[1]);
if (stack.stackSize <= 0)
if (stack.isEmpty())
{
return stack;
return ItemStack.EMPTY;
}
}
@ -828,12 +806,12 @@ public class Utils
public static boolean canInsertStackFullyIntoInventory(ItemStack stack, IInventory inventory, EnumFacing dir, boolean fillToLimit, int limit)
{
if (stack == null)
if (stack.isEmpty())
{
return true;
}
int itemsLeft = stack.stackSize;
int itemsLeft = stack.getCount();
boolean[] canBeInserted = new boolean[inventory.getSizeInventory()];
@ -865,14 +843,14 @@ public class Utils
ItemStack invStack = inventory.getStackInSlot(i);
if (invStack != null && canCombine(stack, invStack))
if (!invStack.isEmpty() && ItemHandlerHelper.canItemStacksStack(stack, invStack))
{
numberMatching += invStack.stackSize;
numberMatching += invStack.getCount();
}
}
}
if (fillToLimit && limit < stack.stackSize + numberMatching)
if (fillToLimit && limit < stack.getCount() + numberMatching)
{
return false;
}
@ -888,12 +866,12 @@ public class Utils
boolean canCombine = canCombine(stack, invStack);
if (canCombine)
{
if (invStack == null)
if (invStack.isEmpty())
{
itemsLeft = 0;
} else
{
itemsLeft -= (invStack.getMaxStackSize() - invStack.stackSize);
itemsLeft -= (invStack.getMaxStackSize() - invStack.getCount());
}
}
@ -918,9 +896,9 @@ public class Utils
*/
public static ItemStack insertStackIntoInventory(ItemStack stack, IInventory inventory, EnumFacing dir, int limit)
{
if (stack == null)
if (stack.isEmpty())
{
return null;
return ItemStack.EMPTY;
}
boolean[] canBeInserted = new boolean[inventory.getSizeInventory()];
@ -953,7 +931,7 @@ public class Utils
if (invStack != null && canCombine(stack, invStack))
{
numberMatching += invStack.stackSize;
numberMatching += invStack.getCount();
}
}
@ -971,15 +949,15 @@ public class Utils
continue;
}
int prevStackSize = stack.stackSize;
int prevStackSize = stack.getCount();
ItemStack[] combinedStacks = combineStacks(stack, inventory.getStackInSlot(i), newLimit);
stack = combinedStacks[0];
inventory.setInventorySlotContents(i, combinedStacks[1]); //TODO
newLimit -= (prevStackSize - stack.stackSize);
newLimit -= (prevStackSize - stack.getCount());
if (newLimit <= 0 || stack.stackSize <= 0)
if (newLimit <= 0 || stack.isEmpty())
{
return stack;
}
@ -1050,7 +1028,7 @@ public class Utils
}
entityItem.setEntityItemStack(stack);
return world.spawnEntityInWorld(entityItem);
return world.spawnEntity(entityItem);
}
public static boolean swapLocations(World initialWorld, BlockPos initialPos, World finalWorld, BlockPos finalPos)
@ -1094,26 +1072,27 @@ public class Utils
if (initialTile != null)
{
TileEntity newTileInitial = BloodMagic.getCrossVersionProxy().createTileFromData(finalWorld, initialTag);
TileEntity newTileInitial = TileEntity.create(finalWorld, initialTag);
finalWorld.setTileEntity(finalPos, newTileInitial);
newTileInitial.setPos(finalPos);
newTileInitial.setWorldObj(finalWorld);
newTileInitial.setWorld(finalWorld);
}
initialWorld.setBlockState(initialPos, finalBlockState, 3);
if (finalTile != null)
{
TileEntity newTileFinal = BloodMagic.getCrossVersionProxy().createTileFromData(initialWorld, finalTag);
TileEntity newTileFinal = TileEntity.create(initialWorld, finalTag);
initialWorld.setTileEntity(initialPos, newTileFinal);
newTileFinal.setPos(initialPos);
newTileFinal.setWorldObj(initialWorld);
newTileFinal.setWorld(initialWorld);
}
initialWorld.notifyNeighborsOfStateChange(initialPos, finalStack.getBlock());
finalWorld.notifyNeighborsOfStateChange(finalPos, initialStack.getBlock());
initialWorld.notifyNeighborsOfStateChange(initialPos, finalStack.getBlock(), true);
finalWorld.notifyNeighborsOfStateChange(finalPos, initialStack.getBlock(), true);
return true;
}
@ -1122,25 +1101,25 @@ public class Utils
public static ItemStack consumeItem(ItemStack stack)
{
Item item = stack.getItem();
boolean largerStack = stack.stackSize > 1;
boolean largerStack = stack.getCount() > 1;
if (largerStack)
{
stack.stackSize -= 1;
stack.shrink(1);
}
if (item.hasContainerItem(stack))
{
ItemStack ret = item.getContainerItem(stack);
if (ret == null)
if (ret.isEmpty())
{
return null;
return ItemStack.EMPTY;
}
if (ret.isItemStackDamageable() && ret.getItemDamage() > ret.getMaxDamage())
{
ret = null;
ret = ItemStack.EMPTY;
}
return ret;
}
return largerStack ? stack : null;
return largerStack ? stack : ItemStack.EMPTY;
}
public static void registerHandlers(Set<ASMDataTable.ASMData> eventHandlers)

View file

@ -6,8 +6,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import WayofTime.bloodmagic.client.key.KeyBindings;
import WayofTime.bloodmagic.client.render.model.CustomModelFactory;
import net.minecraft.client.Minecraft;
@ -93,14 +91,11 @@ public class ClientHandler
private static EnumFacing mrsHoloDirection;
private static boolean mrsHoloDisplay;
boolean doCrystalRenderTest = true;
public static ResourceLocation crystalResource = new ResourceLocation(Constants.Mod.DOMAIN + "textures/entities/defaultCrystalLayer.png");
@SubscribeEvent
public void onTooltipEvent(ItemTooltipEvent event)
{
ItemStack stack = event.getItemStack();
if (stack == null)
if (stack.isEmpty())
{
return;
}
@ -121,7 +116,7 @@ public class ClientHandler
@SubscribeEvent
public void onSoundEvent(PlaySoundEvent event)
{
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
EntityPlayer player = Minecraft.getMinecraft().player;
if (player != null && player.isPotionActive(ModPotions.deafness))
{
event.setResultSound(null);
@ -152,8 +147,8 @@ public class ClientHandler
@SubscribeEvent
public void render(RenderWorldLastEvent event)
{
EntityPlayerSP player = minecraft.thePlayer;
World world = player.worldObj;
EntityPlayerSP player = minecraft.player;
World world = player.getEntityWorld();
if (mrsHoloTile != null)
{
@ -174,20 +169,20 @@ public class ClientHandler
TileEntity tileEntity = world.getTileEntity(minecraft.objectMouseOver.getBlockPos());
if (tileEntity instanceof TileMasterRitualStone && player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() instanceof ItemRitualDiviner)
if (tileEntity instanceof TileMasterRitualStone && !player.getHeldItemMainhand().isEmpty() && player.getHeldItemMainhand().getItem() instanceof ItemRitualDiviner)
renderRitualStones(player, event.getPartialTicks());
}
@SubscribeEvent
public void onMouseEvent(MouseEvent event)
{
EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
EntityPlayerSP player = Minecraft.getMinecraft().player;
if (event.getDwheel() != 0 && player != null && player.isSneaking())
{
ItemStack stack = player.getHeldItemMainhand();
if (stack != null)
if (!stack.isEmpty())
{
Item item = stack.getItem();
@ -226,7 +221,7 @@ public class ClientHandler
ModelResourceLocation location = new ModelResourceLocation("bloodmagic:BlockBloodTank", "inventory");
IBakedModel model = event.getModelRegistry().getObject(location);
if (model instanceof IBakedModel)
if (model != null)
event.getModelRegistry().putObject(location, new CustomModelFactory(model));
if (BloodMagic.isDev() && SUPPRESS_ASSET_ERRORS)
@ -310,8 +305,8 @@ public class ClientHandler
ItemSigilHolding.cycleToNextSigil(stack, mode);
BloodMagicPacketHandler.INSTANCE.sendToServer(new SigilHoldingPacketProcessor(player.inventory.currentItem, mode));
ItemStack newStack = ItemSigilHolding.getItemStackInSlot(stack, ItemSigilHolding.getCurrentItemOrdinal(stack));
if (newStack != null)
Minecraft.getMinecraft().ingameGUI.setRecordPlaying(newStack.getDisplayName(), false);
if (!newStack.isEmpty())
player.sendStatusMessage(newStack.getTextComponent(), true);
}
private static TextureAtlasSprite forName(TextureMap textureMap, String name, String dir)
@ -321,7 +316,7 @@ public class ClientHandler
private void renderRitualStones(EntityPlayerSP player, float partialTicks)
{
World world = player.worldObj;
World world = player.getEntityWorld();
ItemRitualDiviner ritualDiviner = (ItemRitualDiviner) player.inventory.getCurrentItem().getItem();
EnumFacing direction = ritualDiviner.getDirection(player.inventory.getCurrentItem());
Ritual ritual = RitualRegistry.getRitualForId(ritualDiviner.getCurrentRitual(player.inventory.getCurrentItem()));
@ -385,8 +380,8 @@ public class ClientHandler
public static void renderRitualStones(TileMasterRitualStone masterRitualStone, float partialTicks)
{
EntityPlayerSP player = minecraft.thePlayer;
World world = player.worldObj;
EntityPlayerSP player = minecraft.player;
World world = player.world;
EnumFacing direction = mrsHoloDirection;
Ritual ritual = mrsHoloRitual;
@ -462,28 +457,4 @@ public class ClientHandler
mrsHoloRitual = null;
mrsHoloDirection = EnumFacing.NORTH;
}
protected void renderHotbarItem(int x, int y, float partialTicks, EntityPlayer player, @Nullable ItemStack stack)
{
if (stack != null)
{
float animation = (float) stack.animationsToGo - partialTicks;
if (animation > 0.0F)
{
GlStateManager.pushMatrix();
float f1 = 1.0F + animation / 5.0F;
GlStateManager.translate((float) (x + 8), (float) (y + 12), 0.0F);
GlStateManager.scale(1.0F / f1, (f1 + 1.0F) / 2.0F, 1.0F);
GlStateManager.translate((float) (-(x + 8)), (float) (-(y + 12)), 0.0F);
}
minecraft.getRenderItem().renderItemAndEffectIntoGUI(player, stack, x, y);
if (animation > 0.0F)
GlStateManager.popMatrix();
minecraft.getRenderItem().renderItemOverlays(minecraft.fontRendererObj, stack, x, y);
}
}
}

View file

@ -147,8 +147,6 @@ public class CraftingHandler
event.setCost(1);
event.setOutput(outputStack);
return;
}
}
}

View file

@ -3,6 +3,7 @@ package WayofTime.bloodmagic.util.handler.event;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
@ -101,7 +102,7 @@ public class GenericHandler
{
event.setDamageMultiplier(0);
if (player.worldObj.isRemote)
if (player.getEntityWorld().isRemote)
{
player.motionY *= -0.9;
player.fallDistance = 0;
@ -197,14 +198,14 @@ public class GenericHandler
@SubscribeEvent
public void onEntityHurt(LivingHurtEvent event)
{
if (event.getEntity().worldObj.isRemote)
if (event.getEntity().getEntityWorld().isRemote)
return;
if (event.getSource().getEntity() instanceof EntityPlayer && !PlayerHelper.isFakePlayer((EntityPlayer) event.getSource().getEntity()))
{
EntityPlayer player = (EntityPlayer) event.getSource().getEntity();
if (player.getItemStackFromSlot(EntityEquipmentSlot.CHEST) != null && player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() instanceof ItemPackSacrifice)
if (!player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty() && player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() instanceof ItemPackSacrifice)
{
ItemPackSacrifice pack = (ItemPackSacrifice) player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem();
@ -240,7 +241,7 @@ public class GenericHandler
@SubscribeEvent
public void onLivingUpdate(LivingUpdateEvent event)
{
if (!event.getEntityLiving().worldObj.isRemote)
if (!event.getEntityLiving().getEntityWorld().isRemote)
{
EntityLivingBase entity = event.getEntityLiving();
if (entity instanceof EntityPlayer && entity.ticksExisted % 50 == 0) //TODO: Change to an incremental counter
@ -265,7 +266,7 @@ public class GenericHandler
if (animal.getAttackTarget() != null && animal.getDistanceSqToEntity(animal.getAttackTarget()) < 4)
{
animal.worldObj.createExplosion(null, animal.posX, animal.posY + (double) (animal.height / 16.0F), animal.posZ, 2 + animal.getActivePotionEffect(ModPotions.sacrificialLamb).getAmplifier() * 1.5f, false);
animal.getEntityWorld().createExplosion(null, animal.posX, animal.posY + (double) (animal.height / 16.0F), animal.posZ, 2 + animal.getActivePotionEffect(ModPotions.sacrificialLamb).getAmplifier() * 1.5f, false);
targetTaskMap.remove(animal);
attackTaskMap.remove(animal);
}
@ -284,7 +285,7 @@ public class GenericHandler
EntityPlayer player = (EntityPlayer) entity;
if (player.isSneaking() && player.isPotionActive(ModPotions.cling) && Utils.isPlayerBesideSolidBlockFace(player) && !player.onGround)
{
if (player.worldObj.isRemote)
if (player.getEntityWorld().isRemote)
{
player.motionY = 0;
player.motionX *= 0.8;
@ -307,14 +308,15 @@ public class GenericHandler
if (entity.isPotionActive(ModPotions.fireFuse))
{
entity.worldObj.spawnParticle(EnumParticleTypes.FLAME, entity.posX + entity.worldObj.rand.nextDouble() * 0.3, entity.posY + entity.worldObj.rand.nextDouble() * 0.3, entity.posZ + entity.worldObj.rand.nextDouble() * 0.3, 0, 0.06d, 0);
Random random = entity.getEntityWorld().rand;
entity.getEntityWorld().spawnParticle(EnumParticleTypes.FLAME, entity.posX + random.nextDouble() * 0.3, entity.posY + random.nextDouble() * 0.3, entity.posZ + random.nextDouble() * 0.3, 0, 0.06d, 0);
int r = entity.getActivePotionEffect(ModPotions.fireFuse).getAmplifier();
int radius = 1 * r + 1;
if (entity.getActivePotionEffect(ModPotions.fireFuse).getDuration() <= 3)
{
entity.worldObj.createExplosion(null, entity.posX, entity.posY, entity.posZ, radius, false);
entity.getEntityWorld().createExplosion(null, entity.posX, entity.posY, entity.posZ, radius, false);
}
}
@ -335,7 +337,7 @@ public class GenericHandler
if (player instanceof EntityPlayerMP)
{
BlockPos pos = player.getPosition();
DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(player.worldObj.provider.getDimension(), pos.getX() >> 4, pos.getZ() >> 4);
DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(player.getEntityWorld().provider.getDimension(), pos.getX() >> 4, pos.getZ() >> 4);
if (holder != null)
{
BloodMagicPacketHandler.sendTo(new DemonAuraPacketProcessor(holder), (EntityPlayerMP) player);
@ -352,7 +354,7 @@ public class GenericHandler
{
IBlockState state = event.getTargetBlock();
Block block = state.getBlock();
if (block != null && block instanceof BlockAltar && event.getEntityPlayer() != null && event.getEntityPlayer() instanceof EntityPlayerMP && event.getEntityPlayer().getHeldItemMainhand() != null && event.getEntityPlayer().getHeldItemMainhand().getItem() instanceof ItemAltarMaker)
if (block instanceof BlockAltar && event.getEntityPlayer() != null && event.getEntityPlayer() instanceof EntityPlayerMP && !event.getEntityPlayer().getHeldItemMainhand().isEmpty() && event.getEntityPlayer().getHeldItemMainhand().getItem() instanceof ItemAltarMaker)
{
ItemAltarMaker altarMaker = (ItemAltarMaker) event.getEntityPlayer().getHeldItemMainhand().getItem();
ChatUtil.sendNoSpam(event.getEntityPlayer(), TextHelper.localizeEffect("chat.BloodMagic.altarMaker.destroy", altarMaker.destroyAltar(event.getEntityPlayer())));
@ -398,7 +400,7 @@ public class GenericHandler
return;
ItemStack held = event.getItemStack();
if (held != null && held.getItem() instanceof IBindable)
if (!held.isEmpty() && held.getItem() instanceof IBindable)
{
held = NBTHelper.checkNBT(held);
IBindable bindable = (IBindable) held.getItem();
@ -418,7 +420,7 @@ public class GenericHandler
BindableHelper.setItemOwnerName(held, player.getDisplayNameString());
}
if (held != null && held.getItem() instanceof IBloodOrb)
if (!held.isEmpty() && held.getItem() instanceof IBloodOrb)
{
held = NBTHelper.checkNBT(held);
IBloodOrb bloodOrb = (IBloodOrb) held.getItem();
@ -466,10 +468,10 @@ public class GenericHandler
EntityPlayer player = (EntityPlayer) entity;
ItemStack heldStack = player.getHeldItemMainhand();
if (heldStack != null && heldStack.getItem() == ModItems.BOUND_SWORD && !(attackedEntity instanceof EntityAnimal))
if (!heldStack.isEmpty() && heldStack.getItem() == ModItems.BOUND_SWORD && !(attackedEntity instanceof EntityAnimal))
for (int i = 0; i <= EnchantmentHelper.getLootingModifier(player); i++)
if (attackedEntity.getEntityWorld().rand.nextDouble() < 0.2)
event.getDrops().add(new EntityItem(attackedEntity.worldObj, attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, new ItemStack(ModItems.BLOOD_SHARD, 1, 0)));
event.getDrops().add(new EntityItem(attackedEntity.getEntityWorld(), attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, new ItemStack(ModItems.BLOOD_SHARD, 1, 0)));
}
}
@ -480,14 +482,14 @@ public class GenericHandler
EntityPlayer player = event.getEntityPlayer();
ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantments.MENDING, player);
if (itemstack != null && itemstack.isItemDamaged())
if (!itemstack.isEmpty() && itemstack.isItemDamaged())
{
int i = Math.min(xpToDurability(event.getOrb().xpValue), itemstack.getItemDamage());
event.getOrb().xpValue -= durabilityToXp(i);
itemstack.setItemDamage(itemstack.getItemDamage() - i);
}
if (!player.worldObj.isRemote)
if (!player.getEntityWorld().isRemote)
{
for (ItemStack stack : player.inventory.mainInventory)
{

View file

@ -308,7 +308,7 @@ public class LivingArmourHandler
@SubscribeEvent
public void onArrowFire(ArrowLooseEvent event)
{
World world = event.getEntityPlayer().worldObj;
World world = event.getEntityPlayer().getEntityWorld();
ItemStack stack = event.getBow();
EntityPlayer player = event.getEntityPlayer();
@ -368,7 +368,7 @@ public class LivingArmourHandler
entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;
world.spawnEntityInWorld(entityarrow);
world.spawnEntity(entityarrow);
}
}
}

View file

@ -87,7 +87,7 @@ public class StatTrackerHandler
if (armour != null)
{
StatTrackerHealthboost.incrementCounter(armour, event.getAmount());
if (player.worldObj.canSeeSky(player.getPosition()) && player.worldObj.provider.isDaytime())
if (player.getEntityWorld().canSeeSky(player.getPosition()) && player.getEntityWorld().provider.isDaytime())
{
StatTrackerSolarPowered.incrementCounter(armour, event.getAmount());
}
@ -124,7 +124,7 @@ public class StatTrackerHandler
if (sourceEntity != null && !source.isMagicDamage() && !source.isProjectile())
StatTrackerPhysicalProtect.incrementCounter(armour, amount);
if (source.equals(DamageSource.fall))
if (source.equals(DamageSource.FALL))
StatTrackerFallProtect.incrementCounter(armour, amount);
if (source.isProjectile())
@ -162,7 +162,7 @@ public class StatTrackerHandler
{
StatTrackerMeleeDamage.incrementCounter(armour, amount);
if (player.worldObj.getLight(player.getPosition()) <= 9)
if (player.getEntityWorld().getLight(player.getPosition()) <= 9)
StatTrackerNightSight.incrementCounter(armour, amount);
if (mainWeapon != null && mainWeapon.getItem() instanceof ItemSpade)

View file

@ -56,7 +56,7 @@ public class WillHandler
if (remainder == null || ((IDemonWill) stack.getItem()).getWill(pickupType, stack) < 0.0001 || PlayerDemonWillHandler.isDemonWillFull(pickupType, player))
{
stack.stackSize = 0;
stack.setCount(0);
event.setResult(Event.Result.ALLOW);
}
}
@ -67,7 +67,7 @@ public class WillHandler
{
if (event.getSource() instanceof EntityDamageSourceIndirect)
{
Entity sourceEntity = ((EntityDamageSourceIndirect) event.getSource()).getSourceOfDamage();
Entity sourceEntity = event.getSource().getSourceOfDamage();
if (sourceEntity instanceof EntitySentientArrow)
{
@ -84,21 +84,21 @@ public class WillHandler
DamageSource source = event.getSource();
Entity entity = source.getEntity();
if (attackedEntity.isPotionActive(ModPotions.soulSnare) && (attackedEntity instanceof EntityMob || attackedEntity.worldObj.getDifficulty() == EnumDifficulty.PEACEFUL))
if (attackedEntity.isPotionActive(ModPotions.soulSnare) && (attackedEntity instanceof EntityMob || attackedEntity.getEntityWorld().getDifficulty() == EnumDifficulty.PEACEFUL))
{
PotionEffect eff = attackedEntity.getActivePotionEffect(ModPotions.soulSnare);
int lvl = eff.getAmplifier();
double amountOfSouls = attackedEntity.getEntityWorld().rand.nextDouble() * (lvl + 1) * (lvl + 1) * 5;
ItemStack soulStack = ((IDemonWill) ModItems.MONSTER_SOUL).createWill(0, amountOfSouls);
event.getDrops().add(new EntityItem(attackedEntity.worldObj, attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, soulStack));
event.getDrops().add(new EntityItem(attackedEntity.getEntityWorld(), attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, soulStack));
}
if (entity != null && entity instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) entity;
ItemStack heldStack = player.getHeldItemMainhand();
if (heldStack != null && heldStack.getItem() instanceof IDemonWillWeapon && !player.worldObj.isRemote)
if (heldStack != null && heldStack.getItem() instanceof IDemonWillWeapon && !player.getEntityWorld().isRemote)
{
IDemonWillWeapon demonWillWeapon = (IDemonWillWeapon) heldStack.getItem();
List<ItemStack> droppedSouls = demonWillWeapon.getRandomDemonWillDrop(attackedEntity, player, heldStack, event.getLootingLevel());
@ -114,7 +114,7 @@ public class WillHandler
EnumDemonWillType pickupType = ((IDemonWill) remainder.getItem()).getType(remainder);
if (((IDemonWill) remainder.getItem()).getWill(pickupType, remainder) >= 0.0001)
{
event.getDrops().add(new EntityItem(attackedEntity.worldObj, attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, remainder));
event.getDrops().add(new EntityItem(attackedEntity.getEntityWorld(), attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, remainder));
}
}
}

View file

@ -16,7 +16,7 @@ public class RecipeHelper
if (recipe != null)
{
ItemStack resultStack = recipe.getRecipeOutput();
if (resultStack != null && resultStack.getItem() != null)
if (!resultStack.isEmpty())
{
if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage())
{
@ -36,7 +36,7 @@ public class RecipeHelper
if (recipe != null)
{
ItemStack resultStack = recipe.getOutput();
if (resultStack != null && resultStack.getItem() != null)
if (!resultStack.isEmpty())
{
if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage())
{
@ -56,7 +56,7 @@ public class RecipeHelper
if (recipe != null)
{
ItemStack resultStack = recipe.getRecipeOutput();
if (resultStack != null && resultStack.getItem() != null)
if (!resultStack.isEmpty())
{
if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage())
{