diff --git a/projects/pswg/src/main/java/com/parzivail/pswg/block/ThermalDetonatorBlock.java b/projects/pswg/src/main/java/com/parzivail/pswg/block/ThermalDetonatorBlock.java new file mode 100644 index 000000000..c056fd334 --- /dev/null +++ b/projects/pswg/src/main/java/com/parzivail/pswg/block/ThermalDetonatorBlock.java @@ -0,0 +1,72 @@ +package com.parzivail.pswg.block; + +import com.parzivail.pswg.container.SwgEntities; +import com.parzivail.pswg.entity.BlasterBoltEntity; +import com.parzivail.pswg.entity.ThermalDetonatorEntity; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.projectile.ArrowEntity; +import net.minecraft.entity.projectile.ProjectileEntity; +import net.minecraft.text.Text; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.explosion.Explosion; + +public class ThermalDetonatorBlock extends Block +{ + + public ThermalDetonatorBlock(Settings settings) + { + super(settings); + } + + @Override + public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) + { + if (entity instanceof BlasterBoltEntity) + { + var tde = new ThermalDetonatorEntity(SwgEntities.Misc.ThermalDetonator, world); + tde.setPos(pos.getX(), pos.getY(), pos.getZ()); + tde.setPrimed(true); + tde.setLife(0); + world.spawnEntity(tde); + } + if (entity instanceof PlayerEntity player) + { + player.sendMessage(Text.of("IHATEYOU"), true); + } + super.onEntityCollision(state, world, pos, entity); + } + + @Override + public void onProjectileHit(World world, BlockState state, BlockHitResult hit, ProjectileEntity projectile) + { + if (projectile instanceof BlasterBoltEntity bbe) + { + explode(world, hit.getBlockPos()); + } + super.onProjectileHit(world, state, hit, projectile); + } + + @Override + public void onDestroyedByExplosion(World world, BlockPos pos, Explosion explosion) + { + explode(world, pos); + super.onDestroyedByExplosion(world, pos, explosion); + } + + public void explode(World world, BlockPos blockPos) + { + world.setBlockState(blockPos, Blocks.AIR.getDefaultState(), Block.NOTIFY_ALL | Block.REDRAW_ON_MAIN_THREAD); + var tde = new ThermalDetonatorEntity(SwgEntities.Misc.ThermalDetonator, world); + tde.setPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + tde.setPrimed(true); + tde.setLife(0); + + world.spawnEntity(tde); + } +} diff --git a/projects/pswg/src/main/java/com/parzivail/pswg/client/sound/SoundHelper.java b/projects/pswg/src/main/java/com/parzivail/pswg/client/sound/SoundHelper.java index 8b9fc22e5..db2aad682 100644 --- a/projects/pswg/src/main/java/com/parzivail/pswg/client/sound/SoundHelper.java +++ b/projects/pswg/src/main/java/com/parzivail/pswg/client/sound/SoundHelper.java @@ -4,6 +4,7 @@ import com.parzivail.pswg.features.lightsabers.client.ThrownLightsaberEntity; import net.minecraft.client.MinecraftClient; import net.minecraft.client.sound.SoundInstance; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.sound.SoundEvent; public class SoundHelper diff --git a/projects/pswg/src/main/java/com/parzivail/pswg/client/sound/ThermalDetonatorEntitySoundInstance.java b/projects/pswg/src/main/java/com/parzivail/pswg/client/sound/ThermalDetonatorEntitySoundInstance.java new file mode 100644 index 000000000..12c82d69b --- /dev/null +++ b/projects/pswg/src/main/java/com/parzivail/pswg/client/sound/ThermalDetonatorEntitySoundInstance.java @@ -0,0 +1,64 @@ +package com.parzivail.pswg.client.sound; + +import com.parzivail.pswg.container.SwgSounds; +import com.parzivail.pswg.entity.ThermalDetonatorEntity; +import com.parzivail.pswg.item.ThermalDetonatorItem; +import com.parzivail.pswg.item.ThermalDetonatorTag; +import com.parzivail.util.sound.DopplerSoundInstance; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.sound.MovingSoundInstance; +import net.minecraft.client.sound.SoundInstance; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.sound.SoundCategory; +import net.minecraft.text.Text; + +@Environment(EnvType.CLIENT) +public class ThermalDetonatorEntitySoundInstance extends MovingSoundInstance +{ + private final ThermalDetonatorEntity detonatorEntity; + + public ThermalDetonatorEntitySoundInstance(ThermalDetonatorEntity detonatorEntity) + { + super(SwgSounds.Explosives.THERMAL_DETONATOR_BEEP, SoundCategory.PLAYERS, SoundInstance.createRandom()); + this.detonatorEntity = detonatorEntity; + this.repeat = true; + this.repeatDelay = 0; + this.volume = 1F; + this.x = (float)detonatorEntity.getX(); + this.y = (float)detonatorEntity.getY(); + this.z = (float)detonatorEntity.getZ(); + } + + @Override + public void tick() + { + + if (detonatorEntity.isRemoved() || !areConditionsMet(detonatorEntity)) + { + setDone(); + return; + } + x = (float)this.detonatorEntity.getX(); + y = (float)this.detonatorEntity.getY(); + z = (float)this.detonatorEntity.getZ(); + float distanceToPlayer32 = 32; + if (detonatorEntity.getWorld().getClosestPlayer(detonatorEntity, 32) != null) + { + distanceToPlayer32 = detonatorEntity.getWorld().getClosestPlayer(detonatorEntity, 32).distanceTo(detonatorEntity); + } + volume = ((32 - distanceToPlayer32) / 32); + //detonatorEntity.getWorld().getClosestPlayer(detonatorEntity, 32).sendMessage(Text.of(""+volume), true); + + } + + public static boolean areConditionsMet(ThermalDetonatorEntity tde) + { + if (tde.isPrimed()) + { + return true; + } + return false; + } +} diff --git a/projects/pswg/src/main/java/com/parzivail/pswg/client/sound/ThermalDetonatorItemSoundInstance.java b/projects/pswg/src/main/java/com/parzivail/pswg/client/sound/ThermalDetonatorItemSoundInstance.java new file mode 100644 index 000000000..c7e88767b --- /dev/null +++ b/projects/pswg/src/main/java/com/parzivail/pswg/client/sound/ThermalDetonatorItemSoundInstance.java @@ -0,0 +1,102 @@ +package com.parzivail.pswg.client.sound; + +import com.parzivail.pswg.container.SwgSounds; +import com.parzivail.pswg.features.lightsabers.LightsaberItem; +import com.parzivail.pswg.features.lightsabers.data.LightsaberTag; +import com.parzivail.pswg.item.ThermalDetonatorItem; +import com.parzivail.pswg.item.ThermalDetonatorTag; +import com.parzivail.util.sound.DopplerSoundInstance; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.sound.SoundInstance; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.sound.SoundCategory; + +@Environment(EnvType.CLIENT) +public class ThermalDetonatorItemSoundInstance extends DopplerSoundInstance +{ + private final PlayerEntity player; + + public ThermalDetonatorItemSoundInstance(PlayerEntity player) + { + super(player, SwgSounds.Explosives.THERMAL_DETONATOR_BEEP, SoundCategory.PLAYERS, SoundInstance.createRandom()); + this.player = player; + this.repeat = true; + this.repeatDelay = 0; + this.volume = 0.75F; + this.x = (float)player.getX(); + this.y = (float)player.getY(); + this.z = (float)player.getZ(); + } + + @Override + public boolean canPlay() + { + return !this.player.isSilent(); + } + + @Override + public boolean shouldAlwaysPlay() + { + return true; + } + + @Override + public void tick() + { + super.tick(); + + if (this.player.isRemoved()) + { + this.setDone(); + return; + } + + var foundDetonator = false; + + if (player.getMainHandStack().getItem() instanceof ThermalDetonatorItem) + foundDetonator = true; + + if (!foundDetonator && player.getOffHandStack().getItem() instanceof ThermalDetonatorItem) + foundDetonator = true; + + if (!areConditionsMet(player)) + { + this.setDone(); + return; + } + if (foundDetonator) + { + volume = 0.75f; + } + else + { + volume = 0.25f; + } + + this.x = (float)this.player.getX(); + this.y = (float)this.player.getY(); + this.z = (float)this.player.getZ(); + } + + public static boolean areConditionsMet(PlayerEntity player) + { + //return isPrimed(player.getMainHandStack()) || isPrimed(player.getOffHandStack()); + for (int i = 0; i < player.getInventory().size(); i++) + if (player.getInventory().getStack(i).getItem() instanceof ThermalDetonatorItem) + { + return isPrimed(player.getInventory().getStack(i)); + } + return false; + } + + private static boolean isPrimed(ItemStack stack) + { + if (!(stack.getItem() instanceof ThermalDetonatorItem)) + return false; + + var tdt = new ThermalDetonatorTag(stack.getOrCreateNbt()); + return tdt.primed; + } +} diff --git a/projects/pswg/src/main/java/com/parzivail/pswg/container/SwgBlocks.java b/projects/pswg/src/main/java/com/parzivail/pswg/container/SwgBlocks.java index 193f1d5e0..78802e79a 100644 --- a/projects/pswg/src/main/java/com/parzivail/pswg/container/SwgBlocks.java +++ b/projects/pswg/src/main/java/com/parzivail/pswg/container/SwgBlocks.java @@ -930,6 +930,14 @@ public static class Cage public static final BlockEntityType CreatureCageBlockEntityType = FabricBlockEntityTypeBuilder.create(CreatureCageBlockEntity::new, BlockUtil.concat(DyedCreatureTerrarium, CreatureTerrarium, Creature)).build(); } + @RegistryOrder(26) + public static class Misc + { + @RegistryName("thermal_detonator_block") + @ClientBlockRegistryData(renderLayer = RenderLayerHint.CUTOUT_MIPPED) + public static final ThermalDetonatorBlock ThermalDetonatorBlock = new ThermalDetonatorBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).nonOpaque().strength(0.5F)); + } + public static void register() { RegistryHelper.registerAutoId(Resources.MODID, SwgBlocks.class, Object.class, SwgBlocks::tryRegisterBlock); diff --git a/projects/pswg/src/main/java/com/parzivail/pswg/container/SwgSounds.java b/projects/pswg/src/main/java/com/parzivail/pswg/container/SwgSounds.java index cf17103a6..1bb448bd3 100644 --- a/projects/pswg/src/main/java/com/parzivail/pswg/container/SwgSounds.java +++ b/projects/pswg/src/main/java/com/parzivail/pswg/container/SwgSounds.java @@ -26,6 +26,7 @@ public static void register() Lightsaber.register(); Blaster.register(); Ship.register(); + Explosives.register(); for (var pair : SOUND_EVENTS.entrySet()) Registry.register(Registries.SOUND_EVENT, pair.getKey(), pair.getValue()); @@ -118,4 +119,14 @@ private static void register() { } } + + public static class Explosives + { + public static final SoundEvent THERMAL_DETONATOR_BEEP = of(Resources.id("explosives.thermaldetonator.beep")); + public static final SoundEvent THERMAL_DETONATOR_ARM = of(Resources.id("explosives.thermaldetonator.arm")); + public static final SoundEvent THERMAL_DETONATOR_EXPLOSION = of(Resources.id("explosives.thermaldetonator.explode")); + private static void register() + { + } + } } diff --git a/projects/pswg/src/main/java/com/parzivail/pswg/entity/BlasterBoltEntity.java b/projects/pswg/src/main/java/com/parzivail/pswg/entity/BlasterBoltEntity.java index 8940fde2e..07ac57458 100644 --- a/projects/pswg/src/main/java/com/parzivail/pswg/entity/BlasterBoltEntity.java +++ b/projects/pswg/src/main/java/com/parzivail/pswg/entity/BlasterBoltEntity.java @@ -1,6 +1,7 @@ package com.parzivail.pswg.entity; import com.parzivail.pswg.Resources; +import com.parzivail.pswg.block.ThermalDetonatorBlock; import com.parzivail.pswg.container.SwgDamageTypes; import com.parzivail.pswg.container.SwgPackets; import com.parzivail.pswg.container.SwgParticles; @@ -307,7 +308,10 @@ protected void onCollision(HitResult hitResult) var state = getWorld().getBlockState(blockPos); if(state.getBlock() instanceof TargetBlock targetBlock){ targetBlock.onProjectileHit(getWorld(), state, blockHit, this); - + } + else if (state.getBlock() instanceof ThermalDetonatorBlock tdb) + { + tdb.explode(getWorld(), blockPos); } if (state.isIn(SwgTags.Blocks.BLASTER_REFLECT)) diff --git a/projects/pswg/src/main/java/com/parzivail/pswg/entity/ThermalDetonatorEntity.java b/projects/pswg/src/main/java/com/parzivail/pswg/entity/ThermalDetonatorEntity.java index 796400e76..72c322412 100644 --- a/projects/pswg/src/main/java/com/parzivail/pswg/entity/ThermalDetonatorEntity.java +++ b/projects/pswg/src/main/java/com/parzivail/pswg/entity/ThermalDetonatorEntity.java @@ -1,24 +1,63 @@ package com.parzivail.pswg.entity; +import com.parzivail.pswg.client.sound.ThermalDetonatorEntitySoundInstance; +import com.parzivail.pswg.client.sound.ThermalDetonatorItemSoundInstance; +import com.parzivail.pswg.container.SwgItems; import com.parzivail.pswg.container.SwgParticles; +import com.parzivail.pswg.container.SwgSounds; import com.parzivail.util.entity.IPrecisionSpawnEntity; import com.parzivail.util.entity.IPrecisionVelocityEntity; +import com.parzivail.util.entity.collision.IComplexEntityHitbox; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.sound.SoundManager; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityDimensions; +import net.minecraft.entity.EntityPose; import net.minecraft.entity.EntityType; +import net.minecraft.entity.damage.DamageSource; +import net.minecraft.entity.damage.DamageTypes; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket; import net.minecraft.particle.ParticleTypes; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; +import net.minecraft.sound.SoundCategory; +import net.minecraft.sound.SoundEvents; +import net.minecraft.text.Text; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.hit.EntityHitResult; import net.minecraft.util.hit.HitResult; +import net.minecraft.util.math.Box; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; +import java.util.Objects; + public class ThermalDetonatorEntity extends ThrowableExplosive implements IPrecisionSpawnEntity, IPrecisionVelocityEntity { public int texturePhase = 0; + public ThermalDetonatorEntitySoundInstance soundInstance = new ThermalDetonatorEntitySoundInstance(this); public ThermalDetonatorEntity(EntityType type, World world) { super(type, world); setExplosionPower(5f); + if (getWorld() instanceof ClientWorld) + { + MinecraftClient.getInstance().getSoundManager().play(soundInstance); + } + } + + @Override + public void explode() + { + getWorld().playSound(null, getBlockPos(), SwgSounds.Explosives.THERMAL_DETONATOR_EXPLOSION, SoundCategory.PLAYERS, 1f, 1f); + MinecraftClient.getInstance().getSoundManager().stop(soundInstance); + super.explode(); } @Override @@ -78,4 +117,22 @@ protected void onCollision(HitResult hitResult) super.onCollision(hitResult); } + + @Override + public ActionResult interact(PlayerEntity player, Hand hand) + { + if (!isPrimed() && age > 30) + { + getWorld().spawnEntity(dropItem(SwgItems.Explosives.ThermalDetonator)); + + this.discard(); + } + return super.interact(player, hand); + } + + @Override + public boolean canHit() + { + return true; + } } diff --git a/projects/pswg/src/main/java/com/parzivail/pswg/entity/ThrowableExplosive.java b/projects/pswg/src/main/java/com/parzivail/pswg/entity/ThrowableExplosive.java index a727e29d4..5c74f7e1a 100644 --- a/projects/pswg/src/main/java/com/parzivail/pswg/entity/ThrowableExplosive.java +++ b/projects/pswg/src/main/java/com/parzivail/pswg/entity/ThrowableExplosive.java @@ -1,5 +1,6 @@ package com.parzivail.pswg.entity; +import com.parzivail.pswg.container.SwgItems; import com.parzivail.pswg.container.SwgTags; import com.parzivail.util.entity.IPrecisionSpawnEntity; import com.parzivail.util.entity.IPrecisionVelocityEntity; @@ -7,14 +8,18 @@ import com.parzivail.util.network.PreciseEntitySpawnS2CPacket; import net.minecraft.entity.EntityType; import net.minecraft.entity.damage.DamageSource; +import net.minecraft.entity.damage.DamageTypes; import net.minecraft.entity.data.DataTracker; import net.minecraft.entity.data.TrackedData; import net.minecraft.entity.data.TrackedDataHandlerRegistry; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.thrown.ThrownEntity; import net.minecraft.nbt.NbtCompound; import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket; import net.minecraft.registry.tag.DamageTypeTags; import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.HitResult; import net.minecraft.util.math.Direction; @@ -91,13 +96,10 @@ public void tick() { if (isPrimed()) this.explode(); - else - this.discard(); } super.tick(); } - public float getExplosionPower() { return explosionPower; diff --git a/projects/pswg/src/main/java/com/parzivail/pswg/item/ThermalDetonatorItem.java b/projects/pswg/src/main/java/com/parzivail/pswg/item/ThermalDetonatorItem.java index 6a9336dec..0b1ec6e6e 100644 --- a/projects/pswg/src/main/java/com/parzivail/pswg/item/ThermalDetonatorItem.java +++ b/projects/pswg/src/main/java/com/parzivail/pswg/item/ThermalDetonatorItem.java @@ -1,9 +1,9 @@ package com.parzivail.pswg.item; import com.parzivail.pswg.Resources; -import com.parzivail.pswg.container.SwgDamageTypes; -import com.parzivail.pswg.container.SwgEntities; -import com.parzivail.pswg.container.SwgItems; +import com.parzivail.pswg.client.sound.SoundHelper; +import com.parzivail.pswg.client.sound.ThermalDetonatorItemSoundInstance; +import com.parzivail.pswg.container.*; import com.parzivail.pswg.entity.ThermalDetonatorEntity; import com.parzivail.tarkin.api.TarkinLang; import com.parzivail.util.client.TextUtil; @@ -13,13 +13,14 @@ import com.parzivail.util.item.ILeftClickConsumer; import net.minecraft.client.MinecraftClient; import net.minecraft.client.item.TooltipContext; +import net.minecraft.client.sound.SoundInstance; +import net.minecraft.client.sound.SoundManager; +import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemConvertible; -import net.minecraft.item.ItemStack; +import net.minecraft.item.*; import net.minecraft.nbt.NbtCompound; import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket; import net.minecraft.registry.RegistryKeys; @@ -27,23 +28,36 @@ import net.minecraft.sound.SoundEvents; import net.minecraft.stat.Stats; import net.minecraft.text.Text; -import net.minecraft.util.Hand; -import net.minecraft.util.TypedActionResult; -import net.minecraft.util.UseAction; +import net.minecraft.util.*; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; import java.util.List; -public class ThermalDetonatorItem extends Item implements ILeftClickConsumer, IDefaultNbtProvider, ICooldownItem, ICustomVisualItemEquality +public class ThermalDetonatorItem extends BlockItem implements ILeftClickConsumer, IDefaultNbtProvider, ICooldownItem, ICustomVisualItemEquality { + public final int baseTicksToExplosion = 150; + public ThermalDetonatorItemSoundInstance soundInstance; @TarkinLang public static final String I18N_TOOLTIP_CONTROLS = Resources.tooltip("thermal_detonator.controls"); public ThermalDetonatorItem(Settings settings) { - super(settings); + super(SwgBlocks.Misc.ThermalDetonatorBlock, settings); + } + + @Override + public ActionResult useOnBlock(ItemUsageContext context) + { + var stack = context.getStack(); + ThermalDetonatorTag tdt = new ThermalDetonatorTag(stack.getOrCreateNbt()); + if (context.getPlayer().isSneaking() && !tdt.primed) + { + return super.useOnBlock(context); + } + use(context.getWorld(), context.getPlayer(), context.getHand()); + return ActionResult.PASS; } public ThermalDetonatorEntity createThermalDetonator(World world, int life, boolean primed, ItemStack stack, PlayerEntity player) @@ -90,7 +104,7 @@ public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, { stack.decrement(1); } - tdt.ticksToExplosion = 150; + tdt.ticksToExplosion = baseTicksToExplosion; tdt.shouldRender = true; tdt.primed = false; } @@ -108,7 +122,12 @@ public boolean areStacksVisuallyEqual(ItemStack original, ItemStack updated) @Override public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks) { + ThermalDetonatorTag tdt = new ThermalDetonatorTag(stack.getOrCreateNbt()); + if (tdt.primed) + { + MinecraftClient.getInstance().getSoundManager().stop(soundInstance); + } if (user instanceof PlayerEntity playerEntity) { boolean inCreative = playerEntity.getAbilities().creativeMode; @@ -139,7 +158,7 @@ public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int playerEntity.incrementStat(Stats.USED.getOrCreateStat(this)); } } - tdt.ticksToExplosion = 150; + tdt.ticksToExplosion = baseTicksToExplosion; tdt.serializeAsSubtag(stack); } @@ -178,11 +197,25 @@ public TypedActionResult use(World world, PlayerEntity user, Hand han public TypedActionResult useLeft(World world, PlayerEntity user, Hand hand, boolean isRepeatEvent) { ThermalDetonatorTag tdt = new ThermalDetonatorTag(user.getMainHandStack().getOrCreateNbt()); + soundInstance = new ThermalDetonatorItemSoundInstance(user); if (!tdt.primed) { tdt.primed = true; - tdt.ticksToExplosion = 150; + tdt.ticksToExplosion = baseTicksToExplosion; + user.playSound(SwgSounds.Explosives.THERMAL_DETONATOR_ARM, 1f, 1f); + + if (world instanceof ClientWorld) + { + user.playSound(SwgSounds.Explosives.THERMAL_DETONATOR_ARM, 1f, 1f); + MinecraftClient.getInstance().getSoundManager().play(soundInstance); + } } + else + { + tdt.primed = false; + MinecraftClient.getInstance().getSoundManager().stop(soundInstance); + } + tdt.serializeAsSubtag(user.getMainHandStack()); return TypedActionResult.success(user.getMainHandStack()); } @@ -205,7 +238,7 @@ public float getCooldownProgress(PlayerEntity player, World world, ItemStack sta ThermalDetonatorTag tdt = new ThermalDetonatorTag(stack.getOrCreateNbt()); if (tdt.primed) { - return (float)(-150 + tdt.ticksToExplosion) / -150; + return (float)(-baseTicksToExplosion + tdt.ticksToExplosion) / -baseTicksToExplosion; } else { diff --git a/projects/pswg/src/main/resources/assets/pswg/lang/en_us.json b/projects/pswg/src/main/resources/assets/pswg/lang/en_us.json index 6f914e4e2..a98f20297 100644 --- a/projects/pswg/src/main/resources/assets/pswg/lang/en_us.json +++ b/projects/pswg/src/main/resources/assets/pswg/lang/en_us.json @@ -409,6 +409,7 @@ "block.pswg.tall_lamp": "Tall Lamp", "block.pswg.tatooine_log": "Tatooine Log", "block.pswg.tatooine_wood": "Tatooine Wood", + "block.pswg.thermal_detonator_block": "### Thermal Detonator Block", "block.pswg.thorilide_block": "Thorilide Block", "block.pswg.thorilide_ore": "Thorilide Ore", "block.pswg.titanium_block": "Block of Titanium", diff --git a/projects/pswg/src/main/resources/assets/pswg/models/block/thermal_detonator_block.p3d b/projects/pswg/src/main/resources/assets/pswg/models/block/thermal_detonator_block.p3d new file mode 100644 index 000000000..ec65dcbe8 Binary files /dev/null and b/projects/pswg/src/main/resources/assets/pswg/models/block/thermal_detonator_block.p3d differ diff --git a/projects/pswg/src/main/resources/assets/pswg/models/item/thermal_detonator_primed.png.mcmeta b/projects/pswg/src/main/resources/assets/pswg/models/item/thermal_detonator_primed.png.mcmeta new file mode 100644 index 000000000..45f6fb941 --- /dev/null +++ b/projects/pswg/src/main/resources/assets/pswg/models/item/thermal_detonator_primed.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": true, + "frametime": 3 + } +} diff --git a/projects/pswg/src/main/resources/assets/pswg/sounds.json b/projects/pswg/src/main/resources/assets/pswg/sounds.json index 18f921ae5..d2e17bbe9 100644 --- a/projects/pswg/src/main/resources/assets/pswg/sounds.json +++ b/projects/pswg/src/main/resources/assets/pswg/sounds.json @@ -242,5 +242,23 @@ "sounds": [ "pswg:door/pneumatic" ] - } + }, + "explosives.thermaldetonator.beep": { + "subtitle": "subtitle.pswg.explosives.thermaldetonator.beep", + "sounds": [ + "pswg:explosives/thermal_detonator/beep/beep_loop" + ] + }, + "explosives.thermaldetonator.arm": { + "subtitle": "subtitle.pswg.explosives.thermaldetonator.arm", + "sounds": [ + "pswg:explosives/thermal_detonator/beep/arm" + ] + }, + "explosives.thermaldetonator.explode": { + "subtitle": "subtitle.pswg.explosives.thermaldetonator.explode", + "sounds": [ + "pswg:explosives/thermal_detonator/explosion/thermal_detonator_explosion" + ] + } } diff --git a/projects/pswg/src/main/resources/assets/pswg/sounds/explosives/thermal_detonator/beep/arm.ogg b/projects/pswg/src/main/resources/assets/pswg/sounds/explosives/thermal_detonator/beep/arm.ogg new file mode 100644 index 000000000..d1465b080 Binary files /dev/null and b/projects/pswg/src/main/resources/assets/pswg/sounds/explosives/thermal_detonator/beep/arm.ogg differ diff --git a/projects/pswg/src/main/resources/assets/pswg/sounds/explosives/thermal_detonator/beep/beep_loop.ogg b/projects/pswg/src/main/resources/assets/pswg/sounds/explosives/thermal_detonator/beep/beep_loop.ogg new file mode 100644 index 000000000..742e95dee Binary files /dev/null and b/projects/pswg/src/main/resources/assets/pswg/sounds/explosives/thermal_detonator/beep/beep_loop.ogg differ diff --git a/projects/pswg/src/main/resources/assets/pswg/sounds/explosives/thermal_detonator/explosion/thermal_detonator_explosion.ogg b/projects/pswg/src/main/resources/assets/pswg/sounds/explosives/thermal_detonator/explosion/thermal_detonator_explosion.ogg new file mode 100644 index 000000000..e75b783f3 Binary files /dev/null and b/projects/pswg/src/main/resources/assets/pswg/sounds/explosives/thermal_detonator/explosion/thermal_detonator_explosion.ogg differ diff --git a/projects/pswg/src/main/resources/assets/pswg/textures/item/thermal_detonator_primed.png b/projects/pswg/src/main/resources/assets/pswg/textures/item/thermal_detonator_primed.png new file mode 100644 index 000000000..ed5cc0a5b Binary files /dev/null and b/projects/pswg/src/main/resources/assets/pswg/textures/item/thermal_detonator_primed.png differ diff --git a/projects/pswg/src/main/resources/assets/pswg/textures/item/thermal_detonator_primed.png.mcmeta b/projects/pswg/src/main/resources/assets/pswg/textures/item/thermal_detonator_primed.png.mcmeta new file mode 100644 index 000000000..45f6fb941 --- /dev/null +++ b/projects/pswg/src/main/resources/assets/pswg/textures/item/thermal_detonator_primed.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": true, + "frametime": 3 + } +} diff --git a/projects/pswg/src/main/resources/data/pswg/loot_tables/blocks/thermal_detonator_block.json b/projects/pswg/src/main/resources/data/pswg/loot_tables/blocks/thermal_detonator_block.json new file mode 100644 index 000000000..186dcc2ea --- /dev/null +++ b/projects/pswg/src/main/resources/data/pswg/loot_tables/blocks/thermal_detonator_block.json @@ -0,0 +1 @@ +{"type":"minecraft:block","pools":[{"rolls":1,"entries":[{"type":"minecraft:item","name":"pswg:thermal_detonator_block"}],"conditions":[{"condition":"minecraft:survives_explosion"}]}]} diff --git a/projects/tarkin/src/main/java/com/parzivail/datagen/tarkin/config/PswgTarkin.java b/projects/tarkin/src/main/java/com/parzivail/datagen/tarkin/config/PswgTarkin.java index e75efa2a2..985d3d955 100644 --- a/projects/tarkin/src/main/java/com/parzivail/datagen/tarkin/config/PswgTarkin.java +++ b/projects/tarkin/src/main/java/com/parzivail/datagen/tarkin/config/PswgTarkin.java @@ -1284,6 +1284,8 @@ public static void generateBlocks(List assets) BlockGenerator.blockNoModelDefaultDrops(SwgBlocks.Workbench.Lightsaber) .blockTag(BlockTags.PICKAXE_MINEABLE) .build(assets); + BlockGenerator.blockNoModelDefaultDrops(SwgBlocks.Misc.ThermalDetonatorBlock) + .build(assets); } public static void build(List assets)