Added Syringe Throwing Daggers and Slate Ampoules
The new Throwing Daggers deal 8 damage and have a chance to drop a Slate Ampoule based on the mob killed's max health. Crafted using the Hellfire Forge. Using a Slate Ampoule next to a Blood Altar fills its main tank with 500LP .
This commit is contained in:
parent
abe7333e64
commit
d15daa737c
|
@ -60,7 +60,7 @@ e6d9cf699667aaa47efff37b2b033895dee29c15 assets/bloodmagic/blockstates/waterritu
|
|||
42f26f715bddd16c069f9b51e3767b36477c8908 assets/bloodmagic/blockstates/woodtilepath.json
|
||||
3c6ce233dae6c1307d9016406c324bbe844b4e1e assets/bloodmagic/blockstates/wornstonebrickpath.json
|
||||
d59655f12d1724b73b77c373fb6864fcff69db12 assets/bloodmagic/blockstates/wornstonetilepath.json
|
||||
d368d170cab57d2e1b382b4ff461424f82dc47aa assets/bloodmagic/lang/en_us.json
|
||||
0492479fed31666acdf2d5f3fb2dab3b6ebdf6b5 assets/bloodmagic/lang/en_us.json
|
||||
34445195b9f2459475cde53454bc8e37d32865d7 assets/bloodmagic/models/block/accelerationrune.json
|
||||
bcdbccc49d4509571be6988762ab87126275a4c8 assets/bloodmagic/models/block/airritualstone.json
|
||||
adf6c0b1e25451609486dc8c8cfbd9cf0f8c67f4 assets/bloodmagic/models/block/alchemicalreactionchamber.json
|
||||
|
@ -332,6 +332,7 @@ cc71421e98ee7ee047a4cfbb6cb69529c2b02d4e assets/bloodmagic/models/item/selfsacri
|
|||
6cc73920a09d4d6925154732f4064d8d03590f25 assets/bloodmagic/models/item/sigilofholding.json
|
||||
ea5747638d0b5dcc03f008b202cc60a11e0827bb assets/bloodmagic/models/item/sigilofmagnetism.json
|
||||
dd4a590f68820a04ca4a71df507e8a39ca6bd393 assets/bloodmagic/models/item/silk_touch_anointment.json
|
||||
96eca80edd26a325bd65f325f4c3d651b1080912 assets/bloodmagic/models/item/slate_ampoule.json
|
||||
08bee690d5092e3c9e6c04c43f50af668fdb3b7e assets/bloodmagic/models/item/slate_vial.json
|
||||
dd4a590f68820a04ca4a71df507e8a39ca6bd393 assets/bloodmagic/models/item/smelting_anointment.json
|
||||
db0f63198089161b8d4ecfb1ec8a45f7dc5ba83d assets/bloodmagic/models/item/soulaxe.json
|
||||
|
@ -351,6 +352,7 @@ fe2b201007c974229509f6900c6eb8b03d158b0a assets/bloodmagic/models/item/soulsword
|
|||
2dc28b0e2b7ae7bb0bcf8c8e74b9ba7c800446ff assets/bloodmagic/models/item/stonetilepath.json
|
||||
1992b3655f7bbca8b7aac7c53f1a0e7b1ab3124d assets/bloodmagic/models/item/sulfur.json
|
||||
451fa4812d23a207882eb95d89673b1e4c2dd257 assets/bloodmagic/models/item/throwing_dagger.json
|
||||
4f4e6c72a160eb635bdf78ed0a6ba5765fbf51ea assets/bloodmagic/models/item/throwing_dagger_syringe.json
|
||||
d13731c45f6dd23b8e70d2a75d4068bdae88ef5c assets/bloodmagic/models/item/upgradetome.json
|
||||
e8fe01c5cddc268538681889f3161472a8f1c8ad assets/bloodmagic/models/item/variants/growthsigil_activated.json
|
||||
20c802279de4df496057795c2e891fa54a21376f assets/bloodmagic/models/item/variants/growthsigil_deactivated.json
|
||||
|
@ -702,6 +704,7 @@ d6e06747c75fc06e708a15358911f1c63eee86b1 data/bloodmagic/recipes/soulforge/petty
|
|||
dc977e9d98fcba66fbcce3f6c31a746db5ed60f5 data/bloodmagic/recipes/soulforge/shaped_charge.json
|
||||
c4102a1573e632d0b9f894353b0d522a51a7c65e data/bloodmagic/recipes/soulforge/steadfast_crystal_block.json
|
||||
ed0875aaba76e013684b8ea2f8275d5563e90e98 data/bloodmagic/recipes/soulforge/throwing_dagger.json
|
||||
aeca6c087f7add7eec25b7a5df2589a90e1daca9 data/bloodmagic/recipes/soulforge/throwing_dagger_syringe.json
|
||||
978033adf58e34fa317bcea448ac1ddf3f0cd69e data/bloodmagic/recipes/soulforge/vein_charge.json
|
||||
3aa852edda803a2225ebe53d2daa55bd46b0a1b9 data/bloodmagic/recipes/soulforge/vengeful_crystal_block.json
|
||||
d7d993bb729284a5201c164ea81fbe1d8e4e4750 data/bloodmagic/recipes/weak_activation_crystal.json
|
||||
|
|
|
@ -170,6 +170,7 @@
|
|||
"item.bloodmagic.sigilofholding": "Sigil of Holding",
|
||||
"item.bloodmagic.sigilofmagnetism": "Sigil of Magnetism",
|
||||
"item.bloodmagic.silk_touch_anointment": "Soft Coating",
|
||||
"item.bloodmagic.slate_ampoule": "Slate Ampoule",
|
||||
"item.bloodmagic.slate_vial": "Slate-infused Vial",
|
||||
"item.bloodmagic.smelting_anointment": "Slow-burning Oil",
|
||||
"item.bloodmagic.soulaxe": "Sentient Axe",
|
||||
|
@ -185,6 +186,7 @@
|
|||
"item.bloodmagic.steadfastcrystal": "Steadfast Will Crystal",
|
||||
"item.bloodmagic.sulfur": "Sulfur",
|
||||
"item.bloodmagic.throwing_dagger": "Iron Throwing Dagger",
|
||||
"item.bloodmagic.throwing_dagger_syringe": "Syringe Throwing Dagger",
|
||||
"item.bloodmagic.upgradetome": "Living Armour Upgrade Tome",
|
||||
"item.bloodmagic.vengefulcrystal": "Vengeful Will Crystal",
|
||||
"item.bloodmagic.voidsigil": "Void Sigil",
|
||||
|
@ -406,6 +408,7 @@
|
|||
"tooltip.bloodmagic.arcaneAshes": "Ashes used to draw an alchemy circle",
|
||||
"tooltip.bloodmagic.arctool.additionaldrops": "Increases chance of additional outputs by: x%s",
|
||||
"tooltip.bloodmagic.arctool.uses": "Uses remaining: %s",
|
||||
"tooltip.bloodmagic.blood_provider.slate.desc": "A simple ampoule containing 500LP",
|
||||
"tooltip.bloodmagic.config.disabled": "Currently disabled in the Config",
|
||||
"tooltip.bloodmagic.currentBaseType.corrosive": "Corrosive",
|
||||
"tooltip.bloodmagic.currentBaseType.default": "Raw",
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "bloodmagic:item/slate_ampoule"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "bloodmagic:item/throwing_dagger_syringe"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"type": "bloodmagic:soulforge",
|
||||
"input0": {
|
||||
"tag": "forge:stone"
|
||||
},
|
||||
"input1": {
|
||||
"tag": "forge:glass"
|
||||
},
|
||||
"output": {
|
||||
"item": "bloodmagic:throwing_dagger_syringe",
|
||||
"count": 16
|
||||
},
|
||||
"minimumDrain": 10.0,
|
||||
"drain": 2.0
|
||||
}
|
|
@ -13,9 +13,9 @@ import net.minecraft.util.ResourceLocation;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import wayoftime.bloodmagic.entity.projectile.EntityThrowingDagger;
|
||||
import wayoftime.bloodmagic.entity.projectile.AbstractEntityThrowingDagger;
|
||||
|
||||
public class EntityThrowingDaggerRenderer<T extends EntityThrowingDagger> extends EntityRenderer<T>
|
||||
public class EntityThrowingDaggerRenderer<T extends AbstractEntityThrowingDagger> extends EntityRenderer<T>
|
||||
{
|
||||
private final net.minecraft.client.renderer.ItemRenderer itemRenderer;
|
||||
private final float scale;
|
||||
|
@ -47,12 +47,9 @@ public class EntityThrowingDaggerRenderer<T extends EntityThrowingDagger> extend
|
|||
// ArrowRenderer<?> d;
|
||||
matrixStackIn.push();
|
||||
matrixStackIn.scale(this.scale, this.scale, this.scale);
|
||||
// matrixStackIn.rotate(this.renderManager.getCameraOrientation());
|
||||
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(MathHelper.lerp(partialTicks, entityIn.prevRotationYaw, entityIn.rotationYaw) - 90.0F));
|
||||
matrixStackIn.rotate(Vector3f.ZP.rotationDegrees(MathHelper.lerp(partialTicks, entityIn.prevRotationPitch, entityIn.rotationPitch) - 45F));
|
||||
|
||||
// matrixStackIn.rotate(Vector3f.ZP.rotationDegrees(45F));
|
||||
// matrixStackIn.rotate(Vector3f.YP.rotationDegrees(180.0F));
|
||||
this.itemRenderer.renderItem(entityIn.getItem(), ItemCameraTransforms.TransformType.GROUND, packedLightIn, OverlayTexture.NO_OVERLAY, matrixStackIn, bufferIn);
|
||||
matrixStackIn.pop();
|
||||
super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn);
|
||||
|
|
|
@ -354,6 +354,7 @@ public class GeneratorLanguage extends LanguageProvider
|
|||
add("tooltip.bloodmagic.livingarmour.extraExtraInfo", "&9-Hold shift + M for progress info-");
|
||||
|
||||
add("tooltip.bloodmagic.slate_vial", "A glass vial infused with a simple slate");
|
||||
add("tooltip.bloodmagic.blood_provider.slate.desc", "A simple ampoule containing 500LP");
|
||||
|
||||
add("chat.bloodmagic.living_upgrade_level_increase", "%s has leveled up to %d");
|
||||
|
||||
|
@ -556,6 +557,8 @@ public class GeneratorLanguage extends LanguageProvider
|
|||
addItem(BloodMagicItems.LIVING_TOME, "Living Armour Upgrade Tome");
|
||||
|
||||
addItem(BloodMagicItems.THROWING_DAGGER, "Iron Throwing Dagger");
|
||||
addItem(BloodMagicItems.THROWING_DAGGER_SYRINGE, "Syringe Throwing Dagger");
|
||||
addItem(BloodMagicItems.SLATE_AMPOULE, "Slate Ampoule");
|
||||
|
||||
// Anointment Items
|
||||
addItem(BloodMagicItems.SLATE_VIAL, "Slate-infused Vial");
|
||||
|
|
|
@ -224,6 +224,8 @@ public class BloodMagicItems
|
|||
public static final RegistryObject<Item> PLANT_OIL = BASICITEMS.register("plantoil", () -> new ItemBase());
|
||||
|
||||
public static final RegistryObject<Item> THROWING_DAGGER = BASICITEMS.register("throwing_dagger", ItemThrowingDagger::new);
|
||||
public static final RegistryObject<Item> THROWING_DAGGER_SYRINGE = BASICITEMS.register("throwing_dagger_syringe", ItemThrowingDaggerSyringe::new);
|
||||
public static final RegistryObject<Item> SLATE_AMPOULE = BASICITEMS.register("slate_ampoule", () -> new ItemBloodProvider("slate", 500));
|
||||
|
||||
// Anointments
|
||||
public static final RegistryObject<Item> SLATE_VIAL = ITEMS.register("slate_vial", () -> new ItemBase(16, "slate_vial"));
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.particles.RedstoneParticleData;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.altar.IBloodAltar;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerSacrificeHelper;
|
||||
|
||||
public class ItemBloodProvider extends Item
|
||||
{
|
||||
protected final String tooltipBase;
|
||||
public final int lpProvided;
|
||||
|
||||
public ItemBloodProvider(String name, int lpProvided)
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(64).group(BloodMagic.TAB));
|
||||
|
||||
this.tooltipBase = "tooltip.bloodmagic.blood_provider." + name + ".";
|
||||
this.lpProvided = lpProvided;
|
||||
}
|
||||
|
||||
public ItemBloodProvider(String name)
|
||||
{
|
||||
this(name, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand)
|
||||
{
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
IBloodAltar altarEntity = PlayerSacrificeHelper.getAltar(world, player.getPosition());
|
||||
if (altarEntity != null)
|
||||
{
|
||||
double posX = player.getPosX();
|
||||
double posY = player.getPosY();
|
||||
double posZ = player.getPosZ();
|
||||
world.playSound(player, posX, posY, posZ, SoundEvents.BLOCK_GLASS_BREAK, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
|
||||
|
||||
for (int l = 0; l < 8; ++l)
|
||||
world.addParticle(RedstoneParticleData.REDSTONE_DUST, posX + Math.random() - Math.random(), posY + Math.random() - Math.random(), posZ + Math.random() - Math.random(), 0, 0, 0);
|
||||
|
||||
if (!world.isRemote && PlayerHelper.isFakePlayer(player))
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
altarEntity.fillMainTank(lpProvided);
|
||||
if (!player.isCreative())
|
||||
{
|
||||
stack.shrink(1);
|
||||
}
|
||||
}
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
tooltip.add(new TranslationTextComponent(tooltipBase + "desc").mergeStyle(TextFormatting.ITALIC));
|
||||
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
}
|
||||
}
|
|
@ -12,18 +12,20 @@ import net.minecraft.util.Hand;
|
|||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.api.compat.EnumDemonWillType;
|
||||
import wayoftime.bloodmagic.entity.projectile.AbstractEntityThrowingDagger;
|
||||
import wayoftime.bloodmagic.entity.projectile.EntityThrowingDagger;
|
||||
import wayoftime.bloodmagic.will.PlayerDemonWillHandler;
|
||||
|
||||
public class ItemThrowingDagger extends Item
|
||||
{
|
||||
public static int[] soulBracket = new int[] { 16, 60, 200, 400, 1000, 2000, 4000 };
|
||||
public static int[] soulBracket = new int[] { 1, 60, 200, 400, 1000, 2000, 4000 };
|
||||
|
||||
public static double[] soulDrop = new double[] { 2, 4, 7, 10, 13, 15, 18 };
|
||||
public static double[] staticDrop = new double[] { 1, 1, 2, 3, 3, 4, 4 };
|
||||
|
@ -61,9 +63,7 @@ public class ItemThrowingDagger extends Item
|
|||
|
||||
ItemStack copyStack = stack.copy();
|
||||
copyStack.setCount(1);
|
||||
EntityThrowingDagger dagger = new EntityThrowingDagger(copyStack, worldIn, playerIn);
|
||||
dagger.func_234612_a_(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 3F, 0.5F);
|
||||
dagger.setDamage(10);
|
||||
AbstractEntityThrowingDagger dagger = getDagger(copyStack, worldIn, playerIn);
|
||||
|
||||
int level = getLevel(souls);
|
||||
if (level >= 0)
|
||||
|
@ -84,6 +84,14 @@ public class ItemThrowingDagger extends Item
|
|||
return new ActionResult<>(ActionResultType.SUCCESS, stack);
|
||||
}
|
||||
|
||||
public AbstractEntityThrowingDagger getDagger(ItemStack stack, World world, PlayerEntity player)
|
||||
{
|
||||
AbstractEntityThrowingDagger dagger = new EntityThrowingDagger(stack, world, player);
|
||||
dagger.func_234612_a_(player, player.rotationPitch, player.rotationYaw, 0.0F, 3F, 0.5F);
|
||||
dagger.setDamage(10);
|
||||
return dagger;
|
||||
}
|
||||
|
||||
private int getLevel(double soulsRemaining)
|
||||
{
|
||||
int lvl = -1;
|
||||
|
@ -102,7 +110,7 @@ public class ItemThrowingDagger extends Item
|
|||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.throwing_dagger.desc"));
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.throwing_dagger.desc").mergeStyle(TextFormatting.ITALIC));
|
||||
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.entity.projectile.AbstractEntityThrowingDagger;
|
||||
import wayoftime.bloodmagic.entity.projectile.EntityThrowingDaggerSyringe;
|
||||
|
||||
public class ItemThrowingDaggerSyringe extends ItemThrowingDagger
|
||||
{
|
||||
@Override
|
||||
public AbstractEntityThrowingDagger getDagger(ItemStack stack, World world, PlayerEntity player)
|
||||
{
|
||||
AbstractEntityThrowingDagger dagger = new EntityThrowingDaggerSyringe(stack, world, player);
|
||||
dagger.func_234612_a_(player, player.rotationPitch, player.rotationYaw, 0.0F, 3F, 0.5F);
|
||||
dagger.setDamage(8);
|
||||
return dagger;
|
||||
}
|
||||
}
|
|
@ -60,6 +60,7 @@ public class TartaricForgeRecipeProvider implements ISubRecipeProvider
|
|||
TartaricForgeRecipeBuilder.tartaricForge(stack, 60, 1, Ingredient.fromItems(BloodMagicItems.DEFORESTER_CHARGE_ITEM.get())).build(consumer, BloodMagic.rl(basePath + "deforester_charge_smelting"));
|
||||
|
||||
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.THROWING_DAGGER.get(), 16), 32, 5, Ingredient.fromTag(Tags.Items.INGOTS_IRON), Ingredient.fromTag(Tags.Items.INGOTS_IRON), Ingredient.fromTag(Tags.Items.STRING)).build(consumer, BloodMagic.rl(basePath + "throwing_dagger"));
|
||||
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.THROWING_DAGGER_SYRINGE.get(), 16), 10, 2, Ingredient.fromTag(Tags.Items.STONE), Ingredient.fromTag(Tags.Items.GLASS)).build(consumer, BloodMagic.rl(basePath + "throwing_dagger_syringe"));
|
||||
|
||||
// Changed Recipes
|
||||
{
|
||||
|
|
|
@ -5,10 +5,10 @@ import net.minecraft.entity.EntityType;
|
|||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.registration.impl.EntityTypeDeferredRegister;
|
||||
import wayoftime.bloodmagic.common.registration.impl.EntityTypeRegistryObject;
|
||||
import wayoftime.bloodmagic.entity.projectile.AbstractEntityThrowingDagger;
|
||||
import wayoftime.bloodmagic.entity.projectile.EntityBloodLight;
|
||||
import wayoftime.bloodmagic.entity.projectile.EntityShapedCharge;
|
||||
import wayoftime.bloodmagic.entity.projectile.EntitySoulSnare;
|
||||
import wayoftime.bloodmagic.entity.projectile.EntityThrowingDagger;
|
||||
|
||||
public class BloodMagicEntityTypes
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ public class BloodMagicEntityTypes
|
|||
public static final EntityTypeDeferredRegister ENTITY_TYPES = new EntityTypeDeferredRegister(BloodMagic.MODID);
|
||||
|
||||
public static final EntityTypeRegistryObject<EntitySoulSnare> SNARE = ENTITY_TYPES.register("soulsnare", EntityType.Builder.<EntitySoulSnare>create(EntitySoulSnare::new, EntityClassification.MISC).setTrackingRange(64).setUpdateInterval(1).size(0.25f, 0.25f));
|
||||
public static final EntityTypeRegistryObject<EntityThrowingDagger> THROWING_DAGGER = ENTITY_TYPES.register("throwing_dagger", EntityType.Builder.<EntityThrowingDagger>create(EntityThrowingDagger::new, EntityClassification.MISC).setTrackingRange(64).setUpdateInterval(1).size(0.25f, 0.25f));
|
||||
public static final EntityTypeRegistryObject<AbstractEntityThrowingDagger> THROWING_DAGGER = ENTITY_TYPES.register("throwing_dagger", EntityType.Builder.<AbstractEntityThrowingDagger>create(AbstractEntityThrowingDagger::new, EntityClassification.MISC).setTrackingRange(64).setUpdateInterval(1).size(0.25f, 0.25f));
|
||||
public static final EntityTypeRegistryObject<EntityBloodLight> BLOOD_LIGHT = ENTITY_TYPES.register("bloodlight", EntityType.Builder.<EntityBloodLight>create(EntityBloodLight::new, EntityClassification.MISC).setTrackingRange(64).setUpdateInterval(1).size(0.25f, 0.25f));
|
||||
public static final EntityTypeRegistryObject<EntityShapedCharge> SHAPED_CHARGE = ENTITY_TYPES.register("shapedcharge", EntityType.Builder.<EntityShapedCharge>create(EntityShapedCharge::new, EntityClassification.MISC).setTrackingRange(64).setUpdateInterval(1).size(0.4f, 0.4f));
|
||||
|
||||
|
|
|
@ -0,0 +1,687 @@
|
|||
package wayoftime.bloodmagic.entity.projectile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.MoverType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.projectile.AbstractArrowEntity;
|
||||
import net.minecraft.entity.projectile.ProjectileHelper;
|
||||
import net.minecraft.entity.projectile.ProjectileItemEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.network.play.server.SChangeGameStatePacket;
|
||||
import net.minecraft.particles.IParticleData;
|
||||
import net.minecraft.particles.ItemParticleData;
|
||||
import net.minecraft.particles.ParticleTypes;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.EntityRayTraceResult;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceContext;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import wayoftime.bloodmagic.api.compat.EnumDemonWillType;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
import wayoftime.bloodmagic.will.PlayerDemonWillHandler;
|
||||
|
||||
public class AbstractEntityThrowingDagger extends ProjectileItemEntity
|
||||
{
|
||||
@Nullable
|
||||
private BlockState inBlockState;
|
||||
protected boolean inGround;
|
||||
protected int timeInGround;
|
||||
public AbstractArrowEntity.PickupStatus pickupStatus = AbstractArrowEntity.PickupStatus.ALLOWED;
|
||||
public int arrowShake;
|
||||
private int ticksInGround;
|
||||
private double damage = 2.0D;
|
||||
private int knockbackStrength;
|
||||
private SoundEvent hitSound = this.getHitEntitySound();
|
||||
private IntOpenHashSet piercedEntities;
|
||||
private List<Entity> hitEntities;
|
||||
|
||||
// private ItemStack containedStack = ItemStack.EMPTY;
|
||||
private double willDrop = 0;
|
||||
private EnumDemonWillType willType = EnumDemonWillType.DEFAULT;
|
||||
|
||||
public AbstractEntityThrowingDagger(EntityType<? extends AbstractEntityThrowingDagger> type, World world)
|
||||
{
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
public AbstractEntityThrowingDagger(EntityType<? extends AbstractEntityThrowingDagger> type, ItemStack stack, World worldIn, LivingEntity throwerIn)
|
||||
{
|
||||
super(type, throwerIn, worldIn);
|
||||
this.setItem(stack);
|
||||
if (throwerIn instanceof PlayerEntity)
|
||||
{
|
||||
this.pickupStatus = AbstractArrowEntity.PickupStatus.ALLOWED;
|
||||
}
|
||||
}
|
||||
|
||||
public AbstractEntityThrowingDagger(EntityType<? extends AbstractEntityThrowingDagger> type, ItemStack stack, World worldIn, double x, double y, double z)
|
||||
{
|
||||
super(type, x, y, z, worldIn);
|
||||
this.setItem(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(ItemStack stack)
|
||||
{
|
||||
super.setItem(stack);
|
||||
// this.containedStack = stack;
|
||||
}
|
||||
|
||||
protected Item getDefaultItem()
|
||||
{
|
||||
return BloodMagicItems.THROWING_DAGGER.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket<?> createSpawnPacket()
|
||||
{
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
// super.tick();
|
||||
// RayTraceResult raytraceresult = ProjectileHelper.func_234618_a_(this, this::func_230298_a_);
|
||||
//// boolean flag = false;
|
||||
// if (raytraceresult.getType() == RayTraceResult.Type.BLOCK)
|
||||
// {
|
||||
// BlockPos blockpos = ((BlockRayTraceResult) raytraceresult).getPos().offset(((BlockRayTraceResult) raytraceresult).getFace());
|
||||
// BlockState blockstate = this.world.getBlockState(blockpos);
|
||||
// Material material = blockstate.getMaterial();
|
||||
// if (blockstate.isAir() || blockstate.isIn(BlockTags.FIRE) || material.isLiquid() || material.isReplaceable())
|
||||
// {
|
||||
// this.getEntityWorld().setBlockState(blockpos, BloodMagicBlocks.BLOOD_LIGHT.get().getDefaultState());
|
||||
// this.setDead();
|
||||
// }
|
||||
// }
|
||||
|
||||
// super.tick();
|
||||
this.baseTick();
|
||||
boolean flag = this.getNoClip();
|
||||
flag = false;
|
||||
Vector3d vector3d = this.getMotion();
|
||||
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
|
||||
{
|
||||
float f = MathHelper.sqrt(horizontalMag(vector3d));
|
||||
this.rotationYaw = (float) (MathHelper.atan2(vector3d.x, vector3d.z) * (double) (180F / (float) Math.PI));
|
||||
this.rotationPitch = (float) (MathHelper.atan2(vector3d.y, (double) f) * (double) (180F / (float) Math.PI));
|
||||
this.prevRotationYaw = this.rotationYaw;
|
||||
this.prevRotationPitch = this.rotationPitch;
|
||||
}
|
||||
|
||||
BlockPos blockpos = this.getPosition();
|
||||
BlockState blockstate = this.world.getBlockState(blockpos);
|
||||
if (!blockstate.isAir(this.world, blockpos) && !flag)
|
||||
{
|
||||
VoxelShape voxelshape = blockstate.getCollisionShape(this.world, blockpos);
|
||||
if (!voxelshape.isEmpty())
|
||||
{
|
||||
Vector3d vector3d1 = this.getPositionVec();
|
||||
|
||||
for (AxisAlignedBB axisalignedbb : voxelshape.toBoundingBoxList())
|
||||
{
|
||||
if (axisalignedbb.offset(blockpos).contains(vector3d1))
|
||||
{
|
||||
this.inGround = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.arrowShake > 0)
|
||||
{
|
||||
--this.arrowShake;
|
||||
}
|
||||
|
||||
if (this.isWet())
|
||||
{
|
||||
this.extinguish();
|
||||
}
|
||||
|
||||
// this.inBlockState.getBlock()
|
||||
|
||||
if (this.inGround && !flag)
|
||||
{
|
||||
if (this.inBlockState != blockstate && this.func_234593_u_())
|
||||
{
|
||||
this.func_234594_z_();
|
||||
} else if (!this.world.isRemote)
|
||||
{
|
||||
this.func_225516_i_();
|
||||
}
|
||||
|
||||
++this.timeInGround;
|
||||
} else
|
||||
{
|
||||
this.timeInGround = 0;
|
||||
Vector3d vector3d2 = this.getPositionVec();
|
||||
Vector3d vector3d3 = vector3d2.add(vector3d);
|
||||
RayTraceResult raytraceresult = this.world.rayTraceBlocks(new RayTraceContext(vector3d2, vector3d3, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, this));
|
||||
if (raytraceresult.getType() != RayTraceResult.Type.MISS)
|
||||
{
|
||||
vector3d3 = raytraceresult.getHitVec();
|
||||
}
|
||||
|
||||
while (!this.removed)
|
||||
{
|
||||
EntityRayTraceResult entityraytraceresult = this.rayTraceEntities(vector3d2, vector3d3);
|
||||
if (entityraytraceresult != null)
|
||||
{
|
||||
raytraceresult = entityraytraceresult;
|
||||
}
|
||||
|
||||
if (raytraceresult != null && raytraceresult.getType() == RayTraceResult.Type.ENTITY)
|
||||
{
|
||||
Entity entity = ((EntityRayTraceResult) raytraceresult).getEntity();
|
||||
Entity entity1 = this.func_234616_v_();
|
||||
if (entity instanceof PlayerEntity && entity1 instanceof PlayerEntity && !((PlayerEntity) entity1).canAttackPlayer((PlayerEntity) entity))
|
||||
{
|
||||
raytraceresult = null;
|
||||
entityraytraceresult = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (raytraceresult != null && raytraceresult.getType() != RayTraceResult.Type.MISS && !flag && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, raytraceresult))
|
||||
{
|
||||
this.onImpact(raytraceresult);
|
||||
this.isAirBorne = true;
|
||||
}
|
||||
|
||||
if (entityraytraceresult == null || this.getPierceLevel() <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
raytraceresult = null;
|
||||
}
|
||||
|
||||
vector3d = this.getMotion();
|
||||
double d3 = vector3d.x;
|
||||
double d4 = vector3d.y;
|
||||
double d0 = vector3d.z;
|
||||
if (this.getIsCritical())
|
||||
{
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
this.world.addParticle(ParticleTypes.CRIT, this.getPosX() + d3 * (double) i / 4.0D, this.getPosY() + d4 * (double) i / 4.0D, this.getPosZ() + d0 * (double) i / 4.0D, -d3, -d4 + 0.2D, -d0);
|
||||
}
|
||||
}
|
||||
|
||||
double d5 = this.getPosX() + d3;
|
||||
double d1 = this.getPosY() + d4;
|
||||
double d2 = this.getPosZ() + d0;
|
||||
float f1 = MathHelper.sqrt(horizontalMag(vector3d));
|
||||
if (flag)
|
||||
{
|
||||
this.rotationYaw = (float) (MathHelper.atan2(-d3, -d0) * (double) (180F / (float) Math.PI));
|
||||
} else
|
||||
{
|
||||
this.rotationYaw = (float) (MathHelper.atan2(d3, d0) * (double) (180F / (float) Math.PI));
|
||||
}
|
||||
|
||||
this.rotationPitch = (float) (MathHelper.atan2(d4, (double) f1) * (double) (180F / (float) Math.PI));
|
||||
this.rotationPitch = func_234614_e_(this.prevRotationPitch, this.rotationPitch);
|
||||
this.rotationYaw = func_234614_e_(this.prevRotationYaw, this.rotationYaw);
|
||||
float f2 = 0.99F;
|
||||
float f3 = 0.05F;
|
||||
if (this.isInWater())
|
||||
{
|
||||
for (int j = 0; j < 4; ++j)
|
||||
{
|
||||
float f4 = 0.25F;
|
||||
this.world.addParticle(ParticleTypes.BUBBLE, d5 - d3 * 0.25D, d1 - d4 * 0.25D, d2 - d0 * 0.25D, d3, d4, d0);
|
||||
}
|
||||
|
||||
f2 = this.getWaterDrag();
|
||||
}
|
||||
|
||||
this.setMotion(vector3d.scale((double) f2));
|
||||
if (!this.hasNoGravity() && !flag)
|
||||
{
|
||||
Vector3d vector3d4 = this.getMotion();
|
||||
this.setMotion(vector3d4.x, vector3d4.y - (double) 0.05F, vector3d4.z);
|
||||
}
|
||||
|
||||
this.setPosition(d5, d1, d2);
|
||||
this.doBlockCollisions();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void move(MoverType typeIn, Vector3d pos)
|
||||
{
|
||||
super.move(typeIn, pos);
|
||||
if (typeIn != MoverType.SELF && this.func_234593_u_())
|
||||
{
|
||||
this.func_234594_z_();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void writeAdditional(CompoundNBT compound)
|
||||
{
|
||||
super.writeAdditional(compound);
|
||||
compound.putShort("life", (short) this.ticksInGround);
|
||||
if (this.inBlockState != null)
|
||||
{
|
||||
compound.put("inBlockState", NBTUtil.writeBlockState(this.inBlockState));
|
||||
}
|
||||
|
||||
compound.putByte("shake", (byte) this.arrowShake);
|
||||
compound.putBoolean("inGround", this.inGround);
|
||||
compound.putByte("pickup", (byte) this.pickupStatus.ordinal());
|
||||
compound.putDouble("damage", this.damage);
|
||||
// compound.putBoolean("crit", this.getIsCritical());
|
||||
// compound.putByte("PierceLevel", this.getPierceLevel());
|
||||
compound.putString("SoundEvent", Registry.SOUND_EVENT.getKey(this.hitSound).toString());
|
||||
// compound.putBoolean("ShotFromCrossbow", this.getShotFromCrossbow());
|
||||
compound.putDouble("willDrop", willDrop);
|
||||
// this.containedStack.write(compound);
|
||||
compound.putString("willType", this.willType.name);
|
||||
}
|
||||
|
||||
/**
|
||||
* (abstract) Protected helper method to read subclass entity data from NBT.
|
||||
*/
|
||||
public void readAdditional(CompoundNBT compound)
|
||||
{
|
||||
super.readAdditional(compound);
|
||||
this.ticksInGround = compound.getShort("life");
|
||||
if (compound.contains("inBlockState", 10))
|
||||
{
|
||||
this.inBlockState = NBTUtil.readBlockState(compound.getCompound("inBlockState"));
|
||||
}
|
||||
|
||||
this.arrowShake = compound.getByte("shake") & 255;
|
||||
this.inGround = compound.getBoolean("inGround");
|
||||
if (compound.contains("damage", 99))
|
||||
{
|
||||
this.damage = compound.getDouble("damage");
|
||||
}
|
||||
|
||||
if (compound.contains("pickup", 99))
|
||||
{
|
||||
this.pickupStatus = AbstractArrowEntity.PickupStatus.getByOrdinal(compound.getByte("pickup"));
|
||||
} else if (compound.contains("player", 99))
|
||||
{
|
||||
this.pickupStatus = compound.getBoolean("player") ? AbstractArrowEntity.PickupStatus.ALLOWED
|
||||
: AbstractArrowEntity.PickupStatus.DISALLOWED;
|
||||
}
|
||||
this.willDrop = compound.getDouble("willDrop");
|
||||
// this.containedStack = ItemStack.read(compound);
|
||||
this.willType = EnumDemonWillType.getType(compound.getString("willType"));
|
||||
|
||||
// this.setIsCritical(compound.getBoolean("crit"));
|
||||
// this.setPierceLevel(compound.getByte("PierceLevel"));
|
||||
// if (compound.contains("SoundEvent", 8)) {
|
||||
// this.hitSound = Registry.SOUND_EVENT.getOptional(new ResourceLocation(compound.getString("SoundEvent"))).orElse(this.getHitEntitySound());
|
||||
// }
|
||||
//
|
||||
// this.setShotFromCrossbow(compound.getBoolean("ShotFromCrossbow"));
|
||||
}
|
||||
|
||||
public void setDamage(double damage)
|
||||
{
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return this.damage;
|
||||
}
|
||||
|
||||
protected void onEntityHit(EntityRayTraceResult p_213868_1_)
|
||||
{
|
||||
super.onEntityHit(p_213868_1_);
|
||||
Entity entity = p_213868_1_.getEntity();
|
||||
float f = (float) this.getMotion().length();
|
||||
int i = MathHelper.ceil(MathHelper.clamp(this.damage, 0.0D, 2.147483647E9D));
|
||||
if (this.getPierceLevel() > 0)
|
||||
{
|
||||
if (this.piercedEntities == null)
|
||||
{
|
||||
this.piercedEntities = new IntOpenHashSet(5);
|
||||
}
|
||||
|
||||
if (this.hitEntities == null)
|
||||
{
|
||||
this.hitEntities = Lists.newArrayListWithCapacity(5);
|
||||
}
|
||||
|
||||
if (this.piercedEntities.size() >= this.getPierceLevel() + 1)
|
||||
{
|
||||
this.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
this.piercedEntities.add(entity.getEntityId());
|
||||
}
|
||||
|
||||
if (this.getIsCritical())
|
||||
{
|
||||
long j = (long) this.rand.nextInt(i / 2 + 2);
|
||||
i = (int) Math.min(j + (long) i, 2147483647L);
|
||||
}
|
||||
|
||||
Entity entity1 = this.func_234616_v_();
|
||||
DamageSource damagesource;
|
||||
if (entity1 == null)
|
||||
{
|
||||
damagesource = DamageSource.causeThrownDamage(this, this);
|
||||
} else
|
||||
{
|
||||
damagesource = DamageSource.causeThrownDamage(this, entity1);
|
||||
if (entity1 instanceof LivingEntity)
|
||||
{
|
||||
((LivingEntity) entity1).setLastAttackedEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
boolean flag = entity.getType() == EntityType.ENDERMAN;
|
||||
int k = entity.getFireTimer();
|
||||
if (this.isBurning() && !flag)
|
||||
{
|
||||
entity.setFire(5);
|
||||
}
|
||||
|
||||
if (entity.attackEntityFrom(damagesource, (float) i))
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entity.isAlive() && entity1 instanceof PlayerEntity && entity instanceof LivingEntity)
|
||||
{
|
||||
PlayerDemonWillHandler.addDemonWill(willType, (PlayerEntity) entity1, this.getWillDropForMobHealth(((LivingEntity) entity).getMaxHealth()));
|
||||
}
|
||||
|
||||
if (entity instanceof LivingEntity)
|
||||
{
|
||||
LivingEntity livingentity = (LivingEntity) entity;
|
||||
// if (!this.world.isRemote && this.getPierceLevel() <= 0)
|
||||
// {
|
||||
// livingentity.setArrowCountInEntity(livingentity.getArrowCountInEntity() + 1);
|
||||
// }
|
||||
|
||||
if (this.knockbackStrength > 0)
|
||||
{
|
||||
Vector3d vector3d = this.getMotion().mul(1.0D, 0.0D, 1.0D).normalize().scale((double) this.knockbackStrength * 0.6D);
|
||||
if (vector3d.lengthSquared() > 0.0D)
|
||||
{
|
||||
livingentity.addVelocity(vector3d.x, 0.1D, vector3d.z);
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.world.isRemote && entity1 instanceof LivingEntity)
|
||||
{
|
||||
EnchantmentHelper.applyThornEnchantments(livingentity, entity1);
|
||||
EnchantmentHelper.applyArthropodEnchantments((LivingEntity) entity1, livingentity);
|
||||
}
|
||||
|
||||
this.daggerHit(livingentity);
|
||||
if (entity1 != null && livingentity != entity1 && livingentity instanceof PlayerEntity && entity1 instanceof ServerPlayerEntity && !this.isSilent())
|
||||
{
|
||||
((ServerPlayerEntity) entity1).connection.sendPacket(new SChangeGameStatePacket(SChangeGameStatePacket.field_241770_g_, 0.0F));
|
||||
}
|
||||
|
||||
if (!entity.isAlive() && this.hitEntities != null)
|
||||
{
|
||||
this.hitEntities.add(livingentity);
|
||||
}
|
||||
}
|
||||
|
||||
this.playSound(this.hitSound, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
|
||||
if (this.getPierceLevel() <= 0)
|
||||
{
|
||||
this.remove();
|
||||
}
|
||||
} else
|
||||
{
|
||||
entity.forceFireTicks(k);
|
||||
this.setMotion(this.getMotion().scale(-0.1D));
|
||||
this.rotationYaw += 180.0F;
|
||||
this.prevRotationYaw += 180.0F;
|
||||
if (!this.world.isRemote && this.getMotion().lengthSquared() < 1.0E-7D)
|
||||
{
|
||||
if (this.pickupStatus == AbstractArrowEntity.PickupStatus.ALLOWED)
|
||||
{
|
||||
this.entityDropItem(this.getArrowStack(), 0.1F);
|
||||
}
|
||||
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by a player entity when they collide with an entity
|
||||
*/
|
||||
@Override
|
||||
public void onCollideWithPlayer(PlayerEntity entityIn)
|
||||
{
|
||||
if (!this.world.isRemote && (this.inGround || this.getNoClip()) && this.arrowShake <= 0)
|
||||
{
|
||||
boolean flag = this.pickupStatus == AbstractArrowEntity.PickupStatus.ALLOWED || this.pickupStatus == AbstractArrowEntity.PickupStatus.CREATIVE_ONLY && entityIn.abilities.isCreativeMode || this.getNoClip() && this.func_234616_v_().getUniqueID() == entityIn.getUniqueID();
|
||||
if (this.pickupStatus == AbstractArrowEntity.PickupStatus.ALLOWED && !entityIn.inventory.addItemStackToInventory(this.getArrowStack()))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
// System.out.println("Um test?");
|
||||
|
||||
// entityIn.onItemPickup(this, 1);
|
||||
world.playSound(null, entityIn.getPosX(), entityIn.getPosY() + 0.5, entityIn.getPosZ(), SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
this.remove();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected ItemStack getArrowStack()
|
||||
{
|
||||
// Gets the item from the data manager
|
||||
return getItem();
|
||||
}
|
||||
|
||||
// OnHitBlock
|
||||
protected void func_230299_a_(BlockRayTraceResult p_230299_1_)
|
||||
{
|
||||
this.inBlockState = this.world.getBlockState(p_230299_1_.getPos());
|
||||
super.func_230299_a_(p_230299_1_);
|
||||
Vector3d vector3d = p_230299_1_.getHitVec().subtract(this.getPosX(), this.getPosY(), this.getPosZ());
|
||||
this.setMotion(vector3d);
|
||||
Vector3d vector3d1 = vector3d.normalize().scale((double) 0.05F);
|
||||
this.setRawPosition(this.getPosX() - vector3d1.x, this.getPosY() - vector3d1.y, this.getPosZ() - vector3d1.z);
|
||||
this.playSound(this.getHitGroundSound(), 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
|
||||
this.inGround = true;
|
||||
this.arrowShake = 7;
|
||||
// this.setIsCritical(false);
|
||||
// this.setPierceLevel((byte) 0);
|
||||
this.setHitSound(SoundEvents.ENTITY_ARROW_HIT);
|
||||
// this.setShotFromCrossbow(false);
|
||||
this.func_213870_w();
|
||||
}
|
||||
|
||||
private void func_234594_z_()
|
||||
{
|
||||
this.inGround = false;
|
||||
Vector3d vector3d = this.getMotion();
|
||||
this.setMotion(vector3d.mul((double) (this.rand.nextFloat() * 0.2F), (double) (this.rand.nextFloat() * 0.2F), (double) (this.rand.nextFloat() * 0.2F)));
|
||||
this.ticksInGround = 0;
|
||||
}
|
||||
|
||||
private boolean func_234593_u_()
|
||||
{
|
||||
return this.inGround && this.world.hasNoCollisions((new AxisAlignedBB(this.getPositionVec(), this.getPositionVec())).grow(0.06D));
|
||||
}
|
||||
|
||||
protected void func_225516_i_()
|
||||
{
|
||||
++this.ticksInGround;
|
||||
if (this.ticksInGround >= 1200)
|
||||
{
|
||||
this.remove();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void daggerHit(LivingEntity living)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* The sound made when an entity is hit by this projectile
|
||||
*/
|
||||
protected SoundEvent getHitEntitySound()
|
||||
{
|
||||
return SoundEvents.ENTITY_ARROW_HIT;
|
||||
}
|
||||
|
||||
protected final SoundEvent getHitGroundSound()
|
||||
{
|
||||
return this.hitSound;
|
||||
}
|
||||
|
||||
private void func_213870_w()
|
||||
{
|
||||
if (this.hitEntities != null)
|
||||
{
|
||||
this.hitEntities.clear();
|
||||
}
|
||||
|
||||
if (this.piercedEntities != null)
|
||||
{
|
||||
this.piercedEntities.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setHitSound(SoundEvent soundIn)
|
||||
{
|
||||
this.hitSound = soundIn;
|
||||
}
|
||||
|
||||
public boolean getNoClip()
|
||||
{
|
||||
if (!this.world.isRemote)
|
||||
{
|
||||
return this.noClip;
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
// return (this.dataManager.get(CRITICAL) & 2) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getIsCritical()
|
||||
{
|
||||
// byte b0 = this.dataManager.get(CRITICAL);
|
||||
// return (b0 & 1) != 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
public byte getPierceLevel()
|
||||
{
|
||||
return 0;
|
||||
// return this.dataManager.get(PIERCE_LEVEL);
|
||||
}
|
||||
|
||||
protected float getWaterDrag()
|
||||
{
|
||||
return 0.6F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the EntityRayTraceResult representing the entity hit
|
||||
*/
|
||||
@Nullable
|
||||
protected EntityRayTraceResult rayTraceEntities(Vector3d startVec, Vector3d endVec)
|
||||
{
|
||||
return ProjectileHelper.rayTraceEntities(this.world, this, startVec, endVec, this.getBoundingBox().expand(this.getMotion()).grow(1.0D), this::func_230298_a_);
|
||||
}
|
||||
|
||||
protected boolean func_230298_a_(Entity p_230298_1_)
|
||||
{
|
||||
return super.func_230298_a_(p_230298_1_) && (this.piercedEntities == null || !this.piercedEntities.contains(p_230298_1_.getEntityId()));
|
||||
}
|
||||
|
||||
// protected float getGravityVelocity()
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
public void setWillDrop(double willDrop)
|
||||
{
|
||||
this.willDrop = willDrop;
|
||||
}
|
||||
|
||||
public double getWillDropForMobHealth(double hp)
|
||||
{
|
||||
return this.willDrop * hp / 20D;
|
||||
}
|
||||
|
||||
public void setWillType(EnumDemonWillType type)
|
||||
{
|
||||
this.willType = type;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private IParticleData makeParticle()
|
||||
{
|
||||
ItemStack itemstack = this.func_213882_k();
|
||||
return (IParticleData) (itemstack.isEmpty() ? ParticleTypes.LAVA
|
||||
: new ItemParticleData(ParticleTypes.ITEM, itemstack));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for {@link World#setEntityState}
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void handleStatusUpdate(byte id)
|
||||
{
|
||||
if (id == 3)
|
||||
{
|
||||
IParticleData iparticledata = this.makeParticle();
|
||||
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
this.world.addParticle(iparticledata, this.getPosX(), this.getPosY(), this.getPosZ(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,688 +1,26 @@
|
|||
package wayoftime.bloodmagic.entity.projectile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.MoverType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.projectile.AbstractArrowEntity;
|
||||
import net.minecraft.entity.projectile.ProjectileHelper;
|
||||
import net.minecraft.entity.projectile.ProjectileItemEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.network.play.server.SChangeGameStatePacket;
|
||||
import net.minecraft.particles.IParticleData;
|
||||
import net.minecraft.particles.ItemParticleData;
|
||||
import net.minecraft.particles.ParticleTypes;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.EntityRayTraceResult;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceContext;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import wayoftime.bloodmagic.api.compat.EnumDemonWillType;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
import wayoftime.bloodmagic.common.registries.BloodMagicEntityTypes;
|
||||
import wayoftime.bloodmagic.will.PlayerDemonWillHandler;
|
||||
|
||||
public class EntityThrowingDagger extends ProjectileItemEntity
|
||||
public class EntityThrowingDagger extends AbstractEntityThrowingDagger
|
||||
{
|
||||
@Nullable
|
||||
private BlockState inBlockState;
|
||||
protected boolean inGround;
|
||||
protected int timeInGround;
|
||||
public AbstractArrowEntity.PickupStatus pickupStatus = AbstractArrowEntity.PickupStatus.ALLOWED;
|
||||
public int arrowShake;
|
||||
private int ticksInGround;
|
||||
private double damage = 2.0D;
|
||||
private int knockbackStrength;
|
||||
private SoundEvent hitSound = this.getHitEntitySound();
|
||||
private IntOpenHashSet piercedEntities;
|
||||
private List<Entity> hitEntities;
|
||||
|
||||
// private ItemStack containedStack = ItemStack.EMPTY;
|
||||
private double willDrop = 0;
|
||||
private EnumDemonWillType willType = EnumDemonWillType.DEFAULT;
|
||||
|
||||
public EntityThrowingDagger(EntityType<EntityThrowingDagger> p_i50159_1_, World p_i50159_2_)
|
||||
public EntityThrowingDagger(EntityType<EntityThrowingDagger> type, World world)
|
||||
{
|
||||
super(p_i50159_1_, p_i50159_2_);
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
public EntityThrowingDagger(ItemStack stack, World worldIn, LivingEntity throwerIn)
|
||||
{
|
||||
super(BloodMagicEntityTypes.THROWING_DAGGER.getEntityType(), throwerIn, worldIn);
|
||||
this.setItem(stack);
|
||||
if (throwerIn instanceof PlayerEntity)
|
||||
{
|
||||
this.pickupStatus = AbstractArrowEntity.PickupStatus.ALLOWED;
|
||||
}
|
||||
super(BloodMagicEntityTypes.THROWING_DAGGER.get(), stack, worldIn, throwerIn);
|
||||
|
||||
}
|
||||
|
||||
public EntityThrowingDagger(ItemStack stack, World worldIn, double x, double y, double z)
|
||||
{
|
||||
super(BloodMagicEntityTypes.THROWING_DAGGER.getEntityType(), x, y, z, worldIn);
|
||||
this.setItem(stack);
|
||||
super(BloodMagicEntityTypes.THROWING_DAGGER.get(), stack, worldIn, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(ItemStack stack)
|
||||
{
|
||||
super.setItem(stack);
|
||||
// this.containedStack = stack;
|
||||
}
|
||||
|
||||
protected Item getDefaultItem()
|
||||
{
|
||||
return BloodMagicItems.THROWING_DAGGER.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket<?> createSpawnPacket()
|
||||
{
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
// super.tick();
|
||||
// RayTraceResult raytraceresult = ProjectileHelper.func_234618_a_(this, this::func_230298_a_);
|
||||
//// boolean flag = false;
|
||||
// if (raytraceresult.getType() == RayTraceResult.Type.BLOCK)
|
||||
// {
|
||||
// BlockPos blockpos = ((BlockRayTraceResult) raytraceresult).getPos().offset(((BlockRayTraceResult) raytraceresult).getFace());
|
||||
// BlockState blockstate = this.world.getBlockState(blockpos);
|
||||
// Material material = blockstate.getMaterial();
|
||||
// if (blockstate.isAir() || blockstate.isIn(BlockTags.FIRE) || material.isLiquid() || material.isReplaceable())
|
||||
// {
|
||||
// this.getEntityWorld().setBlockState(blockpos, BloodMagicBlocks.BLOOD_LIGHT.get().getDefaultState());
|
||||
// this.setDead();
|
||||
// }
|
||||
// }
|
||||
|
||||
// super.tick();
|
||||
this.baseTick();
|
||||
boolean flag = this.getNoClip();
|
||||
flag = false;
|
||||
Vector3d vector3d = this.getMotion();
|
||||
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
|
||||
{
|
||||
float f = MathHelper.sqrt(horizontalMag(vector3d));
|
||||
this.rotationYaw = (float) (MathHelper.atan2(vector3d.x, vector3d.z) * (double) (180F / (float) Math.PI));
|
||||
this.rotationPitch = (float) (MathHelper.atan2(vector3d.y, (double) f) * (double) (180F / (float) Math.PI));
|
||||
this.prevRotationYaw = this.rotationYaw;
|
||||
this.prevRotationPitch = this.rotationPitch;
|
||||
}
|
||||
|
||||
BlockPos blockpos = this.getPosition();
|
||||
BlockState blockstate = this.world.getBlockState(blockpos);
|
||||
if (!blockstate.isAir(this.world, blockpos) && !flag)
|
||||
{
|
||||
VoxelShape voxelshape = blockstate.getCollisionShape(this.world, blockpos);
|
||||
if (!voxelshape.isEmpty())
|
||||
{
|
||||
Vector3d vector3d1 = this.getPositionVec();
|
||||
|
||||
for (AxisAlignedBB axisalignedbb : voxelshape.toBoundingBoxList())
|
||||
{
|
||||
if (axisalignedbb.offset(blockpos).contains(vector3d1))
|
||||
{
|
||||
this.inGround = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.arrowShake > 0)
|
||||
{
|
||||
--this.arrowShake;
|
||||
}
|
||||
|
||||
if (this.isWet())
|
||||
{
|
||||
this.extinguish();
|
||||
}
|
||||
|
||||
// this.inBlockState.getBlock()
|
||||
|
||||
if (this.inGround && !flag)
|
||||
{
|
||||
if (this.inBlockState != blockstate && this.func_234593_u_())
|
||||
{
|
||||
this.func_234594_z_();
|
||||
} else if (!this.world.isRemote)
|
||||
{
|
||||
this.func_225516_i_();
|
||||
}
|
||||
|
||||
++this.timeInGround;
|
||||
} else
|
||||
{
|
||||
this.timeInGround = 0;
|
||||
Vector3d vector3d2 = this.getPositionVec();
|
||||
Vector3d vector3d3 = vector3d2.add(vector3d);
|
||||
RayTraceResult raytraceresult = this.world.rayTraceBlocks(new RayTraceContext(vector3d2, vector3d3, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, this));
|
||||
if (raytraceresult.getType() != RayTraceResult.Type.MISS)
|
||||
{
|
||||
vector3d3 = raytraceresult.getHitVec();
|
||||
}
|
||||
|
||||
while (!this.removed)
|
||||
{
|
||||
EntityRayTraceResult entityraytraceresult = this.rayTraceEntities(vector3d2, vector3d3);
|
||||
if (entityraytraceresult != null)
|
||||
{
|
||||
raytraceresult = entityraytraceresult;
|
||||
}
|
||||
|
||||
if (raytraceresult != null && raytraceresult.getType() == RayTraceResult.Type.ENTITY)
|
||||
{
|
||||
Entity entity = ((EntityRayTraceResult) raytraceresult).getEntity();
|
||||
Entity entity1 = this.func_234616_v_();
|
||||
if (entity instanceof PlayerEntity && entity1 instanceof PlayerEntity && !((PlayerEntity) entity1).canAttackPlayer((PlayerEntity) entity))
|
||||
{
|
||||
raytraceresult = null;
|
||||
entityraytraceresult = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (raytraceresult != null && raytraceresult.getType() != RayTraceResult.Type.MISS && !flag && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, raytraceresult))
|
||||
{
|
||||
this.onImpact(raytraceresult);
|
||||
this.isAirBorne = true;
|
||||
}
|
||||
|
||||
if (entityraytraceresult == null || this.getPierceLevel() <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
raytraceresult = null;
|
||||
}
|
||||
|
||||
vector3d = this.getMotion();
|
||||
double d3 = vector3d.x;
|
||||
double d4 = vector3d.y;
|
||||
double d0 = vector3d.z;
|
||||
if (this.getIsCritical())
|
||||
{
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
this.world.addParticle(ParticleTypes.CRIT, this.getPosX() + d3 * (double) i / 4.0D, this.getPosY() + d4 * (double) i / 4.0D, this.getPosZ() + d0 * (double) i / 4.0D, -d3, -d4 + 0.2D, -d0);
|
||||
}
|
||||
}
|
||||
|
||||
double d5 = this.getPosX() + d3;
|
||||
double d1 = this.getPosY() + d4;
|
||||
double d2 = this.getPosZ() + d0;
|
||||
float f1 = MathHelper.sqrt(horizontalMag(vector3d));
|
||||
if (flag)
|
||||
{
|
||||
this.rotationYaw = (float) (MathHelper.atan2(-d3, -d0) * (double) (180F / (float) Math.PI));
|
||||
} else
|
||||
{
|
||||
this.rotationYaw = (float) (MathHelper.atan2(d3, d0) * (double) (180F / (float) Math.PI));
|
||||
}
|
||||
|
||||
this.rotationPitch = (float) (MathHelper.atan2(d4, (double) f1) * (double) (180F / (float) Math.PI));
|
||||
this.rotationPitch = func_234614_e_(this.prevRotationPitch, this.rotationPitch);
|
||||
this.rotationYaw = func_234614_e_(this.prevRotationYaw, this.rotationYaw);
|
||||
float f2 = 0.99F;
|
||||
float f3 = 0.05F;
|
||||
if (this.isInWater())
|
||||
{
|
||||
for (int j = 0; j < 4; ++j)
|
||||
{
|
||||
float f4 = 0.25F;
|
||||
this.world.addParticle(ParticleTypes.BUBBLE, d5 - d3 * 0.25D, d1 - d4 * 0.25D, d2 - d0 * 0.25D, d3, d4, d0);
|
||||
}
|
||||
|
||||
f2 = this.getWaterDrag();
|
||||
}
|
||||
|
||||
this.setMotion(vector3d.scale((double) f2));
|
||||
if (!this.hasNoGravity() && !flag)
|
||||
{
|
||||
Vector3d vector3d4 = this.getMotion();
|
||||
this.setMotion(vector3d4.x, vector3d4.y - (double) 0.05F, vector3d4.z);
|
||||
}
|
||||
|
||||
this.setPosition(d5, d1, d2);
|
||||
this.doBlockCollisions();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void move(MoverType typeIn, Vector3d pos)
|
||||
{
|
||||
super.move(typeIn, pos);
|
||||
if (typeIn != MoverType.SELF && this.func_234593_u_())
|
||||
{
|
||||
this.func_234594_z_();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void writeAdditional(CompoundNBT compound)
|
||||
{
|
||||
super.writeAdditional(compound);
|
||||
compound.putShort("life", (short) this.ticksInGround);
|
||||
if (this.inBlockState != null)
|
||||
{
|
||||
compound.put("inBlockState", NBTUtil.writeBlockState(this.inBlockState));
|
||||
}
|
||||
|
||||
compound.putByte("shake", (byte) this.arrowShake);
|
||||
compound.putBoolean("inGround", this.inGround);
|
||||
compound.putByte("pickup", (byte) this.pickupStatus.ordinal());
|
||||
compound.putDouble("damage", this.damage);
|
||||
// compound.putBoolean("crit", this.getIsCritical());
|
||||
// compound.putByte("PierceLevel", this.getPierceLevel());
|
||||
compound.putString("SoundEvent", Registry.SOUND_EVENT.getKey(this.hitSound).toString());
|
||||
// compound.putBoolean("ShotFromCrossbow", this.getShotFromCrossbow());
|
||||
compound.putDouble("willDrop", willDrop);
|
||||
// this.containedStack.write(compound);
|
||||
compound.putString("willType", this.willType.name);
|
||||
}
|
||||
|
||||
/**
|
||||
* (abstract) Protected helper method to read subclass entity data from NBT.
|
||||
*/
|
||||
public void readAdditional(CompoundNBT compound)
|
||||
{
|
||||
super.readAdditional(compound);
|
||||
this.ticksInGround = compound.getShort("life");
|
||||
if (compound.contains("inBlockState", 10))
|
||||
{
|
||||
this.inBlockState = NBTUtil.readBlockState(compound.getCompound("inBlockState"));
|
||||
}
|
||||
|
||||
this.arrowShake = compound.getByte("shake") & 255;
|
||||
this.inGround = compound.getBoolean("inGround");
|
||||
if (compound.contains("damage", 99))
|
||||
{
|
||||
this.damage = compound.getDouble("damage");
|
||||
}
|
||||
|
||||
if (compound.contains("pickup", 99))
|
||||
{
|
||||
this.pickupStatus = AbstractArrowEntity.PickupStatus.getByOrdinal(compound.getByte("pickup"));
|
||||
} else if (compound.contains("player", 99))
|
||||
{
|
||||
this.pickupStatus = compound.getBoolean("player") ? AbstractArrowEntity.PickupStatus.ALLOWED
|
||||
: AbstractArrowEntity.PickupStatus.DISALLOWED;
|
||||
}
|
||||
this.willDrop = compound.getDouble("willDrop");
|
||||
// this.containedStack = ItemStack.read(compound);
|
||||
this.willType = EnumDemonWillType.getType(compound.getString("willType"));
|
||||
|
||||
// this.setIsCritical(compound.getBoolean("crit"));
|
||||
// this.setPierceLevel(compound.getByte("PierceLevel"));
|
||||
// if (compound.contains("SoundEvent", 8)) {
|
||||
// this.hitSound = Registry.SOUND_EVENT.getOptional(new ResourceLocation(compound.getString("SoundEvent"))).orElse(this.getHitEntitySound());
|
||||
// }
|
||||
//
|
||||
// this.setShotFromCrossbow(compound.getBoolean("ShotFromCrossbow"));
|
||||
}
|
||||
|
||||
public void setDamage(double damage)
|
||||
{
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return this.damage;
|
||||
}
|
||||
|
||||
protected void onEntityHit(EntityRayTraceResult p_213868_1_)
|
||||
{
|
||||
super.onEntityHit(p_213868_1_);
|
||||
Entity entity = p_213868_1_.getEntity();
|
||||
float f = (float) this.getMotion().length();
|
||||
int i = MathHelper.ceil(MathHelper.clamp(this.damage, 0.0D, 2.147483647E9D));
|
||||
if (this.getPierceLevel() > 0)
|
||||
{
|
||||
if (this.piercedEntities == null)
|
||||
{
|
||||
this.piercedEntities = new IntOpenHashSet(5);
|
||||
}
|
||||
|
||||
if (this.hitEntities == null)
|
||||
{
|
||||
this.hitEntities = Lists.newArrayListWithCapacity(5);
|
||||
}
|
||||
|
||||
if (this.piercedEntities.size() >= this.getPierceLevel() + 1)
|
||||
{
|
||||
this.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
this.piercedEntities.add(entity.getEntityId());
|
||||
}
|
||||
|
||||
if (this.getIsCritical())
|
||||
{
|
||||
long j = (long) this.rand.nextInt(i / 2 + 2);
|
||||
i = (int) Math.min(j + (long) i, 2147483647L);
|
||||
}
|
||||
|
||||
Entity entity1 = this.func_234616_v_();
|
||||
DamageSource damagesource;
|
||||
if (entity1 == null)
|
||||
{
|
||||
damagesource = DamageSource.causeThrownDamage(this, this);
|
||||
} else
|
||||
{
|
||||
damagesource = DamageSource.causeThrownDamage(this, entity1);
|
||||
if (entity1 instanceof LivingEntity)
|
||||
{
|
||||
((LivingEntity) entity1).setLastAttackedEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
boolean flag = entity.getType() == EntityType.ENDERMAN;
|
||||
int k = entity.getFireTimer();
|
||||
if (this.isBurning() && !flag)
|
||||
{
|
||||
entity.setFire(5);
|
||||
}
|
||||
|
||||
if (entity.attackEntityFrom(damagesource, (float) i))
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entity.isAlive() && entity1 instanceof PlayerEntity && entity instanceof LivingEntity)
|
||||
{
|
||||
PlayerDemonWillHandler.addDemonWill(willType, (PlayerEntity) entity1, this.getWillDropForMobHealth(((LivingEntity) entity).getMaxHealth()));
|
||||
}
|
||||
|
||||
if (entity instanceof LivingEntity)
|
||||
{
|
||||
LivingEntity livingentity = (LivingEntity) entity;
|
||||
// if (!this.world.isRemote && this.getPierceLevel() <= 0)
|
||||
// {
|
||||
// livingentity.setArrowCountInEntity(livingentity.getArrowCountInEntity() + 1);
|
||||
// }
|
||||
|
||||
if (this.knockbackStrength > 0)
|
||||
{
|
||||
Vector3d vector3d = this.getMotion().mul(1.0D, 0.0D, 1.0D).normalize().scale((double) this.knockbackStrength * 0.6D);
|
||||
if (vector3d.lengthSquared() > 0.0D)
|
||||
{
|
||||
livingentity.addVelocity(vector3d.x, 0.1D, vector3d.z);
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.world.isRemote && entity1 instanceof LivingEntity)
|
||||
{
|
||||
EnchantmentHelper.applyThornEnchantments(livingentity, entity1);
|
||||
EnchantmentHelper.applyArthropodEnchantments((LivingEntity) entity1, livingentity);
|
||||
}
|
||||
|
||||
this.daggerHit(livingentity);
|
||||
if (entity1 != null && livingentity != entity1 && livingentity instanceof PlayerEntity && entity1 instanceof ServerPlayerEntity && !this.isSilent())
|
||||
{
|
||||
((ServerPlayerEntity) entity1).connection.sendPacket(new SChangeGameStatePacket(SChangeGameStatePacket.field_241770_g_, 0.0F));
|
||||
}
|
||||
|
||||
if (!entity.isAlive() && this.hitEntities != null)
|
||||
{
|
||||
this.hitEntities.add(livingentity);
|
||||
}
|
||||
}
|
||||
|
||||
this.playSound(this.hitSound, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
|
||||
if (this.getPierceLevel() <= 0)
|
||||
{
|
||||
this.remove();
|
||||
}
|
||||
} else
|
||||
{
|
||||
entity.forceFireTicks(k);
|
||||
this.setMotion(this.getMotion().scale(-0.1D));
|
||||
this.rotationYaw += 180.0F;
|
||||
this.prevRotationYaw += 180.0F;
|
||||
if (!this.world.isRemote && this.getMotion().lengthSquared() < 1.0E-7D)
|
||||
{
|
||||
if (this.pickupStatus == AbstractArrowEntity.PickupStatus.ALLOWED)
|
||||
{
|
||||
this.entityDropItem(this.getArrowStack(), 0.1F);
|
||||
}
|
||||
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by a player entity when they collide with an entity
|
||||
*/
|
||||
@Override
|
||||
public void onCollideWithPlayer(PlayerEntity entityIn)
|
||||
{
|
||||
if (!this.world.isRemote && (this.inGround || this.getNoClip()) && this.arrowShake <= 0)
|
||||
{
|
||||
boolean flag = this.pickupStatus == AbstractArrowEntity.PickupStatus.ALLOWED || this.pickupStatus == AbstractArrowEntity.PickupStatus.CREATIVE_ONLY && entityIn.abilities.isCreativeMode || this.getNoClip() && this.func_234616_v_().getUniqueID() == entityIn.getUniqueID();
|
||||
if (this.pickupStatus == AbstractArrowEntity.PickupStatus.ALLOWED && !entityIn.inventory.addItemStackToInventory(this.getArrowStack()))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
// System.out.println("Um test?");
|
||||
|
||||
// entityIn.onItemPickup(this, 1);
|
||||
world.playSound(null, entityIn.getPosX(), entityIn.getPosY() + 0.5, entityIn.getPosZ(), SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
this.remove();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected ItemStack getArrowStack()
|
||||
{
|
||||
// Gets the item from the data manager
|
||||
return getItem();
|
||||
}
|
||||
|
||||
// OnHitBlock
|
||||
protected void func_230299_a_(BlockRayTraceResult p_230299_1_)
|
||||
{
|
||||
this.inBlockState = this.world.getBlockState(p_230299_1_.getPos());
|
||||
super.func_230299_a_(p_230299_1_);
|
||||
Vector3d vector3d = p_230299_1_.getHitVec().subtract(this.getPosX(), this.getPosY(), this.getPosZ());
|
||||
this.setMotion(vector3d);
|
||||
Vector3d vector3d1 = vector3d.normalize().scale((double) 0.05F);
|
||||
this.setRawPosition(this.getPosX() - vector3d1.x, this.getPosY() - vector3d1.y, this.getPosZ() - vector3d1.z);
|
||||
this.playSound(this.getHitGroundSound(), 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
|
||||
this.inGround = true;
|
||||
this.arrowShake = 7;
|
||||
// this.setIsCritical(false);
|
||||
// this.setPierceLevel((byte) 0);
|
||||
this.setHitSound(SoundEvents.ENTITY_ARROW_HIT);
|
||||
// this.setShotFromCrossbow(false);
|
||||
this.func_213870_w();
|
||||
}
|
||||
|
||||
private void func_234594_z_()
|
||||
{
|
||||
this.inGround = false;
|
||||
Vector3d vector3d = this.getMotion();
|
||||
this.setMotion(vector3d.mul((double) (this.rand.nextFloat() * 0.2F), (double) (this.rand.nextFloat() * 0.2F), (double) (this.rand.nextFloat() * 0.2F)));
|
||||
this.ticksInGround = 0;
|
||||
}
|
||||
|
||||
private boolean func_234593_u_()
|
||||
{
|
||||
return this.inGround && this.world.hasNoCollisions((new AxisAlignedBB(this.getPositionVec(), this.getPositionVec())).grow(0.06D));
|
||||
}
|
||||
|
||||
protected void func_225516_i_()
|
||||
{
|
||||
++this.ticksInGround;
|
||||
if (this.ticksInGround >= 1200)
|
||||
{
|
||||
this.remove();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void daggerHit(LivingEntity living)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* The sound made when an entity is hit by this projectile
|
||||
*/
|
||||
protected SoundEvent getHitEntitySound()
|
||||
{
|
||||
return SoundEvents.ENTITY_ARROW_HIT;
|
||||
}
|
||||
|
||||
protected final SoundEvent getHitGroundSound()
|
||||
{
|
||||
return this.hitSound;
|
||||
}
|
||||
|
||||
private void func_213870_w()
|
||||
{
|
||||
if (this.hitEntities != null)
|
||||
{
|
||||
this.hitEntities.clear();
|
||||
}
|
||||
|
||||
if (this.piercedEntities != null)
|
||||
{
|
||||
this.piercedEntities.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setHitSound(SoundEvent soundIn)
|
||||
{
|
||||
this.hitSound = soundIn;
|
||||
}
|
||||
|
||||
public boolean getNoClip()
|
||||
{
|
||||
if (!this.world.isRemote)
|
||||
{
|
||||
return this.noClip;
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
// return (this.dataManager.get(CRITICAL) & 2) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getIsCritical()
|
||||
{
|
||||
// byte b0 = this.dataManager.get(CRITICAL);
|
||||
// return (b0 & 1) != 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
public byte getPierceLevel()
|
||||
{
|
||||
return 0;
|
||||
// return this.dataManager.get(PIERCE_LEVEL);
|
||||
}
|
||||
|
||||
protected float getWaterDrag()
|
||||
{
|
||||
return 0.6F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the EntityRayTraceResult representing the entity hit
|
||||
*/
|
||||
@Nullable
|
||||
protected EntityRayTraceResult rayTraceEntities(Vector3d startVec, Vector3d endVec)
|
||||
{
|
||||
return ProjectileHelper.rayTraceEntities(this.world, this, startVec, endVec, this.getBoundingBox().expand(this.getMotion()).grow(1.0D), this::func_230298_a_);
|
||||
}
|
||||
|
||||
protected boolean func_230298_a_(Entity p_230298_1_)
|
||||
{
|
||||
return super.func_230298_a_(p_230298_1_) && (this.piercedEntities == null || !this.piercedEntities.contains(p_230298_1_.getEntityId()));
|
||||
}
|
||||
|
||||
// protected float getGravityVelocity()
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
public void setWillDrop(double willDrop)
|
||||
{
|
||||
this.willDrop = willDrop;
|
||||
}
|
||||
|
||||
public double getWillDropForMobHealth(double hp)
|
||||
{
|
||||
return this.willDrop * hp / 20D;
|
||||
}
|
||||
|
||||
public void setWillType(EnumDemonWillType type)
|
||||
{
|
||||
this.willType = type;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private IParticleData makeParticle()
|
||||
{
|
||||
ItemStack itemstack = this.func_213882_k();
|
||||
return (IParticleData) (itemstack.isEmpty() ? ParticleTypes.LAVA
|
||||
: new ItemParticleData(ParticleTypes.ITEM, itemstack));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for {@link World#setEntityState}
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void handleStatusUpdate(byte id)
|
||||
{
|
||||
if (id == 3)
|
||||
{
|
||||
IParticleData iparticledata = this.makeParticle();
|
||||
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
this.world.addParticle(iparticledata, this.getPosX(), this.getPosY(), this.getPosZ(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
package wayoftime.bloodmagic.entity.projectile;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.EntityRayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
import wayoftime.bloodmagic.common.registries.BloodMagicEntityTypes;
|
||||
|
||||
public class EntityThrowingDaggerSyringe extends AbstractEntityThrowingDagger
|
||||
{
|
||||
public EntityThrowingDaggerSyringe(EntityType<EntityThrowingDaggerSyringe> type, World world)
|
||||
{
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
public EntityThrowingDaggerSyringe(ItemStack stack, World worldIn, LivingEntity throwerIn)
|
||||
{
|
||||
super(BloodMagicEntityTypes.THROWING_DAGGER.get(), stack, worldIn, throwerIn);
|
||||
|
||||
}
|
||||
|
||||
public EntityThrowingDaggerSyringe(ItemStack stack, World worldIn, double x, double y, double z)
|
||||
{
|
||||
super(BloodMagicEntityTypes.THROWING_DAGGER.get(), stack, worldIn, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEntityHit(EntityRayTraceResult p_213868_1_)
|
||||
{
|
||||
super.onEntityHit(p_213868_1_);
|
||||
Entity entity = p_213868_1_.getEntity();
|
||||
|
||||
if (entity instanceof LivingEntity)
|
||||
{
|
||||
double maxHealth = ((LivingEntity) entity).getMaxHealth();
|
||||
if (!entity.isAlive())
|
||||
{
|
||||
int count = (int) (maxHealth / 20D) + (world.rand.nextDouble() < ((maxHealth % 20D) / 20D) ? 1 : 0);
|
||||
if (count > 0)
|
||||
InventoryHelper.spawnItemStack(world, this.getPosX(), this.getPosY(), this.getPosZ(), new ItemStack(BloodMagicItems.SLATE_AMPOULE.get(), count));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 744 B |
Binary file not shown.
Before Width: | Height: | Size: 793 B After Width: | Height: | Size: 768 B |
Binary file not shown.
After Width: | Height: | Size: 796 B |
Binary file not shown.
After Width: | Height: | Size: 795 B |
Loading…
Reference in a new issue