add claymore tnt (missing textures)
This commit is contained in:
		
							parent
							
								
									183d0fe38a
								
							
						
					
					
						commit
						8b5c7b53a5
					
				@ -38,7 +38,7 @@ mod_name=Compressed TNT
 | 
				
			|||||||
# 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.2.0
 | 
					mod_version=0.3.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
 | 
				
			||||||
 | 
				
			|||||||
@ -46,6 +46,9 @@ public class blocks {
 | 
				
			|||||||
    public static final RegistryObject<Block> TNT_BLACK_HOLE= BLOCKS.register("tnt_black_hole", () -> new blackHoleTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 1));
 | 
					    public static final RegistryObject<Block> TNT_BLACK_HOLE= BLOCKS.register("tnt_black_hole", () -> new blackHoleTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 1));
 | 
				
			||||||
    public static final RegistryObject<Item> TNT_BLACK_HOLE_ITEM = ITEMS.register("tnt_black_hole", () -> new BlockItem(TNT_BLACK_HOLE.get(), new Item.Properties()));
 | 
					    public static final RegistryObject<Item> TNT_BLACK_HOLE_ITEM = ITEMS.register("tnt_black_hole", () -> new BlockItem(TNT_BLACK_HOLE.get(), new Item.Properties()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static final RegistryObject<Block> TNT_CLAYMORE= BLOCKS.register("tnt_claymore", () -> new claymoreTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 2.0f, 20, 256));
 | 
				
			||||||
 | 
					    public static final RegistryObject<Item> TNT_CLAYMORE_ITEM = ITEMS.register("tnt_claymore", () -> new BlockItem(TNT_CLAYMORE.get(), new Item.Properties()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static void register(IEventBus bus) {
 | 
					    public static void register(IEventBus bus) {
 | 
				
			||||||
        BLOCKS.register(bus);
 | 
					        BLOCKS.register(bus);
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,59 @@
 | 
				
			|||||||
 | 
					package com.jenny.compressedtnt.blocks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.jenny.compressedtnt.entities.claymorePrimedTNT;
 | 
				
			||||||
 | 
					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.entity.player.Player;
 | 
				
			||||||
 | 
					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 org.jetbrains.annotations.NotNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Nullable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class claymoreTNTBlock extends TntBlock {
 | 
				
			||||||
 | 
					    public final float pRadius;
 | 
				
			||||||
 | 
					    public final int fuseTime;
 | 
				
			||||||
 | 
					    public final int projectileCount;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public claymoreTNTBlock(Properties p_57422_, float pRadius, int fuseTime, int projectileCount) {
 | 
				
			||||||
 | 
					        super(p_57422_);
 | 
				
			||||||
 | 
					        this.pRadius = pRadius;
 | 
				
			||||||
 | 
					        this.fuseTime = fuseTime;
 | 
				
			||||||
 | 
					        this.projectileCount = projectileCount;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @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, this.projectileCount);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Deprecated
 | 
				
			||||||
 | 
					    public static void explode(Level p_57434_, BlockPos p_57435_, float pRadius, int fuseTime, int projectileCount) {
 | 
				
			||||||
 | 
					        explode(p_57434_, p_57435_, (LivingEntity)null, pRadius, fuseTime, projectileCount);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Deprecated
 | 
				
			||||||
 | 
					    private static void explode(Level level, BlockPos blockPos, @Nullable LivingEntity entity, float pRadius, int fuseTime, int projectileCount) {
 | 
				
			||||||
 | 
					        if (!level.isClientSide) {
 | 
				
			||||||
 | 
					            claymorePrimedTNT primedtnt = new claymorePrimedTNT(level, (double) blockPos.getX() + (double) 0.5F, (double) blockPos.getY(), (double) blockPos.getZ() + (double) 0.5F, entity, pRadius, fuseTime, projectileCount);
 | 
				
			||||||
 | 
					            level.addFreshEntity(primedtnt);
 | 
				
			||||||
 | 
					            level.gameEvent(entity, GameEvent.PRIME_FUSE, blockPos);
 | 
				
			||||||
 | 
					            level.playSound((Player) null, blockPos.getX(), blockPos.getY(), blockPos.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void wasExploded(Level level, @NotNull BlockPos blockPos, @NotNull Explosion pExplosion) {
 | 
				
			||||||
 | 
					        if (!level.isClientSide) {
 | 
				
			||||||
 | 
					            int ft = (short) (level.random.nextInt(fuseTime / 4) + fuseTime / 8);
 | 
				
			||||||
 | 
					            claymorePrimedTNT primedtnt = new claymorePrimedTNT(level, (double) blockPos.getX() + (double) 0.5F, (double) blockPos.getY(), (double) blockPos.getZ() + (double) 0.5F, pExplosion.getIndirectSourceEntity(), pRadius, ft, projectileCount);
 | 
				
			||||||
 | 
					            level.addFreshEntity(primedtnt);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -25,6 +25,7 @@ public class creativeTab {
 | 
				
			|||||||
        output.accept(blocks.TNT_CLUSTER_8.get());
 | 
					        output.accept(blocks.TNT_CLUSTER_8.get());
 | 
				
			||||||
        output.accept(blocks.TNT_HOMING.get());
 | 
					        output.accept(blocks.TNT_HOMING.get());
 | 
				
			||||||
        output.accept(blocks.TNT_BLACK_HOLE.get());
 | 
					        output.accept(blocks.TNT_BLACK_HOLE.get());
 | 
				
			||||||
 | 
					        output.accept(blocks.TNT_CLAYMORE.get());
 | 
				
			||||||
    }).title(Component.literal("Compressed TNT")).build());
 | 
					    }).title(Component.literal("Compressed TNT")).build());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static void register(IEventBus bus) {
 | 
					    public static void register(IEventBus bus) {
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,76 @@
 | 
				
			|||||||
 | 
					package com.jenny.compressedtnt.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.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.phys.Vec3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Nullable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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");
 | 
				
			||||||
 | 
					        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);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @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));
 | 
				
			||||||
 | 
					            level().addFreshEntity(e);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void addAdditionalSaveData(CompoundTag pCompound) {
 | 
				
			||||||
 | 
					        pCompound.putFloat("ProjectileCount", this.getPCount());
 | 
				
			||||||
 | 
					        super.addAdditionalSaveData(pCompound);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void readAdditionalSaveData(CompoundTag pCompound) {
 | 
				
			||||||
 | 
					        this.setPCount(pCompound.getInt("ProjectileCount"));
 | 
				
			||||||
 | 
					        super.readAdditionalSaveData(pCompound);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setPCount(int pCount) {
 | 
				
			||||||
 | 
					        this.entityData.set(DATA_PCOUNT_ID, pCount);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public int getPCount() {
 | 
				
			||||||
 | 
					        return this.entityData.get(DATA_PCOUNT_ID);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void defineSynchedData() {
 | 
				
			||||||
 | 
					        this.entityData.define(DATA_PCOUNT_ID, 16);
 | 
				
			||||||
 | 
					        super.defineSynchedData();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -29,8 +29,12 @@ public class entities {
 | 
				
			|||||||
                    .sized(0.48F, 0.48F).fireImmune().clientTrackingRange(8).build("tnt_cluster"));
 | 
					                    .sized(0.48F, 0.48F).fireImmune().clientTrackingRange(8).build("tnt_cluster"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static final RegistryObject<EntityType<blackHolePrimedTNT>> TNT_BLACK_HOLE =
 | 
					    public static final RegistryObject<EntityType<blackHolePrimedTNT>> TNT_BLACK_HOLE =
 | 
				
			||||||
            ENTITY_TYPES.register("tnt_chunk", () -> EntityType.Builder.<blackHolePrimedTNT>of(blackHolePrimedTNT::new, MobCategory.MISC)
 | 
					            ENTITY_TYPES.register("tnt_blackhole", () -> EntityType.Builder.<blackHolePrimedTNT>of(blackHolePrimedTNT::new, MobCategory.MISC)
 | 
				
			||||||
                    .sized(0.98F, 0.7F).fireImmune().clientTrackingRange(8).build("tnt_chunk"));
 | 
					                    .sized(0.98F, 0.7F).fireImmune().clientTrackingRange(8).build("tnt_blackhole"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static final RegistryObject<EntityType<claymorePrimedTNT>> TNT_CLAYMORE =
 | 
				
			||||||
 | 
					            ENTITY_TYPES.register("tnt_claymore", () -> EntityType.Builder.<claymorePrimedTNT>of(claymorePrimedTNT::new, MobCategory.MISC)
 | 
				
			||||||
 | 
					                    .sized(0.98F, 0.7F).fireImmune().clientTrackingRange(8).build("tnt_claymore"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static void register(IEventBus eventBus) {
 | 
					    public static void register(IEventBus eventBus) {
 | 
				
			||||||
        ENTITY_TYPES.register(eventBus);
 | 
					        ENTITY_TYPES.register(eventBus);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user