Begin Sigil migration
This commit is contained in:
parent
96c617886a
commit
a0cd54969b
|
@ -7,10 +7,11 @@ import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
|||
|
||||
import java.util.Locale;
|
||||
|
||||
@Deprecated
|
||||
public class Constants {
|
||||
public static class NBT {
|
||||
public static final String OWNER_UUID = "ownerUUID";
|
||||
public static final String OWNER_NAME = "ownerNAME";
|
||||
public static final String OWNER_UUID = "uuid";
|
||||
public static final String OWNER_NAME = "name";
|
||||
public static final String USES = "uses";
|
||||
public static final String ACTIVATED = "activated";
|
||||
public static final String UNUSABLE = "unusable";
|
||||
|
|
|
@ -3,6 +3,8 @@ package WayofTime.bloodmagic.api.iface;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Implement this interface on any Item that can be bound to a player.
|
||||
*/
|
||||
|
@ -16,7 +18,10 @@ public interface IBindable {
|
|||
* @param stack - The owned ItemStack
|
||||
* @return - The username of the Item's owner
|
||||
*/
|
||||
String getOwnerName(ItemStack stack);
|
||||
@Nullable
|
||||
default String getOwnerName(ItemStack stack) {
|
||||
return !stack.isEmpty() && stack.hasTagCompound() ? stack.getTagCompound().getString("name") : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the UUID of the Item's owner.
|
||||
|
@ -26,7 +31,10 @@ public interface IBindable {
|
|||
* @param stack - The owned ItemStack
|
||||
* @return - The UUID of the Item's owner
|
||||
*/
|
||||
String getOwnerUUID(ItemStack stack);
|
||||
@Nullable
|
||||
default String getOwnerUUID(ItemStack stack) {
|
||||
return !stack.isEmpty() && stack.hasTagCompound() ? stack.getTagCompound().getString("uuid") : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the player attempts to bind the item.
|
||||
|
@ -35,5 +43,7 @@ public interface IBindable {
|
|||
* @param stack - The ItemStack to attempt binding
|
||||
* @return If binding was successful.
|
||||
*/
|
||||
boolean onBind(EntityPlayer player, ItemStack stack);
|
||||
default boolean onBind(EntityPlayer player, ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,11 +25,11 @@ public class ItemBindable extends Item implements IBindable {
|
|||
|
||||
@Override
|
||||
public String getOwnerName(ItemStack stack) {
|
||||
return !stack.isEmpty() ? stack.getTagCompound().getString(Constants.NBT.OWNER_NAME) : null;
|
||||
return !stack.isEmpty() && stack.hasTagCompound() ? stack.getTagCompound().getString(Constants.NBT.OWNER_NAME) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwnerUUID(ItemStack stack) {
|
||||
return !stack.isEmpty() ? stack.getTagCompound().getString(Constants.NBT.OWNER_UUID) : null;
|
||||
return !stack.isEmpty() && stack.hasTagCompound() ? stack.getTagCompound().getString(Constants.NBT.OWNER_UUID) : null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ import WayofTime.bloodmagic.ConfigHandler;
|
|||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.block.BlockAltar;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.item.sigil.ItemSigilDivination;
|
||||
import WayofTime.bloodmagic.item.sigil.ItemSigilSeer;
|
||||
import WayofTime.bloodmagic.item.sigil.sigil.ItemSigilDivination;
|
||||
import WayofTime.bloodmagic.tile.TileAltar;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
|
|
|
@ -15,6 +15,8 @@ import WayofTime.bloodmagic.item.routing.ItemFluidRouterFilter;
|
|||
import WayofTime.bloodmagic.item.routing.ItemNodeRouter;
|
||||
import WayofTime.bloodmagic.item.routing.ItemRouterFilter;
|
||||
import WayofTime.bloodmagic.item.sigil.*;
|
||||
import WayofTime.bloodmagic.item.sigil.sigil.*;
|
||||
import WayofTime.bloodmagic.item.sigil.sigil.ItemSigilDivination;
|
||||
import WayofTime.bloodmagic.item.soul.*;
|
||||
import WayofTime.bloodmagic.item.types.ComponentType;
|
||||
import WayofTime.bloodmagic.item.types.ReagentType;
|
||||
|
@ -146,28 +148,28 @@ public class RegistrarBloodMagicItems {
|
|||
new ItemBoundAxe().setRegistryName("bound_axe"),
|
||||
new ItemBoundShovel().setRegistryName("bound_shovel"),
|
||||
new ItemSigilDivination().setRegistryName("sigil_divination"),
|
||||
new ItemSigilAir().setRegistryName("sigil_air"),
|
||||
new ItemSigil(new SigilAir(), "air").setRegistryName("sigil_air"),
|
||||
new ItemSigilWater().setRegistryName("sigil_water"),
|
||||
new ItemSigilLava().setRegistryName("sigil_lava"),
|
||||
new ItemSigilVoid().setRegistryName("sigil_void"),
|
||||
new ItemSigilGreenGrove().setRegistryName("sigil_green_grove"),
|
||||
new ItemSigilBloodLight().setRegistryName("sigil_blood_light"),
|
||||
new ItemSigilElementalAffinity().setRegistryName("sigil_elemental_affinity"),
|
||||
new ItemSigil(new SigilBloodLight(), "blood_light").setRegistryName("sigil_blood_light"),
|
||||
new ItemSigil(new SigilElementalAffinity(), "elemental_affinity").setRegistryName("sigil_elemental_affinity"),
|
||||
new ItemSigilMagnetism().setRegistryName("sigil_magnetism"),
|
||||
new ItemSigilSuppression().setRegistryName("sigil_suppression"),
|
||||
new ItemSigilHaste().setRegistryName("sigil_haste"),
|
||||
new ItemSigilFastMiner().setRegistryName("sigil_fast_miner"),
|
||||
new ItemSigil(new SigilFastMiner(), "fast_miner").setRegistryName("sigil_fast_miner"),
|
||||
new ItemSigilSeer().setRegistryName("sigil_seer"),
|
||||
new ItemSigilPhantomBridge().setRegistryName("sigil_phantom_bridge"),
|
||||
new ItemSigilWhirlwind().setRegistryName("sigil_whirlwind"),
|
||||
new ItemSigilCompression().setRegistryName("sigil_compression"),
|
||||
new ItemSigilEnderSeverance().setRegistryName("sigil_ender_severance"),
|
||||
new ItemSigil(new SigilEnderSeverance(), "ender_severance").setRegistryName("sigil_ender_severance"),
|
||||
new ItemSigilHolding().setRegistryName("sigil_holding"),
|
||||
new ItemSigilTeleposition().setRegistryName("sigil_teleposition"),
|
||||
new ItemSigilTransposition().setRegistryName("sigil_transposition"),
|
||||
new ItemSigilClaw().setRegistryName("sigil_claw"),
|
||||
new ItemSigilBounce().setRegistryName("sigil_bounce"),
|
||||
new ItemSigilFrost().setRegistryName("sigil_frost"),
|
||||
new ItemSigil(new SigilClaw(), "claw").setRegistryName("sigil_claw"),
|
||||
new ItemSigil(new SigilBounce(), "bounce").setRegistryName("sigil_bounce"),
|
||||
new ItemSigil(new SigilFrost(), "frost").setRegistryName("sigil_frost"),
|
||||
new ItemEnum<>(ComponentType.class, "component").setRegistryName("component"),
|
||||
new ItemEnum<>(ReagentType.class, "reagent").setRegistryName("reagent"),
|
||||
new ItemDemonCrystal().setRegistryName("item_demon_crystal"),
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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]));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
// }
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -36,10 +36,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.common.ISpecialArmor;
|
||||
|
@ -956,4 +953,24 @@ public class Utils {
|
|||
stack.getTagCompound().setLong(Constants.NBT.LEAST_SIG, itemUUID.getLeastSignificantBits());
|
||||
}
|
||||
}
|
||||
|
||||
public static RayTraceResult rayTrace(EntityPlayer player, boolean useLiquids) {
|
||||
float pitch = player.rotationPitch;
|
||||
float yaw = player.rotationYaw;
|
||||
Vec3d eyePosition = new Vec3d(player.posX, player.posY + (double) player.getEyeHeight(), player.posZ);
|
||||
|
||||
float f2 = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI);
|
||||
float f3 = MathHelper.sin(-yaw * 0.017453292F - (float) Math.PI);
|
||||
float f4 = -MathHelper.cos(-pitch * 0.017453292F);
|
||||
float f5 = MathHelper.sin(-pitch * 0.017453292F);
|
||||
float f6 = f3 * f4;
|
||||
float f7 = f2 * f4;
|
||||
|
||||
double reachDistance = 5.0D;
|
||||
if (player instanceof EntityPlayerMP)
|
||||
reachDistance = ((EntityPlayerMP)player).interactionManager.getBlockReachDistance();
|
||||
|
||||
Vec3d reachPosition = eyePosition.addVector((double) f6 * reachDistance, (double) f5 * reachDistance, (double) f7 * reachDistance);
|
||||
return player.getEntityWorld().rayTraceBlocks(eyePosition, reachPosition, useLiquids, !useLiquids, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import WayofTime.bloodmagic.util.helper.TextHelper;
|
|||
import com.google.common.base.Strings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
@ -69,6 +70,7 @@ import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
|||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerPickupXpEvent;
|
||||
|
@ -371,6 +373,13 @@ public class GenericHandler {
|
|||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public void onTooltip(ItemTooltipEvent event) {
|
||||
if (event.getItemStack().getItem() instanceof IBindable)
|
||||
if (((IBindable) event.getItemStack().getItem()).getOwnerUUID(event.getItemStack()) != null)
|
||||
event.getToolTip().add(I18n.format("tooltip.bloodmagic.currentOwner", PlayerHelper.getUsernameFromStack(event.getItemStack())));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void selfSacrificeEvent(SacrificeKnifeUsedEvent event) {
|
||||
EntityPlayer player = event.player;
|
||||
|
|
Loading…
Reference in a new issue