new algorithm for carpet bomb arrow & particles for carpet bomb arrow
This commit is contained in:
parent
6be0064866
commit
f7bf084070
@ -38,7 +38,7 @@ mod_name=Enhanced Explosives
|
||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=All Rights Reserved
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=0.8.8
|
||||
mod_version=0.8.9
|
||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||
# This should match the base package used for the mod sources.
|
||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
|
@ -1,8 +1,9 @@
|
||||
package com.jenny.enhancedexplosives.entities.arrows;
|
||||
|
||||
import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import com.jenny.enhancedexplosives.items.items;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import com.jenny.enhancedexplosives.particles.particles;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
@ -12,8 +13,6 @@ import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class carpetArrow extends baseArrow {
|
||||
private int tick = 0;
|
||||
private Vec3 pos = position();
|
||||
public final int childCount = 32;
|
||||
|
||||
public carpetArrow(EntityType<carpetArrow> pEntityType, Level pLevel) {
|
||||
@ -26,26 +25,24 @@ public class carpetArrow extends baseArrow {
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
pos = position();
|
||||
super.tick();
|
||||
if (level().isClientSide()) {
|
||||
level().addParticle(ParticleTypes.SMOKE, this.getX(), this.getY(), this.getZ(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
tick++;
|
||||
if (pos.y > position().y) {
|
||||
if (getDeltaMovement().y < 0) {
|
||||
spawnChildren(childCount);
|
||||
discard();
|
||||
}
|
||||
}
|
||||
|
||||
protected void spawnChildren(int count) {
|
||||
Vec3 delta = getDeltaMovement();
|
||||
RandomSource rng = level().getRandom();
|
||||
for (int i = 0; i < count; i++) {
|
||||
concussiveArrow arrow = new concussiveArrow(entities.ARROW_CONCUSSIVE.get(), level());
|
||||
Vec3 move = delta.add((float) rng.nextInt(-10, 11) / 10, 0, (float) rng.nextInt(-10, 11) / 10);
|
||||
carpetArrowPart arrow = new carpetArrowPart(entities.ARROW_CARPT_PART.get(), level());
|
||||
double r = (double) rng.nextIntBetweenInclusive(-100, 100) / 200;
|
||||
Vec3 move = new Vec3(
|
||||
(double) rng.nextIntBetweenInclusive(-100, 100) / 100,
|
||||
0,
|
||||
(double) rng.nextIntBetweenInclusive(-100, 100) / 100).normalize().multiply(r, 0, r);
|
||||
arrow.setPos(position());
|
||||
arrow.setDeltaMovement(delta.add(move.multiply(0.2, 0, 0.2)));
|
||||
arrow.setDeltaMovement(move.add(getDeltaMovement()));
|
||||
level().addFreshEntity(arrow);
|
||||
}
|
||||
}
|
||||
@ -54,4 +51,18 @@ public class carpetArrow extends baseArrow {
|
||||
protected ItemStack getPickupItem() {
|
||||
return new ItemStack(items.CARPET_ARROW.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticles(float partialTicks) {
|
||||
for (int i = 1; i <= ConfigClient.calcPCount(3); i++) {
|
||||
double m = (double) level().getRandom().nextIntBetweenInclusive(-100, 100) / 100;
|
||||
Vec3 DeltaMovement = getDeltaMovement();
|
||||
Vec3 pos = new Vec3(
|
||||
(double) level().getRandom().nextIntBetweenInclusive(-5, 5) / 10,
|
||||
0,
|
||||
(double) level().getRandom().nextIntBetweenInclusive(-5, 5) / 10
|
||||
).normalize().multiply(m, 0, m).add(getPosition(partialTicks));
|
||||
level().addParticle(particles.CARPET_ARROW_PARTICLE.get(), pos.x, pos.y, pos.z, DeltaMovement.x, DeltaMovement.y, DeltaMovement.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,56 @@
|
||||
package com.jenny.enhancedexplosives.entities.arrows;
|
||||
|
||||
import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import com.jenny.enhancedexplosives.items.items;
|
||||
import com.jenny.enhancedexplosives.particles.particles;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class carpetArrowPart extends baseArrow {
|
||||
public carpetArrowPart(EntityType<carpetArrowPart> pEntityType, Level pLevel) {
|
||||
super(pEntityType, pLevel);
|
||||
}
|
||||
|
||||
public carpetArrowPart(Level pLevel, LivingEntity pShooter) {
|
||||
super(pLevel, pShooter, entities.ARROW_CARPT_PART.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (this.inGround) {
|
||||
this.level().explode(this, getX(), getY(), getZ(), 8.0f, Level.ExplosionInteraction.NONE);
|
||||
this.discard();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPostHurtEffects(@NotNull LivingEntity pTarget) {
|
||||
this.level().explode(this, getX(), getY(), getZ(), 8.0f, Level.ExplosionInteraction.NONE);
|
||||
this.discard();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected ItemStack getPickupItem() {
|
||||
return new ItemStack(items.CONCUSSIVE_ARROW.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticles(float partialTicks) {
|
||||
for (int i = 1; i <= ConfigClient.calcPCount(1); i++) {
|
||||
double m = (double) level().getRandom().nextIntBetweenInclusive(- 100, 100) / 100;
|
||||
Vec3 DeltaMovement = getDeltaMovement();
|
||||
Vec3 pos = new Vec3(
|
||||
(double) level().getRandom().nextIntBetweenInclusive(-5, 5) / 10,
|
||||
0,
|
||||
(double) level().getRandom().nextIntBetweenInclusive(-5, 5) / 10
|
||||
).normalize().multiply(m, m, m).add(getPosition(partialTicks));
|
||||
level().addParticle(particles.CONCUSSIVE_ARROW_PARTICLE.get(), pos.x, pos.y, pos.z, DeltaMovement.x, DeltaMovement.y, DeltaMovement.z);
|
||||
}
|
||||
}
|
||||
}
|
@ -63,6 +63,10 @@ public class entities {
|
||||
ENTITY_TYPES.register("arrow_claymore", () -> EntityType.Builder.<claymoreArrow>of(claymoreArrow::new, MobCategory.MISC)
|
||||
.sized(0.48F, 0.48F).clientTrackingRange(64).build("arrow_claymore"));
|
||||
|
||||
public static final RegistryObject<EntityType<carpetArrowPart>> ARROW_CARPT_PART =
|
||||
ENTITY_TYPES.register("arrow_carpet_part", () -> EntityType.Builder.<carpetArrowPart>of(carpetArrowPart::new, MobCategory.MISC)
|
||||
.sized(0.48F, 0.48F).clientTrackingRange(64).build("arrow_carpet_part"));
|
||||
|
||||
public static final RegistryObject<EntityType<dynamite>> DYNAMITE =
|
||||
ENTITY_TYPES.register("dynamite", () -> EntityType.Builder.<dynamite>of(dynamite::new, MobCategory.MISC)
|
||||
.sized(0.48F, 0.48F).clientTrackingRange(64).build("dynamite"));
|
||||
@ -85,6 +89,7 @@ public class entities {
|
||||
EntityRenderers.register(ARROW_TNT.get(), TNTArrowRenderer::new);
|
||||
EntityRenderers.register(ARROW_CONCUSSIVE.get(), TNTArrowRenderer::new);
|
||||
EntityRenderers.register(ARROW_CARPET.get(), TNTArrowRenderer::new);
|
||||
EntityRenderers.register(ARROW_CARPT_PART.get(), TNTArrowRenderer::new);
|
||||
EntityRenderers.register(ARROW_CLAYMORE.get(), baseArrowRenderer::new);
|
||||
}
|
||||
}
|
@ -3,9 +3,16 @@ package com.jenny.enhancedexplosives;
|
||||
import com.jenny.enhancedexplosives.particles.ArrowParticle;
|
||||
import com.jenny.enhancedexplosives.particles.particles;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.TextureSheetParticle;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraft.core.particles.SimpleParticleType;
|
||||
import net.minecraftforge.client.event.RegisterParticleProvidersEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import static com.jenny.enhancedexplosives.EnhancedExplosives.MODID;
|
||||
|
||||
@ -17,5 +24,7 @@ public class eventBusEvents {
|
||||
ArrowParticle.Provider::new);
|
||||
Minecraft.getInstance().particleEngine.register(particles.TNT_ARROW_PARTICLE.get(),
|
||||
ArrowParticle.Provider::new);
|
||||
Minecraft.getInstance().particleEngine.register(particles.CARPET_ARROW_PARTICLE.get(),
|
||||
ArrowParticle.Provider::new);
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,7 @@
|
||||
package com.jenny.enhancedexplosives.particles;
|
||||
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.core.particles.SimpleParticleType;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
@ -19,6 +16,8 @@ public class particles {
|
||||
PARTICLES.register("particle_concussive_arrow", () -> new SimpleParticleType(true));
|
||||
public static final RegistryObject<SimpleParticleType> TNT_ARROW_PARTICLE =
|
||||
PARTICLES.register("particle_tnt_arrow", () -> new SimpleParticleType(true));
|
||||
public static final RegistryObject<SimpleParticleType> CARPET_ARROW_PARTICLE =
|
||||
PARTICLES.register("particle_carpet_arrow", () -> new SimpleParticleType(true));
|
||||
|
||||
public static void register(IEventBus bus) {
|
||||
PARTICLES.register(bus);
|
||||
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"textures": [
|
||||
"enhancedexplosives:particle_carpet_arrow"
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 126 B |
Loading…
x
Reference in New Issue
Block a user