Added most of the rest of the Anointment framework and a few more items.

Includes a Fortune, Silk Touch, and +damage Anointment.
This commit is contained in:
WayofTime 2021-01-12 08:27:47 -05:00
parent 8d9319e271
commit 7f2c40a1c4
114 changed files with 962 additions and 218 deletions

View file

@ -217,6 +217,12 @@ public class BloodMagicItems
public static final RegistryObject<Item> SALTPETER = BASICITEMS.register("saltpeter", () -> new ItemBase());
public static final RegistryObject<Item> PLANT_OIL = BASICITEMS.register("plantoil", () -> new ItemBase());
// Anointments
public static final RegistryObject<Item> SLATE_VIAL = ITEMS.register("slate_vial", () -> new ItemBase(16, "slate_vial"));
public static final RegistryObject<Item> MELEE_DAMAGE_ANOINTMENT = ITEMS.register("melee_anointment", () -> new ItemAnointmentProvider(BloodMagic.rl("melee_damage"), 0xFF0000, 1, 128));
public static final RegistryObject<Item> SILK_TOUCH_ANOINTMENT = ITEMS.register("silk_touch_anointment", () -> new ItemAnointmentProvider(BloodMagic.rl("silk_touch"), 0x00B0FF, 1, 256));
public static final RegistryObject<Item> FORTUNE_ANOINTMENT = ITEMS.register("fortune_anointment", () -> new ItemAnointmentProvider(BloodMagic.rl("fortune"), 3381504, 1, 128));
// Fragments
public static final RegistryObject<Item> IRON_FRAGMENT = BASICITEMS.register("ironfragment", () -> new ItemBase());
public static final RegistryObject<Item> GOLD_FRAGMENT = BASICITEMS.register("goldfragment", () -> new ItemBase());

View file

@ -4,22 +4,35 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SwordItem;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.SoundEvents;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
import wayoftime.bloodmagic.BloodMagic;
import wayoftime.bloodmagic.anointment.Anointment;
import wayoftime.bloodmagic.anointment.AnointmentData;
import wayoftime.bloodmagic.anointment.AnointmentHolder;
import wayoftime.bloodmagic.core.AnointmentRegistrar;
public class ItemAnointmentProvider extends Item
{
public Anointment anointment;
// public Anointment anointment;
public ResourceLocation anointRL;
private int colour;
private int level;
private int maxDamage;
public ItemAnointmentProvider(Anointment anointment)
public ItemAnointmentProvider(ResourceLocation anointRL, int colour, int level, int maxDamage)
{
super(new Item.Properties().maxStackSize(16).group(BloodMagic.TAB));
this.anointment = anointment;
this.anointRL = anointRL;
this.colour = colour;
this.level = level;
this.maxDamage = maxDamage;
// this.anointment = anointment;
}
@Override
@ -27,7 +40,6 @@ public class ItemAnointmentProvider extends Item
{
ItemStack stack = player.getHeldItem(hand);
ItemStack weaponStack = player.getHeldItem(hand == Hand.MAIN_HAND ? Hand.OFF_HAND : Hand.MAIN_HAND);
// if (world.isRemote && !unusable)
// {
// Vector3d vec = player.getLookVec();
@ -50,7 +62,45 @@ public class ItemAnointmentProvider extends Item
{
if (!weaponStack.isEmpty() && isItemValidForApplication(weaponStack))
{
ToolType d;
AnointmentHolder holder = AnointmentHolder.fromItemStack(weaponStack);
if (holder == null)
{
holder = new AnointmentHolder();
}
if (holder.applyAnointment(weaponStack, AnointmentRegistrar.ANOINTMENT_MAP.get(anointRL), new AnointmentData(level, 0, maxDamage)))
{
// if (world instanceof ServerWorld)
{
SoundEvent soundevent = SoundEvents.ITEM_BOTTLE_EMPTY;
world.playSound(null, player.getPosition(), soundevent, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
stack.shrink(1);
holder.toItemStack(weaponStack);
return ActionResult.resultSuccess(stack);
}
}
} else
{
if (!weaponStack.isEmpty() && isItemValidForApplication(weaponStack))
{
AnointmentHolder holder = AnointmentHolder.fromItemStack(weaponStack);
if (holder == null)
{
holder = new AnointmentHolder();
}
if (holder.canApplyAnointment(weaponStack, AnointmentRegistrar.ANOINTMENT_MAP.get(anointRL), new AnointmentData(level, 0, maxDamage)))
{
boolean flag1 = false;
double d0 = (double) (colour >> 16 & 255) / 255.0D;
double d1 = (double) (colour >> 8 & 255) / 255.0D;
double d2 = (double) (colour >> 0 & 255) / 255.0D;
for (int i = 0; i < 16; i++)
{
world.addParticle(flag1 ? ParticleTypes.AMBIENT_ENTITY_EFFECT
: ParticleTypes.ENTITY_EFFECT, player.getPosXRandom(0.3D), player.getPosYRandom(), player.getPosZRandom(0.3D), d0, d1, d2);
}
}
}
}
@ -71,4 +121,9 @@ public class ItemAnointmentProvider extends Item
{
return stack.getItem() instanceof SwordItem;
}
public int getColor()
{
return colour;
}
}

View file

@ -23,7 +23,17 @@ public class ItemBase extends Item
public ItemBase(String desc)
{
super(new Item.Properties().maxStackSize(64).group(BloodMagic.TAB));
this(64, desc);
}
public ItemBase(int stackSize)
{
this(stackSize, "");
}
public ItemBase(int stackSize, String desc)
{
super(new Item.Properties().maxStackSize(stackSize).group(BloodMagic.TAB));
this.desc = desc;
}