From ad3444d58e6a04e9a607e204a8df9478e9cb9525 Mon Sep 17 00:00:00 2001 From: Juniper <86971433+JuneDeveloper@users.noreply.github.com> Date: Tue, 5 Sep 2023 23:55:29 +0100 Subject: [PATCH] Refactored keybinds --- .../teampropulsive/PropulsiveClient.java | 31 ++------- .../teampropulsive/block/BlueprintTable.java | 1 - .../keybind/DockShipKeybind.java | 2 +- .../keybind/MapScreenKeybind.java | 2 +- .../keybind/ShipDownKeybind.java | 2 +- .../keybind/ShipThrottleDownKeybind.java | 4 +- .../keybind/ShipThrottleUpKeybind.java | 4 +- .../screen/BlueprintScreen.java | 39 ----------- .../screen/BlueprintScreenHandler.java | 66 ------------------- 9 files changed, 12 insertions(+), 139 deletions(-) delete mode 100644 src/main/java/io/github/teampropulsive/screen/BlueprintScreen.java delete mode 100644 src/main/java/io/github/teampropulsive/screen/BlueprintScreenHandler.java diff --git a/src/main/java/io/github/teampropulsive/PropulsiveClient.java b/src/main/java/io/github/teampropulsive/PropulsiveClient.java index 0ba7454..4804cd7 100644 --- a/src/main/java/io/github/teampropulsive/PropulsiveClient.java +++ b/src/main/java/io/github/teampropulsive/PropulsiveClient.java @@ -1,35 +1,20 @@ package io.github.teampropulsive; -import io.github.teampropulsive.block.Blocks; -import io.github.teampropulsive.block.BlueprintTable; -import io.github.teampropulsive.block.BlueprintTableBlockEntity; import io.github.teampropulsive.block.BlueprintTableBlockEntityRenderer; import io.github.teampropulsive.client.world.SpaceDimensionEffects; import io.github.teampropulsive.client.world.SpaceSkyRenderer; import io.github.teampropulsive.keybind.ShipDownKeybind; import io.github.teampropulsive.keybind.ShipThrottleDownKeybind; import io.github.teampropulsive.keybind.ShipThrottleUpKeybind; -import io.github.teampropulsive.screen.BlueprintScreen; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.client.rendering.v1.BlockEntityRendererRegistry; import net.fabricmc.fabric.api.client.rendering.v1.DimensionRenderingRegistry; -import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry; -import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; -import net.minecraft.block.entity.BlockEntityType; -import net.minecraft.block.entity.SignBlockEntity; import net.minecraft.client.gui.screen.ingame.HandledScreens; import net.minecraft.client.render.block.entity.BlockEntityRendererFactories; -import net.minecraft.client.render.block.entity.BlockEntityRendererFactory; -import net.minecraft.client.render.block.entity.SignBlockEntityRenderer; import net.minecraft.client.render.entity.model.EntityModelLayer; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; -import net.minecraft.screen.CraftingScreenHandler; -import net.minecraft.screen.ScreenHandlerType; import net.minecraft.util.Identifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,8 +29,8 @@ import static io.github.teampropulsive.Propulsive.*; import static io.github.teampropulsive.block.Blocks.BLUEPRINT_TABLE_BLOCK_ENTITY; -import static io.github.teampropulsive.keybind.DockShipKeybind.DockKeybindRegister; -import static io.github.teampropulsive.keybind.MapScreenKeybind.MapScreenKeybindRegister; +import static io.github.teampropulsive.keybind.DockShipKeybind.dockKeybindRegister; +import static io.github.teampropulsive.keybind.MapScreenKeybind.mapScreenKeybindRegister; @Environment(EnvType.CLIENT) public class PropulsiveClient implements ClientModInitializer { @@ -75,14 +60,12 @@ public void onInitializeClient() { EARTH.render(); // Key binds - MapScreenKeybindRegister(); - DockKeybindRegister(); - ShipThrottleUpKeybind.ShipThrottleUpKeybind(); - ShipThrottleDownKeybind.ShipThrottleDownKeybind(); - ShipDownKeybind.ShipDownKeybind(); + mapScreenKeybindRegister(); + dockKeybindRegister(); + ShipThrottleUpKeybind.shipThrottleUpKeybind(); + ShipThrottleDownKeybind.shipThrottleDownKeybind(); + ShipDownKeybind.shipDownKeybind(); - // Screen handler - HandledScreens.register(BLUEPRINT_SCREEN_HANDLER, BlueprintScreen::new); } // Returns contributors from git repo or from the fallback list in the JAR if network is unavailable diff --git a/src/main/java/io/github/teampropulsive/block/BlueprintTable.java b/src/main/java/io/github/teampropulsive/block/BlueprintTable.java index 5a48c4a..6e850cc 100644 --- a/src/main/java/io/github/teampropulsive/block/BlueprintTable.java +++ b/src/main/java/io/github/teampropulsive/block/BlueprintTable.java @@ -1,6 +1,5 @@ package io.github.teampropulsive.block; -import io.github.teampropulsive.screen.BlueprintScreen; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.block.BlockState; diff --git a/src/main/java/io/github/teampropulsive/keybind/DockShipKeybind.java b/src/main/java/io/github/teampropulsive/keybind/DockShipKeybind.java index aae6aca..9eeb68e 100644 --- a/src/main/java/io/github/teampropulsive/keybind/DockShipKeybind.java +++ b/src/main/java/io/github/teampropulsive/keybind/DockShipKeybind.java @@ -7,7 +7,7 @@ public class DockShipKeybind { public static KeyBinding dockShipKey; - public static void DockKeybindRegister() { + public static void dockKeybindRegister() { dockShipKey = KeyBindingHelper.registerKeyBinding(new KeyBinding( "key.propulsive.dock", InputUtil.Type.KEYSYM, diff --git a/src/main/java/io/github/teampropulsive/keybind/MapScreenKeybind.java b/src/main/java/io/github/teampropulsive/keybind/MapScreenKeybind.java index bf73885..fd5a244 100644 --- a/src/main/java/io/github/teampropulsive/keybind/MapScreenKeybind.java +++ b/src/main/java/io/github/teampropulsive/keybind/MapScreenKeybind.java @@ -8,7 +8,7 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; public class MapScreenKeybind { private static KeyBinding openMapScreenKey; - public static void MapScreenKeybindRegister() { + public static void mapScreenKeybindRegister() { openMapScreenKey = KeyBindingHelper.registerKeyBinding(new KeyBinding( "key.propulsive.open", InputUtil.Type.KEYSYM, diff --git a/src/main/java/io/github/teampropulsive/keybind/ShipDownKeybind.java b/src/main/java/io/github/teampropulsive/keybind/ShipDownKeybind.java index 983b876..383a5da 100644 --- a/src/main/java/io/github/teampropulsive/keybind/ShipDownKeybind.java +++ b/src/main/java/io/github/teampropulsive/keybind/ShipDownKeybind.java @@ -7,7 +7,7 @@ public class ShipDownKeybind { private static KeyBinding shipDownKeybind; - public static void ShipDownKeybind() { + public static void shipDownKeybind() { shipDownKeybind = KeyBindingHelper.registerKeyBinding(new KeyBinding( "key.propulsive.ship.down", InputUtil.Type.KEYSYM, diff --git a/src/main/java/io/github/teampropulsive/keybind/ShipThrottleDownKeybind.java b/src/main/java/io/github/teampropulsive/keybind/ShipThrottleDownKeybind.java index 6890301..8720d89 100644 --- a/src/main/java/io/github/teampropulsive/keybind/ShipThrottleDownKeybind.java +++ b/src/main/java/io/github/teampropulsive/keybind/ShipThrottleDownKeybind.java @@ -1,7 +1,5 @@ package io.github.teampropulsive.keybind; -import io.github.teampropulsive.screen.MapScreen; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.minecraft.client.option.KeyBinding; import net.minecraft.client.util.InputUtil; @@ -9,7 +7,7 @@ public class ShipThrottleDownKeybind { public static KeyBinding shipThrottleDownKeybind; - public static void ShipThrottleDownKeybind() { + public static void shipThrottleDownKeybind() { shipThrottleDownKeybind = KeyBindingHelper.registerKeyBinding(new KeyBinding( "key.propulsive.ship.tdown", InputUtil.Type.KEYSYM, diff --git a/src/main/java/io/github/teampropulsive/keybind/ShipThrottleUpKeybind.java b/src/main/java/io/github/teampropulsive/keybind/ShipThrottleUpKeybind.java index cfeda26..9798d03 100644 --- a/src/main/java/io/github/teampropulsive/keybind/ShipThrottleUpKeybind.java +++ b/src/main/java/io/github/teampropulsive/keybind/ShipThrottleUpKeybind.java @@ -1,7 +1,5 @@ package io.github.teampropulsive.keybind; -import io.github.teampropulsive.screen.MapScreen; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.minecraft.client.option.KeyBinding; import net.minecraft.client.util.InputUtil; @@ -9,7 +7,7 @@ public class ShipThrottleUpKeybind { public static KeyBinding shipThrottleUpKeybind; - public static void ShipThrottleUpKeybind() { + public static void shipThrottleUpKeybind() { shipThrottleUpKeybind = KeyBindingHelper.registerKeyBinding(new KeyBinding( "key.propulsive.ship.tup", InputUtil.Type.KEYSYM, diff --git a/src/main/java/io/github/teampropulsive/screen/BlueprintScreen.java b/src/main/java/io/github/teampropulsive/screen/BlueprintScreen.java deleted file mode 100644 index 381b9a6..0000000 --- a/src/main/java/io/github/teampropulsive/screen/BlueprintScreen.java +++ /dev/null @@ -1,39 +0,0 @@ -package io.github.teampropulsive.screen; - -import com.mojang.blaze3d.systems.RenderSystem; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.ingame.HandledScreen; -import net.minecraft.client.render.GameRenderer; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.Inventory; -import net.minecraft.text.Text; -import net.minecraft.util.Identifier; - -@Environment(EnvType.CLIENT) -public class BlueprintScreen extends HandledScreen { - //A path to the gui texture. In this example we use the texture from the dispenser - private static final Identifier TEXTURE = new Identifier("minecraft", "textures/gui/container/dispenser.png"); - - public BlueprintScreen(BlueprintScreenHandler handler, PlayerInventory inventory, Text title) { - super(handler, inventory, title); - } - - - - @Override - protected void init() { - super.init(); - // Center the title - titleX = (backgroundWidth - textRenderer.getWidth(title)) / 2; - } - - @Override - protected void drawBackground(DrawContext context, float delta, int mouseX, int mouseY) { - - } -} - diff --git a/src/main/java/io/github/teampropulsive/screen/BlueprintScreenHandler.java b/src/main/java/io/github/teampropulsive/screen/BlueprintScreenHandler.java deleted file mode 100644 index 6ea8ad0..0000000 --- a/src/main/java/io/github/teampropulsive/screen/BlueprintScreenHandler.java +++ /dev/null @@ -1,66 +0,0 @@ -package io.github.teampropulsive.screen; - -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.Inventory; -import net.minecraft.inventory.SimpleInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.slot.Slot; - -public class BlueprintScreenHandler extends ScreenHandler { - private final Inventory inventory; - - //This constructor gets called on the client when the server wants it to open the screenHandler, - //The client will call the other constructor with an empty Inventory and the screenHandler will automatically - //sync this empty inventory with the inventory on the server. - public BlueprintScreenHandler(int syncId, PlayerInventory playerInventory) { - this(syncId, playerInventory, new SimpleInventory(9)); - } - - //This constructor gets called from the BlockEntity on the server without calling the other constructor first, the server knows the inventory of the container - //and can therefore directly provide it as an argument. This inventory will then be synced to the client. - public BlueprintScreenHandler(int syncId, PlayerInventory playerInventory, Inventory inventory) { - super(BLUEPRINT_SCREEN_HANDLER, syncId); - checkSize(inventory, 9); - this.inventory = inventory; - //some inventories do custom logic when a player opens it. - inventory.onOpen(playerInventory.player); - - //This will place the slot in the correct locations for a 3x3 Grid. The slots exist on both server and client! - //This will not render the background of the slots however, this is the Screens job - int m; - int l; - //Our inventory - for (m = 0; m < 3; ++m) { - for (l = 0; l < 3; ++l) { - this.addSlot(new Slot(inventory, l + m * 3, 62 + l * 18, 17 + m * 18)); - } - } - //The player inventory - for (m = 0; m < 3; ++m) { - for (l = 0; l < 9; ++l) { - this.addSlot(new Slot(playerInventory, l + m * 9 + 9, 8 + l * 18, 84 + m * 18)); - } - } - //The player Hotbar - for (m = 0; m < 9; ++m) { - this.addSlot(new Slot(playerInventory, m, 8 + m * 18, 142)); - } - - } - - @Override - public ItemStack quickMove(PlayerEntity player, int slot) { - return null; - } - - @Override - public boolean canUse(PlayerEntity player) { - return this.inventory.canPlayerUse(player); - } - - - -} -