Skip to content

Commit

Permalink
fix: meteor chunk entity works again (+ textures!) (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustAPotota authored Dec 22, 2024
1 parent dff802d commit 07cb8c4
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/main/generated/assets/galacticraft/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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) {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -41,16 +40,8 @@ public ThrowableMeteorChunkItem(Properties settings) {
@Override
public InteractionResultHolder<ItemStack> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/dev/galacticraft/mod/util/Translations.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
9 changes: 9 additions & 0 deletions src/main/resources/assets/galacticraft/sounds.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 07cb8c4

Please sign in to comment.