Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rocket refactoring + starting some features / fixes #331

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
db479b9
fix: remove rocket entity when damaged in survival
LeMayday May 27, 2024
355c091
fix: rocket does not drop when broken
LeMayday May 27, 2024
2634eaf
feature: player dismounts rocket close to the ground
LeMayday May 27, 2024
09237df
refactor: improve onPlace readability
LeMayday May 27, 2024
fb17484
fix: rocket does not break when launchpad is broken
LeMayday May 28, 2024
f163dbd
fix: dropped rocket will copy NBT data rather than spawn default item
LeMayday May 30, 2024
ab0229d
Merge remote-tracking branch 'upstream/main' into fix-rocket-bugs
LeMayday May 30, 2024
ed914cb
Merge branch 'TeamGalacticraft:main' into fix-rocket-bugs
LeMayday Jun 1, 2024
08f8f18
feat: certain projectiles bounce off rocket
LeMayday Jun 1, 2024
2df9783
fix: rocket no longer hangs when exited
LeMayday Jun 1, 2024
d0697ab
refactor: moved GC vehicle-related files to new folder
LeMayday Jun 2, 2024
4b2f0f4
refactor: vehicles inherit from GCVehicleEntity
LeMayday Jun 3, 2024
afe4ccb
fix: lander gets instantiated on the destination celestial body
LeMayday Jun 3, 2024
e5bb153
refactor: added RequiresFuel interface for vehicles
LeMayday Jun 3, 2024
29cf630
refactor: added RideableVehicleEntity class for further subdivision o…
LeMayday Jun 3, 2024
92e309f
refactor: moved fuel related methods out of rocket interface
LeMayday Jun 4, 2024
a312475
refactor: reorganized methods to have consistent order
LeMayday Jun 4, 2024
1b57bd7
refactor: reorganized rocketentity code
LeMayday Jun 4, 2024
5a046b1
refactor: added inventory-related methods to GCVehicleEntity
LeMayday Jun 4, 2024
124031e
implemented IDE suggestions
LeMayday Jun 4, 2024
4c1140d
refactor: AbstractLanderEntity extends GCPlayerRideableVehicleEntity
LeMayday Jun 4, 2024
d5648a8
refactor: added inventory interfaces to rocket interface
LeMayday Jun 5, 2024
bd558f0
refactor: changed rideable vehicle class to PlayerRideable interface
LeMayday Jun 5, 2024
81c2373
refactor: removed assumption that all GCVehicleEntities will have vie…
LeMayday Jun 5, 2024
5f39eb9
refactor: RequiresFuel now extends ScalableFuelLevel
LeMayday Jun 5, 2024
4853665
refactor: created GCFueledVehicleEntity class
LeMayday Jun 5, 2024
c631d53
refactor: lander reorganized based on new super classes
LeMayday Jun 5, 2024
f0cdcdd
refactor: buggy reorganized based on new superclasses
LeMayday Jun 5, 2024
cafbb8b
refactor: rocket reorganized based on new superclasses
LeMayday Jun 5, 2024
beee0b9
fix: fixed compiler error where fuel data needed to be a long
LeMayday Jun 5, 2024
e3438ac
refactor: removed PlayerRideable interface
LeMayday Jun 6, 2024
c5eddd7
refactor: moved lerp back to Rocket
LeMayday Jun 6, 2024
92bee8a
refactor: initialized inventory
LeMayday Jun 6, 2024
ea83fad
refactor: reorganized AbstractLanderEntity again
LeMayday Jun 6, 2024
6d2cbb7
refactor: readded isPickable to rocket
LeMayday Jun 6, 2024
c3967cb
trying to make the rocket inventory screen work
LeMayday Jun 8, 2024
7106237
fix: changed rocket inventory default key to G
LeMayday Jun 8, 2024
4263491
style: made some changes based on IDEA suggestions
LeMayday Jun 8, 2024
066d1ee
style: style changes
LeMayday Jun 9, 2024
b63f88a
refactor: simplified abstract lander entity interaction code
LeMayday Jun 9, 2024
8dbef26
feat: messing around with rocket inventory
LeMayday Jun 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/main/java/dev/galacticraft/api/rocket/entity/RequiresFuel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package dev.galacticraft.api.rocket.entity;

import dev.galacticraft.mod.content.entity.ScalableFuelLevel;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
import net.minecraft.world.level.material.Fluid;
import org.jetbrains.annotations.Nullable;

public interface RequiresFuel extends ScalableFuelLevel {

@Nullable
Fluid getFuelTankFluid();

long getFuelTankAmount();

long getFuelTankCapacity();

boolean isTankEmpty();

Storage<FluidVariant> getFuelTank();

}
12 changes: 3 additions & 9 deletions src/main/java/dev/galacticraft/api/rocket/entity/Rocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@
import dev.galacticraft.api.rocket.LaunchStage;
import dev.galacticraft.api.rocket.RocketData;
import dev.galacticraft.api.rocket.part.*;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory;
import net.minecraft.core.BlockPos;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.entity.HasCustomInventoryScreen;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public interface Rocket extends RocketData {
public interface Rocket extends RocketData, RequiresFuel, HasCustomInventoryScreen, ExtendedScreenHandlerFactory {
/**
* Returns the launch stage of this rocket.
* @return the launch stage of this rocket.
Expand Down Expand Up @@ -79,10 +78,5 @@ public interface Rocket extends RocketData {
*/
void dropItems(DamageSource source, boolean exploded);

@Nullable Fluid getFuelTankFluid();
long getFuelTankAmount();
long getFuelTankCapacity();
Storage<FluidVariant> getFuelTank();

Entity asEntity();
}
2 changes: 1 addition & 1 deletion src/main/java/dev/galacticraft/mod/GalacticraftClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import dev.galacticraft.mod.content.GCBlocks;
import dev.galacticraft.mod.content.GCEntityTypes;
import dev.galacticraft.mod.content.block.environment.FallenMeteorBlock;
import dev.galacticraft.mod.content.entity.orbital.RocketEntity;
import dev.galacticraft.mod.content.entity.vehicle.RocketEntity;
import dev.galacticraft.mod.content.item.GCItems;
import dev.galacticraft.mod.events.ClientEventHandler;
import dev.galacticraft.mod.misc.cape.CapesLoader;
Expand Down
29 changes: 25 additions & 4 deletions src/main/java/dev/galacticraft/mod/client/GCKeyBinds.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package dev.galacticraft.mod.client;

import dev.galacticraft.mod.client.gui.screen.ingame.CelestialSelectionScreen;
import dev.galacticraft.mod.content.entity.vehicle.RocketEntity;
import dev.galacticraft.mod.util.Translations;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.KeyMapping;
Expand All @@ -31,20 +32,40 @@

public class GCKeyBinds {
public static final KeyMapping OPEN_CELESTIAL_SCREEN = new KeyMapping(Translations.Keybindings.OPEN_CELESTIAL_SCREEN, GLFW.GLFW_KEY_M, KeyMapping.CATEGORY_MISC);
public static final KeyMapping OPEN_ROCKET_INVENTORY = new KeyMapping(Translations.Keybindings.ROCKET_INVENTORY, GLFW.GLFW_KEY_F, KeyMapping.CATEGORY_INVENTORY);
//public static final KeyMapping OPEN_ROCKET_INVENTORY = new KeyMapping(Translations.Keybindings.ROCKET_INVENTORY, GLFW.GLFW_KEY_G, KeyMapping.CATEGORY_INVENTORY);

public static void register() {
KeyBindingHelper.registerKeyBinding(OPEN_CELESTIAL_SCREEN);
KeyBindingHelper.registerKeyBinding(OPEN_ROCKET_INVENTORY);
//KeyBindingHelper.registerKeyBinding(OPEN_ROCKET_INVENTORY);
}

public static void handleKeybinds(Minecraft client) {
if (client.level != null && client.player != null) {
if (client.screen == null) {
while (OPEN_CELESTIAL_SCREEN.consumeClick()) {
while (OPEN_CELESTIAL_SCREEN.consumeClick()) {
if (client.screen == null) {
client.setScreen(new CelestialSelectionScreen(true, null, false, null));
}
}
// while (OPEN_ROCKET_INVENTORY.consumeClick()) {
// if (client.player.getVehicle() instanceof RocketEntity rocket) {
// rocket.openCustomInventoryScreen(client.player);
// }
// }
// if (client.screen == null) {
// while (OPEN_CELESTIAL_SCREEN.consumeClick()) {
// client.setScreen(new CelestialSelectionScreen(true, null, false, null));
// }
// }
// if (client.player.getVehicle() instanceof RocketEntity rocket) {
// while (OPEN_ROCKET_INVENTORY.consumeClick()) {
// rocket.openCustomInventoryScreen(client.player);
// }
// }
// if (OPEN_CELESTIAL_SCREEN.consumeClick() && client.screen == null) {
// client.setScreen(new CelestialSelectionScreen(true, null, false, null));
// } else if (OPEN_ROCKET_INVENTORY.consumeClick() && client.player.getVehicle() instanceof RocketEntity rocket) {
// rocket.openCustomInventoryScreen(client.player);
// }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
package dev.galacticraft.mod.client.gui.overlay;

import dev.galacticraft.api.rocket.LaunchStage;
import dev.galacticraft.mod.content.entity.orbital.RocketEntity;
import dev.galacticraft.mod.content.entity.vehicle.RocketEntity;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.util.FastColor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
package dev.galacticraft.mod.client.gui.overlay;

import com.mojang.blaze3d.platform.Window;
import dev.galacticraft.mod.content.entity.orbital.lander.LanderEntity;
import dev.galacticraft.mod.content.entity.vehicle.LanderEntity;
import dev.galacticraft.mod.util.Translations;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.mojang.blaze3d.vertex.*;
import com.mojang.math.Axis;
import dev.galacticraft.mod.Constant;
import dev.galacticraft.mod.content.entity.orbital.RocketEntity;
import dev.galacticraft.mod.content.entity.vehicle.RocketEntity;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.GameRenderer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import net.minecraft.world.entity.player.Inventory;

public class ParachestScreen extends AbstractContainerScreen<ParachestMenu> {
private static ResourceLocation[] parachestTexture = new ResourceLocation[4];
private static final ResourceLocation[] parachestTexture = new ResourceLocation[4];

static {
for (int i = 0; i < 4; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import net.minecraft.world.entity.player.Inventory;

public class RocketInventoryScreen extends AbstractContainerScreen<RocketMenu> {

public RocketInventoryScreen(RocketMenu abstractContainerMenu, Inventory inventory, Component component) {
super(abstractContainerMenu, inventory, component);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import dev.galacticraft.mod.content.GCEntityTypes;
import dev.galacticraft.mod.content.GCRocketParts;
import dev.galacticraft.mod.content.block.entity.RocketWorkbenchBlockEntity;
import dev.galacticraft.mod.content.entity.orbital.RocketEntity;
import dev.galacticraft.mod.content.entity.vehicle.RocketEntity;
import dev.galacticraft.mod.machine.storage.VariableSizedContainer;
import dev.galacticraft.mod.network.packets.SelectPartPacket;
import dev.galacticraft.mod.screen.RocketWorkbenchMenu;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import dev.galacticraft.mod.content.entity.orbital.lander.LanderEntity;
import dev.galacticraft.mod.content.entity.vehicle.LanderEntity;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import dev.galacticraft.mod.client.model.GCModelLoader;
import dev.galacticraft.mod.client.model.GCModelState;
import dev.galacticraft.mod.client.model.GCSheets;
import dev.galacticraft.mod.content.entity.Buggy;
import dev.galacticraft.mod.content.entity.vehicle.Buggy;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@
import dev.galacticraft.mod.Constant;
import dev.galacticraft.mod.client.model.entity.LanderModel;
import dev.galacticraft.mod.client.render.entity.model.GCEntityModelLayer;
import dev.galacticraft.mod.content.entity.orbital.lander.LanderEntity;
import dev.galacticraft.mod.content.entity.vehicle.LanderEntity;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.resources.ResourceLocation;
import org.lwjgl.opengl.GL11;

public class LanderEntityRenderer extends EntityRenderer<LanderEntity> {
protected final LanderModel model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import dev.galacticraft.api.entity.rocket.render.RocketPartRendererRegistry;
import dev.galacticraft.api.rocket.LaunchStage;
import dev.galacticraft.api.rocket.part.RocketPart;
import dev.galacticraft.mod.content.entity.orbital.RocketEntity;
import dev.galacticraft.mod.content.entity.vehicle.RocketEntity;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.culling.Frustum;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import dev.galacticraft.api.rocket.RocketData;
import dev.galacticraft.api.rocket.part.RocketPart;
import dev.galacticraft.mod.content.GCEntityTypes;
import dev.galacticraft.mod.content.entity.orbital.RocketEntity;
import dev.galacticraft.mod.content.entity.vehicle.RocketEntity;
import net.fabricmc.fabric.api.client.rendering.v1.BuiltinItemRendererRegistry;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import dev.galacticraft.api.rocket.LaunchStage;
import dev.galacticraft.mod.Constant;
import dev.galacticraft.mod.content.GCSounds;
import dev.galacticraft.mod.content.entity.orbital.RocketEntity;
import dev.galacticraft.mod.content.entity.vehicle.RocketEntity;
import net.minecraft.client.resources.sounds.AbstractTickableSoundInstance;
import net.minecraft.client.resources.sounds.SoundInstance;
import net.minecraft.sounds.SoundSource;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/dev/galacticraft/mod/content/GCEntityTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
import dev.galacticraft.mod.Constant.Entity;
import dev.galacticraft.mod.content.entity.*;
import dev.galacticraft.mod.content.entity.boss.SkeletonBoss;
import dev.galacticraft.mod.content.entity.orbital.RocketEntity;
import dev.galacticraft.mod.content.entity.orbital.lander.LanderEntity;
import dev.galacticraft.mod.content.entity.vehicle.Buggy;
import dev.galacticraft.mod.content.entity.vehicle.RocketEntity;
import dev.galacticraft.mod.content.entity.vehicle.LanderEntity;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
import net.minecraft.core.registries.BuiltInRegistries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import dev.galacticraft.api.rocket.LaunchStage;
import dev.galacticraft.mod.content.entity.orbital.RocketEntity;
import dev.galacticraft.mod.content.entity.vehicle.RocketEntity;
import net.minecraft.advancements.critereon.ContextAwarePredicate;
import net.minecraft.advancements.critereon.EntityPredicate;
import net.minecraft.advancements.critereon.SimpleCriterionTrigger;
Expand Down
Loading