From d226be663d757f673e8b51e853c670e9f1247a70 Mon Sep 17 00:00:00 2001 From: screret <68943070+screret@users.noreply.github.com> Date: Fri, 1 Dec 2023 12:11:08 +0200 Subject: [PATCH] fix rocket launching, disable sky rendering mixin temporarily --- .../gcyr/common/entity/RocketEntity.java | 20 ++++++++++++------- .../gcyr/mixin/LevelRendererMixin.java | 2 ++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/argent_matter/gcyr/common/entity/RocketEntity.java b/common/src/main/java/argent_matter/gcyr/common/entity/RocketEntity.java index cc94e8dc..b84e7fbb 100644 --- a/common/src/main/java/argent_matter/gcyr/common/entity/RocketEntity.java +++ b/common/src/main/java/argent_matter/gcyr/common/entity/RocketEntity.java @@ -28,6 +28,7 @@ import com.lowdragmc.lowdraglib.gui.modular.IUIHolder; import com.lowdragmc.lowdraglib.gui.modular.ModularUI; import com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup; +import com.lowdragmc.lowdraglib.gui.texture.ProgressTexture; import com.lowdragmc.lowdraglib.gui.texture.TextTexture; import com.lowdragmc.lowdraglib.gui.widget.ButtonWidget; import com.lowdragmc.lowdraglib.gui.widget.LabelWidget; @@ -180,7 +181,7 @@ public InteractionResult interact(Player player, InteractionHand hand) { public ModularUI createUI(Player entityPlayer) { return new ModularUI(176, 166, this, entityPlayer) .widget(new LabelWidget(7, 7, this.getDisplayName().getString())) - .widget(new TankWidget(this.fuelTank, 16, 20, 20, 58, true, true).setBackground(GuiTextures.FLUID_TANK_BACKGROUND)) + .widget(new TankWidget(this.fuelTank, 16, 20, 20, 58, true, true).setBackground(GuiTextures.FLUID_TANK_BACKGROUND).setFillDirection(ProgressTexture.FillDirection.DOWN_TO_UP)) .widget(new SlotWidget(configSlot, 0, 40, 20)) .widget(new SlotWidget(satelliteSlot, 0, 60, 20)) .widget(new ButtonWidget(40, 60, 36, 18, new GuiTextureGroup(GuiTextures.BUTTON.copy().setColor(0xFFAA0000), new TextTexture("menu.gcyr.launch")), (clickData) -> this.startRocket())) @@ -307,7 +308,7 @@ public long computeRequiredFuelAmountForDestination(@Nullable Planet destination Planet current = PlanetData.getPlanetFromLevelOrOrbit(this.level().dimension()).orElse(null); if (current == null || destination == null) { return (long) (this.getFuelCapacity() * 0.85); - } else if (destination.parentWorld() == current.level() || current.parentWorld() == destination.level()) { + } else if (destination.parentWorld() == current.level() || current.parentWorld() == destination.level() || current == destination) { return GCyRConfig.INSTANCE.rocket.moonFuelAmount; } else if (current.solarSystem().equals(destination.solarSystem())) { return GCyRConfig.INSTANCE.rocket.solarSystemFuelAmount; @@ -334,7 +335,10 @@ public void startRocket() { } else if (GCyRItems.KEYCARD.isIn(config)) { this.destination = KeyCardBehaviour.getSavedPlanet(config); } - if (this.fuelTank.getFluidAmount() < computeRequiredFuelAmountForDestination(this.destination)) return; + if (this.fuelTank.getFluidAmount() < computeRequiredFuelAmountForDestination(this.destination)) { + sendVehicleHasNoFuelMessage(player); + return; + } if (PlanetIdChipBehaviour.getSpaceStationId(config) != null || KeyCardBehaviour.getSavedStation(config) != null) { this.destinationIsSpaceStation = true; @@ -570,6 +574,8 @@ public void unBuild() { if (!configSlot.getStackInSlot(0).isEmpty()) this.spawnAtLocation(configSlot.getStackInSlot(0)); + if (!satelliteSlot.getStackInSlot(0).isEmpty()) + this.spawnAtLocation(satelliteSlot.getStackInSlot(0)); BlockPos origin = this.blockPosition(); for (PosWithState state : this.getBlocks()) { @@ -601,10 +607,10 @@ private void buildSpaceStation(ItemStack stack, BlockPos origin) { BlockPos pos = state.pos(); if (start) origin = pos; start = false; - if (origin.compareTo(pos) < 0) origin = new BlockPos( - Math.min(pos.getX(), origin.getX()), - Math.min(pos.getY(), origin.getY()), - Math.min(pos.getZ(), origin.getZ())); + if (origin.compareTo(pos.offset(original)) < 0) origin = new BlockPos( + Math.min(pos.getX() + original.getX(), origin.getX()), + Math.min(pos.getY() + original.getY(), origin.getY()), + Math.min(pos.getZ() + original.getZ(), origin.getZ())); } origin = new BlockPos(original.getX() - origin.getX() / 2, original.getY(), original.getZ() - origin.getZ() / 2); diff --git a/common/src/main/java/argent_matter/gcyr/mixin/LevelRendererMixin.java b/common/src/main/java/argent_matter/gcyr/mixin/LevelRendererMixin.java index 7bc3dcdd..e616ff39 100644 --- a/common/src/main/java/argent_matter/gcyr/mixin/LevelRendererMixin.java +++ b/common/src/main/java/argent_matter/gcyr/mixin/LevelRendererMixin.java @@ -14,6 +14,7 @@ @Mixin(LevelRenderer.class) public abstract class LevelRendererMixin { + /* TODO find out how to make sodium happy with this. :sadge: @WrapWithCondition(method = "renderSky", slice = @Slice( from = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShaderTexture(ILnet/minecraft/resources/ResourceLocation;)V") @@ -26,4 +27,5 @@ public abstract class LevelRendererMixin { } return true; } + */ }