Move some base classes into the API

Add Javadocs for API classes that didn't already have them

Redo

'nother redo

Another redo

Update ItemSigil.java

Last one, I swear

Fix
This commit is contained in:
Arcaratus 2016-03-22 21:10:05 -04:00
parent 6a40dbab0a
commit 0383f0fb31
41 changed files with 331 additions and 343 deletions

View file

@ -1,5 +1,6 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
@ -37,12 +38,12 @@ public class ItemSigilAir extends ItemSigilBase
player.motionY = vec.yCoord * wantedVelocity;
player.motionZ = vec.zCoord * wantedVelocity;
player.velocityChanged = true;
world.playSound((EntityPlayer) 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);
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);
player.fallDistance = 0;
if (!player.capabilities.isCreativeMode)
this.setUnusable(stack, !syphonNetwork(stack, player, getLPUsed()));
this.setUnusable(stack, !NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()));
}
return super.onItemRightClick(stack, world, player, hand);

View file

@ -4,12 +4,10 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import WayofTime.bloodmagic.api.impl.ItemSigil;
import lombok.Getter;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -17,25 +15,20 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.iface.ISigil;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.client.IVariantProvider;
import WayofTime.bloodmagic.item.ItemBindable;
import WayofTime.bloodmagic.util.helper.TextHelper;
@Getter
public class ItemSigilBase extends ItemBindable implements ISigil, IVariantProvider
public class ItemSigilBase extends ItemSigil implements IVariantProvider
{
protected final String tooltipBase;
private final String name;
private boolean toggleable;
public ItemSigilBase(String name, int lpUsed)
{
super();
super(lpUsed);
setUnlocalizedName(Constants.Mod.MODID + ".sigil." + name);
setLPUsed(lpUsed);
this.name = name;
this.tooltipBase = "tooltip.BloodMagic.sigil." + name + ".";
@ -46,12 +39,6 @@ public class ItemSigilBase extends ItemBindable implements ISigil, IVariantProvi
this(name, 0);
}
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{
return super.onItemRightClick(stack, world, player, hand);
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced)
@ -69,37 +56,4 @@ public class ItemSigilBase extends ItemBindable implements ISigil, IVariantProvi
ret.add(new ImmutablePair<Integer, String>(0, "type=normal"));
return ret;
}
public void setToggleable()
{
this.toggleable = true;
}
public boolean isUnusable(ItemStack stack)
{
NBTHelper.checkNBT(stack);
return stack.getTagCompound().getBoolean(Constants.NBT.UNUSABLE);
}
public ItemStack setUnusable(ItemStack stack, boolean unusable)
{
NBTHelper.checkNBT(stack);
stack.getTagCompound().setBoolean(Constants.NBT.UNUSABLE, unusable);
return stack;
}
public boolean getActivated(ItemStack stack)
{
return stack.getItemDamage() > 0;
}
public ItemStack setActivated(ItemStack stack, boolean activated)
{
if (this.toggleable)
stack.setItemDamage(activated ? 1 : 0);
return stack;
}
}

View file

@ -45,7 +45,7 @@ public class ItemSigilBloodLight extends ItemSigilBase
{
world.setBlockState(blockPos, ModBlocks.bloodLight.getDefaultState());
if (!world.isRemote)
NetworkHelper.syphonAndDamage(NetworkHelper.getSoulNetwork(player), player, getLPUsed());
NetworkHelper.syphonAndDamage(NetworkHelper.getSoulNetwork(player), player, getLpUsed());
resetCooldown(stack);
player.swingArm(hand);
return super.onItemRightClick(stack, world, player, hand);
@ -55,7 +55,7 @@ public class ItemSigilBloodLight extends ItemSigilBase
if (!world.isRemote)
{
world.spawnEntityInWorld(new EntityBloodLight(world, player));
NetworkHelper.syphonAndDamage(NetworkHelper.getSoulNetwork(player), player, getLPUsed());
NetworkHelper.syphonAndDamage(NetworkHelper.getSoulNetwork(player), player, getLpUsed());
}
resetCooldown(stack);
}

View file

@ -7,7 +7,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemSigilCompression extends ItemSigilToggleable
public class ItemSigilCompression extends ItemSigilToggleableBase
{
public ItemSigilCompression()
{

View file

@ -7,7 +7,7 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
public class ItemSigilElementalAffinity extends ItemSigilToggleable
public class ItemSigilElementalAffinity extends ItemSigilToggleableBase
{
public ItemSigilElementalAffinity()
{

View file

@ -11,7 +11,7 @@ import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.registry.ModPotions;
public class ItemSigilEnderSeverance extends ItemSigilToggleable
public class ItemSigilEnderSeverance extends ItemSigilToggleableBase
{
public ItemSigilEnderSeverance()
{

View file

@ -7,7 +7,7 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
public class ItemSigilFastMiner extends ItemSigilToggleable
public class ItemSigilFastMiner extends ItemSigilToggleableBase
{
public ItemSigilFastMiner()
{

View file

@ -12,7 +12,7 @@ import net.minecraftforge.common.IPlantable;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.Constants;
public class ItemSigilGreenGrove extends ItemSigilToggleable
public class ItemSigilGreenGrove extends ItemSigilToggleableBase
{
public ItemSigilGreenGrove()
{

View file

@ -7,7 +7,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class ItemSigilHaste extends ItemSigilToggleable
public class ItemSigilHaste extends ItemSigilToggleableBase
{
public ItemSigilHaste()
{

View file

@ -1,5 +1,6 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
@ -60,7 +61,7 @@ public class ItemSigilLava extends ItemSigilBase
return super.onItemRightClick(stack, world, player, hand);
}
if (this.canPlaceLava(world, blockpos1) && syphonNetwork(stack, player, getLPUsed()) && this.tryPlaceLava(world, blockpos1))
if (this.canPlaceLava(world, blockpos1) && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()) && this.tryPlaceLava(world, blockpos1))
{
return super.onItemRightClick(stack, world, player, hand);
}
@ -89,7 +90,7 @@ public class ItemSigilLava extends ItemSigilBase
FluidStack fluid = new FluidStack(FluidRegistry.LAVA, 1000);
int amount = ((IFluidHandler) tile).fill(side, fluid, false);
if (amount > 0 && syphonNetwork(stack, player, getLPUsed()))
if (amount > 0 && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()))
{
((IFluidHandler) tile).fill(side, fluid, true);
}
@ -107,7 +108,7 @@ public class ItemSigilLava extends ItemSigilBase
return EnumActionResult.FAIL;
}
if (this.canPlaceLava(world, newPos) && syphonNetwork(stack, player, getLPUsed()))
if (this.canPlaceLava(world, newPos) && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()))
{
return this.tryPlaceLava(world, newPos) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
}

View file

@ -10,7 +10,7 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
public class ItemSigilMagnetism extends ItemSigilToggleable
public class ItemSigilMagnetism extends ItemSigilToggleableBase
{
public ItemSigilMagnetism()
{

View file

@ -7,7 +7,7 @@ import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.registry.ModBlocks;
public class ItemSigilPhantomBridge extends ItemSigilToggleable
public class ItemSigilPhantomBridge extends ItemSigilToggleableBase
{
public ItemSigilPhantomBridge()
{

View file

@ -10,7 +10,7 @@ import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.tile.TileSpectralBlock;
import WayofTime.bloodmagic.util.Utils;
public class ItemSigilSuppression extends ItemSigilToggleable
public class ItemSigilSuppression extends ItemSigilToggleableBase
{
public ItemSigilSuppression()
{

View file

@ -1,98 +0,0 @@
package WayofTime.bloodmagic.item.sigil;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import WayofTime.bloodmagic.item.ItemBindable;
import WayofTime.bloodmagic.util.helper.TextHelper;
public class ItemSigilToggleable extends ItemSigilBase
{
public ItemSigilToggleable(String name, int lpUsed)
{
super(name, lpUsed);
setToggleable();
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced)
{
super.addInformation(stack, player, tooltip, advanced);
if (getActivated(stack))
tooltip.add(TextHelper.localize("tooltip.BloodMagic.activated"));
else
tooltip.add(TextHelper.localize("tooltip.BloodMagic.deactivated"));
}
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{
if (!world.isRemote && !isUnusable(stack))
{
if (player.isSneaking())
setActivated(stack, !getActivated(stack));
if (getActivated(stack) && ItemBindable.syphonNetwork(stack, player, getLPUsed()))
return super.onItemRightClick(stack, world, player, hand);
}
return super.onItemRightClick(stack, world, player, hand);
}
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
return (ItemBindable.syphonNetwork(stack, player, getLPUsed()) && onSigilUse(stack, player, world, pos, side, hitX, hitY, hitZ)) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
}
public boolean onSigilUse(ItemStack itemStack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ)
{
return false;
}
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
{
if (!worldIn.isRemote && entityIn instanceof EntityPlayerMP && getActivated(stack))
{
if (worldIn.getWorldTime() % 100 == 0)
{
if (!ItemBindable.syphonNetwork(stack, (EntityPlayer) entityIn, getLPUsed()))
{
setActivated(stack, false);
}
}
onSigilUpdate(stack, worldIn, (EntityPlayer) entityIn, itemSlot, isSelected);
}
}
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
{
}
@Override
public List<Pair<Integer, String>> getVariants()
{
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
ret.add(new ImmutablePair<Integer, String>(0, "active=false"));
ret.add(new ImmutablePair<Integer, String>(1, "active=true"));
return ret;
}
}

View file

@ -0,0 +1,54 @@
package WayofTime.bloodmagic.item.sigil;
import java.util.ArrayList;
import java.util.List;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.impl.ItemSigilToggleable;
import WayofTime.bloodmagic.client.IVariantProvider;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import WayofTime.bloodmagic.util.helper.TextHelper;
public class ItemSigilToggleableBase extends ItemSigilToggleable implements IVariantProvider
{
protected final String tooltipBase;
private final String name;
public ItemSigilToggleableBase(String name, int lpUsed)
{
super(lpUsed);
setToggleable();
setUnlocalizedName(Constants.Mod.MODID + ".sigil." + name);
this.name = name;
this.tooltipBase = "tooltip.BloodMagic.sigil." + name + ".";
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced)
{
super.addInformation(stack, player, tooltip, advanced);
if (getActivated(stack))
tooltip.add(TextHelper.localize("tooltip.BloodMagic.activated"));
else
tooltip.add(TextHelper.localize("tooltip.BloodMagic.deactivated"));
}
@Override
public List<Pair<Integer, String>> getVariants()
{
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
ret.add(new ImmutablePair<Integer, String>(0, "active=false"));
ret.add(new ImmutablePair<Integer, String>(1, "active=true"));
return ret;
}
}

View file

@ -2,6 +2,7 @@ package WayofTime.bloodmagic.item.sigil;
import java.util.List;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.effect.EntityLightningBolt;
@ -73,7 +74,7 @@ public class ItemSigilTransposition extends ItemSigilBase
{
if (rightClickedBlock.getBlock().getPlayerRelativeBlockHardness(state, player, world, blockPos) >= 0 && rightClickedBlock.getBlock().getBlockHardness(state, world, blockPos) >= 0)
{
int cost = getLPUsed();
int cost = getLpUsed();
NBTTagCompound tileNBTTag = new NBTTagCompound();
String blockName = rightClickedBlock.getBlock().getRegistryName();
@ -94,7 +95,7 @@ public class ItemSigilTransposition extends ItemSigilBase
stack.getTagCompound().setByte(Constants.NBT.CONTAINED_BLOCK_META, metadata);
stack.getTagCompound().setTag(Constants.NBT.CONTAINED_TILE_ENTITY, tileNBTTag);
syphonNetwork(stack, player, cost);
NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, cost);
lightning(world, blockPos);
world.removeTileEntity(blockPos);

View file

@ -1,5 +1,6 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@ -56,7 +57,7 @@ public class ItemSigilVoid extends ItemSigilBase
return super.onItemRightClick(stack, world, player, hand);
}
if (world.getBlockState(blockpos).getBlock().getMaterial(world.getBlockState(blockpos)).isLiquid() && syphonNetwork(stack, player, getLPUsed()))
if (world.getBlockState(blockpos).getBlock().getMaterial(world.getBlockState(blockpos)).isLiquid() && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()))
{
world.setBlockToAir(blockpos);
return super.onItemRightClick(stack, world, player, hand);
@ -68,7 +69,7 @@ public class ItemSigilVoid extends ItemSigilBase
}
if (!player.capabilities.isCreativeMode)
this.setUnusable(stack, !syphonNetwork(stack, player, getLPUsed()));
this.setUnusable(stack, !NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()));
}
return super.onItemRightClick(stack, world, player, hand);
@ -92,7 +93,7 @@ public class ItemSigilVoid extends ItemSigilBase
{
FluidStack amount = ((IFluidHandler) tile).drain(side, 1000, false);
if (amount != null && amount.amount > 0 && syphonNetwork(stack, player, getLPUsed()))
if (amount != null && amount.amount > 0 && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()))
{
((IFluidHandler) tile).drain(side, 1000, true);
return EnumActionResult.SUCCESS;
@ -108,7 +109,7 @@ public class ItemSigilVoid extends ItemSigilBase
return EnumActionResult.FAIL;
}
if (world.getBlockState(newPos).getBlock() instanceof IFluidBlock && syphonNetwork(stack, player, getLPUsed()))
if (world.getBlockState(newPos).getBlock() instanceof IFluidBlock && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()))
{
world.setBlockToAir(newPos);
return EnumActionResult.SUCCESS;

View file

@ -1,5 +1,6 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import net.minecraft.block.BlockCauldron;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
@ -57,7 +58,7 @@ public class ItemSigilWater extends ItemSigilBase
if (!player.canPlayerEdit(blockpos1, movingobjectposition.sideHit, stack))
return super.onItemRightClick(stack, world, player, hand);
if (this.canPlaceWater(world, blockpos1) && syphonNetwork(stack, player, getLPUsed()) && this.tryPlaceWater(world, blockpos1))
if (this.canPlaceWater(world, blockpos1) && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()) && this.tryPlaceWater(world, blockpos1))
return super.onItemRightClick(stack, world, player, hand);
}
}
@ -81,19 +82,19 @@ public class ItemSigilWater extends ItemSigilBase
FluidStack fluid = new FluidStack(FluidRegistry.WATER, 1000);
int amount = ((IFluidHandler) tile).fill(side, fluid, false);
if (amount > 0 && syphonNetwork(stack, player, getLPUsed()))
if (amount > 0 && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()))
((IFluidHandler) tile).fill(side, fluid, true);
return EnumActionResult.FAIL;
}
if (world.getBlockState(blockPos).getBlock() == Blocks.cauldron && syphonNetwork(stack, 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;
}
BlockPos newPos = blockPos.offset(side);
return (player.canPlayerEdit(newPos, side, stack) && this.canPlaceWater(world, newPos) && syphonNetwork(stack, player, getLPUsed()) && this.tryPlaceWater(world, newPos)) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
return (player.canPlayerEdit(newPos, side, stack) && this.canPlaceWater(world, newPos) && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()) && this.tryPlaceWater(world, newPos)) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
}
public boolean canPlaceWater(World world, BlockPos blockPos)

View file

@ -7,7 +7,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class ItemSigilWhirlwind extends ItemSigilToggleable
public class ItemSigilWhirlwind extends ItemSigilToggleableBase
{
public ItemSigilWhirlwind()
{