commit e7f9022dfb43d97df818875637b5535d4e397226 Author: Nicolas Klier Date: Thu Oct 27 10:28:51 2022 +0200 Initial release diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..1fc365f --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,39 @@ +# Automatically build the project and run any configured tests for every push +# and submitted pull request. This can help catch issues that only occur on +# certain platforms or Java versions, and provides a first line of defence +# against bad commits. + +name: build +on: [pull_request, push] + +jobs: + build: + strategy: + matrix: + # Use these Java versions + java: [ + 17, # Current Java LTS & minimum supported by Minecraft + ] + # and run on both Linux and Windows + os: [ubuntu-20.04, windows-2022] + runs-on: ${{ matrix.os }} + steps: + - name: checkout repository + uses: actions/checkout@v2 + - name: validate gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: setup jdk ${{ matrix.java }} + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - name: make gradle wrapper executable + if: ${{ runner.os != 'Windows' }} + run: chmod +x ./gradlew + - name: build + run: ./gradlew build + - name: capture build artifacts + if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS + uses: actions/upload-artifact@v2 + with: + name: Artifacts + path: build/libs/ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..09cd281 --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +# gradle + +.gradle/ +build/ +out/ +classes/ + +# eclipse + +*.launch + +# idea + +.idea/ +*.iml +*.ipr +*.iws + +# vscode + +.settings/ +.vscode/ +bin/ +.classpath +.project + +# macos + +*.DS_Store + +# fabric + +run/ diff --git a/.metadata/.lock b/.metadata/.lock new file mode 100644 index 0000000..e69de29 diff --git a/.metadata/.log b/.metadata/.log new file mode 100644 index 0000000..c983cad --- /dev/null +++ b/.metadata/.log @@ -0,0 +1,90 @@ +!SESSION 2022-10-27 09:06:48.296 ----------------------------------------------- +eclipse.buildId=4.25.0.I20220831-1800 +java.version=17.0.4.1 +java.vendor=Eclipse Adoptium +BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=de_DE +Framework arguments: -product org.eclipse.epp.package.java.product +Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product + +!ENTRY org.eclipse.jface 2 0 2022-10-27 09:07:03.785 +!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation. +!SUBENTRY 1 org.eclipse.jface 2 0 2022-10-27 09:07:03.785 +!MESSAGE A conflict occurred for CTRL+SHIFT+T: +Binding(CTRL+SHIFT+T, + ParameterizedCommand(Command(org.eclipse.jdt.ui.navigate.open.type,Open Type, + Open a type in a Java editor, + Category(org.eclipse.ui.category.navigate,Navigate,null,true), + WorkbenchHandlerServiceHandler("org.eclipse.jdt.ui.navigate.open.type"), + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +Binding(CTRL+SHIFT+T, + ParameterizedCommand(Command(org.eclipse.lsp4e.symbolinworkspace,Go to Symbol in Workspace, + , + Category(org.eclipse.lsp4e.category,Language Servers,null,true), + WorkbenchHandlerServiceHandler("org.eclipse.lsp4e.symbolinworkspace"), + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +!SUBENTRY 1 org.eclipse.jface 2 0 2022-10-27 09:07:03.785 +!MESSAGE A conflict occurred for ALT+SHIFT+R: +Binding(ALT+SHIFT+R, + ParameterizedCommand(Command(org.eclipse.jdt.ui.edit.text.java.rename.element,Rename - Refactoring , + Rename the selected element, + Category(org.eclipse.jdt.ui.category.refactoring,Refactor - Java,Java Refactoring Actions,true), + WorkbenchHandlerServiceHandler("org.eclipse.jdt.ui.edit.text.java.rename.element"), + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +Binding(ALT+SHIFT+R, + ParameterizedCommand(Command(org.eclipse.ui.edit.rename,Rename, + Rename the selected item, + Category(org.eclipse.ui.category.file,File,null,true), + WorkbenchHandlerServiceHandler("org.eclipse.ui.edit.rename"), + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) + +!ENTRY org.eclipse.equinox.app 4 2 2022-10-27 09:07:07.669 +!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.equinox.app". +!STACK 0 +org.eclipse.swt.SWTException: Widget is disposed + at org.eclipse.swt.SWT.error(SWT.java:4918) + at org.eclipse.swt.SWT.error(SWT.java:4833) + at org.eclipse.swt.SWT.error(SWT.java:4804) + at org.eclipse.swt.widgets.Widget.error(Widget.java:450) + at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:369) + at org.eclipse.swt.widgets.Shell.close(Shell.java:547) + at org.eclipse.ui.splash.AbstractSplashHandler.dispose(AbstractSplashHandler.java:65) + at org.eclipse.ui.internal.Workbench$3$1.applicationRunning(Workbench.java:801) + at org.eclipse.equinox.internal.app.EclipseAppHandle$1.run(EclipseAppHandle.java:279) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) + at org.eclipse.equinox.internal.app.EclipseAppHandle.applicationRunning(EclipseAppHandle.java:267) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1092) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046) + at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) + at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550) + at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596) + at org.eclipse.equinox.launcher.Main.run(Main.java:1467) + +!ENTRY org.eclipse.egit.ui 2 0 2022-10-27 09:07:07.709 +!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git +user global configuration and to define the default location to store repositories: 'N:\'. If this is +not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and +EGit might behave differently since they see different configuration options. +This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.location b/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.location new file mode 100644 index 0000000..9a840d9 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.location differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version new file mode 100644 index 0000000..25cb955 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index new file mode 100644 index 0000000..d237251 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version new file mode 100644 index 0000000..6b2aaa7 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree b/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree new file mode 100644 index 0000000..0fa42e3 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources new file mode 100644 index 0000000..61df0ea Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources differ diff --git a/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi new file mode 100644 index 0000000..49c6ac4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi @@ -0,0 +1,2167 @@ + + + + activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration + + + + + + + + topLevel + + + Minimized + MinimizedByZoom + + + persp.actionSet:org.eclipse.ui.cheatsheets.actionSet + persp.actionSet:org.eclipse.search.searchActionSet + persp.actionSet:org.eclipse.text.quicksearch.actionSet + persp.actionSet:org.eclipse.ui.edit.text.actionSet.annotationNavigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.navigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo + persp.actionSet:org.eclipse.ui.externaltools.ExternalToolsSet + persp.actionSet:org.eclipse.ui.actionSet.keyBindings + persp.actionSet:org.eclipse.ui.actionSet.openFiles + persp.actionSet:org.eclipse.debug.ui.launchActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaElementCreationActionSet + persp.actionSet:org.eclipse.ui.NavigateActionSet + persp.viewSC:org.eclipse.jdt.ui.PackageExplorer + persp.viewSC:org.eclipse.jdt.ui.TypeHierarchy + persp.viewSC:org.eclipse.jdt.ui.SourceView + persp.viewSC:org.eclipse.jdt.ui.JavadocView + persp.viewSC:org.eclipse.search.ui.views.SearchView + persp.viewSC:org.eclipse.ui.console.ConsoleView + persp.viewSC:org.eclipse.ui.views.ContentOutline + persp.viewSC:org.eclipse.ui.views.ProblemView + persp.viewSC:org.eclipse.ui.views.ResourceNavigator + persp.viewSC:org.eclipse.ui.views.TaskList + persp.viewSC:org.eclipse.ui.views.ProgressView + persp.viewSC:org.eclipse.ui.navigator.ProjectExplorer + persp.viewSC:org.eclipse.ui.texteditor.TemplatesView + persp.viewSC:org.eclipse.pde.runtime.LogView + persp.newWizSC:org.eclipse.jdt.ui.wizards.JavaProjectWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewPackageCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewClassCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewEnumCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewRecordCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewAnnotationCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewJavaWorkingSetWizard + persp.newWizSC:org.eclipse.ui.wizards.new.folder + persp.newWizSC:org.eclipse.ui.wizards.new.file + persp.newWizSC:org.eclipse.ui.editors.wizards.UntitledTextFileWizard + persp.perspSC:org.eclipse.jdt.ui.JavaBrowsingPerspective + persp.perspSC:org.eclipse.debug.ui.DebugPerspective + persp.showIn:org.eclipse.jdt.ui.PackageExplorer + persp.showIn:org.eclipse.team.ui.GenericHistoryView + persp.showIn:org.eclipse.ui.navigator.ProjectExplorer + persp.actionSet:org.eclipse.debug.ui.breakpointActionSet + persp.actionSet:org.eclipse.jdt.debug.ui.JDTDebugActionSet + persp.showIn:org.eclipse.egit.ui.RepositoriesView + persp.actionSet:org.eclipse.eclemma.ui.CoverageActionSet + persp.showIn:org.eclipse.eclemma.ui.CoverageView + persp.viewSC:org.eclipse.tm.terminal.view.ui.TerminalsView + persp.showIn:org.eclipse.tm.terminal.view.ui.TerminalsView + persp.newWizSC:org.eclipse.jdt.junit.wizards.NewTestCaseCreationWizard + persp.actionSet:org.eclipse.jdt.junit.JUnitActionSet + persp.viewSC:org.eclipse.ant.ui.views.AntView + + + + org.eclipse.e4.primaryNavigationStack + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:Java + + + + + View + categoryTag:Git + + + + + + + + org.eclipse.e4.secondaryNavigationStack + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:Ant + + + + + org.eclipse.e4.secondaryDataStack + + View + categoryTag:General + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:Terminal + + + + + + + + active + Maximized + + View + categoryTag:Help + + + View + categoryTag:General + + + View + categoryTag:Help + + + + + + + View + categoryTag:Help + + + + + + View + categoryTag:General + active + activeOnClose + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Help + + + + org.eclipse.e4.primaryDataStack + EditorStack + + + + + + + View + categoryTag:Java + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:Git + + + + + View + categoryTag:Terminal + + + + + View + categoryTag:Java + + + + + View + categoryTag:Ant + + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + Draggable + + + toolbarSeparator + + + + Draggable + + + Draggable + + + Draggable + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + toolbarSeparator + + + + Draggable + + + stretch + SHOW_RESTORE_MENU + + + Draggable + HIDEABLE + SHOW_RESTORE_MENU + + + + + stretch + + + Draggable + + + Draggable + + + + + TrimStack + Draggable + + + + + + + + + + + + + + + + + + + + + + platform:win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + platform:win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Editor + removeOnHide + + + + + View + categoryTag:Ant + + + + + View + categoryTag:Gradle + + + + + View + categoryTag:Gradle + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + + + View + categoryTag:Java + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + NoRestore + + + + + View + categoryTag:Git + + + + + View + categoryTag:Help + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Oomph + + + + + View + categoryTag:General + + + + + View + categoryTag:Version Control (Team) + + + + + View + categoryTag:Version Control (Team) + + + View + categoryTag:Help + + + + + View + categoryTag:Terminal + + + + + View + categoryTag:Other + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:Help + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + glue + move_after:PerspectiveSpacer + SHOW_RESTORE_MENU + + + move_after:Spacer Glue + HIDEABLE + SHOW_RESTORE_MENU + + + glue + move_after:SearchField + SHOW_RESTORE_MENU + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache b/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache new file mode 100644 index 0000000..593f470 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache b/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache new file mode 100644 index 0000000..593f470 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt b/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt new file mode 100644 index 0000000..8586397 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt @@ -0,0 +1 @@ +java \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache b/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache new file mode 100644 index 0000000..593f470 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat b/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat new file mode 100644 index 0000000..0edae4b Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml b/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml new file mode 100644 index 0000000..a4ee3cb --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml new file mode 100644 index 0000000..9e390f5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml new file mode 100644 index 0000000..5b48696 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml @@ -0,0 +1,10 @@ + +
+
+ + + + + +
+
diff --git a/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser b/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser new file mode 100644 index 0000000..abbf8e5 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser differ diff --git a/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log b/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log new file mode 100644 index 0000000..e2de4dd --- /dev/null +++ b/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log @@ -0,0 +1 @@ +2022-10-27 09:07:07,701 [Worker-5: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update. diff --git a/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.2.0.0.20220705-1221.xml b/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.2.0.0.20220705-1221.xml new file mode 100644 index 0000000..abdf1c7 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.2.0.0.20220705-1221.xml @@ -0,0 +1,41 @@ + + + + %date [%thread] %-5level %logger{35} - %msg%n + + + OFF + + + + + ${org.eclipse.m2e.log.dir}/0.log + + ${org.eclipse.m2e.log.dir}/%i.log + 1 + 10 + + + 10MB + + + %date [%thread] %-5level %logger{35} - %msg%n + + + + + + WARN + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml b/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml new file mode 100644 index 0000000..5ca0b77 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml @@ -0,0 +1,3 @@ + +
+
diff --git a/.metadata/.plugins/org.eclipse.ui.intro/introstate b/.metadata/.plugins/org.eclipse.ui.intro/introstate new file mode 100644 index 0000000..02f134f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.intro/introstate @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml b/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml new file mode 100644 index 0000000..d05c8d7 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.metadata/version.ini b/.metadata/version.ini new file mode 100644 index 0000000..c96d3b0 --- /dev/null +++ b/.metadata/version.ini @@ -0,0 +1,3 @@ +#Thu Oct 27 09:07:00 CEST 2022 +org.eclipse.core.runtime=2 +org.eclipse.platform=4.25.0.v20220831-1800 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0e259d4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/README.md b/README.md new file mode 100644 index 0000000..fd96346 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# Fabric Example Mod + +## Setup + +For setup instructions please see the [fabric wiki page](https://fabricmc.net/wiki/tutorial:setup) that relates to the IDE that you are using. + +## License + +This template is available under the CC0 license. Feel free to learn from it and incorporate it in your own projects. diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..c18d7f0 --- /dev/null +++ b/build.gradle @@ -0,0 +1,81 @@ +plugins { + id 'fabric-loom' version '1.0-SNAPSHOT' + id 'maven-publish' +} + +sourceCompatibility = JavaVersion.VERSION_17 +targetCompatibility = JavaVersion.VERSION_17 + +archivesBaseName = project.archives_base_name +version = project.mod_version +group = project.maven_group + +repositories { + // Add repositories to retrieve artifacts from in here. + // You should only use this when depending on other mods because + // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. + // See https://docs.gradle.org/current/userguide/declaring_repositories.html + // for more information about repositories. +} + +dependencies { + // To change the versions see the gradle.properties file + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + + // Fabric API. This is technically optional, but you probably want it anyway. + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + + // Uncomment the following line to enable the deprecated Fabric API modules. + // These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time. + + // modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}" +} + +processResources { + inputs.property "version", project.version + + filesMatching("fabric.mod.json") { + expand "version": project.version + } +} + +tasks.withType(JavaCompile).configureEach { + // Minecraft 1.18 (1.18-pre2) upwards uses Java 17. + it.options.release = 17 +} + +java { + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() +} + +loom { + accessWidenerPath = file("src/main/resources/customstructures.accesswidener") +} + +jar { + from("LICENSE") { + rename { "${it}_${project.archivesBaseName}"} + } +} + +// configure the maven publication +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + // Notice: This block does NOT have the same function as the block in the top level. + // The repositories here will be used for publishing your artifact, not for + // retrieving dependencies. + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..93161f4 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,16 @@ +# Done to increase the memory available to gradle. +org.gradle.jvmargs=-Xmx1G + +# Fabric Properties + # check these on https://fabricmc.net/develop + minecraft_version=1.19.2 + yarn_mappings=1.19.2+build.8 + loader_version=0.14.9 + +# Mod Properties + mod_version = 1.0.0 + maven_group = com.example + archives_base_name = fabric-example-mod + +# Dependencies + fabric_version=0.60.0+1.19.2 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..41d9927 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..ae04661 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..1b6c787 --- /dev/null +++ b/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..b02216b --- /dev/null +++ b/settings.gradle @@ -0,0 +1,10 @@ +pluginManagement { + repositories { + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + mavenCentral() + gradlePluginPortal() + } +} diff --git a/src/main/java/de/nicolasklier/custom_structures/CustomStructures.java b/src/main/java/de/nicolasklier/custom_structures/CustomStructures.java new file mode 100644 index 0000000..40aa40b --- /dev/null +++ b/src/main/java/de/nicolasklier/custom_structures/CustomStructures.java @@ -0,0 +1,35 @@ +package de.nicolasklier.custom_structures; + +import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.item.v1.FabricItemSettings; +import net.minecraft.item.Item; +import net.minecraft.item.ItemGroup; +import net.minecraft.util.Identifier; +import net.minecraft.util.registry.Registry; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import de.nicolasklier.custom_structures.events.PlayerTick; +import de.nicolasklier.custom_structures.items.StructureSpawner; + +public class CustomStructures implements ModInitializer { + // This logger is used to write text to the console and the log file. + // It is considered best practice to use your mod id as the logger's name. + // That way, it's clear which mod wrote info, warnings, and errors. + public static final Logger LOGGER = LoggerFactory.getLogger("customstructure"); + + public static final Item STRUCTURE_SPAWNER = new StructureSpawner(new FabricItemSettings().group(ItemGroup.MISC) + .maxCount(1)); + + @Override + public void onInitialize() { + // This code runs as soon as Minecraft is in a mod-load-ready state. + // However, some things (like resources) may still be uninitialized. + // Proceed with mild caution. + + Registry.register(Registry.ITEM, new Identifier("customstructures", "structure_spawner"), STRUCTURE_SPAWNER); + + new PlayerTick(); + } +} diff --git a/src/main/java/de/nicolasklier/custom_structures/Helper.java b/src/main/java/de/nicolasklier/custom_structures/Helper.java new file mode 100644 index 0000000..185ef23 --- /dev/null +++ b/src/main/java/de/nicolasklier/custom_structures/Helper.java @@ -0,0 +1,84 @@ +package de.nicolasklier.custom_structures; + +import net.minecraft.client.MinecraftClient; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.decoration.ItemFrameEntity; +import net.minecraft.entity.projectile.ProjectileUtil; +import net.minecraft.util.hit.EntityHitResult; +import net.minecraft.util.hit.HitResult; +import net.minecraft.util.math.Box; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.RaycastContext; + +public class Helper { + public static HitResult raycastInDirection(MinecraftClient client, float tickDelta, Vec3d direction) { + Entity entity = client.getCameraEntity(); + if (entity == null || client.world == null) { + return null; + } + + double reachDistance = 100f; // Custom reach size of 100 blocks. + HitResult target = raycast(entity, reachDistance, tickDelta, false, direction); + double extendedReach = reachDistance; + + Vec3d cameraPos = entity.getCameraPosVec(tickDelta); + + extendedReach = extendedReach * extendedReach; + if (target != null) { + extendedReach = target.getPos().squaredDistanceTo(cameraPos); + } + + Vec3d vec3d3 = cameraPos.add(direction.multiply(reachDistance)); + Box box = entity + .getBoundingBox() + .stretch(entity.getRotationVec(1.0F).multiply(reachDistance)) + .expand(1.0D, 1.0D, 1.0D); + + EntityHitResult entityHitResult = ProjectileUtil.raycast( + entity, + cameraPos, + vec3d3, + box, + (entityx) -> !entityx.isSpectator(), + extendedReach + ); + + if (entityHitResult == null) { + return target; + } + + Entity entity2 = entityHitResult.getEntity(); + Vec3d vec3d4 = entityHitResult.getPos(); + double g = cameraPos.squaredDistanceTo(vec3d4); + + if (g > reachDistance) { + return null; + } else if (g < extendedReach || target == null) { + target = entityHitResult; + if (entity2 instanceof LivingEntity || entity2 instanceof ItemFrameEntity) { + client.targetedEntity = entity2; + } + } + + return target; + } + + private static HitResult raycast( + Entity entity, + double maxDistance, + float tickDelta, + boolean includeFluids, + Vec3d direction + ) { + Vec3d end = entity.getCameraPosVec(tickDelta).add(direction.multiply(maxDistance)); + return entity.world.raycast(new RaycastContext( + entity.getCameraPosVec(tickDelta), + end, + RaycastContext.ShapeType.OUTLINE, + includeFluids ? RaycastContext.FluidHandling.ANY : RaycastContext.FluidHandling.NONE, + entity + )); + } + +} diff --git a/src/main/java/de/nicolasklier/custom_structures/events/PlayerTick.java b/src/main/java/de/nicolasklier/custom_structures/events/PlayerTick.java new file mode 100644 index 0000000..e85781f --- /dev/null +++ b/src/main/java/de/nicolasklier/custom_structures/events/PlayerTick.java @@ -0,0 +1,67 @@ +package de.nicolasklier.custom_structures.events; + +import java.util.HashMap; +import java.util.Iterator; + +import de.nicolasklier.custom_structures.CustomStructures; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; +import net.minecraft.block.BlockState; +import net.minecraft.sound.SoundCategory; +import net.minecraft.sound.SoundEvents; +import net.minecraft.util.math.BlockPos; + +public class PlayerTick { + + public static HashMap queue = new HashMap<>(); + public static Iterator queueKeys; + + /** + * How many ticks to wait until the next block will be placed. + */ + public static int placeDelay = 3; + private static int tickCount = 0; + + public PlayerTick() { + registerClientEndTick(); + + CustomStructures.LOGGER.info("Client end tick event registered."); + } + + private void registerClientEndTick() { + ClientTickEvents.END_CLIENT_TICK.register((instance) -> { + if (instance.world == null) { + return; + } + + if (tickCount < placeDelay) { + tickCount++; + + return; + } + + tickCount = 0; + + if (queue.isEmpty()) + return; + + for (int i = 0; i < 100; i++) { + if (queueKeys == null || !queueKeys.hasNext()) + return; + + BlockPos pos = queueKeys.next(); + BlockState state = queue.get(pos); + + if (state == null) + return; + + //CustomStructures.LOGGER.info("Build at " + pos.toShortString() + "\t Q:" + queue.size()); + + instance.getServer().getOverworld().setBlockState(pos, state); + instance.world.addBlockBreakParticles(pos, state); + instance.world.playSound(pos, SoundEvents.BLOCK_STONE_PLACE, SoundCategory.BLOCKS, 1f, 1f, true); + + queue.remove(pos); + } + }); + } +} diff --git a/src/main/java/de/nicolasklier/custom_structures/items/StructureSpawner.java b/src/main/java/de/nicolasklier/custom_structures/items/StructureSpawner.java new file mode 100644 index 0000000..309b6ce --- /dev/null +++ b/src/main/java/de/nicolasklier/custom_structures/items/StructureSpawner.java @@ -0,0 +1,48 @@ +package de.nicolasklier.custom_structures.items; + +import de.nicolasklier.custom_structures.Helper; +import de.nicolasklier.custom_structures.structures.Generations; +import de.nicolasklier.custom_structures.structures.StaircaseNoiseOptions; +import de.nicolasklier.custom_structures.structures.StaircaseOptions; +import net.minecraft.client.MinecraftClient; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Hand; +import net.minecraft.util.TypedActionResult; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.hit.HitResult; +import net.minecraft.util.hit.HitResult.Type; +import net.minecraft.world.World; + +public class StructureSpawner extends Item { + + public StructureSpawner(Settings settings) { + super(settings); + } + + @Override + public TypedActionResult use(World world, PlayerEntity user, Hand hand) { + MinecraftClient client = MinecraftClient.getInstance(); + HitResult hit = Helper.raycastInDirection(client, client.getTickDelta(), client.cameraEntity.getRotationVec(client.getTickDelta())); + + Generations gen = new Generations(); + + if (hit.getType() == Type.BLOCK) { + BlockHitResult result = (BlockHitResult) hit; + client.player.sendChatMessage("Coords: " + result.getBlockPos().toShortString(), null); + + // Spawn structure at raycast hit + StaircaseOptions options = new StaircaseOptions(); + options.stretch = 2; + options.height = 10; + options.noise = new StaircaseNoiseOptions(); + options.mirror = true; + + gen.spawnStaircase(result.getBlockPos().add(0, 1, 0), options); + } + + return TypedActionResult.success(user.getStackInHand(hand)); + } + +} diff --git a/src/main/java/de/nicolasklier/custom_structures/mixin/ExampleMixin.java b/src/main/java/de/nicolasklier/custom_structures/mixin/ExampleMixin.java new file mode 100644 index 0000000..7e8d860 --- /dev/null +++ b/src/main/java/de/nicolasklier/custom_structures/mixin/ExampleMixin.java @@ -0,0 +1,17 @@ +package de.nicolasklier.custom_structures.mixin; + +import net.minecraft.client.gui.screen.TitleScreen; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import de.nicolasklier.custom_structures.CustomStructures; + +@Mixin(TitleScreen.class) +public class ExampleMixin { + @Inject(at = @At("HEAD"), method = "init()V") + private void init(CallbackInfo info) { + CustomStructures.LOGGER.info("This line is printed by an example mod mixin!"); + } +} diff --git a/src/main/java/de/nicolasklier/custom_structures/mixin/PlayerTickMixin.java b/src/main/java/de/nicolasklier/custom_structures/mixin/PlayerTickMixin.java new file mode 100644 index 0000000..50064bb --- /dev/null +++ b/src/main/java/de/nicolasklier/custom_structures/mixin/PlayerTickMixin.java @@ -0,0 +1,53 @@ +package de.nicolasklier.custom_structures.mixin; + +import java.util.HashMap; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import net.minecraft.block.BlockState; +import net.minecraft.client.MinecraftClient; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.sound.SoundCategory; +import net.minecraft.sound.SoundEvents; +import net.minecraft.util.math.BlockPos; + +@Mixin(PlayerEntity.class) +public class PlayerTickMixin { + + private static HashMap queue = new HashMap<>(); + + /** + * How many ticks to wait until the next block will be placed. + */ + private static int placeDelay = 2; + private static int tickCount = 0; + + @Inject(method = "tick", at = @At("RETURN")) + private void tick(CallbackInfo info) { + if (tickCount < placeDelay) { + tickCount++; + + return; + } + + tickCount = 0; + + MinecraftClient instance = MinecraftClient.getInstance(); + + if (queue.isEmpty()) + return; + + BlockPos pos = (BlockPos) queue.keySet().toArray()[0]; + BlockState state = queue.get(pos); + queue.remove(pos); + + System.out.println("Build at " + pos.toShortString()); + + instance.world.setBlockState(pos, state); + instance.world.addBlockBreakParticles(pos, state); + instance.world.playSound(pos, SoundEvents.BLOCK_STONE_PLACE, SoundCategory.BLOCKS, 1f, 1f, true); + } +} diff --git a/src/main/java/de/nicolasklier/custom_structures/mixin/WorldPresetMixin.java b/src/main/java/de/nicolasklier/custom_structures/mixin/WorldPresetMixin.java new file mode 100644 index 0000000..90c3a0b --- /dev/null +++ b/src/main/java/de/nicolasklier/custom_structures/mixin/WorldPresetMixin.java @@ -0,0 +1,60 @@ +package de.nicolasklier.custom_structures.mixin; + +import java.util.Map; +import java.util.Optional; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import de.nicolasklier.custom_structures.worldgen.StairChunkGenerator; +import net.minecraft.util.Identifier; +import net.minecraft.util.registry.BuiltinRegistries; +import net.minecraft.util.registry.Registry; +import net.minecraft.util.registry.RegistryEntry; +import net.minecraft.util.registry.RegistryKey; +import net.minecraft.world.dimension.DimensionOptions; +import net.minecraft.world.dimension.DimensionTypes; +import net.minecraft.world.gen.WorldPreset; +import net.minecraft.world.gen.WorldPresets; +import net.minecraft.world.gen.chunk.ChunkGenerator; +import net.minecraft.world.gen.chunk.FlatChunkGenerator; +import net.minecraft.world.gen.chunk.FlatChunkGeneratorConfig; + +@Mixin(WorldPresets.Registrar.class) +public abstract class WorldPresetMixin { + // defining our registry key. this key provides an Identifier for our preset, that we can use for our lang files and data elements. + private static final RegistryKey VOID_WORLD = RegistryKey.of(Registry.WORLD_PRESET_KEY, new Identifier("customstructures", "stair_world")); + @Shadow protected abstract RegistryEntry register(RegistryKey key, DimensionOptions dimensionOptions); + @Shadow protected abstract DimensionOptions createOverworldOptions(ChunkGenerator chunkGenerator); + + /*private static final DimensionOptions OVERWORLD_OPTIONS = new DimensionOptions( + BuiltinRegistries.DIMENSION_TYPE.getOrCreateEntry(DimensionTypes.OVERWORLD), + StairChunkGenerator.forOverworld() + );*/ + + @Inject(method = "initAndGetDefault", at = @At("RETURN")) + private void addPresets(CallbackInfoReturnable> cir) { + // the register() method is shadowed from the target class + /*this.register(VOID_WORLD, this.createOverworldOptions( + // a FlatChunkGenerator is the easiest way to get a void world, but you can replace this FlatChunkGenerator constructor with a NoiseChunkGenerator, or your own custom ChunkGenerator. + new FlatChunkGenerator( + // passing null will use the default structure set + null, + new FlatChunkGeneratorConfig( + // we don't need to overwrite the structure set + Optional.empty(), + BuiltinRegistries.BIOME) + ) + ) + ); + + BuiltinRegistries.add(BuiltinRegistries.WORLD_PRESET, new Identifier("customstructures", "stair_world"), new WorldPreset( + Map.of( + DimensionOptions.OVERWORLD, OVERWORLD_OPTIONS + )) + );*/ + } +} \ No newline at end of file diff --git a/src/main/java/de/nicolasklier/custom_structures/structures/Generations.java b/src/main/java/de/nicolasklier/custom_structures/structures/Generations.java new file mode 100644 index 0000000..f155698 --- /dev/null +++ b/src/main/java/de/nicolasklier/custom_structures/structures/Generations.java @@ -0,0 +1,183 @@ +package de.nicolasklier.custom_structures.structures; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Set; + +import de.nicolasklier.custom_structures.CustomStructures; +import de.nicolasklier.custom_structures.events.PlayerTick; +import de.nicolasklier.custom_structures.utils.PerlinNoise; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.Material; +import net.minecraft.client.MinecraftClient; +import net.minecraft.state.property.Properties; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.util.math.Direction.Axis; + +public class Generations { + + List fence_whitelist = new ArrayList<>(); + + public Generations() { + fence_whitelist.add(Blocks.OAK_FENCE); + fence_whitelist.add(Blocks.BIRCH_FENCE); + fence_whitelist.add(Blocks.SPRUCE_FENCE); + fence_whitelist.add(Blocks.JUNGLE_FENCE); + } + + public void spawnStaircase(BlockPos at, StaircaseOptions options) { + Map placeQueue = new HashMap<>(); + MinecraftClient instance = MinecraftClient.getInstance(); + int length = options.height * options.stretch * (options.mirror ? 2 : 1); + + Random rng = new Random(); + PerlinNoise noise = null; + + int y = -(options.weight); + int step = 0; + + if (options.noise != null) { + noise = new PerlinNoise(rng, options.noise.roughness, length, length); + noise.initialise(); + } + + // Final length is height times stretch factor. If mirroring is enabled, then it will be twice as long. + int x = 0; + boolean isMirroring = y > options.height * options.stretch; + + if (step >= options.stretch) { + step = 0; + + // Check if we already reached our final height. If yes, go downwards + if (isMirroring) { + y -= 1; + } else { + y++; + } + } + + for (int z = 0; z < options.width; z++) { + boolean isNextHeight = true; + + if (options.stretch > 1) { + if (isMirroring) { + isNextHeight = step == 0; + } else { + isNextHeight = step + 1 == options.stretch; + } + } + + Block block = Blocks.COBBLESTONE; + + // Build supporting fence + if (x % options.fenceVerticalDensity == 0 && y > 0) { + // From left to right + for (int z2 = 0; z2 <= options.width; z2 += (options.width - 1) / options.fenceHorizontalDensity) { + // Place fence manually on ground because the loop below offsets by one. + placeQueue.put(at.add(x + 1, 0, z2), getRandomFance(rng)); + + int y2 = y - options.weight; + while (true) { + Material mat = instance.getServer().getOverworld().getBlockState(new BlockPos(x, y2, z2)).getMaterial(); + if (mat == Material.AIR || mat == Material.WATER) { + placeQueue.put(at.add(x, y2, z2), getRandomFance(rng)); + placeQueue.put(at.add(x + 1, y2 + 1, z2), getRandomFance(rng)); + } else { + break; + } + + y2--; + } + } + } + + boolean putStair = false; + + // Decide if there should be mossy cobblestone or glass. If yes, then don't put a stair there. + if (rng.nextFloat() < options.chanceMossyCobblestone / 100f) { + block = Blocks.MOSSY_COBBLESTONE; + } else if (rng.nextFloat() < options.chanceGlass / 100f) { + block = Blocks.GLASS; + } else { + putStair = true; + } + + // Build actual block + for (int j = 0; j < options.weight; j++) { + // Building imperfection + if (rng.nextFloat() < 0.001) continue; + + placeQueue.put(at.add(x, y + j, z), block.getDefaultState()); + } + + Direction facing = isMirroring ? Direction.WEST : Direction.EAST; + + // Build stair or not + if (putStair && isNextHeight) { + BlockState stairState = Blocks.COBBLESTONE_STAIRS.getDefaultState().with(Properties.HORIZONTAL_FACING, facing); + + if (isMirroring) + stairState = stairState.with(Properties.HORIZONTAL_FACING, facing); + + if (rng.nextFloat() < options.chanceSlap / 100f) { + placeQueue.put(at.add(x, y + options.weight, z), Blocks.SMOOTH_STONE_SLAB.getDefaultState()); + } else { + CustomStructures.LOGGER.info("Noise [" + x + ", " + y + "]: " + noise.getValueAt(x, y + options.weight)); + if (noise.getValueAt(x, y + options.weight) < options.chanceWoodStair / 100f) { + + // Override stair as wood stair, copying the facing. + stairState = Blocks.OAK_STAIRS.getDefaultState() + .with(Properties.HORIZONTAL_FACING, stairState.get(Properties.HORIZONTAL_FACING)); + } else if (rng.nextFloat() > options.chanceMossyCobblestone / 100f) { + stairState = Blocks.MOSSY_COBBLESTONE_STAIRS.getDefaultState() + .with(Properties.HORIZONTAL_FACING, stairState.get(Properties.HORIZONTAL_FACING)); + } + + placeQueue.put(at.add(x, y + options.weight, z), stairState); + } + } else { + if (rng.nextFloat() < 0.04) { + placeQueue.put(at.add(x, y + options.weight - 1, z), Blocks.GLOWSTONE.getDefaultState()); + } + } + + // Build wall + if ((z == 0 || z == options.width - 1) && options.wallHeight > 0) { + for (int y2 = 0; y2 < options.wallHeight; y2++) { + placeQueue.put(at.add(x, y + y2 + options.weight, z), Blocks.OAK_PLANKS.getDefaultState()); + } + + placeQueue.put(at.add(x, y + options.wallHeight + options.weight, z), Blocks.OAK_FENCE.getDefaultState()); + placeQueue.put(at.add(x, y + options.wallHeight + options.weight + 1, z), Blocks.OAK_FENCE.getDefaultState()); + placeQueue.put(at.add(x, y + options.wallHeight + options.weight + 2, z), Blocks.OAK_PLANKS.getDefaultState()); + + if (isNextHeight) { + placeQueue.put(at.add(x, y + options.wallHeight + options.weight + 3, z), Blocks.OAK_STAIRS.getDefaultState() + .with(Properties.HORIZONTAL_FACING, facing)); + } + } + } + + step++; + } + + PlayerTick.queue.putAll(placeQueue); + + Set set = placeQueue.keySet(); + List list = new ArrayList<>(set); + //Collections.shuffle(list); + PlayerTick.queueKeys = list.iterator(); + } + + + private BlockState getRandomFance(Random rng) { + return fence_whitelist.get(rng.nextInt(0, fence_whitelist.size() - 1)).getDefaultState(); + } +} \ No newline at end of file diff --git a/src/main/java/de/nicolasklier/custom_structures/structures/StaircaseNoiseOptions.java b/src/main/java/de/nicolasklier/custom_structures/structures/StaircaseNoiseOptions.java new file mode 100644 index 0000000..af8d471 --- /dev/null +++ b/src/main/java/de/nicolasklier/custom_structures/structures/StaircaseNoiseOptions.java @@ -0,0 +1,11 @@ +package de.nicolasklier.custom_structures.structures; + +import java.util.Random; + +public class StaircaseNoiseOptions { + + public float roughness = 0.1f; + + public Random rng = new Random(); + +} diff --git a/src/main/java/de/nicolasklier/custom_structures/structures/StaircaseOptions.java b/src/main/java/de/nicolasklier/custom_structures/structures/StaircaseOptions.java new file mode 100644 index 0000000..3b79d15 --- /dev/null +++ b/src/main/java/de/nicolasklier/custom_structures/structures/StaircaseOptions.java @@ -0,0 +1,74 @@ +package de.nicolasklier.custom_structures.structures; + +public class StaircaseOptions { + /** + * Width of the staircase on the Z-axis. + */ + public int width = 21; + + /** + * Thickness of the staircase. + */ + public int weight = 3; + + /** + * Height of the staircase on the Y-axis. + */ + public int height = 32; + + /** + * Padding between the support fences vertically (XY-plane). + */ + public int fenceVerticalDensity = 10; + + /** + * Padding between the support fences horizontally (ZY-plane). + */ + public int fenceHorizontalDensity = 3; + + /** + * Height of the wall left & right. Set to 0 to disable this feature. + */ + public int wallHeight = 2; + + /** + * Scratch the staircase along the X-axis. + */ + public int stretch = 4; + + /** + * Mirror staircase when height is reached. This will double your length. + */ + public boolean mirror = false; + + /** + * Value between 0% and 100% being the chance to spawn glass. + */ + public short chanceGlass = 10; + + /** + * Value between 0% and 100% being the chance to spawn glowstone. + */ + public short chanceGlowstone = 4; + + /** + * Value between 0% and 100% being the chance to spawn mossy cobblestone. + */ + public short chanceMossyCobblestone = 20; + + /** + * Value between 0% and 100% being the chance to spawn a slap instead of an stair. + */ + public short chanceSlap = 5; + + /** + * Value between 0% and 100% being the chance to spawn a wooden stair instead of an cobblestone stair. + */ + public short chanceWoodStair = 50; + + /** + * Adds variation to the stretch of the staircase. This will override `stretch`. + * To disable this feature set it to null. + */ + public StaircaseNoiseOptions noise = null; +} diff --git a/src/main/java/de/nicolasklier/custom_structures/utils/PerlinNoise.java b/src/main/java/de/nicolasklier/custom_structures/utils/PerlinNoise.java new file mode 100644 index 0000000..773b9aa --- /dev/null +++ b/src/main/java/de/nicolasklier/custom_structures/utils/PerlinNoise.java @@ -0,0 +1,110 @@ +package de.nicolasklier.custom_structures.utils; + +import java.util.Random; + +public class PerlinNoise { + /** Source of entropy */ + private Random rand_; + + /** Amount of roughness */ + float roughness_; + + /** Plasma fractal grid */ + private float[][] grid_; + + + /** Generate a noise source based upon the midpoint displacement fractal. + * + * @param rand The random number generator + * @param roughness a roughness parameter + * @param width the width of the grid + * @param height the height of the grid + */ + public PerlinNoise(Random rand, float roughness, int width, int height) { + roughness_ = roughness / width; + grid_ = new float[width][height]; + rand_ = (rand == null) ? new Random() : rand; + } + + + public void initialise() { + int xh = grid_.length - 1; + int yh = grid_[0].length - 1; + + // set the corner points + grid_[0][0] = rand_.nextFloat() - 0.5f; + grid_[0][yh] = rand_.nextFloat() - 0.5f; + grid_[xh][0] = rand_.nextFloat() - 0.5f; + grid_[xh][yh] = rand_.nextFloat() - 0.5f; + + // generate the fractal + generate(0, 0, xh, yh); + } + + + // Add a suitable amount of random displacement to a point + private float roughen(float v, int l, int h) { + return v + roughness_ * (float) (rand_.nextGaussian() * (h - l)); + } + + + // generate the fractal + private void generate(int xl, int yl, int xh, int yh) { + int xm = (xl + xh) / 2; + int ym = (yl + yh) / 2; + if ((xl == xm) && (yl == ym)) return; + + grid_[xm][yl] = 0.5f * (grid_[xl][yl] + grid_[xh][yl]); + grid_[xm][yh] = 0.5f * (grid_[xl][yh] + grid_[xh][yh]); + grid_[xl][ym] = 0.5f * (grid_[xl][yl] + grid_[xl][yh]); + grid_[xh][ym] = 0.5f * (grid_[xh][yl] + grid_[xh][yh]); + + float v = roughen(0.5f * (grid_[xm][yl] + grid_[xm][yh]), xl + yl, yh + + xh); + grid_[xm][ym] = v; + grid_[xm][yl] = roughen(grid_[xm][yl], xl, xh); + grid_[xm][yh] = roughen(grid_[xm][yh], xl, xh); + grid_[xl][ym] = roughen(grid_[xl][ym], yl, yh); + grid_[xh][ym] = roughen(grid_[xh][ym], yl, yh); + + generate(xl, yl, xm, ym); + generate(xm, yl, xh, ym); + generate(xl, ym, xm, yh); + generate(xm, ym, xh, yh); + } + + public float getValueAt(int x, int y) { + return grid_[x][y]; + } + + + /** + * Dump out as a CSV + */ + public void printAsCSV() { + for(int i = 0;i < grid_.length;i++) { + for(int j = 0;j < grid_[0].length;j++) { + System.out.print(grid_[i][j]); + System.out.print(","); + } + System.out.println(); + } + } + + + /** + * Convert to a Boolean array + * @return the boolean array + */ + public boolean[][] toBooleans() { + int w = grid_.length; + int h = grid_[0].length; + boolean[][] ret = new boolean[w][h]; + for(int i = 0;i < w;i++) { + for(int j = 0;j < h;j++) { + ret[i][j] = grid_[i][j] < 0; + } + } + return ret; + } +} diff --git a/src/main/resources/assets/customstructures/icon.png b/src/main/resources/assets/customstructures/icon.png new file mode 100644 index 0000000..047b91f Binary files /dev/null and b/src/main/resources/assets/customstructures/icon.png differ diff --git a/src/main/resources/assets/customstructures/lang/en_us.json b/src/main/resources/assets/customstructures/lang/en_us.json new file mode 100644 index 0000000..65a44f5 --- /dev/null +++ b/src/main/resources/assets/customstructures/lang/en_us.json @@ -0,0 +1,3 @@ +{ + "generator.customstructures.void_world": "Staircase world" +} \ No newline at end of file diff --git a/src/main/resources/assets/customstructures/models/item/structure_spawner.json b/src/main/resources/assets/customstructures/models/item/structure_spawner.json new file mode 100644 index 0000000..3b0aebc --- /dev/null +++ b/src/main/resources/assets/customstructures/models/item/structure_spawner.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "customstructures:item/structure_spawner" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/customstructures/structure_spawner2.png b/src/main/resources/assets/customstructures/structure_spawner2.png new file mode 100644 index 0000000..e5353f1 Binary files /dev/null and b/src/main/resources/assets/customstructures/structure_spawner2.png differ diff --git a/src/main/resources/assets/customstructures/textures/item/structure_spawner.png b/src/main/resources/assets/customstructures/textures/item/structure_spawner.png new file mode 100644 index 0000000..b68ddbd Binary files /dev/null and b/src/main/resources/assets/customstructures/textures/item/structure_spawner.png differ diff --git a/src/main/resources/customstructures.accesswidener b/src/main/resources/customstructures.accesswidener new file mode 100644 index 0000000..c3813f0 --- /dev/null +++ b/src/main/resources/customstructures.accesswidener @@ -0,0 +1,3 @@ +accessWidener v1 named +extendable class net/minecraft/world/gen/chunk/NoiseChunkGenerator +accessible class net/minecraft/world/gen/WorldPresets$Registrar \ No newline at end of file diff --git a/src/main/resources/customstructures.mixins.json b/src/main/resources/customstructures.mixins.json new file mode 100644 index 0000000..85c939f --- /dev/null +++ b/src/main/resources/customstructures.mixins.json @@ -0,0 +1,15 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "de.nicolasklier.custom_structures.mixin", + "compatibilityLevel": "JAVA_17", + "mixins": [ + ], + "client": [ + "ExampleMixin", + "PlayerTickMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/src/main/resources/data/minecraft/tags/worldgen/world_preset/normal.json b/src/main/resources/data/minecraft/tags/worldgen/world_preset/normal.json new file mode 100644 index 0000000..fabc2a3 --- /dev/null +++ b/src/main/resources/data/minecraft/tags/worldgen/world_preset/normal.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "customstructures:stair_world" + ] +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..ffb9bc8 --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,39 @@ +{ + "schemaVersion": 1, + "id": "customstructures", + "version": "0.1", + "accessWidener": "customstructures.accesswidener", + + "name": "Custom Structures", + "description": "Place weird looking structures into your world or generate worlds full of them!", + "authors": [ + "Nicolas Klier" + ], + "contact": { + "homepage": "https://klier.dev/", + "sources": "https://github.com/Mondei1/customstructures" + }, + + "license": "CC0-1.0", + "icon": "assets/customstructures/icon.png", + + "environment": "*", + "entrypoints": { + "main": [ + "de.nicolasklier.custom_structures.CustomStructures" + ] + }, + "mixins": [ + "customstructures.mixins.json" + ], + + "depends": { + "fabricloader": ">=0.14.9", + "fabric-api": "*", + "minecraft": "~1.19", + "java": ">=17" + }, + "suggests": { + "another-mod": "*" + } +}