Begin Sigil migration

This commit is contained in:
Nicholas Ignoffo 2017-10-08 21:42:40 -07:00
parent 96c617886a
commit a0cd54969b
27 changed files with 648 additions and 430 deletions

View file

@ -1,73 +0,0 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider;
import WayofTime.bloodmagic.api.iface.ISigil;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectProvider {
public ItemSigilAir() {
super("air", 50);
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if (stack.getItem() instanceof ISigil.Holding)
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
if (PlayerHelper.isFakePlayer(player))
return ActionResult.newResult(EnumActionResult.FAIL, stack);
boolean unusable = isUnusable(stack);
if (world.isRemote && !unusable) {
Vec3d vec = player.getLookVec();
double wantedVelocity = 1.7;
// TODO - Revisit after potions
if (player.isPotionActive(RegistrarBloodMagic.BOOST)) {
int amplifier = player.getActivePotionEffect(RegistrarBloodMagic.BOOST).getAmplifier();
wantedVelocity += (1 + amplifier) * (0.35);
}
player.motionX = vec.x * wantedVelocity;
player.motionY = vec.y * wantedVelocity;
player.motionZ = vec.z * wantedVelocity;
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
}
if (!world.isRemote) {
if (!player.capabilities.isCreativeMode)
this.setUnusable(stack, !NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()));
if (!unusable)
player.fallDistance = 0;
}
return super.onItemRightClick(world, player, hand);
}
@Override
public boolean applyOnHitEffect(EnumDemonWillType type, ItemStack swordStack, ItemStack providerStack, EntityLivingBase attacker, EntityLivingBase target) {
target.addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 200, 0));
return true;
}
@Override
public boolean providesEffectForWill(EnumDemonWillType type) {
return false;
}
}

View file

@ -1,82 +0,0 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.iface.ISigil;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
import WayofTime.bloodmagic.entity.projectile.EntityBloodLight;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
public class ItemSigilBloodLight extends ItemSigilBase {
public ItemSigilBloodLight() {
super("blood_light", 10);
}
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
if (getCooldownRemainder(stack) > 0)
reduceCooldown(stack);
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if (stack.getItem() instanceof ISigil.Holding)
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
if (PlayerHelper.isFakePlayer(player))
return ActionResult.newResult(EnumActionResult.FAIL, stack);
RayTraceResult mop = this.rayTrace(world, player, false);
if (getCooldownRemainder(stack) > 0)
return super.onItemRightClick(world, player, hand);
if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) {
BlockPos blockPos = mop.getBlockPos().offset(mop.sideHit);
if (world.isAirBlock(blockPos)) {
world.setBlockState(blockPos, RegistrarBloodMagicBlocks.BLOOD_LIGHT.getDefaultState());
if (!world.isRemote)
NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed());
resetCooldown(stack);
player.swingArm(hand);
return super.onItemRightClick(world, player, hand);
}
} else {
if (!world.isRemote) {
world.spawnEntity(new EntityBloodLight(world, player));
NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed());
}
resetCooldown(stack);
}
return super.onItemRightClick(world, player, hand);
}
@Override
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
return oldStack.getItem() != newStack.getItem();
}
public int getCooldownRemainder(ItemStack stack) {
return NBTHelper.checkNBT(stack).getTagCompound().getInteger(Constants.NBT.TICKS_REMAINING);
}
public void reduceCooldown(ItemStack stack) {
NBTHelper.checkNBT(stack).getTagCompound().setInteger(Constants.NBT.TICKS_REMAINING, getCooldownRemainder(stack) - 1);
}
public void resetCooldown(ItemStack stack) {
NBTHelper.checkNBT(stack).getTagCompound().setInteger(Constants.NBT.TICKS_REMAINING, 10);
}
}

View file

@ -1,22 +0,0 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class ItemSigilBounce extends ItemSigilToggleableBase {
public ItemSigilBounce() {
super("bounce", 100);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
if (PlayerHelper.isFakePlayer(player))
return;
player.addPotionEffect(new PotionEffect(RegistrarBloodMagic.BOUNCE, 2, 0, true, false));
}
}

View file

@ -1,22 +0,0 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class ItemSigilClaw extends ItemSigilToggleableBase {
public ItemSigilClaw() {
super("claw", 100);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
if (PlayerHelper.isFakePlayer(player))
return;
player.addPotionEffect(new PotionEffect(RegistrarBloodMagic.CLING, 2, 0, true, false));
}
}

View file

@ -1,98 +0,0 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.altar.IBloodAltar;
import WayofTime.bloodmagic.api.iface.IAltarReader;
import WayofTime.bloodmagic.api.iface.ISigil;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.tile.TileIncenseAltar;
import WayofTime.bloodmagic.tile.TileInversionPillar;
import WayofTime.bloodmagic.util.ChatUtil;
import WayofTime.bloodmagic.util.helper.NumeralHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
public class ItemSigilDivination extends ItemSigilBase implements IAltarReader {
public ItemSigilDivination() {
super("divination");
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
// if (world instanceof WorldServer)
// {
// System.out.println("Testing...");
//// BuildTestStructure s = new BuildTestStructure();
//// s.placeStructureAtPosition(new Random(), Rotation.CLOCKWISE_180, (WorldServer) world, player.getPosition(), 0);
// DungeonTester.testDungeonElementWithOutput((WorldServer) world, player.getPosition());
// }
// if (!world.isRemote)
// {
// EntityCorruptedSheep fred = new EntityCorruptedSheep(world, EnumDemonWillType.DESTRUCTIVE);
// fred.setPosition(player.posX, player.posY, player.posZ);
// world.spawnEntityInWorld(fred);
// }
ItemStack stack = player.getHeldItem(hand);
if (stack.getItem() instanceof ISigil.Holding)
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
if (PlayerHelper.isFakePlayer(player))
return ActionResult.newResult(EnumActionResult.FAIL, stack);
if (!world.isRemote) {
super.onItemRightClick(world, player, hand);
RayTraceResult position = rayTrace(world, player, false);
if (position == null) {
int currentEssence = NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).getCurrentEssence();
List<ITextComponent> toSend = new ArrayList<ITextComponent>();
if (!getOwnerName(stack).equals(PlayerHelper.getUsernameFromPlayer(player)))
toSend.add(new TextComponentTranslation(tooltipBase + "otherNetwork", getOwnerName(stack)));
toSend.add(new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence));
ChatUtil.sendNoSpam(player, toSend.toArray(new ITextComponent[toSend.size()]));
} else {
if (position.typeOfHit == RayTraceResult.Type.BLOCK) {
TileEntity tile = world.getTileEntity(position.getBlockPos());
if (tile != null && tile instanceof IBloodAltar) {
IBloodAltar altar = (IBloodAltar) tile;
int tier = altar.getTier().ordinal() + 1;
int currentEssence = altar.getCurrentBlood();
int capacity = altar.getCapacity();
altar.checkTier();
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentAltarTier", NumeralHelper.toRoman(tier)), new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence), new TextComponentTranslation(tooltipBase + "currentAltarCapacity", capacity));
} else if (tile != null && tile instanceof TileIncenseAltar) {
TileIncenseAltar altar = (TileIncenseAltar) tile;
altar.recheckConstruction();
double tranquility = altar.tranquility;
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentTranquility", (int) ((100D * (int) (100 * tranquility)) / 100d)), new TextComponentTranslation(tooltipBase + "currentBonus", (int) (100 * altar.incenseAddition)));
} else if (tile != null && tile instanceof TileInversionPillar) {
TileInversionPillar pillar = (TileInversionPillar) tile;
double inversion = pillar.getCurrentInversion();
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentInversion", ((int) (10 * inversion)) / 10d));
} else
{
int currentEssence = NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).getCurrentEssence();
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence));
}
}
}
}
return super.onItemRightClick(world, player, hand);
}
}

View file

@ -1,30 +0,0 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
import net.minecraft.entity.Entity;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import java.util.List;
public class ItemSigilEnderSeverance extends ItemSigilToggleableBase {
public ItemSigilEnderSeverance() {
super("ender_severance", 200);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
if (PlayerHelper.isFakePlayer(player))
return;
List<Entity> entityList = world.getEntitiesWithinAABB(Entity.class, new net.minecraft.util.math.AxisAlignedBB(player.posX - 4.5, player.posY - 4.5, player.posZ - 4.5, player.posX + 4.5, player.posY + 4.5, player.posZ + 4.5));
for (Entity entity : entityList) {
if (entity instanceof EntityEnderman)
((EntityEnderman) entity).addPotionEffect(new PotionEffect(RegistrarBloodMagic.PLANAR_BINDING, 40, 0));
}
}
}

View file

@ -1,52 +0,0 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import java.util.List;
public class ItemSigilFastMiner extends ItemSigilToggleableBase {
public ItemSigilFastMiner() {
super("fast_miner", 100);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
if (PlayerHelper.isFakePlayer(player))
return;
player.addPotionEffect(new PotionEffect(MobEffects.HASTE, 2, 0, true, false));
}
@Override
public boolean performArrayEffect(World world, BlockPos pos) {
double radius = 10;
int ticks = 600;
int potionPotency = 2;
AxisAlignedBB bb = new AxisAlignedBB(pos).grow(radius);
List<EntityPlayer> playerList = world.getEntitiesWithinAABB(EntityPlayer.class, bb);
for (EntityPlayer player : playerList) {
if (!player.isPotionActive(MobEffects.HASTE) || (player.isPotionActive(MobEffects.HASTE) && player.getActivePotionEffect(MobEffects.HASTE).getAmplifier() < potionPotency)) {
player.addPotionEffect(new PotionEffect(MobEffects.HASTE, ticks, potionPotency));
if (!player.capabilities.isCreativeMode) {
player.hurtResistantTime = 0;
player.attackEntityFrom(BloodMagicAPI.damageSource, 1.0F);
}
}
}
return false;
}
@Override
public boolean hasArrayEffect() {
return true;
}
}

View file

@ -1,21 +0,0 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import net.minecraft.enchantment.EnchantmentFrostWalker;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemSigilFrost extends ItemSigilToggleableBase {
public ItemSigilFrost() {
super("frost", 100);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
if (PlayerHelper.isFakePlayer(player))
return;
EnchantmentFrostWalker.freezeNearby(player, world, player.getPosition(), 1);
}
}

View file

@ -0,0 +1,51 @@
package WayofTime.bloodmagic.item.sigil.sigil;
import WayofTime.bloodmagic.api.iface.IBindable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
public interface ISigil extends IBindable {
@Nonnull
default EnumActionResult onRightClick(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull World world, @Nonnull EnumHand hand) {
return EnumActionResult.PASS;
}
default EnumActionResult onInteract(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side, @Nonnull EnumHand hand) {
return EnumActionResult.PASS;
}
@Nonnegative
int getCost();
interface Toggle extends ISigil {
default void onToggle(boolean active, @Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull World world, @Nonnull EnumHand hand) {
}
default void onUpdate(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull World world, @Nonnegative int itemSlot, boolean isHeld) {
}
}
interface Holding extends ISigil {
int getSize(ItemStack stack);
int getEquippedSigil(ItemStack stack);
NonNullList<ItemStack> getHeldSigils(ItemStack stack);
void setHeldSigils(ItemStack stack, NonNullList<ItemStack> inventory);
}
}

View file

@ -0,0 +1,148 @@
package WayofTime.bloodmagic.item.sigil.sigil;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.iface.IBindable;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.client.IMeshProvider;
import com.google.common.collect.Lists;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import java.util.List;
public class ItemSigil extends Item implements IBindable, IMeshProvider {
private final ISigil sigil;
public ItemSigil(ISigil sigil, String name) {
this.sigil = sigil;
setCreativeTab(BloodMagic.TAB_BM);
setUnlocalizedName(BloodMagic.MODID + ".sigil." + name);
setMaxStackSize(1);
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
if (PlayerHelper.isFakePlayer(player))
return ActionResult.newResult(EnumActionResult.FAIL, player.getHeldItem(hand));
ItemStack sigilStack = getSigilStack(player, hand);
if (getOwnerUUID(sigilStack) == null)
return ActionResult.newResult(EnumActionResult.FAIL, player.getHeldItem(hand));
if (sigil instanceof ISigil.Toggle && player.isSneaking()) {
boolean newState = toggleState(sigilStack);
((ISigil.Toggle) sigil).onToggle(newState, sigilStack, player, world, hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
return ActionResult.newResult(sigil.onRightClick(sigilStack, player, world, hand), player.getHeldItem(hand));
}
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (PlayerHelper.isFakePlayer(player))
return EnumActionResult.FAIL;
return sigil.onInteract(getSigilStack(player, hand), player, world, pos, facing, hand);
}
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
if (!(entity instanceof EntityPlayer) || PlayerHelper.isFakePlayer((EntityPlayer) entity))
return;
ItemStack sigilStack = stack;
if (sigil instanceof ISigil.Holding) {
ISigil.Holding holding = (ISigil.Holding) sigil;
int current = holding.getEquippedSigil(stack);
sigilStack = holding.getHeldSigils(stack).get(current);
}
if (sigil instanceof ISigil.Toggle && isActive(sigilStack)) {
((ISigil.Toggle) sigil).onUpdate(sigilStack, (EntityPlayer) entity, world, itemSlot, isSelected);
if (entity.ticksExisted % 100 == 0)
NetworkHelper.getSoulNetwork(getOwnerUUID(sigilStack)).syphonAndDamage((EntityPlayer) entity, sigil.getCost());
}
}
@Override
public String getOwnerName(ItemStack stack) {
return sigil.getOwnerName(stack);
}
@Override
public String getOwnerUUID(ItemStack stack) {
return sigil.getOwnerUUID(stack);
}
public boolean toggleState(ItemStack stack) {
if (!stack.hasTagCompound())
return false;
boolean newState = !isActive(stack);
stack.getTagCompound().setBoolean("active", newState);
return newState;
}
public boolean isActive(ItemStack stack) {
return stack.hasTagCompound() && stack.getTagCompound().getBoolean("active");
}
// TODO - Need to get ISigil from holding stack
public ItemStack getSigilStack(EntityPlayer player, EnumHand hand) {
ItemStack held = player.getHeldItem(hand);
if (sigil instanceof ISigil.Holding) {
ISigil.Holding holding = (ISigil.Holding) sigil;
int current = holding.getEquippedSigil(held);
return holding.getHeldSigils(held).get(current);
}
return held;
}
@Override
public boolean onBind(EntityPlayer player, ItemStack stack) {
return sigil.onBind(player, stack);
}
@SideOnly(Side.CLIENT)
@Override
public ItemMeshDefinition getMeshDefinition() {
return s -> {
if (!(sigil instanceof ISigil.Toggle))
return new ModelResourceLocation(s.getItem().getRegistryName(), "inventory");
return new ModelResourceLocation(s.getItem().getRegistryName(), "active=" + isActive(s));
};
}
@Override
public List<String> getVariants() {
if (sigil instanceof ISigil.Toggle) {
return Lists.newArrayList(
"active=true",
"active=false"
);
} else return Lists.newArrayList("inventory");
}
@Nullable
@Override
public ResourceLocation getCustomLocation() {
return null;
}
}

View file

@ -0,0 +1,81 @@
package WayofTime.bloodmagic.item.sigil.sigil;
import WayofTime.bloodmagic.api.altar.IBloodAltar;
import WayofTime.bloodmagic.api.iface.IAltarReader;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.tile.TileIncenseAltar;
import WayofTime.bloodmagic.tile.TileInversionPillar;
import WayofTime.bloodmagic.util.ChatUtil;
import WayofTime.bloodmagic.util.Utils;
import WayofTime.bloodmagic.util.helper.NumeralHelper;
import com.google.common.collect.Lists;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.List;
public class ItemSigilDivination extends ItemSigil implements IAltarReader {
public ItemSigilDivination() {
super(new SigilDivination(), "divination");
}
public static class SigilDivination implements ISigil {
@Nonnull
@Override
public EnumActionResult onRightClick(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull World world, @Nonnull EnumHand hand) {
RayTraceResult rayTrace = Utils.rayTrace(player, false);
if (rayTrace == null || rayTrace.typeOfHit == RayTraceResult.Type.MISS) {
printNetworkInformation(stack, player);
} else if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) {
TileEntity tile = world.getTileEntity(rayTrace.getBlockPos());
String tooltipBase = "tooltip.bloodmagic.sigil.divination.";
if (tile != null && tile instanceof IBloodAltar) {
IBloodAltar altar = (IBloodAltar) tile;
int tier = altar.getTier().ordinal() + 1;
int currentEssence = altar.getCurrentBlood();
int capacity = altar.getCapacity();
altar.checkTier();
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentAltarTier", NumeralHelper.toRoman(tier)), new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence), new TextComponentTranslation(tooltipBase + "currentAltarCapacity", capacity));
} else if (tile != null && tile instanceof TileIncenseAltar) {
TileIncenseAltar altar = (TileIncenseAltar) tile;
altar.recheckConstruction();
double tranquility = altar.tranquility;
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentTranquility", (int) ((100D * (int) (100 * tranquility)) / 100d)), new TextComponentTranslation(tooltipBase + "currentBonus", (int) (100 * altar.incenseAddition)));
} else if (tile != null && tile instanceof TileInversionPillar) {
TileInversionPillar pillar = (TileInversionPillar) tile;
double inversion = pillar.getCurrentInversion();
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentInversion", ((int) (10 * inversion)) / 10d));
} else {
printNetworkInformation(stack, player);
}
}
return EnumActionResult.PASS;
}
@Override
public int getCost() {
return 0;
}
private void printNetworkInformation(ItemStack sigilStack, EntityPlayer player) {
int currentEssence = NetworkHelper.getSoulNetwork(getOwnerUUID(sigilStack)).getCurrentEssence();
List<ITextComponent> toSend = Lists.newArrayList();
if (getOwnerName(sigilStack) != null && !getOwnerName(sigilStack).equals(PlayerHelper.getUsernameFromPlayer(player)))
toSend.add(new TextComponentTranslation("tooltip.bloodmagic.sigil.divination.otherNetwork", getOwnerName(sigilStack)));
toSend.add(new TextComponentTranslation("tooltip.bloodmagic.sigil.divination.currentEssence", currentEssence));
ChatUtil.sendNoSpam(player, toSend.toArray(new ITextComponent[0]));
}
}
}

View file

@ -0,0 +1,52 @@
package WayofTime.bloodmagic.item.sigil.sigil;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class SigilAir implements ISigil {
@Nonnull
@Override
public EnumActionResult onRightClick(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull World world, @Nonnull EnumHand hand) {
if (world.isRemote) {
Vec3d vec = player.getLookVec();
double wantedVelocity = 1.7D;
if (player.isPotionActive(RegistrarBloodMagic.BOOST)) {
int amplifier = player.getActivePotionEffect(RegistrarBloodMagic.BOOST).getAmplifier();
wantedVelocity += (1.0D + amplifier) * 0.35D;
}
player.motionX = vec.x * wantedVelocity;
player.motionY = vec.y * wantedVelocity;
player.motionZ = vec.z * wantedVelocity;
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
}
if (!world.isRemote) {
boolean unusable = false;
if (!player.capabilities.isCreativeMode)
unusable = !NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getCost());
if (!unusable)
player.fallDistance = 0;
}
return EnumActionResult.SUCCESS;
}
@Override
public int getCost() {
return 50;
}
}

View file

@ -0,0 +1,55 @@
package WayofTime.bloodmagic.item.sigil.sigil;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
import WayofTime.bloodmagic.entity.projectile.EntityBloodLight;
import WayofTime.bloodmagic.util.Utils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.CooldownTracker;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class SigilBloodLight implements ISigil {
@Nonnull
@Override
public EnumActionResult onRightClick(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull World world, @Nonnull EnumHand hand) {
Item item = stack.getItem();
RayTraceResult mop = Utils.rayTrace(player, false);
CooldownTracker cooldownTracker = player.getCooldownTracker();
if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) {
BlockPos blockPos = mop.getBlockPos().offset(mop.sideHit);
if (world.getBlockState(blockPos).getBlock().isReplaceable(world, blockPos)) {
world.setBlockState(blockPos, RegistrarBloodMagicBlocks.BLOOD_LIGHT.getDefaultState());
if (!world.isRemote)
NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getCost());
player.swingArm(hand);
cooldownTracker.setCooldown(item, 10);
return EnumActionResult.SUCCESS;
}
} else {
if (!world.isRemote) {
world.spawnEntity(new EntityBloodLight(world, player));
NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getCost());
}
cooldownTracker.setCooldown(item, 10);
return EnumActionResult.SUCCESS;
}
return EnumActionResult.PASS;
}
@Override
public int getCost() {
return 10;
}
}

View file

@ -0,0 +1,22 @@
package WayofTime.bloodmagic.item.sigil.sigil;
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class SigilBounce implements ISigil.Toggle {
@Override
public void onUpdate(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull World world, int itemSlot, boolean isHeld) {
player.addPotionEffect(new PotionEffect(RegistrarBloodMagic.BOUNCE, 2, 0, true, false));
}
@Override
public int getCost() {
return 100;
}
}

View file

@ -0,0 +1,22 @@
package WayofTime.bloodmagic.item.sigil.sigil;
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class SigilClaw implements ISigil.Toggle {
@Override
public void onUpdate(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull World world, int itemSlot, boolean isHeld) {
player.addPotionEffect(new PotionEffect(RegistrarBloodMagic.CLING, 2, 0, true, false));
}
@Override
public int getCost() {
return 100;
}
}

View file

@ -1,25 +1,25 @@
package WayofTime.bloodmagic.item.sigil;
package WayofTime.bloodmagic.item.sigil.sigil;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class ItemSigilElementalAffinity extends ItemSigilToggleableBase {
public ItemSigilElementalAffinity() {
super("elemental_affinity", 200);
}
import javax.annotation.Nonnull;
public class SigilElementalAffinity implements ISigil.Toggle {
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
if (PlayerHelper.isFakePlayer(player))
return;
public void onUpdate(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull World world, int itemSlot, boolean isHeld) {
player.fallDistance = 0;
player.extinguish();
player.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 2, 1, true, false));
player.addPotionEffect(new PotionEffect(MobEffects.WATER_BREATHING, 2, 0, true, false));
}
@Override
public int getCost() {
return 200;
}
}

View file

@ -0,0 +1,26 @@
package WayofTime.bloodmagic.item.sigil.sigil;
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
import net.minecraft.entity.Entity;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.List;
public class SigilEnderSeverance implements ISigil.Toggle {
@Override
public void onUpdate(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull World world, int itemSlot, boolean isHeld) {
List<Entity> entityList = world.getEntitiesWithinAABB(Entity.class, new net.minecraft.util.math.AxisAlignedBB(player.posX - 4.5, player.posY - 4.5, player.posZ - 4.5, player.posX + 4.5, player.posY + 4.5, player.posZ + 4.5));
entityList.stream().filter(e -> e instanceof EntityEnderman).forEach(e -> ((EntityEnderman) e).addPotionEffect(new PotionEffect(RegistrarBloodMagic.PLANAR_BINDING, 40, 0)));
}
@Override
public int getCost() {
return 200;
}
}

View file

@ -0,0 +1,48 @@
package WayofTime.bloodmagic.item.sigil.sigil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class SigilFastMiner implements ISigil.Toggle {
@Override
public void onUpdate(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull World world, int itemSlot, boolean isHeld) {
player.addPotionEffect(new PotionEffect(MobEffects.HASTE, 2, 0, true, false));
}
@Override
public int getCost() {
return 100;
}
// @Override
// public boolean performArrayEffect(World world, BlockPos pos) {
// double radius = 10;
// int ticks = 600;
// int potionPotency = 2;
//
// AxisAlignedBB bb = new AxisAlignedBB(pos).grow(radius);
// List<EntityPlayer> playerList = world.getEntitiesWithinAABB(EntityPlayer.class, bb);
// for (EntityPlayer player : playerList) {
// if (!player.isPotionActive(MobEffects.HASTE) || (player.isPotionActive(MobEffects.HASTE) && player.getActivePotionEffect(MobEffects.HASTE).getAmplifier() < potionPotency)) {
// player.addPotionEffect(new PotionEffect(MobEffects.HASTE, ticks, potionPotency));
// if (!player.capabilities.isCreativeMode) {
// player.hurtResistantTime = 0;
// player.attackEntityFrom(BloodMagicAPI.damageSource, 1.0F);
// }
// }
// }
//
// return false;
// }
//
// @Override
// public boolean hasArrayEffect() {
// return true;
// }
}

View file

@ -0,0 +1,21 @@
package WayofTime.bloodmagic.item.sigil.sigil;
import net.minecraft.enchantment.EnchantmentFrostWalker;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class SigilFrost implements ISigil.Toggle {
@Override
public void onUpdate(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull World world, int itemSlot, boolean isHeld) {
EnchantmentFrostWalker.freezeNearby(player, world, player.getPosition(), 1);
}
@Override
public int getCost() {
return 100;
}
}

View file

@ -0,0 +1,53 @@
package WayofTime.bloodmagic.item.sigil.sigil;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.NonNullList;
public class SigilHolding implements ISigil.Holding {
@Override
public int getCost() {
return 0;
}
@Override
public int getSize(ItemStack stack) {
return 5;
}
@Override
public int getEquippedSigil(ItemStack stack) {
if (!stack.hasTagCompound() || !stack.getTagCompound().hasKey("current"))
return -1;
return stack.getTagCompound().getInteger("current");
}
@Override
public NonNullList<ItemStack> getHeldSigils(ItemStack stack) {
NonNullList<ItemStack> inventory = NonNullList.withSize(getSize(stack), ItemStack.EMPTY);
if (!stack.hasTagCompound() || !stack.getTagCompound().hasKey("inv"))
return inventory;
NBTTagList invTag = stack.getTagCompound().getTagList("inv", 10);
for (int i = 0; i < invTag.tagCount(); i++)
inventory.set(i, new ItemStack(invTag.getCompoundTagAt(i)));
return inventory;
}
@Override
public void setHeldSigils(ItemStack stack, NonNullList<ItemStack> inventory) {
NBTTagList invTag = new NBTTagList();
for (ItemStack invStack : inventory)
if (!invStack.isEmpty())
invTag.appendTag(invStack.writeToNBT(new NBTTagCompound()));
if (!stack.hasTagCompound())
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setTag("inv", invTag);
}
}