Compare commits
11 Commits
ab77a7246a
...
f7bf084070
Author | SHA1 | Date | |
---|---|---|---|
f7bf084070 | |||
6be0064866 | |||
69a58f1ba9 | |||
f8130fb1eb | |||
5e314c2256 | |||
0961e9654d | |||
129c27ba47 | |||
31306bb116 | |||
27e2c56cb9 | |||
3587ccbc8a | |||
94133e167a |
@ -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.0
|
||||
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,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);
|
||||
|
@ -1,8 +1,11 @@
|
||||
package com.jenny.enhancedexplosives.blocks;
|
||||
|
||||
import com.jenny.enhancedexplosives.entities.tnt.enderPrimedTNT;
|
||||
import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
@ -12,6 +15,7 @@ import net.minecraft.world.level.block.TntBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -47,6 +51,9 @@ public class enderTNTBlock extends TntBlock {
|
||||
level.gameEvent(entity, GameEvent.PRIME_FUSE, blockPos);
|
||||
}
|
||||
}
|
||||
else {
|
||||
spawnParticles(level, blockPos);
|
||||
}
|
||||
}
|
||||
|
||||
private static BlockPos getSpawnPos(Level level, BlockPos blockPos) {
|
||||
@ -82,5 +89,19 @@ public class enderTNTBlock extends TntBlock {
|
||||
level.addFreshEntity(primedtnt);
|
||||
}
|
||||
}
|
||||
else {
|
||||
spawnParticles(level, blockPos);
|
||||
}
|
||||
}
|
||||
|
||||
public static void spawnParticles(Level level, BlockPos blockPos) {
|
||||
if (ConfigClient.tntParticles) {
|
||||
for (int i = 1; i <= ConfigClient.calcPCount(30); i++) {
|
||||
float x = blockPos.getX() + (float) level.getRandom().nextIntBetweenInclusive(-10, 10) / 10 + 0.5F;
|
||||
float y = blockPos.getY() + (float) level.getRandom().nextIntBetweenInclusive(-10, 10) / 10;
|
||||
float z = blockPos.getZ() + (float) level.getRandom().nextIntBetweenInclusive(-10, 10) / 10 + 0.5F;
|
||||
level.addParticle(ParticleTypes.GLOW, x, y, z, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,16 +12,31 @@ public class ConfigClient {
|
||||
private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
|
||||
|
||||
private static final ForgeConfigSpec.ConfigValue<Boolean> C_ARROW_PARTICLES =
|
||||
BUILDER.comment("weather to spawn client-side particles for arrows")
|
||||
BUILDER.comment("whether to spawn client-side particles for arrows")
|
||||
.define("arrowParticles", true);
|
||||
|
||||
private static final ForgeConfigSpec.ConfigValue<Boolean> C_TNT_PARTICLES =
|
||||
BUILDER.comment("weather to spawn client-side particles for tnt")
|
||||
.define("tntParticles", true);
|
||||
|
||||
private static final ForgeConfigSpec.ConfigValue<Double> C_PARTICLE_PERCENT =
|
||||
BUILDER.comment("amount of particles to spawn (0.0 = None, 1.0 = normal, values higher are valid too)")
|
||||
.define("arrowParticleCount", 1.0D);
|
||||
|
||||
public static final ForgeConfigSpec SPEC = BUILDER.build();
|
||||
|
||||
public static boolean ARROW_PARTICLES;
|
||||
public static boolean arrowParticles, tntParticles;
|
||||
public static float particlePercent;
|
||||
|
||||
@SubscribeEvent
|
||||
static void onLoad(final ModConfigEvent event)
|
||||
{
|
||||
ARROW_PARTICLES = C_ARROW_PARTICLES.get();
|
||||
arrowParticles = C_ARROW_PARTICLES.get();
|
||||
tntParticles = C_TNT_PARTICLES.get();
|
||||
particlePercent = C_PARTICLE_PERCENT.get().floatValue();
|
||||
}
|
||||
|
||||
public static int calcPCount(int pCount) {
|
||||
return Math.round(pCount * particlePercent);
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ public class ModBlockStateProvider extends BlockStateProvider {
|
||||
sideTopBottom(blocks.TNT_64.get());
|
||||
sideTopBottom(blocks.TNT_128.get());
|
||||
sideTopBottom(blocks.TNT_ENDER.get());
|
||||
sideTopBottom(blocks.TNT_CLAYMORE.get());
|
||||
blockWithItem(blocks.TNT_BLACK_HOLE);
|
||||
}
|
||||
|
||||
private void blockWithItem(RegistryObject<Block> blockRegistryObject) {
|
||||
|
@ -33,6 +33,7 @@ public class baseArrow extends AbstractArrow {
|
||||
private Potion potion = Potions.EMPTY;
|
||||
private final Set<MobEffectInstance> effects = Sets.newHashSet();
|
||||
private boolean fixedColor;
|
||||
private int tick = 0;
|
||||
|
||||
public baseArrow(EntityType<? extends baseArrow> pEntityType, Level pLevel) {
|
||||
super(pEntityType, pLevel);
|
||||
@ -105,13 +106,13 @@ public class baseArrow extends AbstractArrow {
|
||||
} else {
|
||||
this.makeParticle(2);
|
||||
}
|
||||
this.tick++;
|
||||
} else if (this.inGround && this.inGroundTime != 0 && !this.effects.isEmpty() && this.inGroundTime >= 600) {
|
||||
this.level().broadcastEntityEvent(this, (byte)0);
|
||||
this.potion = Potions.EMPTY;
|
||||
this.effects.clear();
|
||||
this.entityData.set(ID_EFFECT_COLOR, -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void makeParticle(int pParticleAmount) {
|
||||
@ -229,7 +230,11 @@ public class baseArrow extends AbstractArrow {
|
||||
|
||||
}
|
||||
|
||||
public void spawnParticles() {
|
||||
public void spawnParticles(float partialTicks) {
|
||||
|
||||
}
|
||||
|
||||
public int getTick() {
|
||||
return this.tick;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.jenny.enhancedexplosives.entities.arrows;
|
||||
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import com.jenny.enhancedexplosives.items.items;
|
||||
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 org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class claymoreArrow extends baseArrow{
|
||||
public claymoreArrow(EntityType<claymoreArrow> pEntityType, Level pLevel) {
|
||||
super(pEntityType, pLevel);
|
||||
}
|
||||
|
||||
public claymoreArrow(@NotNull Level pLevel, @NotNull LivingEntity pShooter) {
|
||||
super(pLevel, pShooter, entities.ARROW_CLAYMORE.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPostHurtEffects(@NotNull LivingEntity pTarget) {
|
||||
pTarget.hurt(damageSources().mobProjectile(this, (LivingEntity) getOwner()), 15);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
protected ItemStack getPickupItem() {
|
||||
return new ItemStack(items.CONCUSSIVE_ARROW.get(), 0);
|
||||
}
|
||||
}
|
@ -2,11 +2,14 @@ package com.jenny.enhancedexplosives.entities.arrows;
|
||||
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import com.jenny.enhancedexplosives.items.items;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
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 concussiveArrow extends baseArrow{
|
||||
@ -21,12 +24,8 @@ public class concussiveArrow extends baseArrow{
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (level().isClientSide()) {
|
||||
level().addParticle(ParticleTypes.SMOKE, this.getX(), this.getY(), this.getZ(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
if (this.inGround) {
|
||||
this.level().explode(this, getX(), getY(), getZ(), 8.0f, Level.ExplosionInteraction.NONE);
|
||||
//this.level().explode(this, null, new NilExplosionCalculator(), this.getX(), this.getY(), this.getZ(), 8, false, Level.ExplosionInteraction.NONE);
|
||||
this.discard();
|
||||
}
|
||||
}
|
||||
@ -34,7 +33,6 @@ public class concussiveArrow extends baseArrow{
|
||||
@Override
|
||||
protected void doPostHurtEffects(@NotNull LivingEntity pTarget) {
|
||||
this.level().explode(this, getX(), getY(), getZ(), 8.0f, Level.ExplosionInteraction.NONE);
|
||||
//this.level().explode(this, null, new NilExplosionCalculator(), this.getX(), this.getY(), this.getZ(), 8, false, Level.ExplosionInteraction.NONE);
|
||||
this.discard();
|
||||
}
|
||||
|
||||
@ -44,12 +42,16 @@ public class concussiveArrow extends baseArrow{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticles() {
|
||||
for (int i = 0; i < 2; 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);
|
||||
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, m, m).add(getPosition(partialTicks));
|
||||
level().addParticle(particles.CONCUSSIVE_ARROW_PARTICLE.get(), pos.x, pos.y, pos.z, DeltaMovement.x, DeltaMovement.y, DeltaMovement.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,15 @@
|
||||
package com.jenny.enhancedexplosives.entities.arrows;
|
||||
|
||||
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 {
|
||||
@ -22,25 +24,12 @@ public class tntArrow extends baseArrow {
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (level().isClientSide()) {
|
||||
//spawnParticles();
|
||||
}
|
||||
if (this.inGround) {
|
||||
this.level().explode(this, this.getX(), this.getY(), this.getZ(), 2, Level.ExplosionInteraction.TNT);
|
||||
this.discard();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticles() {
|
||||
for (int i = 0; i < 2; 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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPostHurtEffects(@NotNull LivingEntity pTarget) {
|
||||
this.level().explode(this, this.getX(), this.getY(), this.getZ(), 2, Level.ExplosionInteraction.TNT);
|
||||
@ -51,4 +40,18 @@ public class tntArrow extends baseArrow {
|
||||
protected ItemStack getPickupItem() {
|
||||
return new ItemStack(items.TNT_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, m, m).add(getPosition(partialTicks));
|
||||
level().addParticle(particles.TNT_ARROW_PARTICLE.get(), pos.x, pos.y, pos.z, DeltaMovement.x, DeltaMovement.y, DeltaMovement.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.jenny.enhancedexplosives.entities.client;
|
||||
|
||||
import com.jenny.enhancedexplosives.blocks.blocks;
|
||||
import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
import com.jenny.enhancedexplosives.entities.tnt.basePrimedTNT;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Axis;
|
||||
@ -12,11 +12,9 @@ import net.minecraft.client.renderer.entity.TntMinecartRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BaseTNTRenderer extends EntityRenderer<basePrimedTNT> {
|
||||
public class BaseTNTRenderer<T extends basePrimedTNT> extends EntityRenderer<T> {
|
||||
private final BlockRenderDispatcher blockRenderer;
|
||||
|
||||
public BaseTNTRenderer(EntityRendererProvider.Context pContext) {
|
||||
@ -25,7 +23,7 @@ public class BaseTNTRenderer extends EntityRenderer<basePrimedTNT> {
|
||||
this.blockRenderer = pContext.getBlockRenderDispatcher();
|
||||
}
|
||||
|
||||
public void render(basePrimedTNT pEntity, float pEntityYaw, float pPartialTicks, PoseStack pPoseStack, @NotNull MultiBufferSource pBuffer, int pPackedLight) {
|
||||
public void render(T pEntity, float pEntityYaw, float pPartialTicks, PoseStack pPoseStack, @NotNull MultiBufferSource pBuffer, int pPackedLight) {
|
||||
pPoseStack.pushPose();
|
||||
pPoseStack.translate(0.0F, 0.5F, 0.0F);
|
||||
int i = pEntity.getFuse();
|
||||
@ -37,31 +35,20 @@ public class BaseTNTRenderer extends EntityRenderer<basePrimedTNT> {
|
||||
float f1 = 1.0F + f * 0.3F;
|
||||
pPoseStack.scale(f1, f1, f1);
|
||||
}
|
||||
String renderID = pEntity.getRenderID();
|
||||
if (renderID == null) {
|
||||
renderID = "";
|
||||
if (ConfigClient.tntParticles) {
|
||||
pEntity.spawnParticles(pPartialTicks);
|
||||
}
|
||||
Block block = switch (renderID) {
|
||||
case "stronger_8" -> blocks.TNT_8.get();
|
||||
case "stronger_16" -> blocks.TNT_16.get();
|
||||
case "stronger_32" -> blocks.TNT_32.get();
|
||||
case "stronger_64" -> blocks.TNT_64.get();
|
||||
case "stronger_128" -> blocks.TNT_128.get();
|
||||
case "homing" -> blocks.TNT_HOMING.get();
|
||||
case "ender" -> blocks.TNT_ENDER.get();
|
||||
default -> Blocks.NETHER_PORTAL; // placeholder for debugging
|
||||
};
|
||||
|
||||
pEntity.spawnParticles(pPartialTicks);
|
||||
pPoseStack.mulPose(Axis.YP.rotationDegrees(-90.0F));
|
||||
pPoseStack.translate(-0.5F, -0.5F, 0.5F);
|
||||
pPoseStack.mulPose(Axis.YP.rotationDegrees(90.0F));
|
||||
TntMinecartRenderer.renderWhiteSolidBlock(this.blockRenderer, block.defaultBlockState(), pPoseStack, pBuffer, pPackedLight, i / 5 % 2 == 0);
|
||||
TntMinecartRenderer.renderWhiteSolidBlock(this.blockRenderer, pEntity.renderBlock().defaultBlockState(), pPoseStack, pBuffer, pPackedLight, i / 5 % 2 == 0);
|
||||
pPoseStack.popPose();
|
||||
super.render(pEntity, pEntityYaw, pPartialTicks, pPoseStack, pBuffer, pPackedLight);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ResourceLocation getTextureLocation(@NotNull basePrimedTNT pEntity) {
|
||||
public ResourceLocation getTextureLocation(@NotNull T pEntity) {
|
||||
return TextureAtlas.LOCATION_BLOCKS;
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,8 @@ import net.minecraft.world.level.block.Blocks;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TNTArrowRenderer extends EntityRenderer<baseArrow> {
|
||||
private final boolean renderParticles = ConfigClient.ARROW_PARTICLES;
|
||||
private final boolean renderParticles = ConfigClient.arrowParticles;
|
||||
private final BlockRenderDispatcher blockRenderer;
|
||||
private float i = 0;
|
||||
|
||||
public TNTArrowRenderer(EntityRendererProvider.Context pContext) {
|
||||
super(pContext);
|
||||
@ -31,14 +30,14 @@ public class TNTArrowRenderer extends EntityRenderer<baseArrow> {
|
||||
pPoseStack.pushPose();
|
||||
pPoseStack.translate(0.0F, 0.5F, 0.0F);
|
||||
pPoseStack.scale(0.5f, 0.5f, 0.5f);
|
||||
i += 0.1f;
|
||||
int i = pEntity.getTick();
|
||||
pPoseStack.mulPose(Axis.YP.rotationDegrees(-90.0F));
|
||||
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, Math.round(Math.sin(i)) == 0);
|
||||
TntMinecartRenderer.renderWhiteSolidBlock(this.blockRenderer, Blocks.TNT.defaultBlockState(), pPoseStack, pBuffer, pPackedLight, i / 5 % 2 == 0);
|
||||
pPoseStack.popPose();
|
||||
super.render(pEntity, pEntityYaw, pPartialTicks, pPoseStack, pBuffer, pPackedLight);
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.jenny.enhancedexplosives.entities.client;
|
||||
|
||||
import net.minecraft.client.renderer.entity.ArrowRenderer;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.projectile.AbstractArrow;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.minecraft.client.renderer.entity.TippableArrowRenderer.NORMAL_ARROW_LOCATION;
|
||||
|
||||
public class baseArrowRenderer extends ArrowRenderer<AbstractArrow> {
|
||||
public baseArrowRenderer(EntityRendererProvider.Context pContext) {
|
||||
super(pContext);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ResourceLocation getTextureLocation(@NotNull AbstractArrow pEntity) {
|
||||
return NORMAL_ARROW_LOCATION;
|
||||
}
|
||||
}
|
@ -11,7 +11,6 @@ import net.minecraft.client.renderer.entity.TntMinecartRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class clusterTNTRenderer extends EntityRenderer<basePrimedTNT> {
|
||||
@ -40,9 +39,9 @@ public class clusterTNTRenderer extends EntityRenderer<basePrimedTNT> {
|
||||
}
|
||||
|
||||
pPoseStack.mulPose(Axis.YP.rotationDegrees(-90.0F));
|
||||
pPoseStack.translate(-0.5F, -0.5F, 0.5F);
|
||||
pPoseStack.translate(-0.5F, -1.0F, 0.5F);
|
||||
pPoseStack.mulPose(Axis.YP.rotationDegrees(90.0F));
|
||||
TntMinecartRenderer.renderWhiteSolidBlock(this.blockRenderer, Blocks.TNT.defaultBlockState(), pPoseStack, pBuffer, pPackedLight, i / 5 % 2 == 0);
|
||||
TntMinecartRenderer.renderWhiteSolidBlock(this.blockRenderer, pEntity.renderBlock().defaultBlockState(), pPoseStack, pBuffer, pPackedLight, i / 5 % 2 == 0);
|
||||
pPoseStack.popPose();
|
||||
super.render(pEntity, pEntityYaw, pPartialTicks, pPoseStack, pBuffer, pPackedLight);
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
package com.jenny.enhancedexplosives.entities;
|
||||
|
||||
import com.jenny.enhancedexplosives.entities.arrows.*;
|
||||
import com.jenny.enhancedexplosives.entities.client.BaseTNTRenderer;
|
||||
import com.jenny.enhancedexplosives.entities.client.TNTArrowRenderer;
|
||||
import com.jenny.enhancedexplosives.entities.client.clusterTNTRenderer;
|
||||
import com.jenny.enhancedexplosives.entities.client.*;
|
||||
import com.jenny.enhancedexplosives.entities.throwable.dynamite;
|
||||
import com.jenny.enhancedexplosives.entities.tnt.*;
|
||||
|
||||
@ -61,6 +59,14 @@ public class entities {
|
||||
ENTITY_TYPES.register("arrow_carpet", () -> EntityType.Builder.<carpetArrow>of(carpetArrow::new, MobCategory.MISC)
|
||||
.sized(0.48F, 0.48F).clientTrackingRange(64).build("arrow_carpet"));
|
||||
|
||||
public static final RegistryObject<EntityType<claymoreArrow>> ARROW_CLAYMORE =
|
||||
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"));
|
||||
@ -83,5 +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);
|
||||
}
|
||||
}
|
@ -9,18 +9,19 @@ import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.MoverType;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class dynamite extends basePrimedTNT {
|
||||
public dynamite (Level pLevel, double pX, double pY, double pZ, @Nullable LivingEntity pOwner, float power, int fuse) {
|
||||
super(entities.DYNAMITE.get(), pLevel, pOwner, new Vec3(pX, pY, pZ), fuse, power, "dynamite");
|
||||
super(entities.DYNAMITE.get(), pLevel, pOwner, new Vec3(pX, pY, pZ), fuse, power);
|
||||
}
|
||||
|
||||
public dynamite(EntityType<dynamite> entityType, Level level) {
|
||||
super(entityType, level, null);
|
||||
this.setRenderID("dynamite");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -59,4 +60,8 @@ public class dynamite extends basePrimedTNT {
|
||||
Vec3 vec3 = pShooter.getDeltaMovement();
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(vec3.x, pShooter.onGround() ? 0.0D : vec3.y, vec3.z));
|
||||
}
|
||||
|
||||
public Block renderBlock() {
|
||||
return Blocks.TNT;
|
||||
}
|
||||
}
|
||||
|
@ -11,12 +11,11 @@ import javax.annotation.Nullable;
|
||||
public class ClusterPrimedTNT extends basePrimedTNT {
|
||||
|
||||
public ClusterPrimedTNT (Level pLevel, double pX, double pY, double pZ, @Nullable LivingEntity pOwner, float power, int fuse, Vec3 move) {
|
||||
super(entities.TNT_CLUSTER.get(), pLevel, pOwner, new Vec3(pX, pY, pZ), fuse, power, "cluster");
|
||||
super(entities.TNT_CLUSTER.get(), pLevel, pOwner, new Vec3(pX, pY, pZ), fuse, power);
|
||||
this.addDeltaMovement(move);
|
||||
}
|
||||
|
||||
public ClusterPrimedTNT(EntityType<ClusterPrimedTNT> entityType, Level level) {
|
||||
super(entityType, level, null);
|
||||
this.setRenderID("cluster");
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +1,34 @@
|
||||
package com.jenny.enhancedexplosives.entities.tnt;
|
||||
|
||||
import com.jenny.enhancedexplosives.blocks.blocks;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class StrongerPrimedTNT extends basePrimedTNT {
|
||||
public StrongerPrimedTNT (Level pLevel, double pX, double pY, double pZ, @Nullable LivingEntity pOwner, float power, int fuse) {
|
||||
super(entities.TNT_STRONGER.get(), pLevel, pOwner, new Vec3(pX, pY, pZ), fuse, power, "default");
|
||||
this.setRenderID(evalRenderID());
|
||||
super(entities.TNT_STRONGER.get(), pLevel, pOwner, new Vec3(pX, pY, pZ), fuse, power);
|
||||
}
|
||||
|
||||
public StrongerPrimedTNT(EntityType<StrongerPrimedTNT> entityType, Level level) {
|
||||
super(entityType, level, null);
|
||||
this.setRenderID(evalRenderID());
|
||||
}
|
||||
|
||||
public String evalRenderID() {
|
||||
int a = (int) this.getPower();
|
||||
@Override
|
||||
public Block renderBlock() {
|
||||
return switch ((int) this.getPower()) {
|
||||
case 8 -> "stronger_8";
|
||||
case 16 -> "stronger_16";
|
||||
case 32 -> "stronger_32";
|
||||
case 64 -> "stronger_64";
|
||||
case 128 -> "stronger_128";
|
||||
default -> "default";
|
||||
case 8 -> blocks.TNT_8.get();
|
||||
case 16 -> blocks.TNT_16.get();
|
||||
case 32 -> blocks.TNT_32.get();
|
||||
case 64 -> blocks.TNT_64.get();
|
||||
case 128 -> blocks.TNT_128.get();
|
||||
default -> Blocks.END_GATEWAY;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.world.entity.*;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -15,16 +17,15 @@ import javax.annotation.Nullable;
|
||||
public abstract class basePrimedTNT extends Entity implements TraceableEntity {
|
||||
private static final EntityDataAccessor<Integer> DATA_FUSE_ID = SynchedEntityData.defineId(basePrimedTNT.class, EntityDataSerializers.INT);
|
||||
private static final EntityDataAccessor<Float> DATA_POWER_ID = SynchedEntityData.defineId(basePrimedTNT.class, EntityDataSerializers.FLOAT);
|
||||
private static final EntityDataAccessor<String> DATA_RENDER_ID = SynchedEntityData.defineId(basePrimedTNT.class, EntityDataSerializers.STRING);
|
||||
|
||||
@Nullable
|
||||
private LivingEntity owner;
|
||||
|
||||
private String renderID = "default";
|
||||
private int fuse = 0;
|
||||
|
||||
public basePrimedTNT(EntityType<? extends basePrimedTNT> pEntityType, Level pLevel, @Nullable LivingEntity owner) {
|
||||
super(pEntityType, pLevel);
|
||||
commonInit(pLevel, owner);
|
||||
this.fuse = getFuse();
|
||||
}
|
||||
|
||||
private void commonInit(Level pLevel, @Nullable LivingEntity owner) {
|
||||
@ -34,13 +35,13 @@ public abstract class basePrimedTNT extends Entity implements TraceableEntity {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public basePrimedTNT(EntityType<? extends basePrimedTNT> pEntityType, Level pLevel, @Nullable LivingEntity owner, Vec3 pos, int fuse, float power, String renderID) {
|
||||
public basePrimedTNT(EntityType<? extends basePrimedTNT> pEntityType, Level pLevel, @Nullable LivingEntity owner, Vec3 pos, int fuse, float power) {
|
||||
super(pEntityType, pLevel);
|
||||
commonInit(pLevel, owner);
|
||||
setPos(pos);
|
||||
setFuse(fuse);
|
||||
setPower(power);
|
||||
setRenderID(renderID);
|
||||
this.fuse = getFuse();
|
||||
}
|
||||
|
||||
protected void explode() {
|
||||
@ -93,26 +94,24 @@ public abstract class basePrimedTNT extends Entity implements TraceableEntity {
|
||||
return !this.isRemoved();
|
||||
}
|
||||
|
||||
protected Entity.@NotNull MovementEmission getMovementEmission() {
|
||||
return Entity.MovementEmission.NONE;
|
||||
@NotNull
|
||||
protected MovementEmission getMovementEmission() {
|
||||
return MovementEmission.NONE;
|
||||
}
|
||||
|
||||
protected void defineSynchedData() {
|
||||
this.entityData.define(DATA_FUSE_ID, 80);
|
||||
this.entityData.define(DATA_POWER_ID, 4.0f);
|
||||
this.entityData.define(DATA_RENDER_ID, "default");
|
||||
}
|
||||
|
||||
protected void addAdditionalSaveData(CompoundTag pCompound) {
|
||||
pCompound.putShort("Fuse", (short)this.getFuse());
|
||||
pCompound.putFloat("Power", (short)this.getPower());
|
||||
pCompound.putString("RenderID", getRenderID());
|
||||
}
|
||||
|
||||
protected void readAdditionalSaveData(CompoundTag pCompound) {
|
||||
this.setFuse(pCompound.getShort("Fuse"));
|
||||
this.setPower(pCompound.getFloat("Power"));
|
||||
this.setRenderID(pCompound.getString("RenderID"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -124,15 +123,17 @@ public abstract class basePrimedTNT extends Entity implements TraceableEntity {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public void setRenderID(String renderID) {
|
||||
this.entityData.set(DATA_RENDER_ID, renderID);
|
||||
}
|
||||
|
||||
public String getRenderID() {
|
||||
return this.entityData.get(DATA_RENDER_ID);
|
||||
}
|
||||
|
||||
protected float getEyeHeight(@NotNull Pose pPose, @NotNull EntityDimensions pSize) {
|
||||
return 0.15F;
|
||||
}
|
||||
|
||||
public Block renderBlock() {
|
||||
return Blocks.GLASS;
|
||||
}
|
||||
|
||||
public int defaultFuse() {
|
||||
return this.fuse;
|
||||
}
|
||||
|
||||
public void spawnParticles(float partialTicks) {}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.jenny.enhancedexplosives.entities.tnt;
|
||||
|
||||
import com.jenny.enhancedexplosives.blocks.blocks;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
@ -7,6 +8,7 @@ import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.world.entity.*;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
@ -17,13 +19,12 @@ public class blackHolePrimedTNT extends basePrimedTNT {
|
||||
private static final EntityDataAccessor<Float> DATA_SPEED_ID = SynchedEntityData.defineId(blackHolePrimedTNT.class, EntityDataSerializers.FLOAT);
|
||||
|
||||
public blackHolePrimedTNT(Level pLevel, double pX, double pY, double pZ, @Nullable LivingEntity pOwner, float power, int fuse, float speed) {
|
||||
super(entities.TNT_BLACK_HOLE.get(), pLevel, pOwner, new Vec3(pX, pY, pZ), fuse, power, "black_hole");
|
||||
super(entities.TNT_BLACK_HOLE.get(), pLevel, pOwner, new Vec3(pX, pY, pZ), fuse, power);
|
||||
this.setSpeed(speed);
|
||||
}
|
||||
|
||||
public blackHolePrimedTNT(EntityType<blackHolePrimedTNT> entityType, Level level) {
|
||||
super(entityType, level, null);
|
||||
this.setRenderID("black_hole");
|
||||
this.setSpeed(this.getSpeed());
|
||||
}
|
||||
|
||||
@ -86,4 +87,9 @@ public class blackHolePrimedTNT extends basePrimedTNT {
|
||||
this.entityData.define(DATA_SPEED_ID, 4.0f);
|
||||
super.defineSynchedData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block renderBlock() {
|
||||
return blocks.TNT_BLACK_HOLE.get();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.jenny.enhancedexplosives.entities.tnt;
|
||||
|
||||
import com.jenny.enhancedexplosives.blocks.blocks;
|
||||
import com.jenny.enhancedexplosives.entities.arrows.claymoreArrow;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
@ -8,9 +10,9 @@ import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.projectile.Arrow;
|
||||
import net.minecraft.world.entity.projectile.Projectile;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -19,31 +21,31 @@ public class claymorePrimedTNT extends basePrimedTNT {
|
||||
private static final EntityDataAccessor<Integer> DATA_PCOUNT_ID = SynchedEntityData.defineId(claymorePrimedTNT.class, EntityDataSerializers.INT);
|
||||
|
||||
public claymorePrimedTNT(Level pLevel, double pX, double pY, double pZ, @Nullable LivingEntity pOwner, float power, int fuse, int projectileCount) {
|
||||
super(entities.TNT_CLAYMORE.get(), pLevel, pOwner, new Vec3(pX, pY, pZ), fuse, power, "tnt_claymore");
|
||||
super(entities.TNT_CLAYMORE.get(), pLevel, pOwner, new Vec3(pX, pY, pZ), fuse, power);
|
||||
setPCount(projectileCount);
|
||||
}
|
||||
|
||||
public claymorePrimedTNT(EntityType<claymorePrimedTNT> entityType, Level level) {
|
||||
super(entityType, level, null);
|
||||
setRenderID("tnt_claymore");
|
||||
}
|
||||
|
||||
public Vec3 targetVector(RandomSource rng) {
|
||||
return new Vec3(
|
||||
(double) rng.nextInt(-10, 11) / 10,
|
||||
(double) rng.nextInt( 11) / 10,
|
||||
(double) rng.nextInt(-10, 11) / 10);
|
||||
getX() + rng.nextIntBetweenInclusive(-15, 15),
|
||||
getY() + (float) rng.nextIntBetweenInclusive(-10, 10) / 10,
|
||||
getZ() + rng.nextIntBetweenInclusive(-15, 15)
|
||||
).subtract(position().add(0, 0.5, 0)).normalize().multiply(1.3, 1.3, 1.3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explode() {
|
||||
super.explode();
|
||||
RandomSource rng = level().getRandom();
|
||||
for (int i = 0; i < getPCount(); i++) {
|
||||
Vec3 target = targetVector(rng);
|
||||
Vec3 pos = position().add(target);
|
||||
Projectile e = new Arrow(level(),pos.x, pos.y + 1, pos.z);
|
||||
e.setDeltaMovement(target.multiply(5, 0.1, 5));
|
||||
assert this.getOwner() != null;
|
||||
Projectile e = new claymoreArrow(level(), this.getOwner());
|
||||
e.setPos(position().add(0, 0.5, 0));
|
||||
e.setDeltaMovement(target);
|
||||
level().addFreshEntity(e);
|
||||
}
|
||||
|
||||
@ -74,4 +76,9 @@ public class claymorePrimedTNT extends basePrimedTNT {
|
||||
this.entityData.define(DATA_PCOUNT_ID, 16);
|
||||
super.defineSynchedData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block renderBlock() {
|
||||
return blocks.TNT_CLAYMORE.get();
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,11 @@
|
||||
package com.jenny.enhancedexplosives.entities.tnt;
|
||||
|
||||
import com.jenny.enhancedexplosives.blocks.blocks;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.ai.targeting.TargetingConditions;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -18,12 +13,14 @@ import javax.annotation.Nullable;
|
||||
public class enderPrimedTNT extends basePrimedTNT {
|
||||
|
||||
public enderPrimedTNT(Level pLevel, double pX, double pY, double pZ, @Nullable LivingEntity pOwner, float power, int fuse) {
|
||||
super(entities.TNT_ENDER.get(), pLevel, pOwner, new Vec3(pX, pY, pZ), fuse, power, "ender");
|
||||
super(entities.TNT_ENDER.get(), pLevel, pOwner, new Vec3(pX, pY, pZ), fuse, power);
|
||||
}
|
||||
|
||||
public enderPrimedTNT(EntityType<enderPrimedTNT> entityType, Level level) {
|
||||
super(entityType, level, null);
|
||||
setRenderID("ender");
|
||||
}
|
||||
|
||||
public Block renderBlock() {
|
||||
return blocks.TNT_ENDER.get();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
package com.jenny.enhancedexplosives.entities.tnt;
|
||||
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
@ -18,7 +21,7 @@ public class homingPrimedTNT extends basePrimedTNT {
|
||||
Entity target;
|
||||
|
||||
public homingPrimedTNT (Level pLevel, double pX, double pY, double pZ, @Nullable LivingEntity pOwner, float power, int fuse, float speed) {
|
||||
super(entities.TNT_HOMING.get(), pLevel, pOwner, new Vec3(pX, pY, pZ), fuse, power, "homing");
|
||||
super(entities.TNT_HOMING.get(), pLevel, pOwner, new Vec3(pX, pY, pZ), fuse, power);
|
||||
this.target = null;
|
||||
this.setSpeed(speed);
|
||||
}
|
||||
@ -88,4 +91,11 @@ public class homingPrimedTNT extends basePrimedTNT {
|
||||
this.entityData.define(DATA_SPEED_ID, 4.0f);
|
||||
super.defineSynchedData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticles(float partialTicks) {
|
||||
for (int i = 1; i <= ConfigClient.calcPCount(30); i++) {
|
||||
level().addParticle(ParticleTypes.FALLING_OBSIDIAN_TEAR, getX(), getY(), getZ(), this.getDeltaMovement().x, this.getDeltaMovement().y, this.getDeltaMovement().z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.ExplosionDamageCalculator;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -28,12 +30,11 @@ public class selectivePrimedTNT extends basePrimedTNT {
|
||||
}
|
||||
|
||||
public selectivePrimedTNT(Level pLevel, double pX, double pY, double pZ, @Nullable LivingEntity pOwner, float power, int fuse) {
|
||||
super(entities.TNT_SELECTIVE.get(), pLevel, pOwner, new Vec3(pX, pY, pZ), fuse, power, "tnt_selective");
|
||||
super(entities.TNT_SELECTIVE.get(), pLevel, pOwner, new Vec3(pX, pY, pZ), fuse, power);
|
||||
}
|
||||
|
||||
public selectivePrimedTNT(EntityType<selectivePrimedTNT> entityType, Level level) {
|
||||
super(entityType, level, null);
|
||||
this.setRenderID("tnt_selective");
|
||||
}
|
||||
@Override
|
||||
protected void explode() {
|
||||
|
@ -0,0 +1,30 @@
|
||||
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;
|
||||
|
||||
@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);
|
||||
Minecraft.getInstance().particleEngine.register(particles.CARPET_ARROW_PARTICLE.get(),
|
||||
ArrowParticle.Provider::new);
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.jenny.enhancedexplosives.particles;
|
||||
|
||||
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.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,25 @@
|
||||
package com.jenny.enhancedexplosives.particles;
|
||||
|
||||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraft.core.particles.SimpleParticleType;
|
||||
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 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"
|
||||
]
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"textures": [
|
||||
"enhancedexplosives:particle_concussive_arrow"
|
||||
]
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"textures": [
|
||||
"enhancedexplosives:particle_tnt_arrow"
|
||||
]
|
||||
}
|
After Width: | Height: | Size: 28 KiB |
@ -0,0 +1,7 @@
|
||||
{
|
||||
"animation": {
|
||||
"frametime": 1,
|
||||
"interpolate": true,
|
||||
"frames": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 149 B |
After Width: | Height: | Size: 353 B |
After Width: | Height: | Size: 449 B |
After Width: | Height: | Size: 237 B |
After Width: | Height: | Size: 126 B |
After Width: | Height: | Size: 132 B |
After Width: | Height: | Size: 132 B |