added ender tnt
This commit is contained in:
parent
992e1ca255
commit
ab77a7246a
@ -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.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=All Rights Reserved
|
mod_license=All Rights Reserved
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=0.7.2
|
mod_version=0.8.0
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# 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.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
@ -53,6 +53,10 @@ public class blocks {
|
|||||||
public static final RegistryObject<Block> TNT_SELECTIVE = BLOCKS.register("tnt_selective", () -> new selectiveTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 32.0f, 80));
|
public static final RegistryObject<Block> TNT_SELECTIVE = BLOCKS.register("tnt_selective", () -> new selectiveTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 32.0f, 80));
|
||||||
public static final RegistryObject<Item> TNT_SELECTIVE_ITEM = ITEMS.register("tnt_selective", () -> new BlockItemTooltip(TNT_SELECTIVE.get(), new Item.Properties()));
|
public static final RegistryObject<Item> TNT_SELECTIVE_ITEM = ITEMS.register("tnt_selective", () -> new BlockItemTooltip(TNT_SELECTIVE.get(), new Item.Properties()));
|
||||||
|
|
||||||
|
public static final RegistryObject<Block> TNT_ENDER = BLOCKS.register("tnt_ender", () -> new enderTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80));
|
||||||
|
public static final RegistryObject<Item> TNT_ENDER_ITEM = ITEMS.register("tnt_ender", () -> new BlockItemTooltip(TNT_ENDER.get(), new Item.Properties()));
|
||||||
|
|
||||||
|
|
||||||
public static void register(IEventBus bus) {
|
public static void register(IEventBus bus) {
|
||||||
BLOCKS.register(bus);
|
BLOCKS.register(bus);
|
||||||
ITEMS.register(bus);
|
ITEMS.register(bus);
|
||||||
|
@ -0,0 +1,86 @@
|
|||||||
|
package com.jenny.enhancedexplosives.blocks;
|
||||||
|
|
||||||
|
import com.jenny.enhancedexplosives.entities.tnt.enderPrimedTNT;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.sounds.SoundEvents;
|
||||||
|
import net.minecraft.sounds.SoundSource;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
import net.minecraft.world.level.Explosion;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class enderTNTBlock extends TntBlock {
|
||||||
|
public final float pRadius;
|
||||||
|
public final int fuseTime;
|
||||||
|
|
||||||
|
public enderTNTBlock(Properties p_57422_, float pRadius, int fuseTime) {
|
||||||
|
super(p_57422_);
|
||||||
|
this.pRadius = pRadius;
|
||||||
|
this.fuseTime = fuseTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCaughtFire(@NotNull BlockState state, @NotNull Level world, @NotNull BlockPos pos, @Nullable Direction face, @Nullable LivingEntity igniter) {
|
||||||
|
explode(world, pos, igniter, this.pRadius, this.fuseTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public static void explode(Level p_57434_, BlockPos p_57435_, float pRadius, int fuseTime) {
|
||||||
|
explode(p_57434_, p_57435_, null, pRadius, fuseTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
private static void explode(Level level, BlockPos blockPos, @Nullable LivingEntity entity, float pRadius, int fuseTime) {
|
||||||
|
if (!level.isClientSide) {
|
||||||
|
BlockPos pos = getSpawnPos(level, blockPos);
|
||||||
|
if (pos != null) {
|
||||||
|
enderPrimedTNT primedtnt = new enderPrimedTNT(level, pos.getX() + 0.5F, pos.getY(), pos.getZ() + 0.5F, entity, pRadius, fuseTime);
|
||||||
|
level.addFreshEntity(primedtnt);
|
||||||
|
level.playSound(null, primedtnt.getX(), primedtnt.getY(), primedtnt.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||||
|
level.gameEvent(entity, GameEvent.PRIME_FUSE, blockPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BlockPos getSpawnPos(Level level, BlockPos blockPos) {
|
||||||
|
int x = blockPos.getX();
|
||||||
|
int y = blockPos.getY();
|
||||||
|
int z = blockPos.getZ();
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
BlockPos pos = new BlockPos(
|
||||||
|
x + level.getRandom().nextInt(-16, 17),
|
||||||
|
y + level.getRandom().nextInt(-16, 17),
|
||||||
|
z + level.getRandom().nextInt(-16, 17));
|
||||||
|
if (level.isEmptyBlock(pos)) {
|
||||||
|
int ymax = level.getHeight(Heightmap.Types.WORLD_SURFACE, pos.getX(), pos.getZ());
|
||||||
|
if (ymax < pos.getY()) {
|
||||||
|
return new BlockPos(pos.getX(), ymax, pos.getZ());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void wasExploded(Level level, @NotNull BlockPos blockPos, @NotNull Explosion pExplosion) {
|
||||||
|
if (!level.isClientSide) {
|
||||||
|
BlockPos pos = getSpawnPos(level, blockPos);
|
||||||
|
if (pos != null) {
|
||||||
|
enderPrimedTNT primedtnt = new enderPrimedTNT(level, pos.getX() + 0.5F, pos.getY(), pos.getZ() + 0.5F, pExplosion.getIndirectSourceEntity(), pRadius, fuseTime);
|
||||||
|
int i = primedtnt.getFuse();
|
||||||
|
primedtnt.setFuse((short) (level.random.nextInt(i / 4) + i / 8));
|
||||||
|
level.addFreshEntity(primedtnt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -28,6 +28,7 @@ public class creativeTab {
|
|||||||
output.accept(blocks.TNT_BLACK_HOLE.get());
|
output.accept(blocks.TNT_BLACK_HOLE.get());
|
||||||
output.accept(blocks.TNT_CLAYMORE.get());
|
output.accept(blocks.TNT_CLAYMORE.get());
|
||||||
output.accept(blocks.TNT_SELECTIVE.get());
|
output.accept(blocks.TNT_SELECTIVE.get());
|
||||||
|
output.accept(blocks.TNT_ENDER.get());
|
||||||
output.accept(items.TNT_ARROW.get());
|
output.accept(items.TNT_ARROW.get());
|
||||||
output.accept(items.CONCUSSIVE_ARROW.get());
|
output.accept(items.CONCUSSIVE_ARROW.get());
|
||||||
output.accept(items.CARPET_ARROW.get());
|
output.accept(items.CARPET_ARROW.get());
|
||||||
|
@ -26,6 +26,7 @@ public class ModBlockStateProvider extends BlockStateProvider {
|
|||||||
sideTopBottom(blocks.TNT_32.get());
|
sideTopBottom(blocks.TNT_32.get());
|
||||||
sideTopBottom(blocks.TNT_64.get());
|
sideTopBottom(blocks.TNT_64.get());
|
||||||
sideTopBottom(blocks.TNT_128.get());
|
sideTopBottom(blocks.TNT_128.get());
|
||||||
|
sideTopBottom(blocks.TNT_ENDER.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void blockWithItem(RegistryObject<Block> blockRegistryObject) {
|
private void blockWithItem(RegistryObject<Block> blockRegistryObject) {
|
||||||
|
@ -48,6 +48,7 @@ public class BaseTNTRenderer extends EntityRenderer<basePrimedTNT> {
|
|||||||
case "stronger_64" -> blocks.TNT_64.get();
|
case "stronger_64" -> blocks.TNT_64.get();
|
||||||
case "stronger_128" -> blocks.TNT_128.get();
|
case "stronger_128" -> blocks.TNT_128.get();
|
||||||
case "homing" -> blocks.TNT_HOMING.get();
|
case "homing" -> blocks.TNT_HOMING.get();
|
||||||
|
case "ender" -> blocks.TNT_ENDER.get();
|
||||||
default -> Blocks.NETHER_PORTAL; // placeholder for debugging
|
default -> Blocks.NETHER_PORTAL; // placeholder for debugging
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,6 +45,10 @@ public class entities {
|
|||||||
ENTITY_TYPES.register("tnt_claymore", () -> EntityType.Builder.<claymorePrimedTNT>of(claymorePrimedTNT::new, MobCategory.MISC)
|
ENTITY_TYPES.register("tnt_claymore", () -> EntityType.Builder.<claymorePrimedTNT>of(claymorePrimedTNT::new, MobCategory.MISC)
|
||||||
.sized(0.98F, 0.7F).fireImmune().clientTrackingRange(8).build("tnt_claymore"));
|
.sized(0.98F, 0.7F).fireImmune().clientTrackingRange(8).build("tnt_claymore"));
|
||||||
|
|
||||||
|
public static final RegistryObject<EntityType<enderPrimedTNT>> TNT_ENDER =
|
||||||
|
ENTITY_TYPES.register("tnt_ender", () -> EntityType.Builder.<enderPrimedTNT>of(enderPrimedTNT::new, MobCategory.MISC)
|
||||||
|
.sized(0.98F, 0.7F).fireImmune().clientTrackingRange(8).build("tnt_ender"));
|
||||||
|
|
||||||
public static final RegistryObject<EntityType<tntArrow>> ARROW_TNT =
|
public static final RegistryObject<EntityType<tntArrow>> ARROW_TNT =
|
||||||
ENTITY_TYPES.register("arrow_tnt", () -> EntityType.Builder.<tntArrow>of(tntArrow::new, MobCategory.MISC)
|
ENTITY_TYPES.register("arrow_tnt", () -> EntityType.Builder.<tntArrow>of(tntArrow::new, MobCategory.MISC)
|
||||||
.sized(0.48F, 0.48F).clientTrackingRange(64).build("arrow_tnt"));
|
.sized(0.48F, 0.48F).clientTrackingRange(64).build("arrow_tnt"));
|
||||||
@ -71,12 +75,13 @@ public class entities {
|
|||||||
EntityRenderers.register(TNT_BLACK_HOLE.get(), BaseTNTRenderer::new);
|
EntityRenderers.register(TNT_BLACK_HOLE.get(), BaseTNTRenderer::new);
|
||||||
EntityRenderers.register(TNT_CLAYMORE.get(), BaseTNTRenderer::new);
|
EntityRenderers.register(TNT_CLAYMORE.get(), BaseTNTRenderer::new);
|
||||||
EntityRenderers.register(TNT_SELECTIVE.get(), BaseTNTRenderer::new);
|
EntityRenderers.register(TNT_SELECTIVE.get(), BaseTNTRenderer::new);
|
||||||
|
EntityRenderers.register(TNT_ENDER.get(), BaseTNTRenderer::new);
|
||||||
|
|
||||||
EntityRenderers.register(TNT_CLUSTER.get(), clusterTNTRenderer::new);
|
EntityRenderers.register(TNT_CLUSTER.get(), clusterTNTRenderer::new);
|
||||||
|
EntityRenderers.register(DYNAMITE.get(), clusterTNTRenderer::new);
|
||||||
|
|
||||||
EntityRenderers.register(ARROW_TNT.get(), TNTArrowRenderer::new);
|
EntityRenderers.register(ARROW_TNT.get(), TNTArrowRenderer::new);
|
||||||
EntityRenderers.register(ARROW_CONCUSSIVE.get(), TNTArrowRenderer::new);
|
EntityRenderers.register(ARROW_CONCUSSIVE.get(), TNTArrowRenderer::new);
|
||||||
EntityRenderers.register(ARROW_CARPET.get(), TNTArrowRenderer::new);
|
EntityRenderers.register(ARROW_CARPET.get(), TNTArrowRenderer::new);
|
||||||
|
|
||||||
EntityRenderers.register(DYNAMITE.get(), clusterTNTRenderer::new);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.jenny.enhancedexplosives.entities.tnt;
|
||||||
|
|
||||||
|
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.phys.Vec3;
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
public enderPrimedTNT(EntityType<enderPrimedTNT> entityType, Level level) {
|
||||||
|
super(entityType, level, null);
|
||||||
|
setRenderID("ender");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -11,6 +11,7 @@
|
|||||||
"block.enhancedexplosives.tnt_black_hole": "Black Hole TNT",
|
"block.enhancedexplosives.tnt_black_hole": "Black Hole TNT",
|
||||||
"block.enhancedexplosives.tnt_claymore": "Claymore TNT",
|
"block.enhancedexplosives.tnt_claymore": "Claymore TNT",
|
||||||
"block.enhancedexplosives.tnt_selective": "Selective TNT",
|
"block.enhancedexplosives.tnt_selective": "Selective TNT",
|
||||||
|
"block.enhancedexplosives.tnt_ender": "Ender TNT",
|
||||||
|
|
||||||
"item.enhancedexplosives.arrow_tnt": "TNT Arrow",
|
"item.enhancedexplosives.arrow_tnt": "TNT Arrow",
|
||||||
"item.enhancedexplosives.arrow_concussive": "Concussive Arrow",
|
"item.enhancedexplosives.arrow_concussive": "Concussive Arrow",
|
||||||
@ -24,6 +25,7 @@
|
|||||||
"tooltip.enhancedexplosives.tnt_black_hole": "pulls all entities towards itself",
|
"tooltip.enhancedexplosives.tnt_black_hole": "pulls all entities towards itself",
|
||||||
"tooltip.enhancedexplosives.tnt_claymore": "throws arrows into all direcctions upon explosion",
|
"tooltip.enhancedexplosives.tnt_claymore": "throws arrows into all direcctions upon explosion",
|
||||||
"tooltip.enhancedexplosives.tnt_selective": "only destroys the type of block it explodes on",
|
"tooltip.enhancedexplosives.tnt_selective": "only destroys the type of block it explodes on",
|
||||||
|
"tooltip.enhancedexplosives.tnt_ender": "teleports in a 16 block radius upon priming",
|
||||||
|
|
||||||
"tooltip.enhancedexplosives.arrow_tnt": "explodes on impact",
|
"tooltip.enhancedexplosives.arrow_tnt": "explodes on impact",
|
||||||
"tooltip.enhancedexplosives.arrow_concussive": "explodes on impact without block damage",
|
"tooltip.enhancedexplosives.arrow_concussive": "explodes on impact without block damage",
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 151 B |
Binary file not shown.
After Width: | Height: | Size: 775 B |
Binary file not shown.
After Width: | Height: | Size: 508 B |
Loading…
x
Reference in New Issue
Block a user