rename to "Enhanced Explosives"
This commit is contained in:
88 files changed
+212
-218
No files matched your search
@@ -0,0 +1,47 @@
|
||||
package com.jenny.enhancedexplosives.entities.tnt;
|
||||
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
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.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class selectivePrimedTNT extends basePrimedTNT {
|
||||
static class SelectiveExplosionCalculator extends ExplosionDamageCalculator {
|
||||
private final String block;
|
||||
|
||||
public SelectiveExplosionCalculator(String block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public boolean shouldBlockExplode(@NotNull Explosion pExplosion, @NotNull BlockGetter pReader, @NotNull BlockPos pPos, BlockState pState, float pPower) {
|
||||
return pState.getBlock().toString().equals(block);
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
public selectivePrimedTNT(EntityType<selectivePrimedTNT> entityType, Level level) {
|
||||
super(entityType, level, null);
|
||||
this.setRenderID("tnt_selective");
|
||||
}
|
||||
@Override
|
||||
protected void explode() {
|
||||
SelectiveExplosionCalculator dmgCalc = new SelectiveExplosionCalculator(getBlock());
|
||||
this.level().explode(this, null, dmgCalc, position(), getPower(), false, Level.ExplosionInteraction.TNT);
|
||||
}
|
||||
|
||||
public String getBlock() {
|
||||
return level().getBlockState(new BlockPos((int) Math.round(getX()), (int) Math.round(getY() - 1), (int) Math.round(getZ()))).getBlock().toString();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user