Run formatter

This commit is contained in:
Nicholas Ignoffo 2017-08-15 21:30:48 -07:00
parent 61c44a831b
commit 08258fd6ef
606 changed files with 13464 additions and 22975 deletions

View file

@ -1,6 +1,9 @@
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;
@ -15,20 +18,14 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectProvider
{
public ItemSigilAir()
{
public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectProvider {
public ItemSigilAir() {
super("air", 50);
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
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);
@ -36,14 +33,12 @@ public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectP
return ActionResult.newResult(EnumActionResult.FAIL, stack);
boolean unusable = isUnusable(stack);
if (world.isRemote && !unusable)
{
if (world.isRemote && !unusable) {
Vec3d vec = player.getLookVec();
double wantedVelocity = 1.7;
// TODO - Revisit after potions
if (player.isPotionActive(RegistrarBloodMagic.BOOST))
{
if (player.isPotionActive(RegistrarBloodMagic.BOOST)) {
int amplifier = player.getActivePotionEffect(RegistrarBloodMagic.BOOST).getAmplifier();
wantedVelocity += (1 + amplifier) * (0.35);
}
@ -54,8 +49,7 @@ public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectP
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 (!world.isRemote) {
if (!player.capabilities.isCreativeMode)
this.setUnusable(stack, !NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()));
@ -67,15 +61,13 @@ public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectP
}
@Override
public boolean applyOnHitEffect(EnumDemonWillType type, ItemStack swordStack, ItemStack providerStack, EntityLivingBase attacker, EntityLivingBase target)
{
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)
{
public boolean providesEffectForWill(EnumDemonWillType type) {
return false;
}
}

View file

@ -1,31 +1,27 @@
package WayofTime.bloodmagic.item.sigil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.impl.ItemSigil;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.client.IVariantProvider;
import WayofTime.bloodmagic.util.helper.TextHelper;
import com.google.common.base.Strings;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.tuple.Pair;
import WayofTime.bloodmagic.client.IVariantProvider;
import WayofTime.bloodmagic.util.helper.TextHelper;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ItemSigilBase extends ItemSigil implements IVariantProvider
{
public class ItemSigilBase extends ItemSigil implements IVariantProvider {
protected final String tooltipBase;
private final String name;
public ItemSigilBase(String name, int lpUsed)
{
public ItemSigilBase(String name, int lpUsed) {
super(lpUsed);
setUnlocalizedName(BloodMagic.MODID + ".sigil." + name);
@ -35,15 +31,13 @@ public class ItemSigilBase extends ItemSigil implements IVariantProvider
this.tooltipBase = "tooltip.bloodmagic.sigil." + name + ".";
}
public ItemSigilBase(String name)
{
public ItemSigilBase(String name) {
this(name, 0);
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
{
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
if (TextHelper.canTranslate(tooltipBase + "desc"))
tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect(tooltipBase + "desc"))));
@ -57,8 +51,7 @@ public class ItemSigilBase extends ItemSigil implements IVariantProvider
}
@Override
public List<Pair<Integer, String>> getVariants()
{
public List<Pair<Integer, String>> getVariants() {
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
ret.add(Pair.of(0, "type=normal"));
return ret;

View file

@ -1,7 +1,12 @@
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;
@ -11,29 +16,20 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.entity.projectile.EntityBloodLight;
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
public class ItemSigilBloodLight extends ItemSigilBase
{
public ItemSigilBloodLight()
{
public class ItemSigilBloodLight extends ItemSigilBase {
public ItemSigilBloodLight() {
super("bloodLight", 10);
}
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
{
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)
{
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);
@ -45,12 +41,10 @@ public class ItemSigilBloodLight extends ItemSigilBase
if (getCooldownRemainder(stack) > 0)
return super.onItemRightClick(world, player, hand);
if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK)
{
if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) {
BlockPos blockPos = mop.getBlockPos().offset(mop.sideHit);
if (world.isAirBlock(blockPos))
{
if (world.isAirBlock(blockPos)) {
world.setBlockState(blockPos, RegistrarBloodMagicBlocks.BLOOD_LIGHT.getDefaultState());
if (!world.isRemote)
NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed());
@ -58,10 +52,8 @@ public class ItemSigilBloodLight extends ItemSigilBase
player.swingArm(hand);
return super.onItemRightClick(world, player, hand);
}
} else
{
if (!world.isRemote)
{
} else {
if (!world.isRemote) {
world.spawnEntity(new EntityBloodLight(world, player));
NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed());
}
@ -72,23 +64,19 @@ public class ItemSigilBloodLight extends ItemSigilBase
}
@Override
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
{
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
return oldStack.getItem() != newStack.getItem();
}
public int getCooldownRemainder(ItemStack stack)
{
public int getCooldownRemainder(ItemStack stack) {
return NBTHelper.checkNBT(stack).getTagCompound().getInteger(Constants.NBT.TICKS_REMAINING);
}
public void reduceCooldown(ItemStack stack)
{
public void reduceCooldown(ItemStack stack) {
NBTHelper.checkNBT(stack).getTagCompound().setInteger(Constants.NBT.TICKS_REMAINING, getCooldownRemainder(stack) - 1);
}
public void resetCooldown(ItemStack stack)
{
public void resetCooldown(ItemStack stack) {
NBTHelper.checkNBT(stack).getTagCompound().setInteger(Constants.NBT.TICKS_REMAINING, 10);
}
}

View file

@ -7,16 +7,13 @@ import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class ItemSigilBounce extends ItemSigilToggleableBase
{
public ItemSigilBounce()
{
public class ItemSigilBounce extends ItemSigilToggleableBase {
public ItemSigilBounce() {
super("bounce", 100);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
{
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
if (PlayerHelper.isFakePlayer(player))
return;

View file

@ -7,16 +7,13 @@ import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class ItemSigilClaw extends ItemSigilToggleableBase
{
public ItemSigilClaw()
{
public class ItemSigilClaw extends ItemSigilToggleableBase {
public ItemSigilClaw() {
super("claw", 100);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
{
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
if (PlayerHelper.isFakePlayer(player))
return;

View file

@ -7,10 +7,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemSigilCompression extends ItemSigilToggleableBase
{
public ItemSigilCompression()
{
public class ItemSigilCompression extends ItemSigilToggleableBase {
public ItemSigilCompression() {
super("compression", 200);
}
@ -18,8 +16,7 @@ public class ItemSigilCompression extends ItemSigilToggleableBase
// TODO for now, there is a semi-working system in place
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
{
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
if (true)
return; // TODO - Rewrite compression system
@ -28,8 +25,7 @@ public class ItemSigilCompression extends ItemSigilToggleableBase
ItemStack compressedStack = CompressionRegistry.compressInventory(player.inventory.mainInventory.toArray(new ItemStack[player.inventory.mainInventory.size()]), world);
if (compressedStack != null)
{
if (compressedStack != null) {
EntityItem entityItem = new EntityItem(world, player.posX, player.posY, player.posZ, compressedStack);
world.spawnEntity(entityItem);
}

View file

@ -1,9 +1,14 @@
package WayofTime.bloodmagic.item.sigil;
import java.util.ArrayList;
import java.util.List;
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;
@ -14,25 +19,17 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
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.helper.NumeralHelper;
public class ItemSigilDivination extends ItemSigilBase implements IAltarReader
{
public ItemSigilDivination()
{
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)
{
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
// if (world instanceof WorldServer)
// {
// System.out.println("Testing...");
@ -54,42 +51,35 @@ public class ItemSigilDivination extends ItemSigilBase implements IAltarReader
if (PlayerHelper.isFakePlayer(player))
return ActionResult.newResult(EnumActionResult.FAIL, stack);
if (!world.isRemote)
{
if (!world.isRemote) {
super.onItemRightClick(world, player, hand);
RayTraceResult position = rayTrace(world, player, false);
if (position == null)
{
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)
{
} else {
if (position.typeOfHit == RayTraceResult.Type.BLOCK) {
TileEntity tile = world.getTileEntity(position.getBlockPos());
if (tile != null && tile instanceof IBloodAltar)
{
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)
{
} 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)
{
} 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));

View file

@ -7,16 +7,13 @@ import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class ItemSigilElementalAffinity extends ItemSigilToggleableBase
{
public ItemSigilElementalAffinity()
{
public class ItemSigilElementalAffinity extends ItemSigilToggleableBase {
public ItemSigilElementalAffinity() {
super("elementalAffinity", 200);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
{
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
if (PlayerHelper.isFakePlayer(player))
return;

View file

@ -1,7 +1,5 @@
package WayofTime.bloodmagic.item.sigil;
import java.util.List;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
import net.minecraft.entity.Entity;
@ -11,22 +9,20 @@ import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class ItemSigilEnderSeverance extends ItemSigilToggleableBase
{
public ItemSigilEnderSeverance()
{
import java.util.List;
public class ItemSigilEnderSeverance extends ItemSigilToggleableBase {
public ItemSigilEnderSeverance() {
super("enderSeverance", 200);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
{
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)
{
for (Entity entity : entityList) {
if (entity instanceof EntityEnderman)
((EntityEnderman) entity).addPotionEffect(new PotionEffect(RegistrarBloodMagic.PLANAR_BINDING, 40, 0));
}

View file

@ -1,7 +1,5 @@
package WayofTime.bloodmagic.item.sigil;
import java.util.List;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import net.minecraft.entity.player.EntityPlayer;
@ -12,37 +10,32 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class ItemSigilFastMiner extends ItemSigilToggleableBase
{
public ItemSigilFastMiner()
{
import java.util.List;
public class ItemSigilFastMiner extends ItemSigilToggleableBase {
public ItemSigilFastMiner() {
super("fastMiner", 100);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
{
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)
{
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))
{
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)
{
if (!player.capabilities.isCreativeMode) {
player.hurtResistantTime = 0;
player.attackEntityFrom(BloodMagicAPI.damageSource, 1.0F);
}
@ -53,8 +46,7 @@ public class ItemSigilFastMiner extends ItemSigilToggleableBase
}
@Override
public boolean hasArrayEffect()
{
public boolean hasArrayEffect() {
return true;
}
}

View file

@ -1,21 +1,18 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.util.handler.event.GenericHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import WayofTime.bloodmagic.util.handler.event.GenericHandler;
public class ItemSigilFilledHand extends ItemSigilToggleableBase
{
public ItemSigilFilledHand()
{
public class ItemSigilFilledHand extends ItemSigilToggleableBase {
public ItemSigilFilledHand() {
super("hand", 100);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
{
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
if (PlayerHelper.isFakePlayer(player))
return;
GenericHandler.filledHandMap.put(player, 4);

View file

@ -6,16 +6,13 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemSigilFrost extends ItemSigilToggleableBase
{
public ItemSigilFrost()
{
public class ItemSigilFrost extends ItemSigilToggleableBase {
public ItemSigilFrost() {
super("frost", 100);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
{
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
if (PlayerHelper.isFakePlayer(player))
return;

View file

@ -14,23 +14,18 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.BonemealEvent;
import net.minecraftforge.fml.common.eventhandler.Event.Result;
public class ItemSigilGreenGrove extends ItemSigilToggleableBase
{
public ItemSigilGreenGrove()
{
public class ItemSigilGreenGrove extends ItemSigilToggleableBase {
public ItemSigilGreenGrove() {
super("greenGrove", 150);
}
@Override
public boolean onSigilUse(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ)
{
public boolean onSigilUse(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) {
if (PlayerHelper.isFakePlayer(player))
return false;
if (applyBonemeal(world, blockPos, player, stack))
{
if (!world.isRemote)
{
if (applyBonemeal(world, blockPos, player, stack)) {
if (!world.isRemote) {
world.playEvent(2005, blockPos, 0);
}
return true;
@ -40,8 +35,7 @@ public class ItemSigilGreenGrove extends ItemSigilToggleableBase
}
@Override
public void onSigilUpdate(ItemStack stack, World worldIn, EntityPlayer player, int itemSlot, boolean isSelected)
{
public void onSigilUpdate(ItemStack stack, World worldIn, EntityPlayer player, int itemSlot, boolean isSelected) {
if (PlayerHelper.isFakePlayer(player))
return;
@ -51,21 +45,15 @@ public class ItemSigilGreenGrove extends ItemSigilToggleableBase
int posY = (int) player.posY;
int posZ = (int) Math.round(player.posZ - 0.5f);
for (int ix = posX - range; ix <= posX + range; ix++)
{
for (int iz = posZ - range; iz <= posZ + range; iz++)
{
for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++)
{
for (int ix = posX - range; ix <= posX + range; ix++) {
for (int iz = posZ - range; iz <= posZ + range; iz++) {
for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++) {
BlockPos blockPos = new BlockPos(ix, iy, iz);
IBlockState state = worldIn.getBlockState(blockPos);
if (!BloodMagicAPI.INSTANCE.getBlacklist().getGreenGrove().contains(state))
{
if (state.getBlock() instanceof IGrowable)
{
if (worldIn.rand.nextInt(50) == 0)
{
if (!BloodMagicAPI.INSTANCE.getBlacklist().getGreenGrove().contains(state)) {
if (state.getBlock() instanceof IGrowable) {
if (worldIn.rand.nextInt(50) == 0) {
IBlockState preBlockState = worldIn.getBlockState(blockPos);
state.getBlock().updateTick(worldIn, blockPos, state, worldIn.rand);
@ -80,8 +68,7 @@ public class ItemSigilGreenGrove extends ItemSigilToggleableBase
}
}
private boolean applyBonemeal(World worldIn, BlockPos target, EntityPlayer player, ItemStack sigilStack)
{
private boolean applyBonemeal(World worldIn, BlockPos target, EntityPlayer player, ItemStack sigilStack) {
IBlockState iblockstate = worldIn.getBlockState(target);
BonemealEvent event = new BonemealEvent(player, worldIn, target, iblockstate, EnumHand.MAIN_HAND, sigilStack);
@ -90,14 +77,11 @@ public class ItemSigilGreenGrove extends ItemSigilToggleableBase
else if (event.getResult() == Result.ALLOW)
return true;
if (iblockstate.getBlock() instanceof IGrowable)
{
if (iblockstate.getBlock() instanceof IGrowable) {
IGrowable igrowable = (IGrowable) iblockstate.getBlock();
if (igrowable.canGrow(worldIn, target, iblockstate, worldIn.isRemote))
{
if (!worldIn.isRemote)
{
if (igrowable.canGrow(worldIn, target, iblockstate, worldIn.isRemote)) {
if (!worldIn.isRemote) {
if (igrowable.canUseBonemeal(worldIn, worldIn.rand, target, iblockstate))
igrowable.grow(worldIn, worldIn.rand, target, iblockstate);
}

View file

@ -7,16 +7,13 @@ import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class ItemSigilHaste extends ItemSigilToggleableBase
{
public ItemSigilHaste()
{
public class ItemSigilHaste extends ItemSigilToggleableBase {
public ItemSigilHaste() {
super("haste", 250);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
{
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
if (PlayerHelper.isFakePlayer(player))
return;

View file

@ -1,11 +1,17 @@
package WayofTime.bloodmagic.item.sigil;
import java.util.Collections;
import java.util.List;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.iface.IAltarReader;
import WayofTime.bloodmagic.api.iface.IBindable;
import WayofTime.bloodmagic.api.iface.ISigil;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.client.key.IKeybindable;
import WayofTime.bloodmagic.client.key.KeyBindings;
import WayofTime.bloodmagic.util.Utils;
import WayofTime.bloodmagic.util.helper.TextHelper;
import com.google.common.base.Strings;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
@ -18,44 +24,29 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.tuple.Pair;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.iface.IAltarReader;
import WayofTime.bloodmagic.api.iface.IBindable;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.util.Utils;
import WayofTime.bloodmagic.client.key.IKeybindable;
import WayofTime.bloodmagic.util.helper.TextHelper;
import com.google.common.base.Strings;
import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAltarReader, ISigil.Holding
{
public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAltarReader, ISigil.Holding {
public static final int inventorySize = 5;
public ItemSigilHolding()
{
public ItemSigilHolding() {
super("holding");
}
@Override
public void onKeyPressed(ItemStack stack, EntityPlayer player, KeyBindings key, boolean showInChat)
{
if (stack == player.getHeldItemMainhand() && stack.getItem() instanceof ItemSigilHolding && key.equals(KeyBindings.OPEN_HOLDING))
{
public void onKeyPressed(ItemStack stack, EntityPlayer player, KeyBindings key, boolean showInChat) {
if (stack == player.getHeldItemMainhand() && stack.getItem() instanceof ItemSigilHolding && key.equals(KeyBindings.OPEN_HOLDING)) {
Utils.setUUID(stack);
player.openGui(BloodMagic.instance, Constants.Gui.SIGIL_HOLDING_GUI, player.getEntityWorld(), (int) player.posX, (int) player.posY, (int) player.posZ);
}
}
@Override
public String getHighlightTip(ItemStack stack, String displayName)
{
public String getHighlightTip(ItemStack stack, String displayName) {
List<ItemStack> inv = getInternalInventory(stack);
int currentSlot = getCurrentItemOrdinal(stack);
ItemStack item = inv.get(currentSlot);
@ -68,8 +59,7 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
{
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
super.addInformation(stack, world, tooltip, flag);
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.sigil.holding.press", KeyBindings.OPEN_HOLDING.getKey().getDisplayName()));
@ -80,8 +70,7 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
int currentSlot = getCurrentItemOrdinal(stack);
ItemStack item = inv.get(currentSlot);
for (int i = 0; i < inventorySize; i++)
{
for (int i = 0; i < inventorySize; i++) {
ItemStack invStack = inv.get(i);
if (!invStack.isEmpty())
if (!item.isEmpty() && invStack == item)
@ -92,8 +81,7 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
}
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if (PlayerHelper.isFakePlayer(player))
return EnumActionResult.FAIL;
@ -112,8 +100,7 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if (PlayerHelper.isFakePlayer(player))
return ActionResult.newResult(EnumActionResult.FAIL, stack);
@ -134,26 +121,21 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
@Nonnull
@Override
public ItemStack getHeldItem(ItemStack holdingStack, EntityPlayer player)
{
public ItemStack getHeldItem(ItemStack holdingStack, EntityPlayer player) {
return getInternalInventory(holdingStack).get(getCurrentItemOrdinal(holdingStack));
}
public void saveInventory(ItemStack itemStack, List<ItemStack> inventory)
{
public void saveInventory(ItemStack itemStack, List<ItemStack> inventory) {
NBTTagCompound itemTag = itemStack.getTagCompound();
if (itemTag == null)
{
if (itemTag == null) {
itemStack.setTagCompound(new NBTTagCompound());
}
NBTTagList itemList = new NBTTagList();
for (int i = 0; i < inventorySize; i++)
{
if (!inventory.get(i).isEmpty())
{
for (int i = 0; i < inventorySize; i++) {
if (!inventory.get(i).isEmpty()) {
NBTTagCompound tag = new NBTTagCompound();
tag.setByte(Constants.NBT.SLOT, (byte) i);
inventory.get(i).writeToNBT(tag);
@ -165,23 +147,18 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
}
@Override
public void onUpdate(ItemStack itemStack, World world, Entity entity, int itemSlot, boolean isSelected)
{
if (itemStack.getTagCompound() != null)
{
public void onUpdate(ItemStack itemStack, World world, Entity entity, int itemSlot, boolean isSelected) {
if (itemStack.getTagCompound() != null) {
this.tickInternalInventory(itemStack, world, entity, itemSlot, isSelected);
}
}
public void tickInternalInventory(ItemStack itemStack, World world, Entity entity, int itemSlot, boolean isSelected)
{
public void tickInternalInventory(ItemStack itemStack, World world, Entity entity, int itemSlot, boolean isSelected) {
List<ItemStack> inv = getInternalInventory(itemStack);
for (int i = 0; i < inventorySize; i++)
{
for (int i = 0; i < inventorySize; i++) {
ItemStack stack = inv.get(i);
if (stack.isEmpty())
{
if (stack.isEmpty()) {
continue;
}
@ -189,43 +166,40 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
}
}
public static int next(int mode)
{
@Override
public List<Pair<Integer, String>> getVariants() {
return Collections.emptyList();
}
public static int next(int mode) {
int index = mode + 1;
if (index >= inventorySize)
{
if (index >= inventorySize) {
index = 0;
}
return index;
}
public static int prev(int mode)
{
public static int prev(int mode) {
int index = mode - 1;
if (index < 0)
{
if (index < 0) {
index = inventorySize;
}
return index;
}
private static void initModeTag(ItemStack stack)
{
if (!stack.hasTagCompound())
{
private static void initModeTag(ItemStack stack) {
if (!stack.hasTagCompound()) {
stack = NBTHelper.checkNBT(stack);
stack.getTagCompound().setInteger(Constants.NBT.CURRENT_SIGIL, inventorySize);
}
}
public static ItemStack getItemStackInSlot(ItemStack itemStack, int slot)
{
if (itemStack.getItem() instanceof ItemSigilHolding)
{
public static ItemStack getItemStackInSlot(ItemStack itemStack, int slot) {
if (itemStack.getItem() instanceof ItemSigilHolding) {
List<ItemStack> inv = getInternalInventory(itemStack);
if (inv != null)
return inv.get(slot == 5 ? 4 : slot);
@ -236,10 +210,8 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
return ItemStack.EMPTY;
}
public static int getCurrentItemOrdinal(ItemStack stack)
{
if (stack.getItem() instanceof ItemSigilHolding)
{
public static int getCurrentItemOrdinal(ItemStack stack) {
if (stack.getItem() instanceof ItemSigilHolding) {
initModeTag(stack);
int currentSigil = stack.getTagCompound().getInteger(Constants.NBT.CURRENT_SIGIL);
currentSigil = MathHelper.clamp(currentSigil, 0, inventorySize - 1);
@ -249,32 +221,27 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
return 0;
}
public static List<ItemStack> getInternalInventory(ItemStack stack)
{
public static List<ItemStack> getInternalInventory(ItemStack stack) {
initModeTag(stack);
NBTTagCompound tagCompound = stack.getTagCompound();
if (tagCompound == null)
{
if (tagCompound == null) {
return NonNullList.withSize(inventorySize, ItemStack.EMPTY);
}
NBTTagList tagList = tagCompound.getTagList(Constants.NBT.ITEMS, 10);
if (tagList.hasNoTags())
{
if (tagList.hasNoTags()) {
return NonNullList.withSize(inventorySize, ItemStack.EMPTY);
}
List<ItemStack> inv = NonNullList.withSize(inventorySize, ItemStack.EMPTY);
for (int i = 0; i < tagList.tagCount(); i++)
{
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound data = tagList.getCompoundTagAt(i);
byte j = data.getByte(Constants.NBT.SLOT);
if (j >= 0 && j < inv.size())
{
if (j >= 0 && j < inv.size()) {
inv.set(j, new ItemStack(data));
}
}
@ -282,36 +249,29 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
return inv;
}
public static void cycleToNextSigil(ItemStack itemStack, int mode)
{
if (itemStack.getItem() instanceof ItemSigilHolding)
{
public static void cycleToNextSigil(ItemStack itemStack, int mode) {
if (itemStack.getItem() instanceof ItemSigilHolding) {
initModeTag(itemStack);
int index = mode;
if (mode == 120 || mode == -120)
{
if (mode == 120 || mode == -120) {
int currentIndex = getCurrentItemOrdinal(itemStack);
ItemStack currentItemStack = getItemStackInSlot(itemStack, currentIndex);
if (currentItemStack.isEmpty())
return;
if (mode < 0)
{
if (mode < 0) {
index = next(currentIndex);
currentItemStack = getItemStackInSlot(itemStack, index);
while (currentItemStack.isEmpty())
{
while (currentItemStack.isEmpty()) {
index = next(index);
currentItemStack = getItemStackInSlot(itemStack, index);
}
} else
{
} else {
index = prev(currentIndex);
currentItemStack = getItemStackInSlot(itemStack, index);
while (currentItemStack.isEmpty())
{
while (currentItemStack.isEmpty()) {
index = prev(index);
currentItemStack = getItemStackInSlot(itemStack, index);
}
@ -321,10 +281,4 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
itemStack.getTagCompound().setInteger(Constants.NBT.CURRENT_SIGIL, index);
}
}
@Override
public List<Pair<Integer, String>> getVariants()
{
return Collections.emptyList();
}
}

View file

@ -21,55 +21,45 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler;
public class ItemSigilLava extends ItemSigilBase
{
public ItemSigilLava()
{
public class ItemSigilLava extends ItemSigilBase {
public ItemSigilLava() {
super("lava", 1000);
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
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);
if (!world.isRemote && !isUnusable(stack))
{
if (!world.isRemote && !isUnusable(stack)) {
RayTraceResult rayTrace = this.rayTrace(world, player, false);
if (rayTrace != null)
{
if (rayTrace != null) {
ActionResult<ItemStack> ret = ForgeEventFactory.onBucketUse(player, world, stack, rayTrace);
if (ret != null)
return ret;
if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK)
{
if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) {
BlockPos blockpos = rayTrace.getBlockPos();
if (!world.isBlockModifiable(player, blockpos))
{
if (!world.isBlockModifiable(player, blockpos)) {
return super.onItemRightClick(world, player, hand);
}
if (!player.canPlayerEdit(blockpos.offset(rayTrace.sideHit), rayTrace.sideHit, stack))
{
if (!player.canPlayerEdit(blockpos.offset(rayTrace.sideHit), rayTrace.sideHit, stack)) {
return super.onItemRightClick(world, player, hand);
}
BlockPos blockpos1 = blockpos.offset(rayTrace.sideHit);
if (!player.canPlayerEdit(blockpos1, rayTrace.sideHit, stack))
{
if (!player.canPlayerEdit(blockpos1, rayTrace.sideHit, stack)) {
return super.onItemRightClick(world, player, hand);
}
if (this.canPlaceLava(world, blockpos1) && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()) && this.tryPlaceLava(world, blockpos1))
{
if (this.canPlaceLava(world, blockpos1) && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()) && this.tryPlaceLava(world, blockpos1)) {
return super.onItemRightClick(world, player, hand);
}
}
@ -80,27 +70,22 @@ public class ItemSigilLava extends ItemSigilBase
}
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if (world.isRemote || player.isSneaking() || isUnusable(stack))
{
if (world.isRemote || player.isSneaking() || isUnusable(stack)) {
return EnumActionResult.FAIL;
}
if (!world.canMineBlockBody(player, blockPos))
{
if (!world.canMineBlockBody(player, blockPos)) {
return EnumActionResult.FAIL;
}
TileEntity tile = world.getTileEntity(blockPos);
if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side))
{
if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) {
IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
FluidStack fluid = new FluidStack(FluidRegistry.LAVA, 1000);
int amount = handler.fill(fluid, false);
if (amount > 0 && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()))
{
if (amount > 0 && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed())) {
handler.fill(fluid, true);
return EnumActionResult.SUCCESS;
}
@ -111,23 +96,18 @@ public class ItemSigilLava extends ItemSigilBase
return EnumActionResult.FAIL;
}
public boolean canPlaceLava(World world, BlockPos blockPos)
{
if (!world.isAirBlock(blockPos) && world.getBlockState(blockPos).getBlock().getMaterial(world.getBlockState(blockPos)).isSolid())
{
public boolean canPlaceLava(World world, BlockPos blockPos) {
if (!world.isAirBlock(blockPos) && world.getBlockState(blockPos).getBlock().getMaterial(world.getBlockState(blockPos)).isSolid()) {
return false;
} else if ((world.getBlockState(blockPos).getBlock() == Blocks.LAVA || world.getBlockState(blockPos).getBlock() == Blocks.FLOWING_LAVA) && world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)) == 0)
{
} else if ((world.getBlockState(blockPos).getBlock() == Blocks.LAVA || world.getBlockState(blockPos).getBlock() == Blocks.FLOWING_LAVA) && world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)) == 0) {
return false;
} else
{
} else {
world.setBlockState(blockPos, Blocks.FLOWING_LAVA.getBlockState().getBaseState(), 3);
return true;
}
}
public boolean tryPlaceLava(World world, BlockPos pos)
{
public boolean tryPlaceLava(World world, BlockPos pos) {
Material material = world.getBlockState(pos).getBlock().getMaterial(world.getBlockState(pos));
return world.isAirBlock(pos) && !material.isSolid();

View file

@ -1,7 +1,5 @@
package WayofTime.bloodmagic.item.sigil;
import java.util.List;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityXPOrb;
@ -10,16 +8,15 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.world.World;
public class ItemSigilMagnetism extends ItemSigilToggleableBase
{
public ItemSigilMagnetism()
{
import java.util.List;
public class ItemSigilMagnetism extends ItemSigilToggleableBase {
public ItemSigilMagnetism() {
super("magnetism", 50);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
{
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
if (PlayerHelper.isFakePlayer(player))
return;
@ -31,18 +28,14 @@ public class ItemSigilMagnetism extends ItemSigilToggleableBase
List<EntityItem> entities = player.getEntityWorld().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
List<EntityXPOrb> xpOrbs = player.getEntityWorld().getEntitiesWithinAABB(EntityXPOrb.class, new AxisAlignedBB(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
for (EntityItem entity : entities)
{
if (entity != null && !world.isRemote && !entity.isDead)
{
for (EntityItem entity : entities) {
if (entity != null && !world.isRemote && !entity.isDead) {
entity.onCollideWithPlayer(player);
}
}
for (EntityXPOrb xpOrb : xpOrbs)
{
if (xpOrb != null && !world.isRemote)
{
for (EntityXPOrb xpOrb : xpOrbs) {
if (xpOrb != null && !world.isRemote) {
xpOrb.onCollideWithPlayer(player);
}
}

View file

@ -1,42 +1,35 @@
package WayofTime.bloodmagic.item.sigil;
import java.util.HashMap;
import java.util.Map;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.apache.commons.lang3.tuple.Pair;
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
import java.util.HashMap;
import java.util.Map;
public class ItemSigilPhantomBridge extends ItemSigilToggleableBase
{
public class ItemSigilPhantomBridge extends ItemSigilToggleableBase {
private Map<EntityPlayer, Pair<Double, Double>> prevPositionMap = new HashMap<EntityPlayer, Pair<Double, Double>>();
private double expansionFactor = 2;
private int range = 3;
public ItemSigilPhantomBridge()
{
public ItemSigilPhantomBridge() {
super("phantomBridge", 100);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
{
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
if (PlayerHelper.isFakePlayer(player))
return;
if (!prevPositionMap.containsKey(player))
{
if (!prevPositionMap.containsKey(player)) {
prevPositionMap.put(player, Pair.of(player.posX, player.posZ));
}
if ((!player.onGround && !player.isRiding()) && !player.isSneaking())
{
if ((!player.onGround && !player.isRiding()) && !player.isSneaking()) {
prevPositionMap.put(player, Pair.of(player.posX, player.posZ));
return;
}
@ -52,8 +45,7 @@ public class ItemSigilPhantomBridge extends ItemSigilToggleableBase
double playerVelZ = player.posZ - prevPosition.getRight();
double totalVel = Math.sqrt(playerVelX * playerVelX + playerVelZ * playerVelZ);
if (totalVel > 2)
{
if (totalVel > 2) {
//I am SURE you are teleporting!
playerVelX = 0;
playerVelZ = 0;
@ -74,12 +66,9 @@ public class ItemSigilPhantomBridge extends ItemSigilToggleableBase
int truncC = (int) C;
//TODO: Make this for-loop better.
for (int ix = -truncC; ix <= truncC; ix++)
{
for (int iz = -truncC; iz <= truncC; iz++)
{
if (computeEllipse(ix + avgX, iz + avgZ, posX, posZ, offsetPosX, offsetPosZ) > C)
{
for (int ix = -truncC; ix <= truncC; ix++) {
for (int iz = -truncC; iz <= truncC; iz++) {
if (computeEllipse(ix + avgX, iz + avgZ, posX, posZ, offsetPosX, offsetPosZ) > C) {
continue;
}
@ -93,8 +82,7 @@ public class ItemSigilPhantomBridge extends ItemSigilToggleableBase
prevPositionMap.put(player, Pair.of(player.posX, player.posZ));
}
public static double computeEllipse(double x, double z, double focusX1, double focusZ1, double focusX2, double focusZ2)
{
public static double computeEllipse(double x, double z, double focusX1, double focusZ1, double focusX2, double focusZ2) {
return Math.sqrt((x - focusX1) * (x - focusX1) + (z - focusZ1) * (z - focusZ1)) + Math.sqrt((x - focusX2) * (x - focusX2) + (z - focusZ2) * (z - focusZ2));
}
}

View file

@ -1,9 +1,12 @@
package WayofTime.bloodmagic.item.sigil;
import java.util.ArrayList;
import java.util.List;
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.util.ChatUtil;
import WayofTime.bloodmagic.util.helper.NumeralHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
@ -16,36 +19,28 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
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.util.ChatUtil;
public class ItemSigilSeer extends ItemSigilBase implements IAltarReader
{
public ItemSigilSeer()
{
import java.util.ArrayList;
import java.util.List;
public class ItemSigilSeer extends ItemSigilBase implements IAltarReader {
public ItemSigilSeer() {
super("seer");
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
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);
if (!world.isRemote)
{
if (!world.isRemote) {
super.onItemRightClick(world, player, hand);
RayTraceResult rayTrace = rayTrace(world, player, false);
if (rayTrace == null)
{
if (rayTrace == null) {
int currentEssence = NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).getCurrentEssence();
List<ITextComponent> toSend = new ArrayList<ITextComponent>();
@ -53,42 +48,34 @@ public class ItemSigilSeer extends ItemSigilBase implements IAltarReader
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 (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK)
{
} else {
if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) {
TileEntity tile = world.getTileEntity(rayTrace.getBlockPos());
if (tile != null && tile instanceof IBloodAltar)
{
if (tile != null && tile instanceof IBloodAltar) {
IBloodAltar altar = (IBloodAltar) tile;
int tier = altar.getTier().ordinal() + 1;
int currentEssence = altar.getCurrentBlood();
int capacity = altar.getCapacity();
int charge = altar.getTotalCharge();
altar.checkTier();
if (tile instanceof IInventory)
{
if (!((IInventory) tile).getStackInSlot(0).isEmpty())
{
if (tile instanceof IInventory) {
if (!((IInventory) tile).getStackInSlot(0).isEmpty()) {
int progress = altar.getProgress();
int totalLiquidRequired = altar.getLiquidRequired() * ((IInventory) tile).getStackInSlot(0).getCount();
int consumptionRate = (int) (altar.getConsumptionRate() * (altar.getConsumptionMultiplier() + 1));
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentAltarProgress", progress, totalLiquidRequired), new TextComponentTranslation(tooltipBase + "currentAltarConsumptionRate", consumptionRate), new TextComponentTranslation(tooltipBase + "currentAltarTier", NumeralHelper.toRoman(tier)), new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence), new TextComponentTranslation(tooltipBase + "currentAltarCapacity", capacity), new TextComponentTranslation(tooltipBase + "currentCharge", charge));
} else
{
} else {
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentAltarTier", NumeralHelper.toRoman(tier)), new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence), new TextComponentTranslation(tooltipBase + "currentAltarCapacity", capacity), new TextComponentTranslation(tooltipBase + "currentCharge", charge));
}
}
} else if (tile != null && tile instanceof TileIncenseAltar)
{
} 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
{
} else {
int currentEssence = NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).getCurrentEssence();
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence));
}

View file

@ -1,30 +1,22 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.tile.TileSpectralBlock;
import WayofTime.bloodmagic.util.Utils;
import net.minecraftforge.fluids.BlockFluidBase;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class ItemSigilSuppression extends ItemSigilToggleableBase
{
public ItemSigilSuppression()
{
public class ItemSigilSuppression extends ItemSigilToggleableBase {
public ItemSigilSuppression() {
super("suppression", 400);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
{
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
if (PlayerHelper.isFakePlayer(player))
return;
@ -34,14 +26,10 @@ public class ItemSigilSuppression extends ItemSigilToggleableBase
final int radius = 5;
final int refresh = 100;
for (int i = -radius; i <= radius; i++)
{
for (int j = -radius; j <= radius; j++)
{
for (int k = -radius; k <= radius; k++)
{
if (i * i + j * j + k * k >= (radius + 0.50f) * (radius + 0.50f))
{
for (int i = -radius; i <= radius; i++) {
for (int j = -radius; j <= radius; j++) {
for (int k = -radius; k <= radius; k++) {
if (i * i + j * j + k * k >= (radius + 0.50f) * (radius + 0.50f)) {
continue;
}
@ -49,9 +37,8 @@ public class ItemSigilSuppression extends ItemSigilToggleableBase
IBlockState state = world.getBlockState(blockPos);
if (Utils.isBlockLiquid(state) && world.getTileEntity(blockPos) == null)
TileSpectralBlock.createSpectralBlock(world, blockPos, refresh);
else
{
TileSpectralBlock.createSpectralBlock(world, blockPos, refresh);
else {
TileEntity tile = world.getTileEntity(blockPos);
if (tile instanceof TileSpectralBlock)
((TileSpectralBlock) tile).resetDuration(refresh);

View file

@ -1,9 +1,13 @@
package WayofTime.bloodmagic.item.sigil;
import java.util.List;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.iface.ISigil;
import WayofTime.bloodmagic.api.teleport.TeleportQueue;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.ritual.portal.Teleports;
import WayofTime.bloodmagic.tile.TileTeleposer;
import WayofTime.bloodmagic.util.helper.TextHelper;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -16,32 +20,24 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.teleport.TeleportQueue;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.ritual.portal.Teleports;
import WayofTime.bloodmagic.tile.TileTeleposer;
import WayofTime.bloodmagic.util.helper.TextHelper;
public class ItemSigilTeleposition extends ItemSigilBase
{
public ItemSigilTeleposition()
{
import java.util.List;
public class ItemSigilTeleposition extends ItemSigilBase {
public ItemSigilTeleposition() {
super("teleposition");
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
{
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
super.addInformation(stack, world, tooltip, flag);
if (!stack.hasTagCompound())
return;
NBTTagCompound tag = stack.getTagCompound();
if (tag != null && stack.getTagCompound().hasKey(Constants.NBT.DIMENSION_ID) && stack.getTagCompound().hasKey(Constants.NBT.X_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Y_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Z_COORD))
{
if (tag != null && stack.getTagCompound().hasKey(Constants.NBT.DIMENSION_ID) && stack.getTagCompound().hasKey(Constants.NBT.X_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Y_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Z_COORD)) {
tooltip.add(" ");
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.coords", getValue(tag, Constants.NBT.X_COORD), getValue(tag, Constants.NBT.Y_COORD), getValue(tag, Constants.NBT.Z_COORD)));
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.dimension", getValue(tag, Constants.NBT.DIMENSION_ID)));
@ -49,22 +45,18 @@ public class ItemSigilTeleposition extends ItemSigilBase
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
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);
if (!world.isRemote && NBTHelper.checkNBT(stack) != null && stack.getTagCompound().hasKey(Constants.NBT.DIMENSION_ID) && stack.getTagCompound().hasKey(Constants.NBT.X_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Y_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Z_COORD))
{
if (!world.isRemote && NBTHelper.checkNBT(stack) != null && stack.getTagCompound().hasKey(Constants.NBT.DIMENSION_ID) && stack.getTagCompound().hasKey(Constants.NBT.X_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Y_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Z_COORD)) {
BlockPos blockPos = new BlockPos(getValue(stack.getTagCompound(), Constants.NBT.X_COORD), getValue(stack.getTagCompound(), Constants.NBT.Y_COORD), getValue(stack.getTagCompound(), Constants.NBT.Z_COORD)).up();
if (world.provider.getDimension() == getValue(stack.getTagCompound(), Constants.NBT.DIMENSION_ID))
{
if (world.provider.getDimension() == getValue(stack.getTagCompound(), Constants.NBT.DIMENSION_ID)) {
TeleportQueue.getInstance().addITeleport(new Teleports.TeleportSameDim(blockPos, player, getOwnerUUID(stack), true));
} else
{
} else {
TeleportQueue.getInstance().addITeleport(new Teleports.TeleportToDim(blockPos, player, getOwnerUUID(stack), world, getValue(stack.getTagCompound(), Constants.NBT.DIMENSION_ID), true));
}
}
@ -72,18 +64,15 @@ public class ItemSigilTeleposition extends ItemSigilBase
}
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if (stack.getItem() instanceof ISigil.Holding)
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
if (PlayerHelper.isFakePlayer(player))
return EnumActionResult.FAIL;
if (!world.isRemote && player.isSneaking() && NBTHelper.checkNBT(stack) != null)
{
if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof TileTeleposer)
{
if (!world.isRemote && player.isSneaking() && NBTHelper.checkNBT(stack) != null) {
if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof TileTeleposer) {
stack.getTagCompound().setInteger(Constants.NBT.DIMENSION_ID, world.provider.getDimension());
stack.getTagCompound().setInteger(Constants.NBT.X_COORD, pos.getX());
stack.getTagCompound().setInteger(Constants.NBT.Y_COORD, pos.getY());
@ -95,8 +84,7 @@ public class ItemSigilTeleposition extends ItemSigilBase
return EnumActionResult.FAIL;
}
public int getValue(NBTTagCompound tag, String key)
{
public int getValue(NBTTagCompound tag, String key) {
return tag.getInteger(key);
}
}

View file

@ -1,35 +1,30 @@
package WayofTime.bloodmagic.item.sigil;
import java.util.ArrayList;
import java.util.List;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.impl.ItemSigilToggleable;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.client.IMeshProvider;
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable;
import WayofTime.bloodmagic.util.helper.TextHelper;
import com.google.common.base.Strings;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.text.WordUtils;
import javax.annotation.Nullable;
import WayofTime.bloodmagic.util.helper.TextHelper;
import java.util.ArrayList;
import java.util.List;
public class ItemSigilToggleableBase extends ItemSigilToggleable implements IMeshProvider
{
public class ItemSigilToggleableBase extends ItemSigilToggleable implements IMeshProvider {
protected final String tooltipBase;
private final String name;
public ItemSigilToggleableBase(String name, int lpUsed)
{
public ItemSigilToggleableBase(String name, int lpUsed) {
super(lpUsed);
setUnlocalizedName(BloodMagic.MODID + ".sigil." + name);
@ -41,8 +36,7 @@ public class ItemSigilToggleableBase extends ItemSigilToggleable implements IMes
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
{
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
super.addInformation(stack, world, tooltip, flag);
if (!stack.hasTagCompound())
return;
@ -54,21 +48,18 @@ public class ItemSigilToggleableBase extends ItemSigilToggleable implements IMes
@Override
@SideOnly(Side.CLIENT)
public ItemMeshDefinition getMeshDefinition()
{
public ItemMeshDefinition getMeshDefinition() {
return new CustomMeshDefinitionActivatable("ItemSigil" + WordUtils.capitalize(name));
}
@Nullable
@Override
public ResourceLocation getCustomLocation()
{
public ResourceLocation getCustomLocation() {
return null;
}
@Override
public List<String> getVariants()
{
public List<String> getVariants() {
List<String> ret = new ArrayList<String>();
ret.add("active=false");
ret.add("active=true");

View file

@ -1,8 +1,10 @@
package WayofTime.bloodmagic.item.sigil;
import java.util.List;
import WayofTime.bloodmagic.api.BlockStack;
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.api_impl.BloodMagicAPI;
import net.minecraft.block.Block;
@ -12,36 +14,33 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.util.*;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import WayofTime.bloodmagic.api.BlockStack;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
public class ItemSigilTransposition extends ItemSigilBase
{
public ItemSigilTransposition()
{
import java.util.List;
public class ItemSigilTransposition extends ItemSigilBase {
public ItemSigilTransposition() {
super("transposition", 1000);
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
{
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
super.addInformation(stack, world, tooltip, flag);
if (!stack.hasTagCompound())
return;
NBTTagCompound tag = stack.getTagCompound();
if (tag.hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && tag.hasKey(Constants.NBT.CONTAINED_BLOCK_META))
{
if (tag.hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && tag.hasKey(Constants.NBT.CONTAINED_BLOCK_META)) {
tooltip.add(" ");
BlockStack blockStack = new BlockStack(Block.getBlockFromName(tag.getString(Constants.NBT.CONTAINED_BLOCK_NAME)), tag.getByte(Constants.NBT.CONTAINED_BLOCK_META));
tooltip.add(blockStack.getItemStack().getDisplayName());
@ -49,13 +48,11 @@ public class ItemSigilTransposition extends ItemSigilBase
}
@Override
public String getItemStackDisplayName(ItemStack stack)
{
public String getItemStackDisplayName(ItemStack stack) {
stack = NBTHelper.checkNBT(stack);
NBTTagCompound tag = stack.getTagCompound();
if (tag.hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && tag.hasKey(Constants.NBT.CONTAINED_BLOCK_META))
{
if (tag.hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && tag.hasKey(Constants.NBT.CONTAINED_BLOCK_META)) {
BlockStack blockStack = new BlockStack(ForgeRegistries.BLOCKS.getValue(new ResourceLocation(tag.getString(Constants.NBT.CONTAINED_BLOCK_NAME))), tag.getByte(Constants.NBT.CONTAINED_BLOCK_META));
if (blockStack.getItemStack() != null && blockStack.getItemStack().getItem() != null) //TODO: Figure out why it's a null item. This is a patchwork solution.
{
@ -67,8 +64,7 @@ public class ItemSigilTransposition extends ItemSigilBase
}
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if (stack.getItem() instanceof ISigil.Holding)
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
@ -78,28 +74,23 @@ public class ItemSigilTransposition extends ItemSigilBase
stack = NBTHelper.checkNBT(stack);
IBlockState state = world.getBlockState(blockPos);
if (!world.isRemote)
{
if (!world.isRemote) {
if (BloodMagicAPI.INSTANCE.getBlacklist().getTransposition().contains(state))
return EnumActionResult.FAIL;
if (player.isSneaking() && (!stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) || !stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_META)))
{
if (state.getPlayerRelativeBlockHardness(player, world, blockPos) >= 0 && state.getBlockHardness(world, blockPos) >= 0)
{
if (player.isSneaking() && (!stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) || !stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_META))) {
if (state.getPlayerRelativeBlockHardness(player, world, blockPos) >= 0 && state.getBlockHardness(world, blockPos) >= 0) {
int cost = getLpUsed();
NBTTagCompound tileNBTTag = new NBTTagCompound();
String blockName = state.getBlock().getRegistryName().toString();
byte metadata = (byte) state.getBlock().getMetaFromState(state);
if (world.getTileEntity(blockPos) != null)
{
if (world.getTileEntity(blockPos) != null) {
cost *= 5;
world.getTileEntity(blockPos).writeToNBT(tileNBTTag);
if (world.getTileEntity(blockPos) instanceof TileEntityMobSpawner)
{
if (world.getTileEntity(blockPos) instanceof TileEntityMobSpawner) {
cost *= 6;
}
}
@ -115,26 +106,21 @@ public class ItemSigilTransposition extends ItemSigilBase
return EnumActionResult.SUCCESS;
}
} else if (stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_META))
{
} else if (stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_META)) {
IBlockState iblockstate = world.getBlockState(blockPos);
Block block = iblockstate.getBlock();
BlockStack blockToPlace = new BlockStack(Block.getBlockFromName(stack.getTagCompound().getString(Constants.NBT.CONTAINED_BLOCK_NAME)), stack.getTagCompound().getByte(Constants.NBT.CONTAINED_BLOCK_META));
if (!block.isReplaceable(world, blockPos))
{
if (!block.isReplaceable(world, blockPos)) {
blockPos = blockPos.offset(side);
}
if (!stack.isEmpty() && player.canPlayerEdit(blockPos, side, stack) && world.mayPlace(blockToPlace.getBlock(), blockPos, false, side, player))
{
if (world.setBlockState(blockPos, blockToPlace.getState(), 3))
{
if (!stack.isEmpty() && player.canPlayerEdit(blockPos, side, stack) && world.mayPlace(blockToPlace.getBlock(), blockPos, false, side, player)) {
if (world.setBlockState(blockPos, blockToPlace.getState(), 3)) {
blockToPlace.getBlock().onBlockPlacedBy(world, blockPos, blockToPlace.getState(), player, blockToPlace.getItemStack());
// world.playSound((double) ((float) blockPos.getX() + 0.5F), (double) ((float) blockPos.getY() + 0.5F), (double) ((float) blockPos.getZ() + 0.5F), blockToPlace.getBlock().getStepSound().getPlaceSound(), (blockToPlace.getBlock().getStepSound().getVolume() + 1.0F) / 2.0F, blockToPlace.getBlock().getStepSound().getPitch() * 0.8F);
if (stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_TILE_ENTITY) && blockToPlace.getBlock().hasTileEntity(blockToPlace.getState()))
{
if (stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_TILE_ENTITY) && blockToPlace.getBlock().hasTileEntity(blockToPlace.getState())) {
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(Constants.NBT.CONTAINED_TILE_ENTITY);
tag.setInteger("x", blockPos.getX());
tag.setInteger("y", blockPos.getY());

View file

@ -19,59 +19,48 @@ import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler;
public class ItemSigilVoid extends ItemSigilBase
{
public ItemSigilVoid()
{
public class ItemSigilVoid extends ItemSigilBase {
public ItemSigilVoid() {
super("void", 50);
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
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);
if (!world.isRemote && !isUnusable(stack))
{
if (!world.isRemote && !isUnusable(stack)) {
RayTraceResult rayTrace = this.rayTrace(world, player, true);
if (rayTrace != null)
{
if (rayTrace != null) {
ActionResult<ItemStack> ret = ForgeEventFactory.onBucketUse(player, world, stack, rayTrace);
if (ret != null)
return ret;
if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK)
{
if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) {
BlockPos blockpos = rayTrace.getBlockPos();
if (!world.isBlockModifiable(player, blockpos))
{
if (!world.isBlockModifiable(player, blockpos)) {
return super.onItemRightClick(world, player, hand);
}
if (!player.canPlayerEdit(blockpos.offset(rayTrace.sideHit), rayTrace.sideHit, stack))
{
if (!player.canPlayerEdit(blockpos.offset(rayTrace.sideHit), rayTrace.sideHit, stack)) {
return super.onItemRightClick(world, player, hand);
}
if (!player.canPlayerEdit(blockpos, rayTrace.sideHit, stack))
{
if (!player.canPlayerEdit(blockpos, rayTrace.sideHit, stack)) {
return super.onItemRightClick(world, player, hand);
}
if (world.getBlockState(blockpos).getBlock().getMaterial(world.getBlockState(blockpos)).isLiquid() && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()))
{
if (world.getBlockState(blockpos).getBlock().getMaterial(world.getBlockState(blockpos)).isLiquid() && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) {
world.setBlockToAir(blockpos);
return super.onItemRightClick(world, player, hand);
}
}
} else
{
} else {
return super.onItemRightClick(world, player, hand);
}
@ -83,30 +72,25 @@ public class ItemSigilVoid extends ItemSigilBase
}
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if (PlayerHelper.isFakePlayer(player))
return EnumActionResult.FAIL;
if (world.isRemote || player.isSneaking() || isUnusable(stack))
{
if (world.isRemote || player.isSneaking() || isUnusable(stack)) {
return EnumActionResult.FAIL;
}
if (!world.canMineBlockBody(player, blockPos))
{
if (!world.canMineBlockBody(player, blockPos)) {
return EnumActionResult.FAIL;
}
TileEntity tile = world.getTileEntity(blockPos);
if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side))
{
if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) {
IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
FluidStack amount = handler.drain(1000, false);
if (amount != null && amount.amount > 0 && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()))
{
if (amount != null && amount.amount > 0 && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed())) {
handler.drain(1000, true);
return EnumActionResult.SUCCESS;
}
@ -116,13 +100,11 @@ public class ItemSigilVoid extends ItemSigilBase
BlockPos newPos = blockPos.offset(side);
if (!player.canPlayerEdit(newPos, side, stack))
{
if (!player.canPlayerEdit(newPos, side, stack)) {
return EnumActionResult.FAIL;
}
if (world.getBlockState(newPos).getBlock() instanceof IFluidBlock && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()))
{
if (world.getBlockState(newPos).getBlock() instanceof IFluidBlock && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed())) {
world.setBlockToAir(newPos);
return EnumActionResult.SUCCESS;
}

View file

@ -10,12 +10,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
@ -24,34 +19,28 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler;
public class ItemSigilWater extends ItemSigilBase
{
public ItemSigilWater()
{
public class ItemSigilWater extends ItemSigilBase {
public ItemSigilWater() {
super("water", 100);
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
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);
if (!world.isRemote && !isUnusable(stack))
{
if (!world.isRemote && !isUnusable(stack)) {
RayTraceResult rayTrace = this.rayTrace(world, player, false);
if (rayTrace != null)
{
if (rayTrace != null) {
ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(player, world, stack, rayTrace);
if (ret != null)
return ret;
if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK)
{
if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) {
BlockPos blockpos = rayTrace.getBlockPos();
if (!world.isBlockModifiable(player, blockpos))
@ -75,8 +64,7 @@ public class ItemSigilWater extends ItemSigilBase
}
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if (world.isRemote || player.isSneaking() || isUnusable(stack))
return EnumActionResult.FAIL;
@ -85,14 +73,12 @@ public class ItemSigilWater extends ItemSigilBase
return EnumActionResult.FAIL;
TileEntity tile = world.getTileEntity(blockPos);
if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side))
{
if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) {
IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
FluidStack fluid = new FluidStack(FluidRegistry.WATER, 1000);
int amount = handler.fill(fluid, false);
if (amount > 0 && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()))
{
if (amount > 0 && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) {
handler.fill(fluid, true);
return EnumActionResult.SUCCESS;
}
@ -100,8 +86,7 @@ public class ItemSigilWater extends ItemSigilBase
return EnumActionResult.FAIL;
}
if (world.getBlockState(blockPos).getBlock() == Blocks.CAULDRON && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()))
{
if (world.getBlockState(blockPos).getBlock() == Blocks.CAULDRON && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) {
world.setBlockState(blockPos, Blocks.CAULDRON.getDefaultState().withProperty(BlockCauldron.LEVEL, 3));
return EnumActionResult.SUCCESS;
}
@ -109,8 +94,7 @@ public class ItemSigilWater extends ItemSigilBase
return EnumActionResult.FAIL;
}
public boolean canPlaceWater(World world, BlockPos blockPos)
{
public boolean canPlaceWater(World world, BlockPos blockPos) {
if (!world.isAirBlock(blockPos) && world.getBlockState(blockPos).getBlock().getMaterial(world.getBlockState(blockPos)).isSolid())
return false;
else if ((world.getBlockState(blockPos).getBlock() == Blocks.WATER || world.getBlockState(blockPos).getBlock() == Blocks.FLOWING_WATER) && world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)) == 0)
@ -119,19 +103,15 @@ public class ItemSigilWater extends ItemSigilBase
return true;
}
public boolean tryPlaceWater(World worldIn, BlockPos pos)
{
public boolean tryPlaceWater(World worldIn, BlockPos pos) {
Material material = worldIn.getBlockState(pos).getBlock().getMaterial(worldIn.getBlockState(pos));
boolean notSolid = !material.isSolid();
if (!worldIn.isAirBlock(pos) && !notSolid)
{
if (!worldIn.isAirBlock(pos) && !notSolid) {
return false;
} else
{
if (worldIn.provider.doesWaterVaporize())
{
} else {
if (worldIn.provider.doesWaterVaporize()) {
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
@ -139,8 +119,7 @@ public class ItemSigilWater extends ItemSigilBase
for (int l = 0; l < 8; ++l)
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, (double) i + Math.random(), (double) j + Math.random(), (double) k + Math.random(), 0.0D, 0.0D, 0.0D, 0);
} else
{
} else {
if (!worldIn.isRemote && notSolid && !material.isLiquid())
worldIn.destroyBlock(pos, true);

View file

@ -7,16 +7,13 @@ import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class ItemSigilWhirlwind extends ItemSigilToggleableBase
{
public ItemSigilWhirlwind()
{
public class ItemSigilWhirlwind extends ItemSigilToggleableBase {
public ItemSigilWhirlwind() {
super("whirlwind", 250);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
{
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
if (PlayerHelper.isFakePlayer(player))
return;