Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
paulyhedral committed Dec 5, 2024
1 parent 1799460 commit f988f17
Show file tree
Hide file tree
Showing 38 changed files with 252 additions and 825 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,20 @@ jobs:
name: Get last version
run: |
echo "latest_version=$(cat .release-info/${{ github.ref_name }}/VERSION)" >> $GITHUB_ENV
- id: get_bump_level
name: Get bump level
run: |
echo "bump_level=$(cat .release-info/${{ github.ref_name }}/BUMP_LEVEL)" >> $GITHUB_ENV
- id: bump_version
name: Bump version
uses: cbrgm/semver-bump-action@main
with:
current-version: ${{ env.latest_version }}
bump-level: patch
bump-level: ${{ env.bump_level || 'patch' }}
- id: reset_bump_level
name: Reset bump level
run: |
echo "patch" > .release-info/${{ github.ref_name }}/BUMP_LEVEL
- name: Build with Gradle
uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7
with:
Expand All @@ -54,8 +62,8 @@ jobs:
git config --global user.email "[email protected]"
git config --global user.name "SweetRPG CI"
echo "${{ steps.bump_version.outputs.new_version }}" > .release-info/${{ github.ref_name }}/VERSION
git add .release-info/${{ github.ref_name }}/VERSION
git commit -m "Update ${{ github.ref_name }} VERSION file"
git add .release-info/${{ github.ref_name }}/*
git commit -m "Update ${{ github.ref_name }} .release-info files"
git push origin
- name: Release artifacts
uses: softprops/action-gh-release@v1
Expand Down
17 changes: 0 additions & 17 deletions src/main/java/com/sweetrpg/crafttracker/CraftTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public CraftTracker() {
ModBlocks.BLOCKS.register(modEventBus);
ModBlockEntityTypes.TILE_ENTITIES.register(modEventBus);
ModItems.ITEMS.register(modEventBus);
// ModEntityTypes.ENTITIES.register(modEventBus);
ModContainerTypes.CONTAINERS.register(modEventBus);
ModSerializers.SERIALIZERS.register(modEventBus);
ModRecipeSerializers.RECIPE_SERIALIZERS.register(modEventBus);
Expand All @@ -70,10 +69,6 @@ public CraftTracker() {
// Client Events
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
modEventBus.addListener(this::clientSetup);
// modEventBus.addListener(ModBlocks::registerBlockColours);
// modEventBus.addListener(ClientEventHandler::onModelBakeEvent);
// modEventBus.addListener(ClientSetup::setupTileEntityRenderers);
// modEventBus.addListener(ClientSetup::setupEntityRenderers);
modEventBus.addListener(ClientSetup::addClientReloadListeners);
modEventBus.addListener(ClientSetup::addKeyBindings);

Expand All @@ -85,9 +80,6 @@ public CraftTracker() {
AddonManager.init();
}

// public void commonSetup(final FMLCommonSetupEvent event) {
// }

public void serverStarting(final ServerStartingEvent event) {
LOGGER.debug("Server starting");
}
Expand Down Expand Up @@ -119,22 +111,13 @@ private void gatherData(final GatherDataEvent event) {
DataGenerator gen = event.getGenerator();

if(event.includeClient()) {
// BlockstateProvider blockstates = new BlockstateProvider(gen, event.getExistingFileHelper());
// gen.addProvider(blockstates);
// gen.addProvider(new ItemModelProvider(gen, blockstates.getExistingHelper()));
gen.addProvider(new CTLangProvider(gen, Constants.LOCALE_EN_US));
gen.addProvider(new CTLangProvider(gen, Constants.LOCALE_EN_GB));
gen.addProvider(new CTLangProvider(gen, Constants.LOCALE_DE_DE));
}

if(event.includeServer()) {
// gen.addProvider(new DTBlockTagsProvider(gen));
gen.addProvider(new CTAdvancementProvider(gen));
// BlockTagsProvider blockTagProvider = new CHBlockTagsProvider(gen, event.getExistingFileHelper());
// gen.addProvider(blockTagProvider);
// gen.addProvider(new ItemTagsProvider(gen, blockTagProvider, event.getExistingFileHelper()));
// gen.addProvider(new RecipeProvider(gen));
// gen.addProvider(new LootTableProvider(gen));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,13 @@
public class ClientSetup {

public static void setupScreenManagers(final FMLClientSetupEvent event) {
// MenuScreens.register(ModContainerTypes.CAT_BOWL.get(), CatBowlScreen::new);
}

// public static void setupEntityRenderers(final EntityRenderersEvent.RegisterLayerDefinitions event) {
// }

// public static void setupTileEntityRenderers(final EntityRenderersEvent.RegisterRenderers event) {
// }

public static void addClientReloadListeners(final RegisterClientReloadListenersEvent event) {
// event.registerReloadListener(CatTextureManager.INSTANCE);
}

public static void addKeyBindings(final FMLClientSetupEvent event) {

MinecraftForge.EVENT_BUS.addListener(ClientEventHandler::onClientTick);
MinecraftForge.EVENT_BUS.addListener(ClientEventHandler::onScreenInit);
MinecraftForge.EVENT_BUS.addListener(ClientEventHandler::onKeyInput);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,10 @@
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.client.event.MovementInputUpdateEvent;
import net.minecraftforge.client.event.ScreenEvent;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;

public class ClientEventHandler {

public static void onClientTick(TickEvent.ClientTickEvent event) {
CraftTracker.LOGGER.trace("#onClientTick: {}", event);

// if(event.phase != TickEvent.Phase.END) return;
//
// if(ModKeyBindings.ADD_TO_QUEUE_MAPPING.consumeClick()) {
// CraftTracker.LOGGER.debug("#onKeyInput: ADD_TO_QUEUE_MAPPING");
//
// handleAddToQueue();
// }
// else if(ModKeyBindings.TOGGLE_CRAFT_QUEUE_MAPPING.consumeClick()) {
// CraftTracker.LOGGER.debug("#onKeyInput: TOGGLE_CRAFT_LIST_MAPPING");
//
// handleToggleCraftList();
// }
// else if(ModKeyBindings.TOGGLE_SHOPPING_LIST_MAPPING.consumeClick()) {
// CraftTracker.LOGGER.debug("#onKeyInput: TOGGLE_SHOPPING_LIST_MAPPING");
//
// handleToggleShoppingList();
// }
// else if(ModKeyBindings.OPEN_QUEUE_MANAGER_MAPPING.consumeClick()) {
// CraftTracker.LOGGER.debug("#onKeyInput: OPEN_QUEUE_MANAGER_MAPPING");
//
// QueueManagementScreen.open();
// }
// else if(ModKeyBindings.POPULATE_SHOPPING_LIST_MAPPING.consumeClick()) {
// CraftTracker.LOGGER.debug("#onKeyInput: POPULATE_SHOPPING_LIST_MAPPING");
//
// handlePopulateShoppingList();
// }
}

// @SubscribeEvent
public static void onKeyInput(final InputEvent.KeyInputEvent event) {
CraftTracker.LOGGER.trace("#onKeyInput: {}", event);

Expand Down Expand Up @@ -213,7 +179,6 @@ private static void handleAddToQueue() {

var player = Minecraft.getInstance().player;
CraftingQueueManager.INSTANCE.addProduct(player, res, 1);
// PacketHandler.sendToServer(new AddToQueueData(res, 1));
}
});
}
Expand All @@ -224,41 +189,10 @@ public void onInputEvent(final MovementInputUpdateEvent event) {

}

// public static void onScreenRemove() {
// CraftTracker.LOGGER.trace("#onScreenRemove: {}", event);
//
// CTRuntime.INSTANCE.screenOpen = false;
// }

@SubscribeEvent
public static void onScreenInit(final ScreenEvent.InitScreenEvent.Post event) {
CraftTracker.LOGGER.trace("#onScreenInit: {}", event);

// CTRuntime.INSTANCE.screenOpen = true;

// Screen screen = event.getScreen();
// if(screen instanceof InventoryScreen || screen instanceof CreativeModeInventoryScreen) {
// boolean creative = screen instanceof CreativeModeInventoryScreen;
//// CraftTracker.LOGGER.debug("#onScreenInit: creative {}", creative);
//
// // boolean dtLoaded = ModList.get().isLoaded("doggytalents");
// Minecraft mc = Minecraft.getInstance();
// int width = mc.getWindow().getGuiScaledWidth();
// int height = mc.getWindow().getGuiScaledHeight();
// int sizeX = creative ? 195 : 176;
// int sizeY = creative ? 136 : 166;
// int guiLeft = (width - sizeX) / 2 - ((creative) ? 15 : 0);
// int guiTop = (height - sizeY) / 2 - ((!creative) ? 13 : 0);
//
// int x = guiLeft + (creative ? 36 : sizeX / 2 - 10);
// int y = guiTop + (creative ? 7 : 48);
//
// event.addListener(new SmallButton(x, y, new TranslatableComponent("X"), (btn) -> {
// CraftTracker.LOGGER.debug("#onScreenInit: SMALL BUTTON PRESSED {}", btn);
//// PacketHandler.send(PacketDistributor.SERVER.noArg(), new AddToQueueData("TODO"));
////// btn.active = false;
// }));
// }
}

@SubscribeEvent
Expand All @@ -267,71 +201,10 @@ public void onScreenDrawForeground(final ScreenEvent.DrawScreenEvent event) {

Screen screen = event.getScreen();
if(screen instanceof InventoryScreen || screen instanceof CreativeModeInventoryScreen) {
boolean creative = screen instanceof CreativeModeInventoryScreen;
// CraftTracker.LOGGER.debug("#onScreenInit: creative {}", creative);

// CatInventoryButton btn = null;
//
// //TODO just create a static variable in this class
// for (Widget widget : screen.renderables) {
// if (widget instanceof CatInventoryButton) {
// btn = (CatInventoryButton) widget;
// break;
// }
// }
//
// if (btn.visible && btn.isHoveredOrFocused()) {
// Minecraft mc = Minecraft.getInstance();
// int width = mc.getWindow().getGuiScaledWidth();
// int height = mc.getWindow().getGuiScaledHeight();
// int sizeX = creative ? 195 : 176;
// int sizeY = creative ? 136 : 166;
// int guiLeft = (width - sizeX) / 2;
// int guiTop = (height - sizeY) / 2;
// if (!creative) {
// RecipeBookComponent recipeBook = ((InventoryScreen) screen).getRecipeBookComponent();
// if (recipeBook.isVisible()) {
// guiLeft += 76;
// }
// }
//
// //event.getPoseStack().translate(-guiLeft, -guiTop, 0);
// btn.renderToolTip(event.getPoseStack(), event.getMouseX(), event.getMouseY());
// //event.getPoseStack().translate(guiLeft, guiTop, 0);
// }
// boolean creative = screen instanceof CreativeModeInventoryScreen;

// TODO
}
}

// public void drawSelectionBox(PoseStack matrixStackIn, Player player, float particleTicks, AABB boundingBox) {
// CraftTracker.LOGGER.debug("#drawSelectionBox: {}, player: {}", matrixStackIn, player);
//
// RenderSystem.setShader(GameRenderer::getPositionTexShader);
// RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
// // RenderSystem.disableAlphaTest();
// RenderSystem.depthMask(false);
// RenderSystem.enableBlend();
// RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
// RenderSystem.setShaderColor(0.0F, 0.0F, 0.0F, 0.7F);
// //TODO Used when drawing outline of bounding box
// RenderSystem.lineWidth(2.0F);
//
//
// RenderSystem.disableTexture();
// Vec3 vec3d = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition();
// double d0 = vec3d.x();
// double d1 = vec3d.y();
// double d2 = vec3d.z();
//
// BufferBuilder bufferbuilder = Tesselator.getInstance().getBuilder();
// bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
// LevelRenderer.renderLineBox(matrixStackIn, bufferbuilder, boundingBox.move(-d0, -d1, -d2), 1F, 1F, 0F, 0.8F);
// Tesselator.getInstance().end();
// RenderSystem.setShaderColor(0.0F, 0.0F, 0.0F, 0.3F);
// RenderSystem.depthMask(true);
// RenderSystem.enableTexture();
// RenderSystem.disableBlend();
// //RenderSystem.enableAlphaTest();
// RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ public class ShoppingListOverlay {
yPos += LINE_HEIGHT + 2;
CraftTracker.LOGGER.trace("yPos (materials item {}): {}", i, yPos);
}

};

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ public void init() {

this.minecraft.keyboardHandler.setSendRepeatsToGui(true);

int topX = this.width / 2;
int topY = this.height / 2;

// hide queue overlay and shopping list
this.queueState = CTRuntime.INSTANCE.queueOverlayRequestedState;
CTRuntime.INSTANCE.queueOverlayRequestedState = SUPPRESS;
Expand All @@ -82,8 +79,6 @@ public void render(PoseStack poseStack, int mouseX, int mouseY, float partialTic

this.renderBackground(poseStack);

// GuiComponent.fill(poseStack, topX, topY, width, height, BACKGROUND_COLOR);

// title
GuiComponent.drawCenteredString(poseStack, this.font, I18n.get(Constants.TRANSLATION_KEY_GUI_QUEUE_MGR_TITLE), this.width / 2, topY + 2, TITLE_COLOR);

Expand Down Expand Up @@ -128,7 +123,6 @@ public void renderToolTip(PoseStack pPoseStack, int pMouseX, int pMouseY) {
}
{
var text = String.format("%d", pItem.getIterations());
// this.font.draw(poseStack, text, topX + width + ITEM_X_QTY_OFFSET, y + 6, ITEM_COLOR);
GuiComponent.drawCenteredString(poseStack, this.font, text, topX + width + ITEM_X_QTY_OFFSET, y + 6, ITEM_COLOR);
}
{
Expand Down Expand Up @@ -180,17 +174,7 @@ public void renderToolTip(PoseStack pPoseStack, int pMouseX, int pMouseY) {
this.addRenderableWidget(button);
}

// buttons

super.render(poseStack, mouseX, mouseY, partialTicks);
//RenderHelper.disableStandardItemLighting(); // 1.14 enableGUIStandardItemLighting

// for(Widget widget : this.renderables) {
// if(widget instanceof AbstractWidget w && w.isHoveredOrFocused()) {
// w.renderToolTip(poseStack, mouseX, mouseY);
// break;
// }
// }
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ public static List<Component> splitInto(String text, int maxLength, Font font) {
StringBuilder temp = new StringBuilder();
String[] split = text.split(" ");

for (int i = 0; i < split.length; ++i) {
for(int i = 0; i < split.length; ++i) {
String str = split[i];
int length = font.width(temp + str);

if (length > maxLength) {
if(length > maxLength) {
list.add(new TextComponent(temp.toString()));
temp = new StringBuilder();
}

temp.append(str);
temp.append(" ");

if (i == split.length - 1) {
if(i == split.length - 1) {
list.add(new TextComponent(temp.toString()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,7 @@ public class CommonSetup {
public static void init(final FMLCommonSetupEvent event) {
event.enqueueWork(() -> {
PacketHandler.init();
//TODO CriteriaTriggers.register(criterion)

// CatRespawnCommand.registerSerilizers();

});
}

// public static void registerDispenserBehaviors() {
//
// }


}
Loading

0 comments on commit f988f17

Please sign in to comment.