custom particles
This commit is contained in:
parent
27e2c56cb9
commit
31306bb116
@ -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.3
|
||||
mod_version=0.8.4
|
||||
# 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,6 +1,7 @@
|
||||
package com.jenny.enhancedexplosives;
|
||||
|
||||
import com.jenny.enhancedexplosives.blocks.blocks;
|
||||
import com.jenny.enhancedexplosives.particles.particles;
|
||||
import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import com.jenny.enhancedexplosives.items.items;
|
||||
@ -30,6 +31,7 @@ public class EnhancedExplosives {
|
||||
|
||||
modEventBus.addListener(this::commonSetup);
|
||||
|
||||
particles.register(modEventBus);
|
||||
blocks.register(modEventBus);
|
||||
items.register(modEventBus);
|
||||
creativeTab.register(modEventBus);
|
||||
|
@ -230,7 +230,7 @@ public class baseArrow extends AbstractArrow {
|
||||
|
||||
}
|
||||
|
||||
public void spawnParticles() {
|
||||
public void spawnParticles(float partialTicks) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -3,12 +3,13 @@ package com.jenny.enhancedexplosives.entities.arrows;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import com.jenny.enhancedexplosives.items.items;
|
||||
import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
import com.jenny.enhancedexplosives.particles.particles;
|
||||
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
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 concussiveArrow extends baseArrow{
|
||||
@ -43,12 +44,13 @@ public class concussiveArrow extends baseArrow{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticles() {
|
||||
public void spawnParticles(float partialTicks) {
|
||||
for (int i = 1; i <= ConfigClient.arrowParticleCount; i++) {
|
||||
double x = getX() + (double) level().getRandom().nextInt(-10, 11) / 10;
|
||||
double y = getY() + (double) level().getRandom().nextInt(-10, 11) / 10;
|
||||
double z = getZ() + (double) level().getRandom().nextInt(-10, 11) / 10;
|
||||
level().addParticle(ParticleTypes.WAX_ON, x, y, z, this.getDeltaMovement().x, this.getDeltaMovement().y, this.getDeltaMovement().z);
|
||||
Vec3 pos = getPosition(partialTicks);
|
||||
double x = pos.x + (double) level().getRandom().nextInt(-5, 6) / 10;
|
||||
double y = pos.y + (double) level().getRandom().nextInt(-5, 6) / 10;
|
||||
double z = pos.z + (double) level().getRandom().nextInt(-5, 6) / 10;
|
||||
level().addParticle(particles.CONCUSSIVE_ARROW_PARTICLE.get(), x, y, z, this.getDeltaMovement().x, this.getDeltaMovement().y, this.getDeltaMovement().z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,12 @@ import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
import com.jenny.enhancedexplosives.items.items;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
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 tntArrow extends baseArrow {
|
||||
@ -44,12 +45,13 @@ public class tntArrow extends baseArrow {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticles() {
|
||||
public void spawnParticles(float partialTicks) {
|
||||
for (int i = 1; i <= ConfigClient.arrowParticleCount; i++) {
|
||||
double x = getX() + (double) level().getRandom().nextInt(-10, 11) / 10;
|
||||
double y = getY() + (double) level().getRandom().nextInt(-10, 11) / 10;
|
||||
double z = getZ() + (double) level().getRandom().nextInt(-10, 11) / 10;
|
||||
level().addParticle(ParticleTypes.WAX_ON, x, y, z, this.getDeltaMovement().x, this.getDeltaMovement().y, this.getDeltaMovement().z);
|
||||
Vec3 pos = getPosition(partialTicks);
|
||||
double x = pos.x + (double) level().getRandom().nextInt(-5, 6) / 10;
|
||||
double y = pos.y + (double) level().getRandom().nextInt(-5, 6) / 10;
|
||||
double z = pos.z + (double) level().getRandom().nextInt(-5, 6) / 10;
|
||||
level().addParticle(particles.TNT_ARROW_PARTICLE.get(), x, y, z, this.getDeltaMovement().x, this.getDeltaMovement().y, this.getDeltaMovement().z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class TNTArrowRenderer extends EntityRenderer<baseArrow> {
|
||||
pPoseStack.translate(-0.5F, -0.5F, 0.5F);
|
||||
pPoseStack.mulPose(Axis.YP.rotationDegrees(90.0F));
|
||||
if (renderParticles) {
|
||||
pEntity.spawnParticles();
|
||||
pEntity.spawnParticles(pPartialTicks);
|
||||
}
|
||||
TntMinecartRenderer.renderWhiteSolidBlock(this.blockRenderer, Blocks.TNT.defaultBlockState(), pPoseStack, pBuffer, pPackedLight, i / 5 % 2 == 0);
|
||||
pPoseStack.popPose();
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.jenny.enhancedexplosives;
|
||||
|
||||
import com.jenny.enhancedexplosives.particles.particles;
|
||||
import com.jenny.enhancedexplosives.particles.arrow.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.client.event.RegisterParticleProvidersEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
import static com.jenny.enhancedexplosives.EnhancedExplosives.MODID;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class eventBusEvents {
|
||||
@SubscribeEvent
|
||||
public static void registerParticleFactories(final RegisterParticleProvidersEvent event) {
|
||||
Minecraft.getInstance().particleEngine.register(particles.CONCUSSIVE_ARROW_PARTICLE.get(),
|
||||
ArrowParticle.Provider::new);
|
||||
Minecraft.getInstance().particleEngine.register(particles.TNT_ARROW_PARTICLE.get(),
|
||||
ArrowParticle.Provider::new);
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.jenny.enhancedexplosives.particles.arrow;
|
||||
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.particle.*;
|
||||
import net.minecraft.core.particles.SimpleParticleType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ArrowParticle extends TextureSheetParticle {
|
||||
private final float quadSizeStart;
|
||||
|
||||
protected ArrowParticle(ClientLevel level, double xCoord, double yCoord, double zCoord,
|
||||
SpriteSet spriteSet, double xd, double yd, double zd) {
|
||||
super(level, xCoord, yCoord, zCoord, xd, yd, zd);
|
||||
|
||||
this.friction = 0.8F;
|
||||
this.xd = xd;
|
||||
this.yd = yd;
|
||||
this.zd = zd;
|
||||
this.quadSize *= 0.85F;
|
||||
this.quadSizeStart = this.quadSize;
|
||||
this.lifetime = 20;
|
||||
this.setSpriteFromAge(spriteSet);
|
||||
|
||||
this.rCol = 1f;
|
||||
this.gCol = 1f;
|
||||
this.bCol = 1f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
fadeOut();
|
||||
}
|
||||
|
||||
private void fadeOut() {
|
||||
this.alpha = (-(1/(float)lifetime) * age + 1);
|
||||
this.quadSize = this.quadSizeStart * ((float) age / lifetime);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ParticleRenderType getRenderType() {
|
||||
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class Provider implements ParticleProvider<SimpleParticleType> {
|
||||
private final SpriteSet sprites;
|
||||
|
||||
public Provider(SpriteSet spriteSet) {
|
||||
this.sprites = spriteSet;
|
||||
}
|
||||
|
||||
public Particle createParticle(@NotNull SimpleParticleType particleType, @NotNull ClientLevel level,
|
||||
double x, double y, double z,
|
||||
double dx, double dy, double dz) {
|
||||
return new ArrowParticle(level, x, y, z, this.sprites, dx, dy, dz);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
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;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import static com.jenny.enhancedexplosives.EnhancedExplosives.MODID;
|
||||
|
||||
public class particles {
|
||||
public static final DeferredRegister<ParticleType<?>> PARTICLES = DeferredRegister.create(ForgeRegistries.PARTICLE_TYPES, MODID);
|
||||
|
||||
public static final RegistryObject<SimpleParticleType> CONCUSSIVE_ARROW_PARTICLE =
|
||||
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 void register(IEventBus bus) {
|
||||
PARTICLES.register(bus);
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"textures": [
|
||||
"enhancedexplosives:particle_concussive_arrow"
|
||||
]
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"textures": [
|
||||
"enhancedexplosives:particle_tnt_arrow"
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 123 B |
Binary file not shown.
After Width: | Height: | Size: 123 B |
Loading…
x
Reference in New Issue
Block a user