优化蝴蝶雷发射器
This commit is contained in:
parent
a0259dd5e3
commit
dd1c72bd6e
3 changed files with 33 additions and 8 deletions
|
@ -26,6 +26,7 @@ import net.minecraft.world.item.ItemStack;
|
|||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.entity.EntityTypeTest;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.neoforge.event.EventHooks;
|
||||
import net.neoforged.neoforge.items.ItemHandlerHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -220,7 +221,7 @@ public class Blu43Entity extends Entity implements GeoEntity, OwnableEntity {
|
|||
|
||||
private void triggerExplode() {
|
||||
CustomExplosion explosion = new CustomExplosion(this.level(), this,
|
||||
ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), this, this.getOwner()), 15f,
|
||||
ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), this, this.getOwner()), 10f,
|
||||
this.getX(), this.getEyeY(), this.getZ(), 2f, Explosion.BlockInteraction.KEEP, true);
|
||||
explosion.explode();
|
||||
EventHooks.onExplosionStart(this.level(), explosion);
|
||||
|
@ -242,4 +243,9 @@ public class Blu43Entity extends Entity implements GeoEntity, OwnableEntity {
|
|||
public AnimatableInstanceCache getAnimatableInstanceCache() {
|
||||
return this.cache;
|
||||
}
|
||||
|
||||
public void shoot(double pX, double pY, double pZ, float pVelocity, float pInaccuracy) {
|
||||
Vec3 vec3 = (new Vec3(pX, pY, pZ)).normalize().add(this.random.triangle(0.0, 0.0172275 * (double) pInaccuracy), this.random.triangle(0.0, 0.0172275 * (double) pInaccuracy), this.random.triangle(0.0, 0.0172275 * (double) pInaccuracy)).scale((double) pVelocity);
|
||||
this.setDeltaMovement(vec3);
|
||||
}
|
||||
}
|
|
@ -14,7 +14,6 @@ import net.minecraft.world.item.Item;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.DispenserBlock;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Math;
|
||||
|
||||
|
@ -62,15 +61,11 @@ public class Blu43Mine extends Item {
|
|||
float randomRot = (float) Mth.clamp((2 * Math.random() - 1) * 180, -180, 180);
|
||||
|
||||
var pX = direction.getStepX();
|
||||
var pY = direction.getStepY() + 0.1F;
|
||||
var pY = direction.getStepY();
|
||||
var pZ = direction.getStepZ();
|
||||
Vec3 vec3 = (new Vec3(pX, pY, pZ)).normalize().scale(0.05);
|
||||
blu43.setDeltaMovement(vec3);
|
||||
double d0 = vec3.horizontalDistance();
|
||||
blu43.shoot(pX, pY, pZ, 0.4f, 10);
|
||||
blu43.setYRot(randomRot);
|
||||
blu43.setXRot((float) (Mth.atan2(vec3.y, d0) * (double) (180F / (float) Math.PI)));
|
||||
blu43.yRotO = blu43.getYRot();
|
||||
blu43.xRotO = blu43.getXRot();
|
||||
|
||||
level.addFreshEntity(blu43);
|
||||
stack.shrink(1);
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"category": "misc",
|
||||
"pattern": [
|
||||
"a",
|
||||
"b",
|
||||
"c"
|
||||
],
|
||||
"key": {
|
||||
"a": {
|
||||
"item": "minecraft:stone_pressure_plate"
|
||||
},
|
||||
"b": {
|
||||
"item": "superbwarfare:high_energy_explosives"
|
||||
},
|
||||
"c": {
|
||||
"item": "minecraft:green_concrete"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"id": "superbwarfare:blu_43_mine",
|
||||
"count": 8
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue