Added meadow brook's staff. It's a big stick.

This commit is contained in:
Sollace 2019-02-14 19:11:28 +02:00
parent a7c81197a8
commit 6b66a09414
7 changed files with 177 additions and 1 deletions

View file

@ -10,6 +10,7 @@ import com.minelittlepony.unicopia.item.ItemOfHolding;
import com.minelittlepony.unicopia.item.ItemRottenApple;
import com.minelittlepony.unicopia.item.ItemSpell;
import com.minelittlepony.unicopia.item.ItemSpellbook;
import com.minelittlepony.unicopia.item.ItemStaff;
import com.minelittlepony.unicopia.item.ItemStick;
import com.minelittlepony.unicopia.item.ItemTomato;
import com.minelittlepony.unicopia.item.ItemTomatoSeeds;
@ -107,6 +108,8 @@ public class UItems {
public static final ItemOfHolding bag_of_holding = new ItemOfHolding(Unicopia.MODID, "bag_of_holding");
public static final ItemSpellbook spellbook = new ItemSpellbook(Unicopia.MODID, "spellbook");
public static final Item staff_meadow_brook = new ItemStaff(Unicopia.MODID, "staff_meadow_brook").setMaxDamage(2);
public static final Item alfalfa_seeds = new ItemSeedFood(1, 4, UBlocks.alfalfa, Blocks.FARMLAND)
.setTranslationKey("alfalfa_seeds")
@ -206,6 +209,7 @@ public class UItems {
cloud_farmland, mist_door, anvil,
bag_of_holding, spell, curse, spellbook, mug, enchanted_torch,
staff_meadow_brook,
alfalfa_seeds, alfalfa_leaves,
cereal, sugar_cereal, sugar_block,
@ -233,7 +237,9 @@ public class UItems {
cloud_spawner, cloud_matter, cloud_stairs, cloud_fence, cloud_banister,
cloud_farmland, mist_door, anvil,
bag_of_holding, spell, curse, spellbook, mug, enchanted_torch,
staff_meadow_brook,
alfalfa_seeds, alfalfa_leaves,
cereal, sugar_cereal, sugar_block,

View file

@ -0,0 +1,136 @@
package com.minelittlepony.unicopia.item;
import java.util.List;
import java.util.UUID;
import javax.annotation.Nullable;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.minelittlepony.unicopia.Predicates;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
public class ItemStaff extends ItemSword implements ITossable {
protected static final UUID ATTACK_REACH_MODIFIER = UUID.fromString("FA235E1C-4280-A865-B01B-CBAE9985ACA3");
public ItemStaff(String domain, String name) {
super(ToolMaterial.WOOD);
setTranslationKey(name);
setRegistryName(domain, name);
setMaxStackSize(1);
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack itemstack = player.getHeldItem(hand);
if (canBeThrown(itemstack)) {
toss(world, itemstack, player);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);
}
return super.onItemRightClick(world, player, hand);
}
@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity target) {
World w = player.getEntityWorld();
for (int i = 0; i < 130; i++) {
w.spawnParticle(EnumParticleTypes.BLOCK_CRACK,
target.posX + (target.world.rand.nextFloat() - 0.5F) * (target.width + 1),
(target.posY + target.height/2) + (target.world.rand.nextFloat() - 0.5F) * target.height,
target.posZ + (target.world.rand.nextFloat() - 0.5F) * (target.width + 1),
0, 0, 0,
Block.getStateId(Blocks.LOG.getDefaultState())
);
}
return false;
}
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
tooltip.add(I18n.format(getTranslationKey(stack) + ".tagline"));
}
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
super.hitEntity(stack, target, attacker);
if (Predicates.MAGI.test(attacker)) {
return castContainedEffect(stack, target, attacker);
}
return false;
}
protected boolean castContainedEffect(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
target.getEntityWorld().playSound(null, target.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_CRIT, attacker.getSoundCategory(), 1, 1);
target.knockBack(attacker, 2,
MathHelper.sin(attacker.rotationYaw * 0.017453292F),
-MathHelper.cos(attacker.rotationYaw * 0.017453292F)
);
return true;
}
@Override
public boolean isFull3D() {
return true;
}
@Override
public EnumAction getItemUseAction(ItemStack stack) {
return EnumAction.BOW;
}
@Override
public boolean canBeThrown(ItemStack stack) {
return false;
}
@Override
public void onImpact(World world, BlockPos pos, IBlockState state) {
}
@Override
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot slot) {
Multimap<String, AttributeModifier> multimap = HashMultimap.create();
if (slot == EntityEquipmentSlot.MAINHAND) {
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getAttackDamage(), 0));
multimap.put(EntityPlayer.REACH_DISTANCE.getName(), new AttributeModifier(ATTACK_REACH_MODIFIER, "Weapon modifier", 3, 0));
}
return multimap;
}
}

View file

@ -54,7 +54,7 @@ public class CasterUtils {
.filter(e -> !e.getDead());
}
static Optional<ICaster<?>> toCaster(@Nullable Entity entity) {
public static Optional<ICaster<?>> toCaster(@Nullable Entity entity) {
if (entity instanceof ICaster<?>) {
return Optional.of((ICaster<?>)entity);

View file

@ -27,6 +27,9 @@ item.mist_door.name=Cloud Door
item.dew_drop.name=Dew Drop
item.cloud_anvil.name=Anvilhead Anvil
item.staff_meadow_brook.name=Meadow Brook's Staff
item.staff_meadow_brook.tagline=It's a big stick
item.gem.name=Gem
item.gem.enchanted.name=Gem of %s
item.corrupted_gem.name=Fractured Gem

View file

@ -0,0 +1,25 @@
{
"parent": "item/handheld",
"display": {
"thirdperson_righthand": {
"rotation": [ 0, 90, 55 ],
"translation": [ 0, 4.0, 2.5 ],
"scale": [ 1.25, 1.25, 1.25 ]
},
"thirdperson_lefthand": {
"rotation": [ 0, -90, -55 ],
"translation": [ 0, 4.0, 2.5 ],
"scale": [ 1.25, 1.25, 1.25 ]
},
"firstperson_righthand": {
"rotation": [ 0, 90, 25 ],
"translation": [ 0, 1.9, 0.8 ],
"scale": [ 0.88, 0.88, 0.88 ]
},
"firstperson_lefthand": {
"rotation": [ 0, -90, -25 ],
"translation": [ 0, 1.9, 0.8 ],
"scale": [ 0.88, 0.88, 0.88 ]
}
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "unicopia:item/handheld_staff",
"textures": {
"layer0": "unicopia:items/staff_meadow_brook"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB