diff --git a/CREDITS.txt b/CREDITS.txt index a70c53d..ae7b41b 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -1,65 +1 @@ -Minecraft Forge: Credits/Thank You - -Forge is a set of tools and modifications to the Minecraft base game code to assist -mod developers in creating new and exciting content. It has been in development for -several years now, but I would like to take this time thank a few people who have -helped it along it's way. - -First, the people who originally created the Forge projects way back in Minecraft -alpha. Eloraam of RedPower, and SpaceToad of Buildcraft, without their acceptiance -of me taking over the project, who knows what Minecraft modding would be today. - -Secondly, someone who has worked with me, and developed some of the core features -that allow modding to be as functional, and as simple as it is, cpw. For developing -FML, which stabelized the client and server modding ecosystem. As well as the base -loading system that allows us to modify Minecraft's code as elegently as possible. - -Mezz, who has stepped up as the issue and pull request manager. Helping to keep me -sane as well as guiding the community into creating better additions to Forge. - -Searge, Bspks, Fesh0r, ProfMobious, and all the rest over on the MCP team {of which -I am a part}. For creating some of the core tools needed to make Minecraft modding -both possible, and as stable as can be. - On that note, here is some specific information of the MCP data we use: - * Minecraft Coder Pack (MCP) * - Forge Mod Loader and Minecraft Forge have permission to distribute and automatically - download components of MCP and distribute MCP data files. This permission is not - transitive and others wishing to redistribute the Minecraft Forge source independently - should seek permission of MCP or remove the MCP data files and request their users - to download MCP separately. - -And lastly, the countless community members who have spent time submitting bug reports, -pull requests, and just helping out the community in general. Thank you. - ---LexManos - -========================================================================= - -This is Forge Mod Loader. - -You can find the source code at all times at https://github.com/MinecraftForge/MinecraftForge/tree/1.12.x/src/main/java/net/minecraftforge/fml - -This minecraft mod is a clean open source implementation of a mod loader for minecraft servers -and minecraft clients. - -The code is authored by cpw. - -It began by partially implementing an API defined by the client side ModLoader, authored by Risugami. -http://www.minecraftforum.net/topic/75440- -This support has been dropped as of Minecraft release 1.7, as Risugami no longer maintains ModLoader. - -It also contains suggestions and hints and generous helpings of code from LexManos, author of MinecraftForge. -http://www.minecraftforge.net/ - -Additionally, it contains an implementation of topological sort based on that -published at http://keithschwarz.com/interesting/code/?dir=topological-sort - -It also contains code from the Maven project for performing versioned dependency -resolution. http://maven.apache.org/ - -It also contains a partial repackaging of the javaxdelta library from http://sourceforge.net/projects/javaxdelta/ -with credit to it's authors. - -Forge Mod Loader downloads components from the Minecraft Coder Pack -(http://mcp.ocean-labs.de/index.php/Main_Page) with kind permission from the MCP team. - +@DarkestArgentum on Twitter for ideas \ No newline at end of file diff --git a/README.md b/README.md index e3fc578..3388be7 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,14 @@ +![GlassCutter Banner](https://i.imgur.com/jnLyKd4.png) + +[![Download](https://img.shields.io/static/v1?label=&message=Download&color=2d2d2d&labelColor=dddddd&style=for-the-badge&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAALEQAACxEBf2RfkQAAAAd0SU1FB98BHA41LJJkRpIAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMvvhp8YAAAGGSURBVDhPjZK9SgNBFIVHBEUE8QeMhLAzdzdYBFL7CmnstEjjO4iFjWClFiGJm42VFpYSUptKRfABFBQE7UUI2AmGmPXM5k6cjFE8cJjZ3fPduTOzIiJarvl+bPmuLuWS+K/KmcwUoK4pEGoTnetvYTY7GUpZOCTa0sZi+QRyhQ83pkBShKjDUBvzGKNxr6rU8W4uN8FoX4CKEcB6EMR61OZOEtApEqNIndFvAbiNuAB30QeU+sDYBXSCdw3MrzHvlnx/kdFkC3kU6NkwF3iM0ukFnNM8R0UplZquKHWE85nhV0Kg4o4GrDMwre5x5G9h9aaBHL/VPI849rtqRFfwqALaIcd+F87gYnDy1ha0sY12VcoiR0cLq5/ae3e3gyLbHB2tMAgKQ1fXh+z5a1mpDXQyy8hPIdgyAEMDW8+fWOQJHbfgzXUhxhkXYh/3jcC9C7s2V43c+9DPpHXgeXMIXbqQbV7gAV5hbFixEGMVolUEmvjjXuBeRcoOnp/R/hm81hi0LsQX8OcRBvBjZ8YAAAAASUVORK5CYII=)](https://mrcrayfish.com/mods?id=glasscutter) ![Minecraft](https://img.shields.io/static/v1?label=&message=1.15&color=2d2d2d&labelColor=dddddd&style=for-the-badge&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMjCGJ1kDAAACoElEQVQ4T22SeU8aURTF/ULGtNRWWVQY9lXABWldIDPIMgVbNgEVtaa0damiqGBdipXaJcY2ofEf4ycbTt97pVAabzK5b27u+Z377kwXgK77QthRy7OfXbeJM+ttqKSXN8sdwbT/A0L7elmsYqrPHZmROLPh5YkV4oEBwaKuHj+yyJptLDoAhbq3O1V1XCVObY3FL24mfn5oRPrcwSCRfQOyNWcjVjZdCbtcdwcgXrXUspdOKbDN/XE9tiBJMhXHT60gUIT2dMhcDLMc3NVKQklz0QIkf5qlyEcO6Qs7yPhMJB4amDMFimQSmqNlE8SKAZFzDfxHfVILIIZ10sJ3OwIbcqSuiOjchkzNCboHev9o2YhgiUP8mxnLN24I6/3ghYdtQG5iUMpFBuCP9iKwLsfiLyeCp2rMnZgwX3NArGoxW1Ridl+BzLEVKa8KSxOqNmDdz0kFnxaLHhWEgAyZigWhHXL+pEDy2ozsDxv8vAzTnh7w5kcghqCaFmCT10of4iPIT2mRdPUh4HoCcVwBH/8Ac2kzUkEV5r3EfVSOvbAJa5NDyI0r2oDtWb1EClh+OoC3Pg7v/Bw7p939yI4rsRW2Y3lKh01eh7WpIRyKZqzyjjYgPdIvlaMWRqYuG7wWryYHsRM0sFolZiPvQ3jheIwSmSBPdkByG/B6Wi3RYiVmRX7GiAPiUCRisii8D+jZNKvPBrHCW1GY0bAz6WkDCtOaSyKQFsi4K5NqNiZtehN2Y5uAShETqolhBqJXpfdPuPsuWwAaRdHSkxdc11mPqkGnyY4pyKbpl1GyJ0Pel7yqBoFcF3zqno5f+d8ohYy9Sx7lzQpxo1eirluCDgt++00p6uxttrG4F/A39sJGZWZMfrcp6O6+5kaVzXJHAOj6DeSs8qw5o8oxAAAAAElFTkSuQmCC) [![Curseforge](http://cf.way2muchnoise.eu/full_glasscutter_downloads.svg?badge_style=for_the_badge)](https://www.curseforge.com/minecraft/mc-mods/glasscutter) + # GlassCutter - Adds a glass cutter to create different shaped glass blocks! + +This is a simple mod that adds a glass cutter into the game. This block allows you to cut glass into different shapes. This mod adds stairs and slabs for every type of glass. + +### Crafting: +![Glasscutter Crafting](https://i.imgur.com/aETv57f.png) + +### Screenshots +![Glass Stairs and Slabs](https://i.imgur.com/xWqR3el.png) +![GlassCutter GUI](https://i.imgur.com/igBABjt.png) \ No newline at end of file diff --git a/build.gradle b/build.gradle index 96411da..6145ac5 100644 --- a/build.gradle +++ b/build.gradle @@ -1,89 +1,77 @@ -buildscript { - repositories { - maven { url = 'https://files.minecraftforge.net/maven' } - jcenter() - mavenCentral() - } - dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true - } +plugins { + id 'fabric-loom' version '0.4-SNAPSHOT' + id 'maven-publish' } -apply plugin: 'net.minecraftforge.gradle' -apply plugin: 'eclipse' -version = "1.1.0-${mc_version}" -group = 'com.mrcrayfish' -archivesBaseName = 'glasscutter' +sourceCompatibility = JavaVersion.VERSION_1_8 +targetCompatibility = JavaVersion.VERSION_1_8 -sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. +archivesBaseName = project.archives_base_name +version = project.mod_version +group = project.maven_group -minecraft { - mappings channel: 'snapshot', version: '20200514-1.16' - runs { - client { - workingDirectory project.file('run') - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - property 'forge.logging.console.level', 'debug' - mods { - examplemod { - source sourceSets.main - } - } - } +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}" - server { - workingDirectory project.file('run') - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - property 'forge.logging.console.level', 'debug' - mods { - examplemod { - source sourceSets.main - } - } - } + // Fabric API. This is technically optional, but you probably want it anyway. + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - data { - workingDirectory project.file('run') - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - property 'forge.logging.console.level', 'debug' - args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/') - mods { - examplemod { - source sourceSets.main - } - } - } - } + // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. + // You may need to force-disable transitiveness on them. } -repositories { - maven { - // location of the maven that hosts JEI files - name = "Progwml6 maven" - url = "https://dvs1.progwml6.com/files/maven/" +processResources { + inputs.property "version", project.version + + from(sourceSets.main.resources.srcDirs) { + include "fabric.mod.json" + expand "version": project.version } - maven { - // location of a maven mirror for JEI files, as a fallback - name = "ModMaven" - url = "https://modmaven.k-4u.nl" + + from(sourceSets.main.resources.srcDirs) { + exclude "fabric.mod.json" } } -dependencies { - minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}" - compile fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") +// ensure that the encoding is set to UTF-8, no matter what the system default is +// this fixes some edge cases with special characters not displaying correctly +// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html +tasks.withType(JavaCompile) { + options.encoding = "UTF-8" +} + +// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task +// if it is present. +// If you remove this task, sources will not be generated. +task sourcesJar(type: Jar, dependsOn: classes) { + classifier = "sources" + from sourceSets.main.allSource } jar { - manifest { - attributes([ - "Specification-Title": "Glasscutter", - "Specification-Vendor": "MrCrayfish", - "Specification-Version": "1", // We are version 1 of ourselves - "Implementation-Title": project.name, - "Implementation-Version": "${version}", - "Implementation-Vendor" : "MrCrayfish", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") - ]) + from "LICENSE" +} + +// configure the maven publication +publishing { + publications { + mavenJava(MavenPublication) { + // add all the jars that should be included when publishing to maven + artifact(remapJar) { + builtBy remapJar + } + artifact(sourcesJar) { + builtBy remapSourcesJar + } + } + } + + // select the repositories you want to publish to + repositories { + // uncomment to publish to the local maven + // mavenLocal() } -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index ea8344f..3ea96b0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,18 @@ -org.gradle.jvmargs=-Xmx3G -org.gradle.daemon=false -mc_version=1.16.1 -jei_version=7.0.1.10 -forge_version=32.0.108 +# Done to increase the memory available to gradle. +org.gradle.jvmargs=-Xmx1G + +# Fabric Properties +# check these on https://fabricmc.net/use +minecraft_version=1.16.2 +yarn_mappings=1.16.2+build.1 +loader_version=0.9.1+build.205 + +# Mod Properties +mod_version = 1.1.0-1.16-fabric +maven_group = com.mrcrayfish +archives_base_name = glasscutter + +# Dependencies +# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api +fabric_version=0.17.2+build.396-1.16 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7a3265e..490fda8 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 949819d..9543e93 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip +zipStorePath=wrapper/dists \ No newline at end of file diff --git a/gradlew b/gradlew index cccdd3d..2fe81a7 100644 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or 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 UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$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="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -109,8 +125,8 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` @@ -138,19 +154,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -159,14 +175,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index f955316..62bd9b9 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@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 @@ -13,8 +29,11 @@ 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= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..5b60df3 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,10 @@ +pluginManagement { + repositories { + jcenter() + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + gradlePluginPortal() + } +} diff --git a/src/main/java/com/mrcrayfish/glasscutter/GlassCutter.java b/src/main/java/com/mrcrayfish/glasscutter/GlassCutter.java deleted file mode 100644 index 941221d..0000000 --- a/src/main/java/com/mrcrayfish/glasscutter/GlassCutter.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.mrcrayfish.glasscutter; - -import com.mrcrayfish.glasscutter.client.ClientHandler; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; - -/** - * Author: MrCrayfish - */ -@Mod(Reference.MOD_ID) -public class GlassCutter -{ - public GlassCutter() - { - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onSetupClient); - } - - private void onSetupClient(FMLClientSetupEvent event) - { - ClientHandler.setup(); - } -} diff --git a/src/main/java/com/mrcrayfish/glasscutter/GlassCutterMain.java b/src/main/java/com/mrcrayfish/glasscutter/GlassCutterMain.java new file mode 100644 index 0000000..465e0f0 --- /dev/null +++ b/src/main/java/com/mrcrayfish/glasscutter/GlassCutterMain.java @@ -0,0 +1,25 @@ +package com.mrcrayfish.glasscutter; + +import com.mrcrayfish.glasscutter.client.ClientHandler; +import com.mrcrayfish.glasscutter.init.ModBlocks; +import com.mrcrayfish.glasscutter.init.ModRecipeSerializers; +import com.mrcrayfish.glasscutter.init.ModRecipeTypes; +import com.mrcrayfish.glasscutter.init.ModScreenHandlers; +import net.fabricmc.api.ModInitializer; + +/** + * Main Mod Class. + * @author justAm0dd3r + */ +public class GlassCutterMain implements ModInitializer +{ + @Override + public void onInitialize() { + ModBlocks.tryRegisterAll(); + ModScreenHandlers.registerAll(); + ModRecipeTypes.registerAll(); + ModRecipeSerializers.registerAll(); + + ClientHandler.setup(); + } +} diff --git a/src/main/java/com/mrcrayfish/glasscutter/block/AbstractGlassSlabBlock.java b/src/main/java/com/mrcrayfish/glasscutter/block/AbstractGlassSlabBlock.java index ffebf46..63f9741 100644 --- a/src/main/java/com/mrcrayfish/glasscutter/block/AbstractGlassSlabBlock.java +++ b/src/main/java/com/mrcrayfish/glasscutter/block/AbstractGlassSlabBlock.java @@ -1,58 +1,44 @@ package com.mrcrayfish.glasscutter.block; import net.minecraft.block.BlockState; +import net.minecraft.block.ShapeContext; import net.minecraft.block.SlabBlock; -import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; - -import java.util.function.Supplier; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; /** * Author: MrCrayfish */ public class AbstractGlassSlabBlock extends SlabBlock { - private final Supplier state; + private final BlockState state; - public AbstractGlassSlabBlock(Supplier state, Properties properties) + public AbstractGlassSlabBlock(BlockState state, Settings settings) { - super(properties); + super(settings.nonOpaque().allowsSpawning((a, b, c, d) -> false)); this.state = state; } @Override - public boolean isTransparent(BlockState state) - { - return true; + public VoxelShape getVisualShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { + return VoxelShapes.empty(); } - // Help, what should I use instead???! @Override - @OnlyIn(Dist.CLIENT) - public boolean isSideInvisible(BlockState state, BlockState adjacentState, Direction side) - { - return (adjacentState.getBlock() == this && adjacentState.get(TYPE) == state.get(TYPE)) || adjacentState.getBlock() == this.state.get().getBlock() || super.isSideInvisible(state, adjacentState, side); + public boolean isTranslucent(BlockState state, BlockView world, BlockPos pos) { + return true; } - // Help, what should I use instead???! @Override - @OnlyIn(Dist.CLIENT) - public float getAmbientOcclusionLightValue(BlockState state, IBlockReader worldIn, BlockPos pos) + public float getAmbientOcclusionLightLevel(BlockState state, BlockView worldIn, BlockPos pos) { return 1.0F; } @Override - public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) - { - return true; - } - - @Override - public boolean canSpawnInBlock() { + public boolean canMobSpawnInside() { return false; } } diff --git a/src/main/java/com/mrcrayfish/glasscutter/block/AbstractGlassStairsBlock.java b/src/main/java/com/mrcrayfish/glasscutter/block/AbstractGlassStairsBlock.java index 933b427..a6f70b9 100644 --- a/src/main/java/com/mrcrayfish/glasscutter/block/AbstractGlassStairsBlock.java +++ b/src/main/java/com/mrcrayfish/glasscutter/block/AbstractGlassStairsBlock.java @@ -1,37 +1,38 @@ package com.mrcrayfish.glasscutter.block; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.block.BlockState; import net.minecraft.block.StairsBlock; -import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; - -import java.util.function.Supplier; +import net.minecraft.util.math.Direction; +import net.minecraft.world.BlockView; /** * Author: MrCrayfish */ public class AbstractGlassStairsBlock extends StairsBlock { - private final Supplier state; + private final BlockState state; - public AbstractGlassStairsBlock(Supplier state, Properties properties) + public AbstractGlassStairsBlock(BlockState state, Settings settings) { - super(state, properties); + super(state, settings.nonOpaque().allowsSpawning((a, b, c, d) -> false)); this.state = state; } @Override - public boolean isTransparent(BlockState state) - { + public boolean isTranslucent(BlockState state, BlockView world, BlockPos pos) { return true; } - // Help, what should I use instead???! @Override - @OnlyIn(Dist.CLIENT) + public boolean hasSidedTransparency(BlockState state) { + return true; + } + + @Override + @Environment(EnvType.CLIENT) public boolean isSideInvisible(BlockState state, BlockState adjacentState, Direction side) { if(adjacentState.getBlock() == this && adjacentState.get(HALF) == state.get(HALF)) @@ -41,7 +42,7 @@ public boolean isSideInvisible(BlockState state, BlockState adjacentState, Direc return true; } } - if(adjacentState.getBlock() == this.state.get().getBlock()) + if(adjacentState.getBlock() == this.state.getBlock()) { return true; } @@ -50,20 +51,14 @@ public boolean isSideInvisible(BlockState state, BlockState adjacentState, Direc // Help, what should I use instead???! @Override - @OnlyIn(Dist.CLIENT) - public float getAmbientOcclusionLightValue(BlockState state, IBlockReader worldIn, BlockPos pos) + @Environment(EnvType.CLIENT) + public float getAmbientOcclusionLightLevel(BlockState state, BlockView worldIn, BlockPos pos) { return 1.0F; } @Override - public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) - { + public boolean canMobSpawnInside() { return true; } - - @Override - public boolean canSpawnInBlock() { - return false; - } } diff --git a/src/main/java/com/mrcrayfish/glasscutter/block/GlassSlabBlock.java b/src/main/java/com/mrcrayfish/glasscutter/block/GlassSlabBlock.java index c4bca02..511de9c 100644 --- a/src/main/java/com/mrcrayfish/glasscutter/block/GlassSlabBlock.java +++ b/src/main/java/com/mrcrayfish/glasscutter/block/GlassSlabBlock.java @@ -7,8 +7,8 @@ */ public class GlassSlabBlock extends AbstractGlassSlabBlock { - public GlassSlabBlock(Properties properties) + public GlassSlabBlock(Settings settings) { - super(Blocks.GLASS::getDefaultState, properties); + super(Blocks.GLASS.getDefaultState(), settings); } } diff --git a/src/main/java/com/mrcrayfish/glasscutter/block/GlassStairsBlock.java b/src/main/java/com/mrcrayfish/glasscutter/block/GlassStairsBlock.java index 425163c..774e5b2 100644 --- a/src/main/java/com/mrcrayfish/glasscutter/block/GlassStairsBlock.java +++ b/src/main/java/com/mrcrayfish/glasscutter/block/GlassStairsBlock.java @@ -1,16 +1,14 @@ package com.mrcrayfish.glasscutter.block; -import net.minecraft.block.BlockState; - -import java.util.function.Supplier; +import net.minecraft.block.Blocks; /** * Author: MrCrayfish */ public class GlassStairsBlock extends AbstractGlassStairsBlock { - public GlassStairsBlock(Supplier state, Properties properties) + public GlassStairsBlock(Settings settings) { - super(state, properties); + super(Blocks.GLASS.getDefaultState(), settings); } } diff --git a/src/main/java/com/mrcrayfish/glasscutter/block/GlasscutterBlock.java b/src/main/java/com/mrcrayfish/glasscutter/block/GlasscutterBlock.java index 98c0fcb..780d23b 100644 --- a/src/main/java/com/mrcrayfish/glasscutter/block/GlasscutterBlock.java +++ b/src/main/java/com/mrcrayfish/glasscutter/block/GlasscutterBlock.java @@ -1,107 +1,92 @@ package com.mrcrayfish.glasscutter.block; -import com.mrcrayfish.glasscutter.inventory.container.GlasscutterContainer; -import net.minecraft.block.Block; -import net.minecraft.block.BlockRenderType; -import net.minecraft.block.BlockState; -import net.minecraft.block.HorizontalBlock; +import com.mrcrayfish.glasscutter.Reference; +import com.mrcrayfish.glasscutter.init.ModStats; +import com.mrcrayfish.glasscutter.screen_handler.GlasscutterScreenHandler; +import net.minecraft.block.*; +import net.minecraft.entity.ai.pathing.NavigationType; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.container.INamedContainerProvider; -import net.minecraft.inventory.container.SimpleNamedContainerProvider; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.pathfinding.PathType; -import net.minecraft.state.DirectionProperty; -import net.minecraft.state.StateContainer; -import net.minecraft.util.*; +import net.minecraft.item.ItemPlacementContext; +import net.minecraft.screen.NamedScreenHandlerFactory; +import net.minecraft.screen.ScreenHandlerContext; +import net.minecraft.screen.SimpleNamedScreenHandlerFactory; +import net.minecraft.state.StateManager; +import net.minecraft.state.property.DirectionProperty; +import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; +import net.minecraft.util.ActionResult; +import net.minecraft.util.BlockMirror; +import net.minecraft.util.BlockRotation; +import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.IBlockReader; +import net.minecraft.util.math.Direction; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.world.BlockView; import net.minecraft.world.World; -import javax.annotation.Nullable; - /** - * Author: MrCrayfish + * @author justAm0dd3r */ -public class GlasscutterBlock extends Block -{ - private static final TranslationTextComponent CONTAINER_TITLE = new TranslationTextComponent("container.glasscutter.glasscutter"); - public static final DirectionProperty DIRECTION = HorizontalBlock.HORIZONTAL_FACING; - protected static final VoxelShape SHAPE = Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D); +public class GlasscutterBlock extends Block { + private static final Text TITLE = new TranslatableText("container." + Reference.MOD_ID + ".glasscutter"); + public static final DirectionProperty FACING; + protected static final VoxelShape SHAPE; + + public GlasscutterBlock(AbstractBlock.Settings settings) { + super(settings); + this.setDefaultState(this.stateManager.getDefaultState().with(FACING, Direction.NORTH)); + } - public GlasscutterBlock(Properties properties) - { - super(properties); - this.setDefaultState(this.stateContainer.getBaseState().with(DIRECTION, Direction.NORTH)); - } + public BlockState getPlacementState(ItemPlacementContext ctx) { + return this.getDefaultState().with(FACING, ctx.getPlayerFacing().getOpposite()); + } - @Override - public BlockState getStateForPlacement(BlockItemUseContext context) - { - return this.getDefaultState().with(DIRECTION, context.getPlacementHorizontalFacing().getOpposite()); - } + public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + if (world.isClient) { + return ActionResult.SUCCESS; + } else { + player.openHandledScreen(state.createScreenHandlerFactory(world, pos)); + player.incrementStat(ModStats.INTERACT_WITH_GLASSCUTER); + return ActionResult.CONSUME; + } + } - @Override - public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity playerEntity, Hand hand, BlockRayTraceResult result) - { - if(!world.isRemote) - { - playerEntity.openContainer(state.getContainer(world, pos)); - } - return ActionResultType.SUCCESS; - } + public NamedScreenHandlerFactory createScreenHandlerFactory(BlockState state, World world, BlockPos pos) { + return new SimpleNamedScreenHandlerFactory((i, playerInventory, playerEntity) + -> new GlasscutterScreenHandler(i, playerInventory, ScreenHandlerContext.create(world, pos)), TITLE); + } - @Nullable - @Override - public INamedContainerProvider getContainer(BlockState state, World world, BlockPos pos) - { - return new SimpleNamedContainerProvider((windowId, playerInventory, playerEntity) -> { - return new GlasscutterContainer(windowId, playerInventory, IWorldPosCallable.of(world, pos)); - }, CONTAINER_TITLE); - } + public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { + return SHAPE; + } - @Override - public VoxelShape getShape(BlockState state, IBlockReader reader, BlockPos pos, ISelectionContext context) - { - return SHAPE; - } + public boolean hasSidedTransparency(BlockState state) { + return true; + } - @Override - public boolean isTransparent(BlockState state) - { - return true; - } + public BlockRenderType getRenderType(BlockState state) { + return BlockRenderType.MODEL; + } - @Override - public BlockRenderType getRenderType(BlockState state) - { - return BlockRenderType.MODEL; - } + public BlockState rotate(BlockState state, BlockRotation rotation) { + return state.with(FACING, rotation.rotate(state.get(FACING))); + } - @Override - public BlockState rotate(BlockState state, Rotation rotation) - { - return state.with(DIRECTION, rotation.rotate(state.get(DIRECTION))); - } + public BlockState mirror(BlockState state, BlockMirror mirror) { + return state.rotate(mirror.getRotation(state.get(FACING))); + } - @Override - public BlockState mirror(BlockState state, Mirror mirror) - { - return state.rotate(mirror.toRotation(state.get(DIRECTION))); - } + protected void appendProperties(StateManager.Builder builder) { + builder.add(FACING); + } - @Override - protected void fillStateContainer(StateContainer.Builder builder) - { - builder.add(DIRECTION); - } + public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) { + return false; + } - @Override - public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType pathType) - { - return false; - } + static { + FACING = HorizontalFacingBlock.FACING; + SHAPE = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D); + } } diff --git a/src/main/java/com/mrcrayfish/glasscutter/block/StainedGlassSlabBlock.java b/src/main/java/com/mrcrayfish/glasscutter/block/StainedGlassSlabBlock.java index ac9f166..073f498 100644 --- a/src/main/java/com/mrcrayfish/glasscutter/block/StainedGlassSlabBlock.java +++ b/src/main/java/com/mrcrayfish/glasscutter/block/StainedGlassSlabBlock.java @@ -1,27 +1,24 @@ package com.mrcrayfish.glasscutter.block; import net.minecraft.block.BlockState; -import net.minecraft.block.IBeaconBeamColorProvider; -import net.minecraft.item.DyeColor; - -import java.util.function.Supplier; +import net.minecraft.block.Stainable; +import net.minecraft.util.DyeColor; /** * Author: MrCrayfish */ -public class StainedGlassSlabBlock extends AbstractGlassSlabBlock implements IBeaconBeamColorProvider +public class StainedGlassSlabBlock extends AbstractGlassSlabBlock implements Stainable { private final DyeColor color; - public StainedGlassSlabBlock(DyeColor color, Supplier state, Properties properties) + public StainedGlassSlabBlock(DyeColor color, BlockState state, Settings settings) { - super(state, properties); + super(state, settings); this.color = color; } @Override - public DyeColor getColor() - { - return this.color; + public DyeColor getColor() { + return color; } } diff --git a/src/main/java/com/mrcrayfish/glasscutter/block/StainedGlassStairsBlock.java b/src/main/java/com/mrcrayfish/glasscutter/block/StainedGlassStairsBlock.java index c06adf2..2c5ddc8 100644 --- a/src/main/java/com/mrcrayfish/glasscutter/block/StainedGlassStairsBlock.java +++ b/src/main/java/com/mrcrayfish/glasscutter/block/StainedGlassStairsBlock.java @@ -1,21 +1,19 @@ package com.mrcrayfish.glasscutter.block; import net.minecraft.block.BlockState; -import net.minecraft.block.IBeaconBeamColorProvider; -import net.minecraft.item.DyeColor; - -import java.util.function.Supplier; +import net.minecraft.block.Stainable; +import net.minecraft.util.DyeColor; /** * Author: MrCrayfish */ -public class StainedGlassStairsBlock extends AbstractGlassStairsBlock implements IBeaconBeamColorProvider +public class StainedGlassStairsBlock extends AbstractGlassStairsBlock implements Stainable { private final DyeColor color; - public StainedGlassStairsBlock(DyeColor color, Supplier state, Properties properties) + public StainedGlassStairsBlock(DyeColor color, BlockState state, Settings settings) { - super(state, properties); + super(state, settings); this.color = color; } diff --git a/src/main/java/com/mrcrayfish/glasscutter/client/ClientHandler.java b/src/main/java/com/mrcrayfish/glasscutter/client/ClientHandler.java index 1c09ad8..603eb00 100644 --- a/src/main/java/com/mrcrayfish/glasscutter/client/ClientHandler.java +++ b/src/main/java/com/mrcrayfish/glasscutter/client/ClientHandler.java @@ -1,11 +1,8 @@ package com.mrcrayfish.glasscutter.client; -import com.mrcrayfish.glasscutter.client.gui.screen.inventory.GlasscutterScreen; import com.mrcrayfish.glasscutter.init.ModBlocks; -import com.mrcrayfish.glasscutter.init.ModContainers; -import net.minecraft.client.gui.ScreenManager; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.RenderTypeLookup; +import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; +import net.minecraft.client.render.RenderLayer; /** * Author: MrCrayfish @@ -14,41 +11,10 @@ public class ClientHandler { public static void setup() { - RenderTypeLookup.setRenderLayer(ModBlocks.GLASSCUTTER, RenderType.getCutout()); - RenderTypeLookup.setRenderLayer(ModBlocks.GLASS_STAIRS, RenderType.getCutout()); - RenderTypeLookup.setRenderLayer(ModBlocks.GLASS_SLAB, RenderType.getCutout()); - RenderTypeLookup.setRenderLayer(ModBlocks.WHITE_STAINED_GLASS_STAIRS, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.ORANGE_STAINED_GLASS_STAIRS, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.MAGENTA_STAINED_GLASS_STAIRS, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.LIGHT_BLUE_STAINED_GLASS_STAIRS, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.YELLOW_STAINED_GLASS_STAIRS, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.LIME_STAINED_GLASS_STAIRS, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.PINK_STAINED_GLASS_STAIRS, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.GRAY_STAINED_GLASS_STAIRS, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.LIGHT_GRAY_STAINED_GLASS_STAIRS, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.CYAN_STAINED_GLASS_STAIRS, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.PURPLE_STAINED_GLASS_STAIRS, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.BLUE_STAINED_GLASS_STAIRS, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.BROWN_STAINED_GLASS_STAIRS, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.GREEN_STAINED_GLASS_STAIRS, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.RED_STAINED_GLASS_STAIRS, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.BLACK_STAINED_GLASS_STAIRS, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.WHITE_STAINED_GLASS_SLAB, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.ORANGE_STAINED_GLASS_SLAB, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.MAGENTA_STAINED_GLASS_SLAB, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.LIGHT_BLUE_STAINED_GLASS_SLAB, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.YELLOW_STAINED_GLASS_SLAB, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.LIME_STAINED_GLASS_SLAB, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.PINK_STAINED_GLASS_SLAB, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.GRAY_STAINED_GLASS_SLAB, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.LIGHT_GRAY_STAINED_GLASS_SLAB, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.CYAN_STAINED_GLASS_SLAB, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.PURPLE_STAINED_GLASS_SLAB, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.BLUE_STAINED_GLASS_SLAB, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.BROWN_STAINED_GLASS_SLAB, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.GREEN_STAINED_GLASS_SLAB, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.RED_STAINED_GLASS_SLAB, RenderType.getTranslucent()); - RenderTypeLookup.setRenderLayer(ModBlocks.BLACK_STAINED_GLASS_SLAB, RenderType.getTranslucent()); - ScreenManager.registerFactory(ModContainers.GLASSCUTTER, GlasscutterScreen::new); + // Make the slabs transparency render correctly. + BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.GLASSCUTTER, RenderLayer.getCutout()); + BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.GLASS_STAIRS, RenderLayer.getCutout()); + BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.GLASS_SLAB, RenderLayer.getCutout()); + ModBlocks.getTranslucentBlocks().forEach((block -> BlockRenderLayerMap.INSTANCE.putBlock(block, RenderLayer.getTranslucent()))); } } diff --git a/src/main/java/com/mrcrayfish/glasscutter/client/gui/screen/inventory/GlasscutterScreen.java b/src/main/java/com/mrcrayfish/glasscutter/client/gui/screen/inventory/GlasscutterScreen.java index da2b661..5535045 100644 --- a/src/main/java/com/mrcrayfish/glasscutter/client/gui/screen/inventory/GlasscutterScreen.java +++ b/src/main/java/com/mrcrayfish/glasscutter/client/gui/screen/inventory/GlasscutterScreen.java @@ -1,207 +1,189 @@ package com.mrcrayfish.glasscutter.client.gui.screen.inventory; -import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import com.mrcrayfish.glasscutter.Reference; -import com.mrcrayfish.glasscutter.inventory.container.GlasscutterContainer; import com.mrcrayfish.glasscutter.item.crafting.GlasscuttingRecipe; -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.SimpleSound; -import net.minecraft.client.gui.screen.inventory.ContainerScreen; +import com.mrcrayfish.glasscutter.screen_handler.GlasscutterScreenHandler; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.ingame.HandledScreen; +import net.minecraft.client.sound.PositionedSoundInstance; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundEvents; +import net.minecraft.sound.SoundEvents; +import net.minecraft.text.Text; +import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import java.util.List; /** - * Author: MrCrayfish + * Glasscutter screen. Only client side. + * + * @author justAm0dd3r */ -@OnlyIn(Dist.CLIENT) -public class GlasscutterScreen extends ContainerScreen -{ - private static final ResourceLocation BACKGROUND_TEXTURE = new ResourceLocation(Reference.MOD_ID, "textures/gui/container/glasscutter.png"); - private float sliderProgress; - private boolean clickOnScrollBar; - private int recipeIndexOffset; - private boolean hasItemsInInputSlot; - - public GlasscutterScreen(GlasscutterContainer container, PlayerInventory playerInventory, ITextComponent titleIn) - { - super(container, playerInventory, titleIn); - container.setInventoryUpdateListener(this::onInventoryUpdate); - --this.field_238743_q_; - } - - @Override - public void func_230430_a_(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) - // render - { - super.func_230430_a_(matrixStack, mouseX, mouseY, partialTicks); - this.func_238653_a_(matrixStack, null, mouseX, mouseY); // Render ToolTip - } - -/* - @Override - protected void func_230459_a_(MatrixStack matrixStack, int mouseX, int mouseY) - // drawGuiContainerForegroundLayer - { - // font renderer drawString - this.field_230712_o_.func_238407_a_(matrixStack, this.field_230704_d_.func_230532_e_(), 8.0F, 4.0F, 4210752); - this.field_230712_o_.func_238407_a_(matrixStack, this.playerInventory.getDisplayName().func_230532_e_(), 8.0F, (float) (this.ySize - 94), 4210752); - } -*/ - - protected void func_230450_a_(MatrixStack matrixStack, float partialTicks, int mouseX, int mouseY) - // drawGuiContainerBackgroundLayer - { - // this.renderBackground(); - this.func_230446_a_(matrixStack); - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - this.field_230706_i_.getTextureManager().bindTexture(BACKGROUND_TEXTURE); - int guiLeft = this.guiLeft; - int guiTop = this.guiTop; - - // Blit - this.func_238474_b_(matrixStack, guiLeft, guiTop, 0, 0, this.xSize, this.ySize); - int scrollBarPos = (int) (41.0F * this.sliderProgress); - - // Blit - this.func_238474_b_(matrixStack, guiLeft + 119, guiTop + 15 + scrollBarPos, - 176 + (this.canScroll() ? 0 : 12), 0, 12, 15); - int offsetX = this.guiLeft + 52; - int offsetY = this.guiTop + 14; - int indexOffset = this.recipeIndexOffset + 12; - this.drawRecipeBackgrounds(matrixStack, mouseX, mouseY, offsetX, offsetY, indexOffset); - this.drawRecipeItems(offsetX, offsetY, indexOffset); - } - - private void drawRecipeBackgrounds(MatrixStack matrixStack, int mouseX, int mouseY, int offsetX, int offsetY, int indexOffset) - { - for(int i = this.recipeIndexOffset; i < indexOffset && i < this.container.getRecipeListSize(); ++i) - { - int index = i - this.recipeIndexOffset; - int recipeOffsetX = offsetX + index % 4 * 16; - int recipeOffsetY = offsetY + (index / 4) * 18 + 2; - int vOffset = this.ySize; - if(i == this.container.getSelectedRecipe()) - { - vOffset += 18; +@Environment(EnvType.CLIENT) +public class GlasscutterScreen extends HandledScreen { + private static final Identifier TEXTURE = new Identifier(Reference.MOD_ID, "textures/gui/container/glasscutter.png"); + private float scrollAmount; + private boolean mouseClicked; + private int scrollOffset; + private boolean canCraft; + + public GlasscutterScreen(GlasscutterScreenHandler handler, PlayerInventory inventory, Text title) { + super(handler, inventory, title); + handler.setContentsChangedListener(this::onInventoryChange); + --this.titleY; + } + + public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { + super.render(matrices, mouseX, mouseY, delta); + this.drawMouseoverTooltip(matrices, mouseX, mouseY); + } + + /** + * Draw the background. + */ + protected void drawBackground(MatrixStack matrices, float delta, int mouseX, int mouseY) { + this.renderBackground(matrices); + RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); + assert this.client != null; + this.client.getTextureManager().bindTexture(TEXTURE); + int i = this.x; + int j = this.y; + this.drawTexture(matrices, i, j, 0, 0, this.backgroundWidth, this.backgroundHeight); + int k = (int)(41.0F * this.scrollAmount); + this.drawTexture(matrices, i + 119, j + 15 + k, 176 + (this.shouldScroll() ? 0 : 12), 0, 12, 15); + int l = this.x + 52; + int m = this.y + 14; + int n = this.scrollOffset + 12; + this.renderRecipeBackground(matrices, mouseX, mouseY, l, m, n); + this.renderRecipeIcons(l, m, n); + } + + protected void drawMouseoverTooltip(MatrixStack matrices, int x, int y) { + super.drawMouseoverTooltip(matrices, x, y); + if (this.canCraft) { + int i = this.x + 52; + int j = this.y + 14; + int k = this.scrollOffset + 12; + List list = this.handler.getAvailableRecipes(); + + for(int l = this.scrollOffset; l < k && l < this.handler.getAvailableRecipeCount(); ++l) { + int m = l - this.scrollOffset; + int n = i + m % 4 * 16; + int o = j + m / 4 * 18 + 2; + if (x >= n && x < n + 16 && y >= o && y < o + 18) { + this.renderTooltip(matrices, list.get(l).getOutput(), x, y); } - else if(mouseX >= recipeOffsetX && mouseY >= recipeOffsetY && mouseX < recipeOffsetX + 16 && mouseY < recipeOffsetY + 18) - { - vOffset += 36; + } + } + + } + + private void renderRecipeBackground(MatrixStack matrixStack, int i, int j, int k, int l, int m) { + for(int n = this.scrollOffset; n < m && n < this.handler.getAvailableRecipeCount(); ++n) { + int o = n - this.scrollOffset; + int p = k + o % 4 * 16; + int q = o / 4; + int r = l + q * 18 + 2; + int s = this.backgroundHeight; + if (n == this.handler.getSelectedRecipe()) { + s += 18; + } else if (i >= p && j >= r && i < p + 16 && j < r + 18) { + s += 36; + } + + this.drawTexture(matrixStack, p, r - 1, 0, s, 16, 18); + } + + } + + private void renderRecipeIcons(int x, int y, int scrollOffset) { + List list = this.handler.getAvailableRecipes(); + + for(int i = this.scrollOffset; i < scrollOffset && i < this.handler.getAvailableRecipeCount(); ++i) { + int j = i - this.scrollOffset; + int k = x + j % 4 * 16; + int l = j / 4; + int m = y + l * 18 + 2; + assert this.client != null; + this.client.getItemRenderer().renderInGuiWithOverrides(list.get(i).getOutput(), k, m); + } + + } + + public boolean mouseClicked(double mouseX, double mouseY, int button) { + this.mouseClicked = false; + if (this.canCraft) { + int i = this.x + 52; + int j = this.y + 14; + int k = this.scrollOffset + 12; + + for(int l = this.scrollOffset; l < k; ++l) { + int m = l - this.scrollOffset; + double d = mouseX - (double)(i + m % 4 * 16); + double e = mouseY - (double)(j + m / 4 * 18); + if (d >= 0.0D && e >= 0.0D && d < 16.0D && e < 18.0D) { + assert this.client != null; + if (this.handler.onButtonClick(this.client.player, l)) { + MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_STONECUTTER_SELECT_RECIPE, 1.0F)); + assert this.client.interactionManager != null; + this.client.interactionManager.clickButton(this.handler.syncId, l); + return true; + } } - - // Blit - this.func_238468_a_(matrixStack, recipeOffsetX, recipeOffsetY - 1, 0, vOffset, 16, 18); - } - } - - private void drawRecipeItems(int offsetX, int offsetY, int indexOffset) - { - List list = this.container.getRecipeList(); - for(int i = this.recipeIndexOffset; i < indexOffset && i < this.container.getRecipeListSize(); ++i) - { - int index = i - this.recipeIndexOffset; - int recipeOffsetX = offsetX + index % 4 * 16; - int recipeOffsetY = offsetY + (index / 4) * 18 + 2; - this.field_230706_i_.getItemRenderer().renderItemAndEffectIntoGUI(list.get(i).getRecipeOutput(), recipeOffsetX, recipeOffsetY); - } - } - - @Override - public boolean func_231044_a_(double mouseX, double mouseY, int button) - // mouseClicked - { - this.clickOnScrollBar = false; - if(this.hasItemsInInputSlot) - { - int recipeOffsetX = this.guiLeft + 52; - int recipeOffsetY = this.guiTop + 14; - int recipeOffset = this.recipeIndexOffset + 12; - - for(int i = this.recipeIndexOffset; i < recipeOffset; ++i) - { - int index = i - this.recipeIndexOffset; - double mouseRelativeX = mouseX - (double) (recipeOffsetX + index % 4 * 16); - double mouseRelativeY = mouseY - (double) (recipeOffsetY + index / 4 * 18); - if(mouseRelativeX >= 0.0D && mouseRelativeY >= 0.0D && mouseRelativeX < 16.0D && mouseRelativeY < 18.0D && this.container.enchantItem(this.field_230706_i_.player, i)) - { - Minecraft.getInstance().getSoundHandler().play(SimpleSound.master(SoundEvents.UI_STONECUTTER_SELECT_RECIPE, 1.0F)); - this.field_230706_i_.playerController.sendEnchantPacket((this.container).windowId, i); - return true; - } - } - - recipeOffsetX = this.guiLeft + 119; - recipeOffsetY = this.guiTop + 9; - if(mouseX >= (double) recipeOffsetX && mouseX < (double) (recipeOffsetX + 12) && mouseY >= (double) recipeOffsetY && mouseY < (double) (recipeOffsetY + 54)) - { - this.clickOnScrollBar = true; - } - } - - return super.func_231044_a_(mouseX, mouseY, button); - } - - @Override - public boolean func_231045_a_(double mouseX, double mouseY, int button, double deltaX, double deltaY) - // mouseDragged - { - if(this.clickOnScrollBar && this.canScroll()) - { - int offsetX = this.guiTop + 14; - int width = offsetX + 54; - this.sliderProgress = ((float) mouseY - (float) offsetX - 7.5F) / ((float) (width - offsetX) - 15.0F); - this.sliderProgress = MathHelper.clamp(this.sliderProgress, 0.0F, 1.0F); - this.recipeIndexOffset = (int) ((double) (this.sliderProgress * (float) this.getHiddenRows()) + 0.5D) * 4; - return true; - } - else - { - return super.func_231045_a_(mouseX, mouseY, button, deltaX, deltaY); - } - } - - @Override - public boolean func_231043_a_(double mouseX, double mouseY, double distance) - // mouseScrolled - { - if(this.canScroll()) - { - int hiddenRowsCount = this.getHiddenRows(); - this.sliderProgress = (float) ((double) this.sliderProgress - distance / (double) hiddenRowsCount); - this.sliderProgress = MathHelper.clamp(this.sliderProgress, 0.0F, 1.0F); - this.recipeIndexOffset = (int) ((double) (this.sliderProgress * (float) hiddenRowsCount) + 0.5D) * 4; - } - - return true; - } - - private boolean canScroll() - { - return this.hasItemsInInputSlot && this.container.getRecipeListSize() > 12; - } - - private int getHiddenRows() - { - return (this.container.getRecipeListSize() + 4 - 1) / 4 - 3; - } - - private void onInventoryUpdate() - { - this.hasItemsInInputSlot = this.container.hasItemsInInputSlot(); - if(!this.hasItemsInInputSlot) - { - this.sliderProgress = 0.0F; - this.recipeIndexOffset = 0; - } - } + } + + i = this.x + 119; + j = this.y + 9; + if (mouseX >= (double)i && mouseX < (double)(i + 12) && mouseY >= (double)j && mouseY < (double)(j + 54)) { + this.mouseClicked = true; + } + } + + return super.mouseClicked(mouseX, mouseY, button); + } + + public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { + if (this.mouseClicked && this.shouldScroll()) { + int i = this.y + 14; + int j = i + 54; + this.scrollAmount = ((float)mouseY - (float)i - 7.5F) / ((float)(j - i) - 15.0F); + this.scrollAmount = MathHelper.clamp(this.scrollAmount, 0.0F, 1.0F); + this.scrollOffset = (int)((double)(this.scrollAmount * (float)this.getMaxScroll()) + 0.5D) * 4; + return true; + } else { + return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY); + } + } + + public boolean mouseScrolled(double mouseX, double mouseY, double amount) { + if (this.shouldScroll()) { + int i = this.getMaxScroll(); + this.scrollAmount = (float)((double)this.scrollAmount - amount / (double)i); + this.scrollAmount = MathHelper.clamp(this.scrollAmount, 0.0F, 1.0F); + this.scrollOffset = (int)((double)(this.scrollAmount * (float)i) + 0.5D) * 4; + } + + return true; + } + + private boolean shouldScroll() { + return this.canCraft && this.handler.getAvailableRecipeCount() > 12; + } + + protected int getMaxScroll() { + return (this.handler.getAvailableRecipeCount() + 4 - 1) / 4 - 3; + } + + private void onInventoryChange() { + this.canCraft = this.handler.canCraft(); + if (!this.canCraft) { + this.scrollAmount = 0.0F; + this.scrollOffset = 0; + } + + } } diff --git a/src/main/java/com/mrcrayfish/glasscutter/init/ModBlocks.java b/src/main/java/com/mrcrayfish/glasscutter/init/ModBlocks.java index eea1e6e..b2668c5 100644 --- a/src/main/java/com/mrcrayfish/glasscutter/init/ModBlocks.java +++ b/src/main/java/com/mrcrayfish/glasscutter/init/ModBlocks.java @@ -2,92 +2,92 @@ import com.mrcrayfish.glasscutter.Reference; import com.mrcrayfish.glasscutter.block.*; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.block.material.Material; +import net.minecraft.block.*; import net.minecraft.item.BlockItem; -import net.minecraft.item.DyeColor; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.registries.IForgeRegistry; +import net.minecraft.util.DyeColor; +import net.minecraft.util.registry.Registry; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; -import java.util.List; /** * Author: MrCrayfish */ -@Mod.EventBusSubscriber(modid = Reference.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class ModBlocks { - private static final List BLOCKS = new ArrayList<>(); - private static final List ITEMS = new ArrayList<>(); + public static Block GLASSCUTTER; + public static Block GLASS_STAIRS; + public static Block GLASS_SLAB; - public static final Block GLASSCUTTER = register(new ResourceLocation(Reference.MOD_ID, "glasscutter"), new GlasscutterBlock(Block.Properties.create(Material.ROCK).hardnessAndResistance(3.5F)), ItemGroup.DECORATIONS); - public static final Block GLASS_STAIRS = register(new ResourceLocation(Reference.MOD_ID, "glass_stairs"), new GlassStairsBlock(Blocks.GLASS::getDefaultState, Block.Properties.from(Blocks.GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block GLASS_SLAB = register(new ResourceLocation(Reference.MOD_ID, "glass_slab"), new GlassSlabBlock(Block.Properties.from(Blocks.GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block WHITE_STAINED_GLASS_STAIRS = register(new ResourceLocation(Reference.MOD_ID, "white_stained_glass_stairs"), new StainedGlassStairsBlock(DyeColor.WHITE, Blocks.WHITE_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.WHITE_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block ORANGE_STAINED_GLASS_STAIRS = register(new ResourceLocation(Reference.MOD_ID, "orange_stained_glass_stairs"), new StainedGlassStairsBlock(DyeColor.ORANGE, Blocks.ORANGE_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.ORANGE_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block MAGENTA_STAINED_GLASS_STAIRS = register(new ResourceLocation(Reference.MOD_ID, "magenta_stained_glass_stairs"), new StainedGlassStairsBlock(DyeColor.MAGENTA, Blocks.MAGENTA_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.MAGENTA_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block LIGHT_BLUE_STAINED_GLASS_STAIRS = register(new ResourceLocation(Reference.MOD_ID, "light_blue_stained_glass_stairs"), new StainedGlassStairsBlock(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.LIGHT_BLUE_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block YELLOW_STAINED_GLASS_STAIRS = register(new ResourceLocation(Reference.MOD_ID, "yellow_stained_glass_stairs"), new StainedGlassStairsBlock(DyeColor.YELLOW, Blocks.YELLOW_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.YELLOW_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block LIME_STAINED_GLASS_STAIRS = register(new ResourceLocation(Reference.MOD_ID, "lime_stained_glass_stairs"), new StainedGlassStairsBlock(DyeColor.LIME, Blocks.LIME_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.LIME_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block PINK_STAINED_GLASS_STAIRS = register(new ResourceLocation(Reference.MOD_ID, "pink_stained_glass_stairs"), new StainedGlassStairsBlock(DyeColor.PINK, Blocks.PINK_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.PINK_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block GRAY_STAINED_GLASS_STAIRS = register(new ResourceLocation(Reference.MOD_ID, "gray_stained_glass_stairs"), new StainedGlassStairsBlock(DyeColor.GRAY, Blocks.GRAY_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.GRAY_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block LIGHT_GRAY_STAINED_GLASS_STAIRS = register(new ResourceLocation(Reference.MOD_ID, "light_gray_stained_glass_stairs"), new StainedGlassStairsBlock(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.LIGHT_GRAY_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block CYAN_STAINED_GLASS_STAIRS = register(new ResourceLocation(Reference.MOD_ID, "cyan_stained_glass_stairs"), new StainedGlassStairsBlock(DyeColor.CYAN, Blocks.CYAN_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.CYAN_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block PURPLE_STAINED_GLASS_STAIRS = register(new ResourceLocation(Reference.MOD_ID, "purple_stained_glass_stairs"), new StainedGlassStairsBlock(DyeColor.PURPLE, Blocks.PURPLE_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.PURPLE_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block BLUE_STAINED_GLASS_STAIRS = register(new ResourceLocation(Reference.MOD_ID, "blue_stained_glass_stairs"), new StainedGlassStairsBlock(DyeColor.BLUE, Blocks.BLUE_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.BLUE_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block BROWN_STAINED_GLASS_STAIRS = register(new ResourceLocation(Reference.MOD_ID, "brown_stained_glass_stairs"), new StainedGlassStairsBlock(DyeColor.BROWN, Blocks.BROWN_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.BROWN_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block GREEN_STAINED_GLASS_STAIRS = register(new ResourceLocation(Reference.MOD_ID, "green_stained_glass_stairs"), new StainedGlassStairsBlock(DyeColor.GREEN, Blocks.GREEN_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.GREEN_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block RED_STAINED_GLASS_STAIRS = register(new ResourceLocation(Reference.MOD_ID, "red_stained_glass_stairs"), new StainedGlassStairsBlock(DyeColor.RED, Blocks.RED_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.RED_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block BLACK_STAINED_GLASS_STAIRS = register(new ResourceLocation(Reference.MOD_ID, "black_stained_glass_stairs"), new StainedGlassStairsBlock(DyeColor.BLACK, Blocks.BLACK_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.BLACK_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block WHITE_STAINED_GLASS_SLAB = register(new ResourceLocation(Reference.MOD_ID, "white_stained_glass_slab"), new StainedGlassSlabBlock(DyeColor.WHITE, Blocks.WHITE_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.WHITE_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block ORANGE_STAINED_GLASS_SLAB = register(new ResourceLocation(Reference.MOD_ID, "orange_stained_glass_slab"), new StainedGlassSlabBlock(DyeColor.ORANGE, Blocks.ORANGE_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.ORANGE_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block MAGENTA_STAINED_GLASS_SLAB = register(new ResourceLocation(Reference.MOD_ID, "magenta_stained_glass_slab"), new StainedGlassSlabBlock(DyeColor.MAGENTA, Blocks.MAGENTA_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.MAGENTA_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block LIGHT_BLUE_STAINED_GLASS_SLAB = register(new ResourceLocation(Reference.MOD_ID, "light_blue_stained_glass_slab"), new StainedGlassSlabBlock(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.LIGHT_BLUE_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block YELLOW_STAINED_GLASS_SLAB = register(new ResourceLocation(Reference.MOD_ID, "yellow_stained_glass_slab"), new StainedGlassSlabBlock(DyeColor.YELLOW, Blocks.YELLOW_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.YELLOW_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block LIME_STAINED_GLASS_SLAB = register(new ResourceLocation(Reference.MOD_ID, "lime_stained_glass_slab"), new StainedGlassSlabBlock(DyeColor.LIME, Blocks.LIME_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.LIME_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block PINK_STAINED_GLASS_SLAB = register(new ResourceLocation(Reference.MOD_ID, "pink_stained_glass_slab"), new StainedGlassSlabBlock(DyeColor.PINK, Blocks.PINK_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.PINK_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block GRAY_STAINED_GLASS_SLAB = register(new ResourceLocation(Reference.MOD_ID, "gray_stained_glass_slab"), new StainedGlassSlabBlock(DyeColor.GRAY, Blocks.GRAY_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.GRAY_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block LIGHT_GRAY_STAINED_GLASS_SLAB = register(new ResourceLocation(Reference.MOD_ID, "light_gray_stained_glass_slab"), new StainedGlassSlabBlock(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.LIGHT_GRAY_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block CYAN_STAINED_GLASS_SLAB = register(new ResourceLocation(Reference.MOD_ID, "cyan_stained_glass_slab"), new StainedGlassSlabBlock(DyeColor.CYAN, Blocks.CYAN_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.CYAN_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block PURPLE_STAINED_GLASS_SLAB = register(new ResourceLocation(Reference.MOD_ID, "purple_stained_glass_slab"), new StainedGlassSlabBlock(DyeColor.PURPLE, Blocks.PURPLE_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.PURPLE_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block BLUE_STAINED_GLASS_SLAB = register(new ResourceLocation(Reference.MOD_ID, "blue_stained_glass_slab"), new StainedGlassSlabBlock(DyeColor.BLUE, Blocks.BLUE_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.BLUE_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block BROWN_STAINED_GLASS_SLAB = register(new ResourceLocation(Reference.MOD_ID, "brown_stained_glass_slab"), new StainedGlassSlabBlock(DyeColor.BROWN, Blocks.BROWN_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.BROWN_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block GREEN_STAINED_GLASS_SLAB = register(new ResourceLocation(Reference.MOD_ID, "green_stained_glass_slab"), new StainedGlassSlabBlock(DyeColor.GREEN, Blocks.GREEN_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.GREEN_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block RED_STAINED_GLASS_SLAB = register(new ResourceLocation(Reference.MOD_ID, "red_stained_glass_slab"), new StainedGlassSlabBlock(DyeColor.RED, Blocks.RED_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.RED_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); - public static final Block BLACK_STAINED_GLASS_SLAB = register(new ResourceLocation(Reference.MOD_ID, "black_stained_glass_slab"), new StainedGlassSlabBlock(DyeColor.BLACK, Blocks.BLACK_STAINED_GLASS::getDefaultState, Block.Properties.from(Blocks.BLACK_STAINED_GLASS)), ItemGroup.BUILDING_BLOCKS); + public static ArrayList getTranslucentBlocks() { + return translucentBlocks; + } + + private static final ArrayList translucentBlocks = new ArrayList<>(); + private static final Logger LOGGER = LogManager.getLogger(); + + /** + * Try to register the blocks via reflection. (not that repetitive). Trows tons of reflection exceptions. + * @throws NoSuchFieldException when a field, e.g. {@link Blocks#WHITE_STAINED_GLASS} wasn't found. + * @throws NoSuchMethodException when a method wasn't found. + * @throws InstantiationException when an error occurs during the {@link StainedGlassSlabBlock} or {@link StainedGlassStairsBlock} constructor call. + */ + public static void registerAll() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException, InstantiationException, NoSuchFieldException { + // Glasscutter + GLASSCUTTER = register("glasscutter", new GlasscutterBlock(AbstractBlock.Settings.of(Material.STONE).strength(3.5F)), ItemGroup.DECORATIONS); + // Glass Stairs + GLASS_STAIRS = register("glass_stairs", new GlassStairsBlock(AbstractBlock.Settings.copy(Blocks.GLASS))); + // Glass Slab + GLASS_SLAB = register("glass_slab", new GlassSlabBlock(AbstractBlock.Settings.copy(Blocks.GLASS))); + + for (DyeColor color: DyeColor.values()) { + String[] types = new String[] { "stairs", "slab" }; + for (String type : types) { + // Get the StainedGlassStairsBlock or the StainedGlassSlabBlock constructor. + Constructor constructor = type.equals("stairs") ? StainedGlassStairsBlock.class.getConstructor(DyeColor.class, BlockState.class, + AbstractBlock.Settings.class) : StainedGlassSlabBlock.class.getConstructor(DyeColor.class, BlockState.class, AbstractBlock.Settings.class); + // Get the corresponding block in the Blocks class. + Block block = (Block) Blocks.class.getDeclaredField(color.getName().toUpperCase() + "_STAINED_GLASS").get(Blocks.class); + // Set the field to the (registered) block. + block = register(color.getName() + "_stained_glass_" + type, + (Block) constructor.newInstance(color, block.getDefaultState(), AbstractBlock.Settings.copy(block))); + translucentBlocks.add(block); + } + } + } - private static Block register(ResourceLocation key, Block block, ItemGroup group) - { - block.setRegistryName(key); - BLOCKS.add(block); - BlockItem item = new BlockItem(block, new Item.Properties().group(group)); - item.setRegistryName(key); - ITEMS.add(item); - return block; + /** + * Calls the {@link #registerAll()} method and catches the reflection exceptions when thrown. + */ + public static void tryRegisterAll() { + try { + registerAll(); + } catch (NoSuchFieldException | IllegalAccessException | NoSuchMethodException | InvocationTargetException | InstantiationException e) { + LOGGER.error("Error while trying to register blocks via reflection.", e); + } } - @SubscribeEvent - @SuppressWarnings("unused") - public static void registerBlocks(RegistryEvent.Register event) - { - IForgeRegistry registry = event.getRegistry(); - BLOCKS.forEach(registry::register); - BLOCKS.clear(); + /** + * Register a block and the corresponding block item. + * @param name the name of the block, e.g. "white_stained_glass_slab" + * @param block the actual {@link ItemGroup} + * @param group the {@link ItemGroup} + * @return the (registered) block + */ + private static Block register(final String name, final Block block, final ItemGroup group) { + Registry.register(Registry.ITEM, Reference.MOD_ID + ":" + name, new BlockItem(block, new Item.Settings().group(group))); + return Registry.register(Registry.BLOCK, Reference.MOD_ID + ":" + name, block); } - @SubscribeEvent - @SuppressWarnings("unused") - public static void registerItems(RegistryEvent.Register event) - { - IForgeRegistry registry = event.getRegistry(); - ITEMS.forEach(registry::register); - ITEMS.clear(); + /** + * Same as {@link #register(String, Block, ItemGroup)}. Just with the default item group: {@link ItemGroup#BUILDING_BLOCKS}. + */ + private static Block register(final String name, final Block block) { + return register(name, block, ItemGroup.BUILDING_BLOCKS); } } diff --git a/src/main/java/com/mrcrayfish/glasscutter/init/ModContainers.java b/src/main/java/com/mrcrayfish/glasscutter/init/ModContainers.java deleted file mode 100644 index 361bced..0000000 --- a/src/main/java/com/mrcrayfish/glasscutter/init/ModContainers.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.mrcrayfish.glasscutter.init; - -import com.mrcrayfish.glasscutter.Reference; -import com.mrcrayfish.glasscutter.inventory.container.GlasscutterContainer; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.ContainerType; -import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.registries.IForgeRegistry; - -import java.util.ArrayList; -import java.util.List; - -/** - * Author: MrCrayfish - */ -@Mod.EventBusSubscriber(modid = Reference.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) -public class ModContainers -{ - private static final List> CONTAINER_TYPES = new ArrayList<>(); - - public static final ContainerType GLASSCUTTER = register(Reference.MOD_ID + ":glasscutter", GlasscutterContainer::new); - - private static ContainerType register(String key, ContainerType.IFactory factory) - { - ContainerType type = new ContainerType<>(factory); - type.setRegistryName(key); - CONTAINER_TYPES.add(type); - return type; - } - - @SubscribeEvent - @SuppressWarnings("unused") - public static void registerTypes(final RegistryEvent.Register> event) - { - IForgeRegistry> registry = event.getRegistry(); - CONTAINER_TYPES.forEach(registry::register); - CONTAINER_TYPES.clear(); - } -} diff --git a/src/main/java/com/mrcrayfish/glasscutter/init/ModRecipeSerializers.java b/src/main/java/com/mrcrayfish/glasscutter/init/ModRecipeSerializers.java index 8fe297c..07de677 100644 --- a/src/main/java/com/mrcrayfish/glasscutter/init/ModRecipeSerializers.java +++ b/src/main/java/com/mrcrayfish/glasscutter/init/ModRecipeSerializers.java @@ -2,41 +2,18 @@ import com.mrcrayfish.glasscutter.Reference; import com.mrcrayfish.glasscutter.item.crafting.GlasscuttingRecipe; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.registries.IForgeRegistry; - -import java.util.ArrayList; -import java.util.List; +import net.minecraft.recipe.RecipeSerializer; +import net.minecraft.util.Identifier; +import net.minecraft.util.registry.Registry; /** - * Author: MrCrayfish + * @author justAm0dd3r */ -@Mod.EventBusSubscriber(modid = Reference.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) -public class ModRecipeSerializers -{ - @SuppressWarnings("rawtypes") - private static final List RECIPES = new ArrayList<>(); - - public static final IRecipeSerializer GLASSCUTTING = register(Reference.MOD_ID + ":glasscutting", new GlasscuttingRecipe.Serializer<>(GlasscuttingRecipe::new)); - - private static >> T register(String name, T t) - { - t.setRegistryName(new ResourceLocation(name)); - RECIPES.add(t); - return t; - } +public class ModRecipeSerializers { + public static RecipeSerializer GLASSCUTTING; - @SubscribeEvent - @SuppressWarnings("unused") - public static void registerItems(final RegistryEvent.Register> event) - { - IForgeRegistry> registry = event.getRegistry(); - RECIPES.forEach(item -> event.getRegistry().register(item)); - RECIPES.clear(); + public static void registerAll() { + GLASSCUTTING = Registry.register(Registry.RECIPE_SERIALIZER, + new Identifier(Reference.MOD_ID, "glasscutting"), new GlasscuttingRecipe.Serializer(GlasscuttingRecipe::new)); } } diff --git a/src/main/java/com/mrcrayfish/glasscutter/init/ModRecipeTypes.java b/src/main/java/com/mrcrayfish/glasscutter/init/ModRecipeTypes.java new file mode 100644 index 0000000..37d24c1 --- /dev/null +++ b/src/main/java/com/mrcrayfish/glasscutter/init/ModRecipeTypes.java @@ -0,0 +1,23 @@ +package com.mrcrayfish.glasscutter.init; + +import com.mrcrayfish.glasscutter.Reference; +import com.mrcrayfish.glasscutter.item.crafting.GlasscuttingRecipe; +import net.minecraft.recipe.RecipeType; +import net.minecraft.util.Identifier; +import net.minecraft.util.registry.Registry; + +/** + * @author justAm0dd3r + */ +public class ModRecipeTypes { + public static RecipeType GLASSCUTTING; + + public static void registerAll() { + GLASSCUTTING = Registry.register(Registry.RECIPE_TYPE, new Identifier(Reference.MOD_ID, "glasscutting"), new RecipeType() { + @Override + public String toString() { + return "glasscutting"; + } + }); + } +} diff --git a/src/main/java/com/mrcrayfish/glasscutter/init/ModScreenHandlers.java b/src/main/java/com/mrcrayfish/glasscutter/init/ModScreenHandlers.java new file mode 100644 index 0000000..6c3ce9e --- /dev/null +++ b/src/main/java/com/mrcrayfish/glasscutter/init/ModScreenHandlers.java @@ -0,0 +1,22 @@ +package com.mrcrayfish.glasscutter.init; + +import com.mrcrayfish.glasscutter.Reference; +import com.mrcrayfish.glasscutter.client.gui.screen.inventory.GlasscutterScreen; +import com.mrcrayfish.glasscutter.screen_handler.GlasscutterScreenHandler; +import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry; +import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry; +import net.minecraft.screen.ScreenHandlerType; +import net.minecraft.util.Identifier; + +/** + * @author justAm0dd3r + */ +public class ModScreenHandlers { + public static ScreenHandlerType GLASSCUTTER; + + public static void registerAll() { + GLASSCUTTER = ScreenHandlerRegistry.registerSimple(new Identifier(Reference.MOD_ID, "glasscutter"), + GlasscutterScreenHandler::new); + ScreenRegistry.register(GLASSCUTTER, GlasscutterScreen::new); + } +} diff --git a/src/main/java/com/mrcrayfish/glasscutter/init/ModStats.java b/src/main/java/com/mrcrayfish/glasscutter/init/ModStats.java new file mode 100644 index 0000000..3066a38 --- /dev/null +++ b/src/main/java/com/mrcrayfish/glasscutter/init/ModStats.java @@ -0,0 +1,23 @@ +package com.mrcrayfish.glasscutter.init; + +import com.mrcrayfish.glasscutter.Reference; +import net.minecraft.stat.StatFormatter; +import net.minecraft.stat.Stats; +import net.minecraft.util.Identifier; +import net.minecraft.util.registry.Registry; + +/** + * Mod stats holder class. + * @author justAm0dd3r + */ +public class ModStats { + public static final Identifier INTERACT_WITH_GLASSCUTER = register("interact_with_glasscutter", StatFormatter.DEFAULT); + + @SuppressWarnings("SameParameterValue") + private static Identifier register(String string, StatFormatter statFormatter) { + Identifier identifier = new Identifier(Reference.MOD_ID, string); + Registry.register(Registry.CUSTOM_STAT, string, identifier); + Stats.CUSTOM.getOrCreateStat(identifier, statFormatter); + return identifier; + } +} diff --git a/src/main/java/com/mrcrayfish/glasscutter/inventory/container/GlasscutterContainer.java b/src/main/java/com/mrcrayfish/glasscutter/inventory/container/GlasscutterContainer.java deleted file mode 100644 index c8f2da4..0000000 --- a/src/main/java/com/mrcrayfish/glasscutter/inventory/container/GlasscutterContainer.java +++ /dev/null @@ -1,274 +0,0 @@ -package com.mrcrayfish.glasscutter.inventory.container; - -import com.google.common.collect.Lists; -import com.mrcrayfish.glasscutter.init.ModBlocks; -import com.mrcrayfish.glasscutter.init.ModContainers; -import com.mrcrayfish.glasscutter.item.crafting.GlasscuttingRecipe; -import com.mrcrayfish.glasscutter.item.crafting.RecipeType; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.CraftResultInventory; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Inventory; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.Slot; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IWorldPosCallable; -import net.minecraft.util.IntReferenceHolder; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; - -import java.util.List; - -/** - * Author: MrCrayfish - */ -public class GlasscutterContainer extends Container -{ - private final IWorldPosCallable worldPosCallable; - private final IntReferenceHolder selectedRecipe; - private final World world; - private List recipes; - private ItemStack itemStackInput; - private long lastOnTake; - private final Slot inputInventorySlot; - private final Slot outputInventorySlot; - private Runnable inventoryUpdateListener = () -> {}; - private final IInventory inputInventory; - private final CraftResultInventory inventory; - - public GlasscutterContainer(int windowId, PlayerInventory playerInventory) - { - this(windowId, playerInventory, IWorldPosCallable.DUMMY); - } - - public GlasscutterContainer(int windowId, PlayerInventory playerInventory, final IWorldPosCallable callable) - { - super(ModContainers.GLASSCUTTER, windowId); - this.selectedRecipe = IntReferenceHolder.single(); - this.recipes = Lists.newArrayList(); - this.itemStackInput = ItemStack.EMPTY; - this.inputInventory = new Inventory(1) - { - @Override - public void markDirty() - { - super.markDirty(); - GlasscutterContainer.this.onCraftMatrixChanged(this); - GlasscutterContainer.this.inventoryUpdateListener.run(); - } - }; - this.inventory = new CraftResultInventory(); - this.worldPosCallable = callable; - this.world = playerInventory.player.world; - this.inputInventorySlot = this.addSlot(new Slot(this.inputInventory, 0, 20, 33)); - this.outputInventorySlot = this.addSlot(new Slot(this.inventory, 1, 143, 33) - { - @Override - public boolean isItemValid(ItemStack stack) - { - return false; - } - - @Override - public ItemStack onTake(PlayerEntity playerEntity, ItemStack stack) - { - ItemStack slotStack = GlasscutterContainer.this.inputInventorySlot.decrStackSize(1); - if(!slotStack.isEmpty()) - { - GlasscutterContainer.this.updateRecipeResultSlot(); - } - - stack.getItem().onCreated(stack, playerEntity.world, playerEntity); - callable.consume((world, pos) -> - { - long gameTime = world.getGameTime(); - if(GlasscutterContainer.this.lastOnTake != gameTime) - { - world.playSound(null, pos, SoundEvents.UI_STONECUTTER_TAKE_RESULT, SoundCategory.BLOCKS, 1.0F, 1.0F); - GlasscutterContainer.this.lastOnTake = gameTime; - } - }); - return super.onTake(playerEntity, stack); - } - }); - - for(int i = 0; i < 3; i++) - { - for(int j = 0; j < 9; j++) - { - this.addSlot(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } - - for(int i = 0; i < 9; i++) - { - this.addSlot(new Slot(playerInventory, i, 8 + i * 18, 142)); - } - - this.trackInt(this.selectedRecipe); - } - - @OnlyIn(Dist.CLIENT) - public int getSelectedRecipe() - { - return this.selectedRecipe.get(); - } - - @OnlyIn(Dist.CLIENT) - public List getRecipeList() - { - return this.recipes; - } - - @OnlyIn(Dist.CLIENT) - public int getRecipeListSize() - { - return this.recipes.size(); - } - - @OnlyIn(Dist.CLIENT) - public boolean hasItemsInInputSlot() - { - return this.inputInventorySlot.getHasStack() && !this.recipes.isEmpty(); - } - - @Override - public boolean canInteractWith(PlayerEntity playerEntity) - { - return isWithinUsableDistance(this.worldPosCallable, playerEntity, ModBlocks.GLASSCUTTER); - } - - @Override - public boolean enchantItem(PlayerEntity playerEntity, int index) - { - if(index >= 0 && index < this.recipes.size()) - { - this.selectedRecipe.set(index); - this.updateRecipeResultSlot(); - } - return true; - } - - @Override - public void onCraftMatrixChanged(IInventory inventory) - { - ItemStack stack = this.inputInventorySlot.getStack(); - if(stack.getItem() != this.itemStackInput.getItem()) - { - this.itemStackInput = stack.copy(); - this.updateAvailableRecipes(inventory, stack); - } - } - - private void updateAvailableRecipes(IInventory inventory, ItemStack stack) - { - this.recipes.clear(); - this.selectedRecipe.set(-1); - this.outputInventorySlot.putStack(ItemStack.EMPTY); - if(!stack.isEmpty()) - { - this.recipes = this.world.getRecipeManager().getRecipes(RecipeType.GLASSCUTTING, inventory, this.world); - } - } - - private void updateRecipeResultSlot() - { - if(!this.recipes.isEmpty()) - { - //TODO fix this - GlasscuttingRecipe recipe = this.recipes.get(this.selectedRecipe.get()); - this.outputInventorySlot.putStack(recipe.getCraftingResult(this.inputInventory)); - } - else - { - this.outputInventorySlot.putStack(ItemStack.EMPTY); - } - this.detectAndSendChanges(); - } - - @OnlyIn(Dist.CLIENT) - public void setInventoryUpdateListener(Runnable runnable) - { - this.inventoryUpdateListener = runnable; - } - - public boolean canMergeSlot(ItemStack stack, Slot slot) - { - return slot.inventory != this.inventory && super.canMergeSlot(stack, slot); - } - - public ItemStack transferStackInSlot(PlayerEntity playerEntity, int index) - { - ItemStack copyStack = ItemStack.EMPTY; - Slot slot = this.inventorySlots.get(index); - if(slot != null && slot.getHasStack()) - { - ItemStack slotStack = slot.getStack(); - Item item = slotStack.getItem(); - copyStack = slotStack.copy(); - if(index == 1) - { - item.onCreated(slotStack, playerEntity.world, playerEntity); - if(!this.mergeItemStack(slotStack, 2, 38, true)) - { - return ItemStack.EMPTY; - } - - slot.onSlotChange(slotStack, copyStack); - } - else if(index == 0) - { - if(!this.mergeItemStack(slotStack, 2, 38, false)) - { - return ItemStack.EMPTY; - } - } - else if(this.world.getRecipeManager().getRecipe(RecipeType.GLASSCUTTING, new Inventory(slotStack), this.world).isPresent()) - { - if(!this.mergeItemStack(slotStack, 0, 1, false)) - { - return ItemStack.EMPTY; - } - } - else if(index < 29) - { - if(!this.mergeItemStack(slotStack, 29, 38, false)) - { - return ItemStack.EMPTY; - } - } - else if(index < 38 && !this.mergeItemStack(slotStack, 2, 29, false)) - { - return ItemStack.EMPTY; - } - - if(slotStack.isEmpty()) - { - slot.putStack(ItemStack.EMPTY); - } - - slot.onSlotChanged(); - if(slotStack.getCount() == copyStack.getCount()) - { - return ItemStack.EMPTY; - } - - slot.onTake(playerEntity, slotStack); - this.detectAndSendChanges(); - } - - return copyStack; - } - - public void onContainerClosed(PlayerEntity playerEntity) - { - super.onContainerClosed(playerEntity); - this.inventory.removeStackFromSlot(1); - this.worldPosCallable.consume((world, pos) -> this.clearContainer(playerEntity, playerEntity.world, this.inputInventory)); - } -} diff --git a/src/main/java/com/mrcrayfish/glasscutter/item/crafting/GlasscuttingRecipe.java b/src/main/java/com/mrcrayfish/glasscutter/item/crafting/GlasscuttingRecipe.java index 743da2b..37bf315 100644 --- a/src/main/java/com/mrcrayfish/glasscutter/item/crafting/GlasscuttingRecipe.java +++ b/src/main/java/com/mrcrayfish/glasscutter/item/crafting/GlasscuttingRecipe.java @@ -3,87 +3,77 @@ import com.google.gson.JsonObject; import com.mrcrayfish.glasscutter.init.ModBlocks; import com.mrcrayfish.glasscutter.init.ModRecipeSerializers; -import net.minecraft.inventory.IInventory; +import com.mrcrayfish.glasscutter.init.ModRecipeTypes; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.inventory.Inventory; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.item.crafting.SingleItemRecipe; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.JSONUtils; -import net.minecraft.util.ResourceLocation; +import net.minecraft.network.PacketByteBuf; +import net.minecraft.recipe.CuttingRecipe; +import net.minecraft.recipe.Ingredient; +import net.minecraft.recipe.RecipeSerializer; +import net.minecraft.util.Identifier; +import net.minecraft.util.JsonHelper; import net.minecraft.util.registry.Registry; import net.minecraft.world.World; /** - * Author: MrCrayfish + * @author justAm0dd3r */ -public class GlasscuttingRecipe extends SingleItemRecipe -{ - public GlasscuttingRecipe(ResourceLocation id, String group, Ingredient ingredient, ItemStack stack) - { - super(RecipeType.GLASSCUTTING, ModRecipeSerializers.GLASSCUTTING, id, group, ingredient, stack); - } +public class GlasscuttingRecipe extends CuttingRecipe { + public GlasscuttingRecipe(Identifier id, String group, Ingredient input, ItemStack output) { + super(ModRecipeTypes.GLASSCUTTING, ModRecipeSerializers.GLASSCUTTING, id, group, input, output); + } - @Override - public boolean matches(IInventory inventory, World world) - { - return this.ingredient.test(inventory.getStackInSlot(0)); - } + @Override + public boolean matches(Inventory inv, World world) { + return this.input.test(inv.getStack(0)); + } - @Override - public ItemStack getIcon() - { - return new ItemStack(ModBlocks.GLASSCUTTER); - } + @Override + @Environment(EnvType.CLIENT) + public ItemStack getRecipeKindIcon() { + return new ItemStack(ModBlocks.GLASSCUTTER); + } - public static class Serializer extends net.minecraftforge.registries.ForgeRegistryEntry> implements IRecipeSerializer - { - private final GlasscuttingRecipe.Serializer.IRecipeFactory factory; + public static class Serializer implements RecipeSerializer { + private final RecipeFactory recipeFactory; - public Serializer(GlasscuttingRecipe.Serializer.IRecipeFactory factory) - { - this.factory = factory; - } + public Serializer(RecipeFactory recipeFactory) { + this.recipeFactory = recipeFactory; + } - @Override - public T read(ResourceLocation recipeId, JsonObject json) - { - String group = JSONUtils.getString(json, "group", ""); - Ingredient ingredient; - if(JSONUtils.isJsonArray(json, "ingredient")) - { - ingredient = Ingredient.deserialize(JSONUtils.getJsonArray(json, "ingredient")); - } - else - { - ingredient = Ingredient.deserialize(JSONUtils.getJsonObject(json, "ingredient")); - } - String result = JSONUtils.getString(json, "result"); - int count = JSONUtils.getInt(json, "count"); - ItemStack stack = new ItemStack(Registry.ITEM.getOrDefault(new ResourceLocation(result)), count); - return this.factory.create(recipeId, group, ingredient, stack); - } + public GlasscuttingRecipe read(Identifier identifier, JsonObject jsonObject) { + String string = JsonHelper.getString(jsonObject, "group", ""); + Ingredient ingredient2; + if (JsonHelper.hasArray(jsonObject, "ingredient")) { + ingredient2 = Ingredient.fromJson(JsonHelper.getArray(jsonObject, "ingredient")); + } else { + ingredient2 = Ingredient.fromJson(JsonHelper.getObject(jsonObject, "ingredient")); + } - @Override - public T read(ResourceLocation recipeId, PacketBuffer buffer) - { - String group = buffer.readString(32767); - Ingredient ingredient = Ingredient.read(buffer); - ItemStack stack = buffer.readItemStack(); - return this.factory.create(recipeId, group, ingredient, stack); - } + String string2 = JsonHelper.getString(jsonObject, "result"); + int i = JsonHelper.getInt(jsonObject, "count"); + ItemStack itemStack = new ItemStack(Registry.ITEM.get(new Identifier(string2)), i); + return this.recipeFactory.create(identifier, string, ingredient2, itemStack); + } - @Override - public void write(PacketBuffer buffer, T recipe) - { - buffer.writeString(recipe.group); - recipe.ingredient.write(buffer); - buffer.writeItemStack(recipe.result); - } + public GlasscuttingRecipe read(Identifier identifier, PacketByteBuf packetByteBuf) { + String string = packetByteBuf.readString(32767); + Ingredient ingredient = Ingredient.fromPacket(packetByteBuf); + ItemStack itemStack = packetByteBuf.readItemStack(); + return this.recipeFactory.create(identifier, string, ingredient, itemStack); + } - public interface IRecipeFactory - { - T create(ResourceLocation id, String group, Ingredient ingredient, ItemStack stack); - } - } -} + public void write(PacketByteBuf packetByteBuf, GlasscuttingRecipe recipe) { + packetByteBuf.writeString(recipe.group); + recipe.input.write(packetByteBuf); + packetByteBuf.writeItemStack(recipe.output); + } + + public interface RecipeFactory { + GlasscuttingRecipe create(Identifier identifier, String string, Ingredient ingredient, ItemStack itemStack); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/mrcrayfish/glasscutter/item/crafting/RecipeType.java b/src/main/java/com/mrcrayfish/glasscutter/item/crafting/RecipeType.java deleted file mode 100644 index 507aa9c..0000000 --- a/src/main/java/com/mrcrayfish/glasscutter/item/crafting/RecipeType.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.mrcrayfish.glasscutter.item.crafting; - -import com.mrcrayfish.glasscutter.Reference; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.registry.Registry; - -/** - * Author: MrCrayfish - */ -public class RecipeType -{ - public static final IRecipeType GLASSCUTTING = register(new ResourceLocation(Reference.MOD_ID, "glasscutting")); - - private static > net.minecraft.item.crafting.IRecipeType register(final ResourceLocation resource) - { - return Registry.register(Registry.RECIPE_TYPE, resource, new IRecipeType() - { - @Override - public String toString() - { - return resource.toString(); - } - }); - } -} diff --git a/src/main/java/com/mrcrayfish/glasscutter/jei/GlassCutterJeiPlugin.java b/src/main/java/com/mrcrayfish/glasscutter/jei/GlassCutterJeiPlugin.java deleted file mode 100644 index 6220c0c..0000000 --- a/src/main/java/com/mrcrayfish/glasscutter/jei/GlassCutterJeiPlugin.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.mrcrayfish.glasscutter.jei; - -import com.google.common.io.CharStreams; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.mrcrayfish.glasscutter.Reference; -import com.mrcrayfish.glasscutter.item.crafting.GlasscuttingRecipe; -import mezz.jei.api.IModPlugin; -import mezz.jei.api.JeiPlugin; -import mezz.jei.api.registration.IRecipeCategoryRegistration; -import mezz.jei.api.registration.IRecipeRegistration; -import mezz.jei.util.ErrorUtil; -import net.minecraft.item.DyeColor; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.RecipeManager; -import net.minecraft.util.ResourceLocation; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.List; - -@JeiPlugin -public class GlassCutterJeiPlugin implements IModPlugin { - private GlasscuttingRecipeCategory glasscuttingCategory; - private static final Logger LOGGER = LogManager.getLogger(); - - @Override - public ResourceLocation getPluginUid() { - return new ResourceLocation(Reference.MOD_ID, Reference.MOD_ID); - } - - @Override - public void registerCategories(IRecipeCategoryRegistration registration) { - registration.addRecipeCategories(this.glasscuttingCategory = new GlasscuttingRecipeCategory(registration.getJeiHelpers().getGuiHelper())); - } - - @Override - public void registerRecipes(IRecipeRegistration registration) { - ErrorUtil.checkNotNull(this.glasscuttingCategory, "glasscuttingCategory"); - registration.addRecipes(getGlasscuttingRecipes(), new ResourceLocation(Reference.MOD_ID, "glasscutting")); - LOGGER.debug("Added JEI Recipes."); - } - - private List getGlasscuttingRecipes() { - List recipes = new ArrayList<>(); - for (String type : new String[]{"stairs", "slab", "pane"}) { - for (DyeColor dye : DyeColor.values()) { - String path = "data/" + Reference.MOD_ID + "/recipes/cut_" + dye.toString() - + "_stained_glass_to_" + dye.toString() + "_stained_glass_" + type + ".json"; - ResourceLocation resourceLocation = new ResourceLocation(Reference.MOD_ID, "cut_" + dye.toString() - + "_stained_glass_to_" + dye.toString() + "_stained_glass_" + type + ".json"); - addRecipe(recipes, resourceLocation, path); - } - String path = "data/" + Reference.MOD_ID + "/recipes/cut_glass_to_glass_" + type + ".json"; - ResourceLocation resourceLocation = new ResourceLocation(Reference.MOD_ID, "cut_glass_to_glass_" + type + ".json"); - addRecipe(recipes, resourceLocation, path); - } - String path = "data/" + Reference.MOD_ID + "/recipes/cut_glass_to_glass_bottle.json"; - ResourceLocation resourceLocation = new ResourceLocation(Reference.MOD_ID, "cut_glass_to_glass_bottle.json"); - addRecipe(recipes, resourceLocation, path); - return recipes; - } - - private JsonObject getObjectFromPath(String path) { - String jsonString; - try { - InputStream stream = getClass().getClassLoader().getResourceAsStream(path); - jsonString = CharStreams.toString(new InputStreamReader(stream)); - } - catch (IOException e) { - LOGGER.error("Error while trying to get json object from ResourceLocation.", e); - return null; - } - return new JsonParser().parse(jsonString).getAsJsonObject(); - } - - private void addRecipe(List recipes, ResourceLocation resourceLocation, String path) { - JsonObject object = getObjectFromPath(path); - if (object == null) return; - - IRecipe recipe = RecipeManager.deserializeRecipe(resourceLocation, object); - if (!(recipe instanceof GlasscuttingRecipe)) { - LOGGER.error("Wrong recipe type."); - return; - } - recipes.add((GlasscuttingRecipe)recipe); - } -} diff --git a/src/main/java/com/mrcrayfish/glasscutter/jei/GlasscuttingRecipeCategory.java b/src/main/java/com/mrcrayfish/glasscutter/jei/GlasscuttingRecipeCategory.java deleted file mode 100644 index c8b3ea9..0000000 --- a/src/main/java/com/mrcrayfish/glasscutter/jei/GlasscuttingRecipeCategory.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.mrcrayfish.glasscutter.jei; - -import com.mrcrayfish.glasscutter.Reference; -import com.mrcrayfish.glasscutter.item.crafting.GlasscuttingRecipe; -import mezz.jei.api.constants.VanillaRecipeCategoryUid; -import mezz.jei.api.constants.VanillaTypes; -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.gui.drawable.IDrawable; -import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; -import mezz.jei.api.helpers.IGuiHelper; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.category.extensions.IExtendableRecipeCategory; -import mezz.jei.api.recipe.category.extensions.vanilla.crafting.ICraftingCategoryExtension; -import mezz.jei.config.Constants; -import mezz.jei.plugins.vanilla.stonecutting.StoneCuttingRecipeCategory; -import mezz.jei.recipes.ExtendableRecipeCategoryHelper; -import mezz.jei.util.Translator; -import net.minecraft.block.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.ResourceLocation; - -import java.util.function.Function; - -public class GlasscuttingRecipeCategory implements IExtendableRecipeCategory { - private static final int inputSlot = 0; - private static final int outputSlot = 1; - - private static final ResourceLocation CATEGORY_GLASSCUTTING = new ResourceLocation(Reference.MOD_ID, "glasscutting"); - - public static final int width = 82; - public static final int height = 34; - - private final IDrawable background; - private final IDrawable icon; - private final String localizedName; - - private final ExtendableRecipeCategoryHelper, ICraftingCategoryExtension> extendableHelper = new ExtendableRecipeCategoryHelper<>(GlasscuttingRecipe.class); - public GlasscuttingRecipeCategory(IGuiHelper guiHelper) { - ResourceLocation location = Constants.RECIPE_GUI_VANILLA; - background = guiHelper.createDrawable(location, 0, 220, width, height); - icon = guiHelper.createDrawableIngredient(new ItemStack(Blocks.STONECUTTER)); - localizedName = Translator.translateToLocal("gui.jei.category.glassCutter"); - } - - @Override - public void addCategoryExtension(Class recipeClass, Function extensionFactory) { - extendableHelper.addRecipeExtensionFactory(recipeClass, extensionFactory); - } - - @Override - public ResourceLocation getUid() { - return CATEGORY_GLASSCUTTING; - } - - @Override - public Class getRecipeClass() { - return GlasscuttingRecipe.class; - } - - @Override - public String getTitle() { - return localizedName; - } - - @Override - public IDrawable getBackground() { - return background; - } - - @Override - public IDrawable getIcon() { - return icon; - } - - @Override - public void setIngredients(GlasscuttingRecipe recipe, IIngredients ingredients) { - ingredients.setInputIngredients(recipe.getIngredients()); - ingredients.setOutput(VanillaTypes.ITEM, recipe.getRecipeOutput()); - } - - @Override - public void setRecipe(IRecipeLayout recipeLayout, GlasscuttingRecipe recipe, IIngredients ingredients) { - IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); - guiItemStacks.init(inputSlot, true, 0, 8); - guiItemStacks.init(outputSlot, false, 60, 8); - - guiItemStacks.set(ingredients); - } -} \ No newline at end of file diff --git a/src/main/java/com/mrcrayfish/glasscutter/screen_handler/GlasscutterScreenHandler.java b/src/main/java/com/mrcrayfish/glasscutter/screen_handler/GlasscutterScreenHandler.java new file mode 100644 index 0000000..b3737c5 --- /dev/null +++ b/src/main/java/com/mrcrayfish/glasscutter/screen_handler/GlasscutterScreenHandler.java @@ -0,0 +1,238 @@ +package com.mrcrayfish.glasscutter.screen_handler; + +import com.google.common.collect.Lists; +import com.mrcrayfish.glasscutter.init.ModBlocks; +import com.mrcrayfish.glasscutter.init.ModRecipeTypes; +import com.mrcrayfish.glasscutter.init.ModScreenHandlers; +import com.mrcrayfish.glasscutter.item.crafting.GlasscuttingRecipe; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.CraftingResultInventory; +import net.minecraft.inventory.Inventory; +import net.minecraft.inventory.SimpleInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.screen.Property; +import net.minecraft.screen.ScreenHandler; +import net.minecraft.screen.ScreenHandlerContext; +import net.minecraft.screen.ScreenHandlerType; +import net.minecraft.screen.slot.Slot; +import net.minecraft.sound.SoundCategory; +import net.minecraft.sound.SoundEvents; +import net.minecraft.world.World; + +import java.util.List; + +/** + * @author justAm0dd3r + */ +public class GlasscutterScreenHandler extends ScreenHandler { + private final ScreenHandlerContext context; + private final Property selectedRecipe; + private final World world; + private List availableRecipes; + private ItemStack inputStack; + private long lastTakeTime; + final Slot inputSlot; + final Slot outputSlot; + private Runnable contentsChangedListener; + public final Inventory input; + private final CraftingResultInventory output; + + public GlasscutterScreenHandler(int syncId, PlayerInventory playerInventory) { + this(syncId, playerInventory, ScreenHandlerContext.EMPTY); + } + + public GlasscutterScreenHandler(int syncId, PlayerInventory playerInventory, final ScreenHandlerContext context) { + super(ModScreenHandlers.GLASSCUTTER, syncId); + this.selectedRecipe = Property.create(); + this.availableRecipes = Lists.newArrayList(); + this.inputStack = ItemStack.EMPTY; + this.contentsChangedListener = () -> {}; + this.input = new SimpleInventory(1) { + public void markDirty() { + super.markDirty(); + GlasscutterScreenHandler.this.onContentChanged(this); + GlasscutterScreenHandler.this.contentsChangedListener.run(); + } + }; + this.output = new CraftingResultInventory(); + this.context = context; + this.world = playerInventory.player.world; + this.inputSlot = this.addSlot(new Slot(this.input, 0, 20, 33)); + this.outputSlot = this.addSlot(new Slot(this.output, 1, 143, 33) { + + public boolean canInsert(ItemStack stack) { + return false; + } + + public ItemStack onTakeItem(PlayerEntity player, ItemStack stack) { + stack.onCraft(player.world, player, stack.getCount()); + GlasscutterScreenHandler.this.output.unlockLastRecipe(player); + ItemStack itemStack = GlasscutterScreenHandler.this.inputSlot.takeStack(1); + if (!itemStack.isEmpty()) { + GlasscutterScreenHandler.this.populateResult(); + } + + context.run((world, blockPos) -> { + long l = world.getTime(); + if (GlasscutterScreenHandler.this.lastTakeTime != l) { + world.playSound(null, blockPos, SoundEvents.UI_STONECUTTER_TAKE_RESULT, SoundCategory.BLOCKS, 1.0F, 1.0F); + GlasscutterScreenHandler.this.lastTakeTime = l; + } + }); + return super.onTakeItem(player, stack); + } + }); + + int k; + for(k = 0; k < 3; ++k) { + for(int j = 0; j < 9; ++j) { + this.addSlot(new Slot(playerInventory, j + k * 9 + 9, 8 + j * 18, 84 + k * 18)); + } + } + + + for(k = 0; k < 9; ++k) { + this.addSlot(new Slot(playerInventory, k, 8 + k * 18, 142)); + } + + this.addProperty(this.selectedRecipe); + } + + @Environment(EnvType.CLIENT) + public int getSelectedRecipe() { + return this.selectedRecipe.get(); + } + + @Environment(EnvType.CLIENT) + public List getAvailableRecipes() { + return this.availableRecipes; + } + + @Environment(EnvType.CLIENT) + public int getAvailableRecipeCount() { + return this.availableRecipes.size(); + } + + @Environment(EnvType.CLIENT) + public boolean canCraft() { + return this.inputSlot.hasStack() && !this.availableRecipes.isEmpty(); + } + + public boolean canUse(PlayerEntity player) { + return canUse(this.context, player, ModBlocks.GLASSCUTTER); + } + + public boolean onButtonClick(PlayerEntity player, int id) { + if (this.method_30160(id)) { + this.selectedRecipe.set(id); + this.populateResult(); + } + + return true; + } + + private boolean method_30160(int i) { + return i >= 0 && i < this.availableRecipes.size(); + } + + public void onContentChanged(Inventory inventory) { + ItemStack itemStack = this.inputSlot.getStack(); + if (itemStack.getItem() != this.inputStack.getItem()) { + this.inputStack = itemStack.copy(); + this.updateInput(inventory, itemStack); + } + + } + + private void updateInput(Inventory input, ItemStack stack) { + this.availableRecipes.clear(); + this.selectedRecipe.set(-1); + this.outputSlot.setStack(ItemStack.EMPTY); + if (!stack.isEmpty()) { + this.availableRecipes = this.world.getRecipeManager().getAllMatches(ModRecipeTypes.GLASSCUTTING, input, this.world); + } + } + + private void populateResult() { + if (!this.availableRecipes.isEmpty() && this.method_30160(this.selectedRecipe.get())) { + GlasscuttingRecipe glasscuttingRecipe = this.availableRecipes.get(this.selectedRecipe.get()); + this.output.setLastRecipe(glasscuttingRecipe); + this.outputSlot.setStack(glasscuttingRecipe.craft(this.input)); + } else { + this.outputSlot.setStack(ItemStack.EMPTY); + } + + this.sendContentUpdates(); + } + + public ScreenHandlerType getType() { + return ModScreenHandlers.GLASSCUTTER; + } + + @Environment(EnvType.CLIENT) + public void setContentsChangedListener(Runnable runnable) { + this.contentsChangedListener = runnable; + } + + public boolean canInsertIntoSlot(ItemStack stack, Slot slot) { + return slot.inventory != this.output && super.canInsertIntoSlot(stack, slot); + } + + public ItemStack transferSlot(PlayerEntity player, int index) { + ItemStack itemStack = ItemStack.EMPTY; + Slot slot = this.slots.get(index); + if (slot != null && slot.hasStack()) { + ItemStack itemStack2 = slot.getStack(); + Item item = itemStack2.getItem(); + itemStack = itemStack2.copy(); + if (index == 1) { + item.onCraft(itemStack2, player.world, player); + if (!this.insertItem(itemStack2, 2, 38, true)) { + return ItemStack.EMPTY; + } + + slot.onStackChanged(itemStack2, itemStack); + } else if (index == 0) { + if (!this.insertItem(itemStack2, 2, 38, false)) { + return ItemStack.EMPTY; + } + } else if (this.world.getRecipeManager().getFirstMatch(ModRecipeTypes.GLASSCUTTING, new SimpleInventory(itemStack2), this.world).isPresent()) { + if (!this.insertItem(itemStack2, 0, 1, false)) { + return ItemStack.EMPTY; + } + } else if (index >= 2 && index < 29) { + if (!this.insertItem(itemStack2, 29, 38, false)) { + return ItemStack.EMPTY; + } + } else if (index >= 29 && index < 38 && !this.insertItem(itemStack2, 2, 29, false)) { + return ItemStack.EMPTY; + } + + if (itemStack2.isEmpty()) { + slot.setStack(ItemStack.EMPTY); + } + + slot.markDirty(); + if (itemStack2.getCount() == itemStack.getCount()) { + return ItemStack.EMPTY; + } + + slot.onTakeItem(player, itemStack2); + this.sendContentUpdates(); + } + + return itemStack; + } + + public void close(PlayerEntity player) { + super.close(player); + this.output.removeStack(1); + this.context.run((world, blockPos) -> { + this.dropInventory(player, player.world, this.input); + }); + } +} diff --git a/src/main/resources/assets/glasscutter/lang/en_us.json b/src/main/resources/assets/glasscutter/lang/en_us.json index 26a3080..cd0d292 100644 --- a/src/main/resources/assets/glasscutter/lang/en_us.json +++ b/src/main/resources/assets/glasscutter/lang/en_us.json @@ -34,6 +34,5 @@ "block.glasscutter.light_blue_stained_glass_slab": "Light Blue Stained Glass Slab", "block.glasscutter.magenta_stained_glass_slab": "Magenta Stained Glass Slab", "block.glasscutter.orange_stained_glass_slab": "Orange Stained Glass Slab", - "block.glasscutter.white_stained_glass_slab": "White Stained Glass Slab", - "gui.jei.category.glassCutter": "Glasscutting" + "block.glasscutter.white_stained_glass_slab": "White Stained Glass Slab" } \ 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..3ede93f --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,34 @@ +{ + "schemaVersion": 1, + "id": "glasscutter", + "version": "${version}", + + "name": "GlassCutter", + "description": "Adds a glasscutter to cut different shapes with glass", + "credits": "@DarkestArgentum on Twitter for ideas", + "authors": [ + "MrCrayfish", + "justAm0dd3r" + ], + "contact": { + "homepage": "http://mrcrayfish.com/mods?id=glasscutter", + "sources": "https://github.com/MrCrayfish/GlassCutter" + }, + + "license": "GPLv3", + + "environment": "*", + "entrypoints": { + "main": [ + "com.mrcrayfish.glasscutter.GlassCutterMain" + ] + }, + + "depends": { + "fabricloader": ">=0.7.4", + "fabric": "*" + }, + "suggests": { + "flamingo": "*" + } +}