From 9fde3350a971b16d16c4e8826128bfdbf3376ab5 Mon Sep 17 00:00:00 2001 From: Roelymole Date: Tue, 7 Jan 2025 12:56:30 +0000 Subject: [PATCH 01/10] fix: changed rendering order of dark and light oxygen overlays (resolves #393) --- src/main/java/dev/galacticraft/mod/util/DrawableUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/galacticraft/mod/util/DrawableUtil.java b/src/main/java/dev/galacticraft/mod/util/DrawableUtil.java index c475a4044..1993f79a5 100644 --- a/src/main/java/dev/galacticraft/mod/util/DrawableUtil.java +++ b/src/main/java/dev/galacticraft/mod/util/DrawableUtil.java @@ -50,8 +50,8 @@ public static void drawOxygenBuffer(PoseStack matrices, int x, int y, double sca RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.setShaderTexture(0, Constant.ScreenTexture.OVERLAY); - drawProgressTexture(matrices, x, y, 0, Constant.TextureCoordinate.OXYGEN_DARK_X, Constant.TextureCoordinate.OXYGEN_DARK_Y, Constant.TextureCoordinate.OVERLAY_WIDTH, Constant.TextureCoordinate.OVERLAY_HEIGHT, 256, 256); - drawProgressTexture(matrices, x, (int) (y + Constant.TextureCoordinate.OVERLAY_HEIGHT - (Constant.TextureCoordinate.OVERLAY_HEIGHT * scale)), 0, Constant.TextureCoordinate.OXYGEN_LIGHT_X, Constant.TextureCoordinate.OXYGEN_LIGHT_Y, Constant.TextureCoordinate.OVERLAY_WIDTH, (float) (Constant.TextureCoordinate.OVERLAY_HEIGHT * scale), 256, 256); + drawProgressTexture(matrices, x, y, 0, Constant.TextureCoordinate.OXYGEN_LIGHT_X, Constant.TextureCoordinate.OXYGEN_LIGHT_Y, Constant.TextureCoordinate.OVERLAY_WIDTH, Constant.TextureCoordinate.OVERLAY_HEIGHT, 256, 256); + drawProgressTexture(matrices, x, y, 0, Constant.TextureCoordinate.OXYGEN_DARK_X, Constant.TextureCoordinate.OXYGEN_DARK_Y, Constant.TextureCoordinate.OVERLAY_WIDTH, (float) (Constant.TextureCoordinate.OVERLAY_HEIGHT * (1 - scale)), 256, 256); } public static boolean isWithin(double mouseX, double mouseY, int x, int y, int width, int height) { From 032c057d62110b695287b5d39b94acaf76cd6223 Mon Sep 17 00:00:00 2001 From: Roelymole Date: Tue, 7 Jan 2025 22:28:40 +0000 Subject: [PATCH 02/10] feat: implemented suffocation damage due to a lack of oxygen in space (resolves #390) --- .../galacticraft/damage_type/suffocation.json | 1 + .../minecraft/tags/damage_type/no_impact.json | 5 +++ .../mixin/gear/LivingEntityMixin.java | 29 ++++++++++++ .../content/entity/damage/GCDamageTypes.java | 3 +- .../mod/data/GCDataGenerator.java | 1 + .../mod/data/tag/GCDamageTypeTagProvider.java | 45 +++++++++++++++++++ 6 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 src/main/generated/data/minecraft/tags/damage_type/no_impact.json create mode 100644 src/main/java/dev/galacticraft/mod/data/tag/GCDamageTypeTagProvider.java diff --git a/src/main/generated/data/galacticraft/damage_type/suffocation.json b/src/main/generated/data/galacticraft/damage_type/suffocation.json index c91f288f2..b57cb2ad7 100644 --- a/src/main/generated/data/galacticraft/damage_type/suffocation.json +++ b/src/main/generated/data/galacticraft/damage_type/suffocation.json @@ -1,4 +1,5 @@ { + "effects": "drowning", "exhaustion": 0.0, "message_id": "suffocation", "scaling": "when_caused_by_living_non_player" diff --git a/src/main/generated/data/minecraft/tags/damage_type/no_impact.json b/src/main/generated/data/minecraft/tags/damage_type/no_impact.json new file mode 100644 index 000000000..353bd1948 --- /dev/null +++ b/src/main/generated/data/minecraft/tags/damage_type/no_impact.json @@ -0,0 +1,5 @@ +{ + "values": [ + "galacticraft:suffocation" + ] +} \ No newline at end of file diff --git a/src/main/java/dev/galacticraft/impl/internal/mixin/gear/LivingEntityMixin.java b/src/main/java/dev/galacticraft/impl/internal/mixin/gear/LivingEntityMixin.java index 292ea4940..7ed32b979 100644 --- a/src/main/java/dev/galacticraft/impl/internal/mixin/gear/LivingEntityMixin.java +++ b/src/main/java/dev/galacticraft/impl/internal/mixin/gear/LivingEntityMixin.java @@ -29,6 +29,7 @@ import dev.galacticraft.api.item.OxygenGear; import dev.galacticraft.api.item.OxygenMask; import dev.galacticraft.impl.internal.fabric.GalacticraftAPI; +import dev.galacticraft.mod.content.entity.damage.GCDamageTypes; import dev.galacticraft.mod.Galacticraft; import net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext; import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage; @@ -37,9 +38,13 @@ import net.fabricmc.fabric.api.transfer.v1.storage.Storage; import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction; import net.minecraft.core.Direction; +import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; +import net.minecraft.tags.FluidTags; import net.minecraft.tags.TagKey; import net.minecraft.world.Container; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.damagesource.DamageTypes; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; @@ -67,12 +72,36 @@ public LivingEntityMixin(EntityType type, Level world) { } @Shadow protected abstract int increaseAirSupply(int air); + @Shadow protected abstract int decreaseAirSupply(int air); + + @Inject(method = "baseTick", at = @At(value = "HEAD")) + private void galacticraft_oxygenCheck(CallbackInfo ci) { + LivingEntity entity = ((LivingEntity) (Object) this); + if (entity.isAlive()) { + if (!entity.level().isBreathable(entity.blockPosition().relative(Direction.UP, (int) Math.floor(entity.getEyeHeight(entity.getPose()))))) { + if (!entity.canBreatheUnderwater() && (!(entity instanceof Player) || !((Player)entity).getAbilities().invulnerable)) { + entity.setAirSupply(this.decreaseAirSupply(entity.getAirSupply())); + if (entity.getAirSupply() == -20) { + entity.setAirSupply(0); + entity.hurt(new DamageSource(entity.level().registryAccess() + .registryOrThrow(Registries.DAMAGE_TYPE) + .getHolderOrThrow(GCDamageTypes.SUFFOCATION)), 2.0f); + } + } + } + } + } @Redirect(method = "baseTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;isEyeInFluid(Lnet/minecraft/tags/TagKey;)Z", ordinal = 0)) private boolean galacticraft_testForBreathability(LivingEntity entity, TagKey tag) { return entity.isEyeInFluid(tag) || !entity.level().isBreathable(entity.blockPosition().relative(Direction.UP, (int) Math.floor(this.getEyeHeight(entity.getPose())))); } + @Redirect(method = "baseTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;canBreatheUnderwater()Z")) + private boolean galacticraft_suffocationDamage(LivingEntity entity) { + return entity.canBreatheUnderwater() || !entity.isEyeInFluid(FluidTags.WATER); + } + @Inject(method = "tick", at = @At(value = "RETURN")) private void tickAccessories(CallbackInfo ci) { LivingEntity thisEntity = ((LivingEntity) (Object) this); diff --git a/src/main/java/dev/galacticraft/mod/content/entity/damage/GCDamageTypes.java b/src/main/java/dev/galacticraft/mod/content/entity/damage/GCDamageTypes.java index ed879e9b1..b411c12c8 100644 --- a/src/main/java/dev/galacticraft/mod/content/entity/damage/GCDamageTypes.java +++ b/src/main/java/dev/galacticraft/mod/content/entity/damage/GCDamageTypes.java @@ -26,6 +26,7 @@ import net.minecraft.core.registries.Registries; import net.minecraft.data.worldgen.BootstrapContext; import net.minecraft.resources.ResourceKey; +import net.minecraft.world.damagesource.DamageEffects; import net.minecraft.world.damagesource.DamageScaling; import net.minecraft.world.damagesource.DamageType; @@ -38,7 +39,7 @@ public class GCDamageTypes { public static void bootstrapRegistries(BootstrapContext context) { context.register(OIL_BOOM, new DamageType("oil_boom", DamageScaling.ALWAYS, 0.1f)); context.register(VINE_POISON, new DamageType("vine_poison", 0.0f)); - context.register(SUFFOCATION, new DamageType("suffocation", 0.0f)); + context.register(SUFFOCATION, new DamageType("suffocation", 0.0f, DamageEffects.DROWNING)); context.register(SULFURIC_ACID, new DamageType("sulfuric_acid", 0.0f)); } } diff --git a/src/main/java/dev/galacticraft/mod/data/GCDataGenerator.java b/src/main/java/dev/galacticraft/mod/data/GCDataGenerator.java index 0742b376d..21232eccc 100644 --- a/src/main/java/dev/galacticraft/mod/data/GCDataGenerator.java +++ b/src/main/java/dev/galacticraft/mod/data/GCDataGenerator.java @@ -78,6 +78,7 @@ public void onInitializeDataGenerator(@NotNull FabricDataGenerator generator) { pack.addProvider(GCBannerTagProvider::new); pack.addProvider(GCBiomeTagProvider::new); pack.addProvider(GCBlockTagProvider::new); + pack.addProvider(GCDamageTypeTagProvider::new); pack.addProvider(GCDimensionTagProvider::new); pack.addProvider(GCEntityTypeTagProvider::new); pack.addProvider(GCFluidTagProvider::new); diff --git a/src/main/java/dev/galacticraft/mod/data/tag/GCDamageTypeTagProvider.java b/src/main/java/dev/galacticraft/mod/data/tag/GCDamageTypeTagProvider.java new file mode 100644 index 000000000..8a4dbd6a3 --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/data/tag/GCDamageTypeTagProvider.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.data.tag; + +import dev.galacticraft.mod.content.entity.damage.GCDamageTypes; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.tags.DamageTypeTags; +import net.minecraft.world.damagesource.DamageType; + +import java.util.concurrent.CompletableFuture; + +public class GCDamageTypeTagProvider extends FabricTagProvider { + public GCDamageTypeTagProvider(FabricDataOutput output, CompletableFuture completableFuture) { + super(output, Registries.DAMAGE_TYPE, completableFuture); + } + + @Override + protected void addTags(HolderLookup.Provider arg) { + this.tag(DamageTypeTags.NO_IMPACT) + .add(GCDamageTypes.SUFFOCATION); + } +} \ No newline at end of file From 73e9dddb160cf201a52884e166f0c56ca6fcf8c7 Mon Sep 17 00:00:00 2001 From: Roelymole Date: Tue, 7 Jan 2025 23:01:18 +0000 Subject: [PATCH 03/10] fix: swapped oxygen tanks which were displayed the wrong way round in the oxygen overlay --- .../galacticraft/mod/client/gui/overlay/OxygenOverlay.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/dev/galacticraft/mod/client/gui/overlay/OxygenOverlay.java b/src/main/java/dev/galacticraft/mod/client/gui/overlay/OxygenOverlay.java index 4452c9c60..5bb6e7fa6 100644 --- a/src/main/java/dev/galacticraft/mod/client/gui/overlay/OxygenOverlay.java +++ b/src/main/java/dev/galacticraft/mod/client/gui/overlay/OxygenOverlay.java @@ -45,9 +45,10 @@ public static void onHudRender(GuiGraphics graphics, DeltaTracker delta) { if (body != null && !body.value().atmosphere().breathable()) { Container inv = mc.player.galacticraft$getOxygenTanks(); final int y = 4; - for (int i = 0; i < inv.getContainerSize(); i++) { - Storage storage = ContainerItemContext.withConstant(inv.getItem(i)).find(FluidStorage.ITEM); - int x = mc.getWindow().getGuiScaledWidth() - ((Constant.TextureCoordinate.OVERLAY_WIDTH + y) * (i + 1)); + final int n = inv.getContainerSize(); + for (int i = n; i > 0; i--) { + Storage storage = ContainerItemContext.withConstant(inv.getItem(n - i)).find(FluidStorage.ITEM); + int x = mc.getWindow().getGuiScaledWidth() - ((Constant.TextureCoordinate.OVERLAY_WIDTH + y) * i); int outline = 0x99FFFFFF; From 423b65d60703d60b159059b1013ab1a243038bf9 Mon Sep 17 00:00:00 2001 From: Roelymole Date: Tue, 7 Jan 2025 23:57:01 +0000 Subject: [PATCH 04/10] feat: added more damage type tags --- .../galacticraft/damage_type/suffocation.json | 1 - .../tags/damage_type/bypasses_armor.json | 5 ++++ .../tags/damage_type/bypasses_wolf_armor.json | 5 ++++ .../tags/damage_type/is_drowning.json | 5 ++++ .../tags/damage_type/no_knockback.json | 7 ++++++ .../panic_environmental_causes.json | 6 +++++ .../tags/damage_type/wither_immune_to.json | 7 ++++++ .../content/entity/damage/GCDamageTypes.java | 3 +-- .../mod/data/tag/GCDamageTypeTagProvider.java | 23 +++++++++++++++++++ 9 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 src/main/generated/data/minecraft/tags/damage_type/bypasses_armor.json create mode 100644 src/main/generated/data/minecraft/tags/damage_type/bypasses_wolf_armor.json create mode 100644 src/main/generated/data/minecraft/tags/damage_type/is_drowning.json create mode 100644 src/main/generated/data/minecraft/tags/damage_type/no_knockback.json create mode 100644 src/main/generated/data/minecraft/tags/damage_type/panic_environmental_causes.json create mode 100644 src/main/generated/data/minecraft/tags/damage_type/wither_immune_to.json diff --git a/src/main/generated/data/galacticraft/damage_type/suffocation.json b/src/main/generated/data/galacticraft/damage_type/suffocation.json index b57cb2ad7..c91f288f2 100644 --- a/src/main/generated/data/galacticraft/damage_type/suffocation.json +++ b/src/main/generated/data/galacticraft/damage_type/suffocation.json @@ -1,5 +1,4 @@ { - "effects": "drowning", "exhaustion": 0.0, "message_id": "suffocation", "scaling": "when_caused_by_living_non_player" diff --git a/src/main/generated/data/minecraft/tags/damage_type/bypasses_armor.json b/src/main/generated/data/minecraft/tags/damage_type/bypasses_armor.json new file mode 100644 index 000000000..353bd1948 --- /dev/null +++ b/src/main/generated/data/minecraft/tags/damage_type/bypasses_armor.json @@ -0,0 +1,5 @@ +{ + "values": [ + "galacticraft:suffocation" + ] +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/tags/damage_type/bypasses_wolf_armor.json b/src/main/generated/data/minecraft/tags/damage_type/bypasses_wolf_armor.json new file mode 100644 index 000000000..353bd1948 --- /dev/null +++ b/src/main/generated/data/minecraft/tags/damage_type/bypasses_wolf_armor.json @@ -0,0 +1,5 @@ +{ + "values": [ + "galacticraft:suffocation" + ] +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/tags/damage_type/is_drowning.json b/src/main/generated/data/minecraft/tags/damage_type/is_drowning.json new file mode 100644 index 000000000..353bd1948 --- /dev/null +++ b/src/main/generated/data/minecraft/tags/damage_type/is_drowning.json @@ -0,0 +1,5 @@ +{ + "values": [ + "galacticraft:suffocation" + ] +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/tags/damage_type/no_knockback.json b/src/main/generated/data/minecraft/tags/damage_type/no_knockback.json new file mode 100644 index 000000000..04125930b --- /dev/null +++ b/src/main/generated/data/minecraft/tags/damage_type/no_knockback.json @@ -0,0 +1,7 @@ +{ + "values": [ + "galacticraft:vine_poison", + "galacticraft:suffocation", + "galacticraft:sulfuric_acid" + ] +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/tags/damage_type/panic_environmental_causes.json b/src/main/generated/data/minecraft/tags/damage_type/panic_environmental_causes.json new file mode 100644 index 000000000..bf392f6ad --- /dev/null +++ b/src/main/generated/data/minecraft/tags/damage_type/panic_environmental_causes.json @@ -0,0 +1,6 @@ +{ + "values": [ + "galacticraft:vine_poison", + "galacticraft:sulfuric_acid" + ] +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/tags/damage_type/wither_immune_to.json b/src/main/generated/data/minecraft/tags/damage_type/wither_immune_to.json new file mode 100644 index 000000000..04125930b --- /dev/null +++ b/src/main/generated/data/minecraft/tags/damage_type/wither_immune_to.json @@ -0,0 +1,7 @@ +{ + "values": [ + "galacticraft:vine_poison", + "galacticraft:suffocation", + "galacticraft:sulfuric_acid" + ] +} \ No newline at end of file diff --git a/src/main/java/dev/galacticraft/mod/content/entity/damage/GCDamageTypes.java b/src/main/java/dev/galacticraft/mod/content/entity/damage/GCDamageTypes.java index b411c12c8..ed879e9b1 100644 --- a/src/main/java/dev/galacticraft/mod/content/entity/damage/GCDamageTypes.java +++ b/src/main/java/dev/galacticraft/mod/content/entity/damage/GCDamageTypes.java @@ -26,7 +26,6 @@ import net.minecraft.core.registries.Registries; import net.minecraft.data.worldgen.BootstrapContext; import net.minecraft.resources.ResourceKey; -import net.minecraft.world.damagesource.DamageEffects; import net.minecraft.world.damagesource.DamageScaling; import net.minecraft.world.damagesource.DamageType; @@ -39,7 +38,7 @@ public class GCDamageTypes { public static void bootstrapRegistries(BootstrapContext context) { context.register(OIL_BOOM, new DamageType("oil_boom", DamageScaling.ALWAYS, 0.1f)); context.register(VINE_POISON, new DamageType("vine_poison", 0.0f)); - context.register(SUFFOCATION, new DamageType("suffocation", 0.0f, DamageEffects.DROWNING)); + context.register(SUFFOCATION, new DamageType("suffocation", 0.0f)); context.register(SULFURIC_ACID, new DamageType("sulfuric_acid", 0.0f)); } } diff --git a/src/main/java/dev/galacticraft/mod/data/tag/GCDamageTypeTagProvider.java b/src/main/java/dev/galacticraft/mod/data/tag/GCDamageTypeTagProvider.java index 8a4dbd6a3..b07f6aec6 100644 --- a/src/main/java/dev/galacticraft/mod/data/tag/GCDamageTypeTagProvider.java +++ b/src/main/java/dev/galacticraft/mod/data/tag/GCDamageTypeTagProvider.java @@ -39,7 +39,30 @@ public GCDamageTypeTagProvider(FabricDataOutput output, CompletableFuture Date: Thu, 9 Jan 2025 00:18:46 +0000 Subject: [PATCH 05/10] feat: show oxygen overlay whenever player is wearing both an oxygen mask and oxygen gear --- .../api/accessor/GearInventoryProvider.java | 19 +++++++++++++ .../mixin/gear/LivingEntityMixin.java | 28 +++++++++---------- .../mod/client/gui/overlay/OxygenOverlay.java | 7 +++-- 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/main/java/dev/galacticraft/api/accessor/GearInventoryProvider.java b/src/main/java/dev/galacticraft/api/accessor/GearInventoryProvider.java index 04d58a20b..bc4338196 100644 --- a/src/main/java/dev/galacticraft/api/accessor/GearInventoryProvider.java +++ b/src/main/java/dev/galacticraft/api/accessor/GearInventoryProvider.java @@ -22,8 +22,11 @@ package dev.galacticraft.api.accessor; +import dev.galacticraft.api.item.OxygenGear; +import dev.galacticraft.api.item.OxygenMask; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.Container; +import net.minecraft.world.item.Item; public interface GearInventoryProvider { default Container galacticraft$getGearInv() { @@ -42,6 +45,22 @@ public interface GearInventoryProvider { throw new RuntimeException("This should be overridden by mixin!"); } + default boolean galacticraft$hasMaskAndGear() { + boolean mask = false; + boolean gear = false; + for (int i = 0; i < this.galacticraft$getAccessories().getContainerSize(); i++) { + Item item = this.galacticraft$getAccessories().getItem(i).getItem(); + if (!mask && item instanceof OxygenMask) { + mask = true; + if (gear) break; + } else if (!gear && item instanceof OxygenGear) { + gear = true; + if (mask) break; + } + } + return mask && gear; + } + default void galacticraft$writeGearToNbt(CompoundTag tag) { throw new RuntimeException("This should be overridden by mixin!"); } diff --git a/src/main/java/dev/galacticraft/impl/internal/mixin/gear/LivingEntityMixin.java b/src/main/java/dev/galacticraft/impl/internal/mixin/gear/LivingEntityMixin.java index 7ed32b979..8b04adbc2 100644 --- a/src/main/java/dev/galacticraft/impl/internal/mixin/gear/LivingEntityMixin.java +++ b/src/main/java/dev/galacticraft/impl/internal/mixin/gear/LivingEntityMixin.java @@ -120,20 +120,20 @@ private void galacticraft_modifyAirLevel(int air, CallbackInfoReturnable storage = ContainerItemContext.ofSingleSlot(tankInv.getSlot(i)).find(FluidStorage.ITEM); diff --git a/src/main/java/dev/galacticraft/mod/client/gui/overlay/OxygenOverlay.java b/src/main/java/dev/galacticraft/mod/client/gui/overlay/OxygenOverlay.java index 5bb6e7fa6..9f958dce5 100644 --- a/src/main/java/dev/galacticraft/mod/client/gui/overlay/OxygenOverlay.java +++ b/src/main/java/dev/galacticraft/mod/client/gui/overlay/OxygenOverlay.java @@ -35,6 +35,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.Holder; +import net.minecraft.tags.FluidTags; import net.minecraft.world.Container; public class OxygenOverlay { @@ -42,16 +43,16 @@ public static void onHudRender(GuiGraphics graphics, DeltaTracker delta) { Minecraft mc = Minecraft.getInstance(); if (mc.level != null && mc.player != null && !mc.player.isSpectator()) { Holder> body = mc.level.galacticraft$getCelestialBody(); - if (body != null && !body.value().atmosphere().breathable()) { + boolean nonBreathable = body != null && !body.value().atmosphere().breathable(); + if (mc.player.galacticraft$hasMaskAndGear() || nonBreathable) { Container inv = mc.player.galacticraft$getOxygenTanks(); + final int outline = 0x99FFFFFF; final int y = 4; final int n = inv.getContainerSize(); for (int i = n; i > 0; i--) { Storage storage = ContainerItemContext.withConstant(inv.getItem(n - i)).find(FluidStorage.ITEM); int x = mc.getWindow().getGuiScaledWidth() - ((Constant.TextureCoordinate.OVERLAY_WIDTH + y) * i); - int outline = 0x99FFFFFF; - long amount = 0; long capacity = 1; From af4cb67eb1ce37aac6d6cc78d3a50801a4f53a9e Mon Sep 17 00:00:00 2001 From: Roelymole Date: Thu, 9 Jan 2025 00:58:24 +0000 Subject: [PATCH 06/10] fix: handled edge case where entity is underwater with water breathing in space --- .../impl/internal/mixin/gear/LivingEntityMixin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/dev/galacticraft/impl/internal/mixin/gear/LivingEntityMixin.java b/src/main/java/dev/galacticraft/impl/internal/mixin/gear/LivingEntityMixin.java index 8b04adbc2..31af220a2 100644 --- a/src/main/java/dev/galacticraft/impl/internal/mixin/gear/LivingEntityMixin.java +++ b/src/main/java/dev/galacticraft/impl/internal/mixin/gear/LivingEntityMixin.java @@ -79,7 +79,7 @@ private void galacticraft_oxygenCheck(CallbackInfo ci) { LivingEntity entity = ((LivingEntity) (Object) this); if (entity.isAlive()) { if (!entity.level().isBreathable(entity.blockPosition().relative(Direction.UP, (int) Math.floor(entity.getEyeHeight(entity.getPose()))))) { - if (!entity.canBreatheUnderwater() && (!(entity instanceof Player) || !((Player)entity).getAbilities().invulnerable)) { + if (!entity.isEyeInFluid(FluidTags.WATER) && (!(entity instanceof Player) || !((Player)entity).getAbilities().invulnerable)) { entity.setAirSupply(this.decreaseAirSupply(entity.getAirSupply())); if (entity.getAirSupply() == -20) { entity.setAirSupply(0); From 9034a980b7da0dcb1423d1dec86b891c81e8c459 Mon Sep 17 00:00:00 2001 From: Roelymole Date: Thu, 9 Jan 2025 01:02:59 +0000 Subject: [PATCH 07/10] fix: removed old code --- .../impl/internal/mixin/gear/LivingEntityMixin.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/main/java/dev/galacticraft/impl/internal/mixin/gear/LivingEntityMixin.java b/src/main/java/dev/galacticraft/impl/internal/mixin/gear/LivingEntityMixin.java index 31af220a2..5bc0e8dea 100644 --- a/src/main/java/dev/galacticraft/impl/internal/mixin/gear/LivingEntityMixin.java +++ b/src/main/java/dev/galacticraft/impl/internal/mixin/gear/LivingEntityMixin.java @@ -120,19 +120,6 @@ private void galacticraft_modifyAirLevel(int air, CallbackInfoReturnable Date: Thu, 9 Jan 2025 21:46:16 +0000 Subject: [PATCH 08/10] fix: added no_impact tag to other damage types to prevent weird behavior --- .../generated/data/minecraft/tags/damage_type/no_impact.json | 4 +++- .../galacticraft/mod/data/tag/GCDamageTypeTagProvider.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/generated/data/minecraft/tags/damage_type/no_impact.json b/src/main/generated/data/minecraft/tags/damage_type/no_impact.json index 353bd1948..04125930b 100644 --- a/src/main/generated/data/minecraft/tags/damage_type/no_impact.json +++ b/src/main/generated/data/minecraft/tags/damage_type/no_impact.json @@ -1,5 +1,7 @@ { "values": [ - "galacticraft:suffocation" + "galacticraft:vine_poison", + "galacticraft:suffocation", + "galacticraft:sulfuric_acid" ] } \ No newline at end of file diff --git a/src/main/java/dev/galacticraft/mod/data/tag/GCDamageTypeTagProvider.java b/src/main/java/dev/galacticraft/mod/data/tag/GCDamageTypeTagProvider.java index b07f6aec6..bbca32fbe 100644 --- a/src/main/java/dev/galacticraft/mod/data/tag/GCDamageTypeTagProvider.java +++ b/src/main/java/dev/galacticraft/mod/data/tag/GCDamageTypeTagProvider.java @@ -49,7 +49,9 @@ protected void addTags(HolderLookup.Provider arg) { .add(GCDamageTypes.SUFFOCATION); this.tag(DamageTypeTags.NO_IMPACT) - .add(GCDamageTypes.SUFFOCATION); + .add(GCDamageTypes.VINE_POISON) + .add(GCDamageTypes.SUFFOCATION) + .add(GCDamageTypes.SULFURIC_ACID); this.tag(DamageTypeTags.NO_KNOCKBACK) .add(GCDamageTypes.VINE_POISON) From 5e009e8b48d1a645181b81c2cf855d8adbaf28d6 Mon Sep 17 00:00:00 2001 From: Roelymole Date: Fri, 10 Jan 2025 20:38:15 +0000 Subject: [PATCH 09/10] fix: hide oxygen overlay when F1 pressed --- .../galacticraft/mod/client/gui/overlay/OxygenOverlay.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/galacticraft/mod/client/gui/overlay/OxygenOverlay.java b/src/main/java/dev/galacticraft/mod/client/gui/overlay/OxygenOverlay.java index 9f958dce5..68efbba53 100644 --- a/src/main/java/dev/galacticraft/mod/client/gui/overlay/OxygenOverlay.java +++ b/src/main/java/dev/galacticraft/mod/client/gui/overlay/OxygenOverlay.java @@ -41,9 +41,9 @@ public class OxygenOverlay { public static void onHudRender(GuiGraphics graphics, DeltaTracker delta) { Minecraft mc = Minecraft.getInstance(); - if (mc.level != null && mc.player != null && !mc.player.isSpectator()) { + if (!mc.options.hideGui && mc.level != null && mc.player != null && !mc.player.isSpectator()) { Holder> body = mc.level.galacticraft$getCelestialBody(); - boolean nonBreathable = body != null && !body.value().atmosphere().breathable(); + boolean nonBreathable = (body != null) && !body.value().atmosphere().breathable(); if (mc.player.galacticraft$hasMaskAndGear() || nonBreathable) { Container inv = mc.player.galacticraft$getOxygenTanks(); final int outline = 0x99FFFFFF; From 5131839a73a098a86b7206dd43e352417ec6c569 Mon Sep 17 00:00:00 2001 From: Roelymole Date: Fri, 17 Jan 2025 16:55:08 +0000 Subject: [PATCH 10/10] =?UTF-8?q?fix:=20changed=20the=20oxygen=20tank=20sl?= =?UTF-8?q?ot=20sprite=20to=20the=20letters=20O=E2=82=82=20as=20the=20old?= =?UTF-8?q?=20sprite=20looks=20like=20a=20battery=20and=20doesn't=20match?= =?UTF-8?q?=20the=20new=20oxygen=20tank=20textures?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../galacticraft/textures/slot/oxygen_tank.png | Bin 182 -> 4483 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/galacticraft/textures/slot/oxygen_tank.png b/src/main/resources/assets/galacticraft/textures/slot/oxygen_tank.png index a7b7b71e178299937ebd5cef28d7474a2f27ad4e..7272cdd987ed1084aacb496220a8ccf4f315fcb6 100644 GIT binary patch literal 4483 zcmeHKeNYtV8DGGFrHH3JDtG#}Lv<7f?i_m0nLW;#sj zf85O7?mqAD`MuBcd!FZ=+uebRvU!h^o&P|8Ew|+Uw!OO|EV4Ysg z#n4DpmE;gW_0|YLL0py)B>opAa94I8nst5Hysl)+n-6(vSALeh?wbw17pl)JJajR* zGJj;?dd`p1j{k7&KlX0@$(*{^R?mC-UGKUlPG?_fuQ+`5Z|6*P54`e+SMx_lN1l8< zKODHUF!<}iKfk};HbA_N9xdsm%pIw`m^YHEu&cB!&-!m^bbGGBSysI-A=Juie`?43Js`Sa_)z4q9fr;!8Y z%RmpeKs617?_`H}TrjQiWnOY!dbW5`{yiV}e0q85@Y8*%16hloe6Mg@N8Q?%-<&_z zEq0w?PH?4XSN;6$p61|EDdf?tQFMsxmedimMfBdI{-#sTQl(y)c;vY=2#CCQTY^L+eF8^s^<}E`v_WbU) zjI6(=?r8e_{GG$j9SCiG>F-O2hD=Yas=m_G-@Bb1zM@t(-BaXNqMa))`d1@J_D^Nl zV0Hctte`3uPE>hdi7OG>y*?+r77p$UlIL0cy2a zEhJtVms@D;_Dr-eDoSj%cl{Uzd~#!rx*lN(A{L8TVvI$NHV~A{u|$)j(65qXH;x0bxCFDupOa_(z(fp+q{OK!6ZXAXJ09Qq#69 z^Z5f49)<)BvJy#nL9wSHby=DeYg%l^N+O-9fk5{O-f8IZ+!J7k^7~n@Dl{A6`Mhq- z*q;?uK^ED>EoBvWo)RQn0HO`IIviGMkYloha1=L|h52jid^*q)T#ZgWxANl*=lYOog#R*JMR$rYn8EKCPV z%Nd;t2@)PK8`cvAoUTTLsv2@*MhK|kIkD`A10`}g=jC(&NlDtqk`zlhf|Q+QTu{6}oDyRJTpX#~OiA2Phd%QaD8ip>S4*Ar^7-(-T}ABZ&+g63Id1 zR+rK1b|=h{;%O)2bTAxgpC0aaOmDIy#?vb#j017Jn1#fDl{*QTa)Lrxk~VlU!-Jlf zIO)gqGS1YS_!(=no45m{p50_d`p(KVE7yz^m=SokyJqE@kpeRU&vw`UO|HzzcSR6} zfAC`PO)%~8&=L3+na5jgR3=A9lx&I`x0{NT;9+AZi419+{nDKc2 ziWH!rx2KC^h=qUh0uckJObZS!u3!AANvyB0tv!5!nZ3oNnPHcdnntf^gNSglhRlS= zOd|gUvZc=zC>&?4INTs%kaZxzpkdd{&XNNM7#NlbJ4^3rNc*rKXfA`NtDnm{r-UW| DTDLOL