From 07cb8c4a7ee2982bd50cb9651483e5bb28f884ab Mon Sep 17 00:00:00 2001 From: JustAPotota <43710172+JustAPotota@users.noreply.github.com> Date: Sun, 22 Dec 2024 14:01:05 -0600 Subject: [PATCH] fix: meteor chunk entity works again (+ textures!) (#379) --- .../generated/assets/galacticraft/lang/en_us.json | 1 + .../entity/ThrowableMeteorChunkEntity.java | 6 +++--- .../content/item/HotThrowableMeteorChunkItem.java | 11 +++++------ .../content/item/ThrowableMeteorChunkItem.java | 13 ++----------- .../mod/data/GCTranslationProvider.java | 2 ++ .../dev/galacticraft/mod/util/Translations.java | 4 ++++ .../resources/assets/galacticraft/sounds.json | 9 +++++++++ .../textures/item/hot_throwable_meteor_chunk.png | Bin 0 -> 541 bytes .../textures/item/throwable_meteor_chunk.png | Bin 0 -> 499 bytes 9 files changed, 26 insertions(+), 20 deletions(-) create mode 100644 src/main/resources/assets/galacticraft/textures/item/hot_throwable_meteor_chunk.png create mode 100644 src/main/resources/assets/galacticraft/textures/item/throwable_meteor_chunk.png diff --git a/src/main/generated/assets/galacticraft/lang/en_us.json b/src/main/generated/assets/galacticraft/lang/en_us.json index 4211f9154..2b6c2a86d 100644 --- a/src/main/generated/assets/galacticraft/lang/en_us.json +++ b/src/main/generated/assets/galacticraft/lang/en_us.json @@ -543,6 +543,7 @@ "smithing_template.galacticraft.titanium_upgrade.ingredients": "Compressed Titanium", "star.galacticraft.sol": "Sol", "star.galacticraft.sol.description": "", + "subtitles.galacticraft.entity.throwable_meteor_chunk.throw": "Meteor Chunk flies", "tooltip.galacticraft.creative_only": "Creative Only", "tooltip.galacticraft.energy_remaining": "Energy Remaining: %s", "tooltip.galacticraft.glowstone_lantern": "Glowstone Lanterns are best used to light areas when there is no oxygen for lanterns to burn.", diff --git a/src/main/java/dev/galacticraft/mod/content/entity/ThrowableMeteorChunkEntity.java b/src/main/java/dev/galacticraft/mod/content/entity/ThrowableMeteorChunkEntity.java index f24d3a645..4194b3c40 100644 --- a/src/main/java/dev/galacticraft/mod/content/entity/ThrowableMeteorChunkEntity.java +++ b/src/main/java/dev/galacticraft/mod/content/entity/ThrowableMeteorChunkEntity.java @@ -74,10 +74,10 @@ public void addAdditionalSaveData(CompoundTag compound) { @Override protected Item getDefaultItem() { - if (this.entityData.get(HOT)) { - return GCItems.HOT_THROWABLE_METEOR_CHUNK; - } else { + if (this.entityData == null || !this.entityData.get(HOT)) { return GCItems.THROWABLE_METEOR_CHUNK; + } else { + return GCItems.HOT_THROWABLE_METEOR_CHUNK; } } diff --git a/src/main/java/dev/galacticraft/mod/content/item/HotThrowableMeteorChunkItem.java b/src/main/java/dev/galacticraft/mod/content/item/HotThrowableMeteorChunkItem.java index a75645c32..5899fc13b 100644 --- a/src/main/java/dev/galacticraft/mod/content/item/HotThrowableMeteorChunkItem.java +++ b/src/main/java/dev/galacticraft/mod/content/item/HotThrowableMeteorChunkItem.java @@ -27,6 +27,7 @@ import dev.galacticraft.mod.util.Translations; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Style; +import net.minecraft.sounds.SoundEvents; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; @@ -35,6 +36,7 @@ import net.minecraft.world.level.Level; import java.util.List; +import java.util.Objects; public class HotThrowableMeteorChunkItem extends ThrowableMeteorChunkItem { public static int MAX_TICKS = 45 * 20; @@ -61,12 +63,7 @@ public void inventoryTick(ItemStack stack, Level level, Entity entity, int slotI return; Integer i = stack.get(GCDataComponents.TICKS_UNTIL_COOL); - int ticks; - if (i == null) { - ticks = MAX_TICKS; - } else { - ticks = i; - } + int ticks = Objects.requireNonNullElse(i, MAX_TICKS); if (ticks == 0) { if (entity instanceof Player player) { @@ -77,6 +74,8 @@ public void inventoryTick(ItemStack stack, Level level, Entity entity, int slotI Inventory inventory = player.getInventory(); inventory.setItem(slotId, new ItemStack(GCItems.THROWABLE_METEOR_CHUNK, stack.getCount())); inventory.setChanged(); + + player.playSound(SoundEvents.GENERIC_EXTINGUISH_FIRE, 0.7F, 1.6F + (player.getRandom().nextFloat() - player.getRandom().nextFloat()) * 0.4F); // Entity::playEntityOnFireExtinguishedSound() } } stack.set(GCDataComponents.TICKS_UNTIL_COOL, ticks - 1); diff --git a/src/main/java/dev/galacticraft/mod/content/item/ThrowableMeteorChunkItem.java b/src/main/java/dev/galacticraft/mod/content/item/ThrowableMeteorChunkItem.java index edaa6d14c..2ab66c4bf 100644 --- a/src/main/java/dev/galacticraft/mod/content/item/ThrowableMeteorChunkItem.java +++ b/src/main/java/dev/galacticraft/mod/content/item/ThrowableMeteorChunkItem.java @@ -24,7 +24,6 @@ import dev.galacticraft.mod.content.GCSounds; import dev.galacticraft.mod.content.entity.ThrowableMeteorChunkEntity; -import net.minecraft.sounds.SoundSource; import net.minecraft.stats.Stats; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; @@ -41,16 +40,8 @@ public ThrowableMeteorChunkItem(Properties settings) { @Override public InteractionResultHolder use(Level level, Player player, InteractionHand usedHand) { ItemStack itemStack = player.getItemInHand(usedHand); - level.playSound( - null, - player.getX(), - player.getY(), - player.getZ(), - GCSounds.METEOR_CHUNK_THROW, - SoundSource.NEUTRAL, - 0.5F, - 0.4F / (level.getRandom().nextFloat() * 0.4F + 0.8F) - ); + player.playSound(GCSounds.METEOR_CHUNK_THROW, 0.5F, 0.4F / (level.getRandom().nextFloat() * 0.4F + 0.8F)); + if (!level.isClientSide) { ThrowableMeteorChunkEntity projectile = new ThrowableMeteorChunkEntity(player, level, itemStack.is(GCItems.HOT_THROWABLE_METEOR_CHUNK)); projectile.setItem(itemStack); diff --git a/src/main/java/dev/galacticraft/mod/data/GCTranslationProvider.java b/src/main/java/dev/galacticraft/mod/data/GCTranslationProvider.java index d7604385b..0f0a792d7 100644 --- a/src/main/java/dev/galacticraft/mod/data/GCTranslationProvider.java +++ b/src/main/java/dev/galacticraft/mod/data/GCTranslationProvider.java @@ -130,6 +130,8 @@ protected void generateTranslations(HolderLookup.@NotNull Provider registries) { this.add(Chat.BED_FAIL, "Uh oh, what if the oxygen runs out when I am asleep? I'll need a Cryogenic Chamber to sleep in space!"); this.add(Chat.ROCKET_WARNING, "Press again to launch."); + this.add(Subtitles.THROW_METEOR_CHUNK, "Meteor Chunk flies"); + this.add(RegistryDebug.DUMP, "Dumped: %s"); this.add(RegistryDebug.ID, "%s - %s: %s"); diff --git a/src/main/java/dev/galacticraft/mod/util/Translations.java b/src/main/java/dev/galacticraft/mod/util/Translations.java index 85adfd927..9c93a107c 100644 --- a/src/main/java/dev/galacticraft/mod/util/Translations.java +++ b/src/main/java/dev/galacticraft/mod/util/Translations.java @@ -43,6 +43,10 @@ interface Chat { String ROCKET_WARNING = "chat.galacticraft.rocket.warning"; } + interface Subtitles { + String THROW_METEOR_CHUNK = "subtitles.galacticraft.entity.throwable_meteor_chunk.throw"; + } + interface RegistryDebug { String DUMP = "commands.galacticraft.debug.registry.dump"; String ID = "commands.galacticraft.debug.registry.id"; diff --git a/src/main/resources/assets/galacticraft/sounds.json b/src/main/resources/assets/galacticraft/sounds.json index 1910a1f5b..ed934a5d0 100644 --- a/src/main/resources/assets/galacticraft/sounds.json +++ b/src/main/resources/assets/galacticraft/sounds.json @@ -143,6 +143,15 @@ } ] }, + "entity.throwable_meteor_chunk.throw": { + "subtitle": "subtitles.galacticraft.entity.throwable_meteor_chunk.throw", + "sounds": [ + { + "name": "minecraft:random/bow", + "stream": false + } + ] + }, "ambience.singledrip": { "sounds": [ "galacticraft:ambience/singledrip1", diff --git a/src/main/resources/assets/galacticraft/textures/item/hot_throwable_meteor_chunk.png b/src/main/resources/assets/galacticraft/textures/item/hot_throwable_meteor_chunk.png new file mode 100644 index 0000000000000000000000000000000000000000..4f43139c639933650da7229661b68853ea30a7ca GIT binary patch literal 541 zcmV+&0^Px#1ZP1_K>z@;j|==^1poj6tw}^dR5(w?lglpyQ542MkCMq~q%<_umPHeUkZ4IG zVj&TUCKg?EVPn_7K4je~caD1D`d7jsq zH6%mG!E!A*JWHcnBzPhz?)rWyr>qN;0_ql(2;?@fV;AD&AHo>VD!*?0uTIki2V zfy3H^t-T0BM*<>;VI;+COpWwmao&S0-%TxPX^|t9@1GyVg_xl#m{Gae0IAAD5YCZJ z#qn0EV5qCMxeV-F71o(fS3$pYLE_6(0k4m7GILru*dZY)RbUxo4qvDSV(JC$;#qxM z>pPc!r*Zh|3DJilmF_YYVDb#mi&W56z&7rMZ{YS!qBH*p?mYvu)lO?(p97m~p`X8k zn0;+hoR@mDu%(Ykz{>aa-eEW}L2KI68Le_8>dp!JL`=-eT}G^y@oWma+hW7%jD|$Z zhWG0#GrnIS1$9FCIk;+tqLy5xeu=bLjU4W!qMZF1;1jD~r5d{>;yM5T01jnXNoGw= f04e|g00;m8000000Mb*F00000NkvXXu0mjfsORmn literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/galacticraft/textures/item/throwable_meteor_chunk.png b/src/main/resources/assets/galacticraft/textures/item/throwable_meteor_chunk.png new file mode 100644 index 0000000000000000000000000000000000000000..b13e604a3de662f482cc4fd42dd538afba1b2c79 GIT binary patch literal 499 zcmVPx#1ZP1_K>z@;j|==^1poj6gGod|R5(w?Qr$`dQ4k&#DHB@@2{SSTslX@#tD8y) zq6Y}P?In7Yp2D6$y0aisA&R<)0?WU`#N0NiSk(3#_nbP~RX2SXJ2PkJ`)20Mp?`zh z?PlxXuMKf%nkKDB16>X*oZQtp&pM;C2c6H50}KeP&1g*A-`nD|Vzox8qpP0({6&}E@PukDWHIc+Nu9P5oC0P@p|N#W20CASx7 zV>zOXHz0t-R60+Y>;+}7D@