diff --git a/build.gradle b/build.gradle index dfd6b8a..34c90f2 100644 --- a/build.gradle +++ b/build.gradle @@ -1,78 +1,130 @@ -plugins { - id "com.modrinth.minotaur" version "2.+" - id "com.matthewprenger.cursegradle" version "1.4.0+" - id "net.neoforged.gradle" version "[6.0.18,6.2)" +buildscript { + repositories { + maven { url = 'https://files.minecraftforge.net/maven' } + maven { url "https://plugins.gradle.org/m2/" } + mavenCentral() + } + dependencies { + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true + } + dependencies { + classpath "gradle.plugin.com.matthewprenger:CurseGradle:1.4.0" + } } +apply plugin: 'net.minecraftforge.gradle' +// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. +apply plugin: 'eclipse' +apply plugin: 'maven-publish' +apply plugin: 'com.matthewprenger.cursegradle' -group = 'com.oitsjustjose.charged_explosives' -version = "${mod_version}" -base { archivesName = "ChargedExplosives-${game_version}-${mod_version}" } + +group = 'com.oitsjustjose.charged_explosives' // http://maven.apache.org/guides/mini/guide-naming-conventions.html +archivesBaseName = "ChargedExplosives-${game_version}-${mod_version}" java.toolchain.languageVersion = JavaLanguageVersion.of(17) +println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch')) minecraft { mappings channel: 'official', version: "${game_version}" - copyIdeResources = true runs { client { workingDirectory project.file('run') + property 'forge.logging.console.level', 'debug' - mods { charged_explosives { source sourceSets.main } } + + mods { + charged_explosives { + source sourceSets.main + } + } } server { workingDirectory project.file('run') + property 'forge.logging.console.level', 'debug' - mods { charged_explosives { source sourceSets.main } } + + mods { + charged_explosives { + source sourceSets.main + } + } } } } - -dependencies { - minecraft "net.neoforged:forge:${game_version}-${neo_version}" +repositories { + maven { url = "https://dvs1.progwml6.com/files/maven" } } +dependencies { + minecraft "net.minecraftforge:forge:${game_version}-${forge_version}" +} + +// Example for how to get properties into the manifest for reading by the runtime.. jar { manifest { attributes([ - "Specification-Title" : "charged_explosives", - "Specification-Vendor" : "oitsjustjose.com", - "Specification-Version" : "1", // We are version 1 of ourselves - "Implementation-Title" : project.name, - "Implementation-Version" : "${mod_version}", - "Implementation-Vendor" : "oitsjustjose.com", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + "Specification-Title": "charged_explosives", + "Specification-Vendor": "oitsjustjose.com", + "Specification-Version": "1", // We are version 1 of ourselves + "Implementation-Title": project.name, + "Implementation-Version": "${mod_version}", + "Implementation-Vendor" :"oitsjustjose.com", + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } } -tasks.register('publish') { - dependsOn 'curseforge' - dependsOn 'modrinth' + +// Example configuration to allow publishing using the maven-publish task +// we define a custom artifact that is sourced from the reobfJar output task +// and then declare that to be published +// Note you'll need to add a repository here +def reobfFile = file("$buildDir/reobfJar/output.jar") +def reobfArtifact = artifacts.add('default', reobfFile) { + type 'jar' + builtBy 'reobfJar' +} + +task deobfJar(type: Jar) { + from sourceSets.main.output + classifier = 'Deobf' +} + +task sourcesJar(type: Jar, dependsOn: classes) { + classifier = 'Sources' + from sourceSets.main.allSource +} + +artifacts { + archives deobfJar + archives sourcesJar } curseforge { - apiKey = project.hasProperty("CURSEFORGE_API_KEY") ? project.CURSEFORGE_API_KEY : "" - project { - id = '693885' - changelogType = 'markdown' - changelog = file("./changelog.md") - releaseType = 'release' - addGameVersion "${game_version}" - mainArtifact(jar) { - displayName = "Charged Explosives ${game_version} ${mod_version}" + apiKey = project.hasProperty("CURSEFORGE_API_KEY") ? project.CURSEFORGE_API_KEY : "" + project { + id = '693885' + changelogType = 'markdown' + changelog = file("./changelog.md") + releaseType = 'release' + addGameVersion "1.19" + addGameVersion "1.19.1" + mainArtifact(jar) { + displayName = "Charged Explosives ${game_version} ${mod_version}" + } + } +} + +publishing { + publications { + mavenJava(MavenPublication) { + artifact reobfArtifact + } + } + repositories { + maven { + url "file:///${project.projectDir}/mcmodsrepo" } } } - -modrinth { - token = project.hasProperty("MODRINTH_API_KEY") ? project.MODRINTH_API_KEY : "" - projectId = "sv2l2OG2" - versionName = "Charged Explosives ${game_version} ${mod_version}" - versionNumber = "${game_version}-${mod_version}" - versionType = "release" - uploadFile = jar - gameVersions = ["${game_version}"] - loaders = ["forge"] - changelog = file("./changelog.md").text -} diff --git a/changelog.md b/changelog.md index 2872206..f695674 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,5 @@ -# Charged Explosives Changelog (1.20.1) +# Charged Explosives Changelog (1.19) ## 1.0.0 -Initial port to 1.20.1 and Neoforged! +Initial Release diff --git a/gradle.properties b/gradle.properties index 450f006..2902aa2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ mod_version=1.0.0 -game_version=1.20.1 -neo_version=47.1.25 +game_version=1.19.2 +forge_version=43.1.1 org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 943f0cb..7454180 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 37aef8d..e750102 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip -networkTimeout=10000 +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew old mode 100755 new mode 100644 index 65dcd68..c53aefa --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,10 +32,10 @@ # Busybox and similar reduced shells will NOT work, because this script # requires all of these POSIX shell features: # * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». # # Important for patching: # @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,11 +80,11 @@ do esac done -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -143,16 +143,12 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -209,12 +205,6 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 24584e9..0000000 --- a/settings.gradle +++ /dev/null @@ -1,13 +0,0 @@ -pluginManagement { - repositories { - gradlePluginPortal() - maven { - name = 'NeoForged' - url = 'https://maven.neoforged.net/releases' - } - } -} - -plugins { - id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0' -} \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/charged_explosives/ChargedExplosives.java b/src/main/java/com/oitsjustjose/charged_explosives/ChargedExplosives.java index 3e31d57..fb16376 100644 --- a/src/main/java/com/oitsjustjose/charged_explosives/ChargedExplosives.java +++ b/src/main/java/com/oitsjustjose/charged_explosives/ChargedExplosives.java @@ -6,9 +6,9 @@ import com.oitsjustjose.charged_explosives.common.CommonProxy; import com.oitsjustjose.charged_explosives.common.TickScheduler; import com.oitsjustjose.charged_explosives.common.config.CommonConfig; import com.oitsjustjose.charged_explosives.common.registry.Registry; -import net.minecraft.world.item.CreativeModeTabs; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.BuildCreativeModeTabContentsEvent; +import net.minecraftforge.event.AddReloadListenerEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; @@ -37,7 +37,6 @@ public class ChargedExplosives { MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(SCHEDULER); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::buildContents); this.configSetup(); } @@ -56,9 +55,8 @@ public class ChargedExplosives { ClientConfig.loadConfig(ClientConfig.CLIENT_CONFIG, FMLPaths.CONFIGDIR.get().resolve(MODID + "-client.toml")); } - private void buildContents(BuildCreativeModeTabContentsEvent event) { - if (event.getTabKey() == CreativeModeTabs.REDSTONE_BLOCKS) { - event.accept(ChargedExplosives.getInstance().REGISTRY.CeItem.get()); - } + @SubscribeEvent + public void onSlashReload(AddReloadListenerEvent evt) { } + } \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/charged_explosives/client/gui/ExplosionConfigScreen.java b/src/main/java/com/oitsjustjose/charged_explosives/client/gui/ExplosionConfigScreen.java index 9af8523..11122ee 100644 --- a/src/main/java/com/oitsjustjose/charged_explosives/client/gui/ExplosionConfigScreen.java +++ b/src/main/java/com/oitsjustjose/charged_explosives/client/gui/ExplosionConfigScreen.java @@ -5,7 +5,6 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.oitsjustjose.charged_explosives.ChargedExplosives; import com.oitsjustjose.charged_explosives.common.Util; import com.oitsjustjose.charged_explosives.common.config.CommonConfig; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.screens.Screen; @@ -14,9 +13,11 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; +import net.minecraftforge.client.event.ScreenEvent; import org.jetbrains.annotations.NotNull; import java.util.Objects; +import java.util.function.Function; public class ExplosionConfigScreen extends Screen { @@ -72,70 +73,58 @@ public class ExplosionConfigScreen extends Screen { int rowWidth =/* Width of actual els */ INCR_W + DECR_W + EDIT_BOX_WIDTH + (LW_MOD - EDIT_BOX_WIDTH) /* Offset for the left btn */ + (LW_MOD - EDIT_BOX_WIDTH - EB_MOD) /* Offset for the right btn */; /* Width Adj */ - var widthDecrButton = new Button.Builder(DECR, onPress -> { + this.addRenderableWidget(new Button(BG_X + ((rowWidth / 2) - 1) + FW_MOD, BG_Y + 40, DECR_W, 20, DECR, onPress -> { if (this.explosionWidth > 1) { this.explosionWidth--; this.dirty = true; - this.widthBox.setValue(String.valueOf(this.explosionWidth)); + this.widthBox.setValue("" + this.explosionWidth); } - }).pos(BG_X + ((rowWidth / 2) - 1) + FW_MOD, BG_Y + 40).size(DECR_W, 20).build(); - - var widthIncrButton = new Button.Builder(INCR, onPress -> { + })); + this.widthBox = this.addRenderableWidget(new EditBox(this.font, BG_X + ((rowWidth / 2) - 1) + EB_MOD, BG_Y + 40, EDIT_BOX_WIDTH, 20, Component.literal(""))); + this.widthBox.setValue("" + this.explosionWidth); + this.addRenderableWidget(new Button(BG_X + ((rowWidth / 2) - 1) + LW_MOD, BG_Y + 40, INCR_W, 20, INCR, onPress -> { if (this.explosionWidth < CommonConfig.MAX_EXPLOSION_WIDTH.get()) { this.explosionWidth++; this.dirty = true; - this.widthBox.setValue(String.valueOf(this.explosionWidth)); + this.widthBox.setValue("" + this.explosionWidth); } - }).pos(BG_X + ((rowWidth / 2) - 1) + LW_MOD, BG_Y + 40).size(INCR_W, 20).build(); - - this.addRenderableWidget(widthDecrButton); - this.widthBox = this.addRenderableWidget(new EditBox(this.font, BG_X + ((rowWidth / 2) - 1) + EB_MOD, BG_Y + 40, EDIT_BOX_WIDTH, 20, Component.literal(""))); - this.widthBox.setValue(String.valueOf(this.explosionWidth)); - this.addRenderableWidget(widthIncrButton); + })); /* Depth Adj */ - var depthDecrButton = new Button.Builder(DECR, onPress -> { + this.addRenderableWidget(new Button(BG_X + ((rowWidth / 2) - 1) + FW_MOD, BG_Y + 85, DECR_W, 20, DECR, onPress -> { if (this.explosionDepth > 1) { this.explosionDepth--; this.dirty = true; - this.depthBox.setValue(String.valueOf(this.explosionDepth)); + this.depthBox.setValue("" + this.explosionDepth); } - }).pos(BG_X + ((rowWidth / 2) - 1) + FW_MOD, BG_Y + 85).size(DECR_W, 20).build(); - - var depthIncrButton = new Button.Builder(INCR, onPress -> { + })); + this.depthBox = this.addRenderableWidget(new EditBox(this.font, BG_X + ((rowWidth / 2) - 1) + EB_MOD, BG_Y + 85, EDIT_BOX_WIDTH, 20, Component.literal(""))); + this.depthBox.setValue("" + this.explosionDepth); + this.addRenderableWidget(new Button(BG_X + ((rowWidth / 2) - 1) + LW_MOD, BG_Y + 85, INCR_W, 20, INCR, onPress -> { if (this.explosionDepth < CommonConfig.MAX_EXPLOSION_DEPTH.get()) { this.explosionDepth++; this.dirty = true; - this.depthBox.setValue(String.valueOf(this.explosionDepth)); + this.depthBox.setValue("" + this.explosionDepth); } - }).pos(BG_X + ((rowWidth / 2) - 1) + LW_MOD, BG_Y + 85).size(INCR_W, 20).build(); - - this.addRenderableWidget(depthDecrButton); - this.depthBox = this.addRenderableWidget(new EditBox(this.font, BG_X + ((rowWidth / 2) - 1) + EB_MOD, BG_Y + 85, EDIT_BOX_WIDTH, 20, Component.literal(""))); - this.depthBox.setValue(String.valueOf(this.explosionDepth)); - this.addRenderableWidget(depthIncrButton); + })); /* Height Adj */ - var heightDecrButton = new Button.Builder(DECR, onPress -> { + this.addRenderableWidget(new Button(BG_X + ((rowWidth / 2) - 1) + FW_MOD, BG_Y + 130, DECR_W, 20, DECR, onPress -> { if (this.explosionHeight > 1) { this.explosionHeight--; this.dirty = true; - this.heightBox.setValue(String.valueOf(this.explosionHeight)); + this.heightBox.setValue("" + this.explosionHeight); } - }).pos(BG_X + ((rowWidth / 2) - 1) + FW_MOD, BG_Y + 130).size(DECR_W, 20).build(); - - var heightIncrButton = new Button.Builder(INCR, onPress -> { + })); + this.heightBox = this.addRenderableWidget(new EditBox(this.font, BG_X + ((rowWidth / 2) - 1) + EB_MOD, BG_Y + 130, EDIT_BOX_WIDTH, 20, Component.literal(""))); + this.heightBox.setValue("" + this.explosionHeight); + this.addRenderableWidget(new Button(BG_X + ((rowWidth / 2) - 1) + LW_MOD, BG_Y + 130, INCR_W, 20, INCR, onPress -> { if (this.explosionHeight < CommonConfig.MAX_EXPLOSION_HEIGHT.get()) { this.explosionHeight++; this.dirty = true; - this.heightBox.setValue(String.valueOf(this.explosionHeight)); + this.heightBox.setValue("" + this.explosionHeight); } - }).pos(BG_X + ((rowWidth / 2) - 1) + LW_MOD, BG_Y + 130).size(INCR_W, 20).build(); - - this.addRenderableWidget(heightDecrButton); - this.heightBox = this.addRenderableWidget(new EditBox(this.font, BG_X + ((rowWidth / 2) - 1) + EB_MOD, BG_Y + 130, EDIT_BOX_WIDTH, 20, Component.literal(""))); - this.heightBox.setValue(String.valueOf(this.explosionHeight)); - this.addRenderableWidget(heightIncrButton); + })); } @Override @@ -205,7 +194,12 @@ public class ExplosionConfigScreen extends Screen { } @Override - public void render(@NotNull GuiGraphics stack, int mouseX, int mouseY, float partialTicks) { + public boolean shouldCloseOnEsc() { + return true; + } + + @Override + public void render(@NotNull PoseStack stack, int mouseX, int mouseY, float partialTicks) { final int BG_X = (this.width - TEXTURE_WIDTH) / 2; final int BG_Y = (this.height - TEXTURE_HEIGHT) / 2; @@ -213,16 +207,17 @@ public class ExplosionConfigScreen extends Screen { RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.setShaderTexture(0, BACKGROUND_TEXTURE); + this.blit(stack, (this.width - TEXTURE_WIDTH) / 2, (this.height - TEXTURE_HEIGHT) / 2, 0, 0, TEXTURE_WIDTH, TEXTURE_WIDTH); + + + this.font.draw(stack, this.title, BG_X + (float) (TEXTURE_WIDTH / 2) - (float) (this.font.width(this.title) / 2), BG_Y + PADDING, 4210752); - stack.blit(BACKGROUND_TEXTURE, (this.width - TEXTURE_WIDTH) / 2, (this.height - TEXTURE_HEIGHT) / 2, 0, 0, TEXTURE_WIDTH, TEXTURE_WIDTH); - /* GUI Title */ - stack.drawString(this.font, this.title, (int)(BG_X + (float) (TEXTURE_WIDTH / 2) - (float) (this.font.width(this.title) / 2)), BG_Y + PADDING, 4210752, false ); /* Width Title */ - stack.drawString(this.font, this.widthTitle, (int)(BG_X + (float) (TEXTURE_WIDTH / 2) - (float) (this.font.width(this.widthTitle) / 2)), BG_Y + 20 + this.font.lineHeight, 7089453, false); + this.font.draw(stack, this.widthTitle, BG_X + (float) (TEXTURE_WIDTH / 2) - (float) (this.font.width(this.widthTitle) / 2), BG_Y + 20 + this.font.lineHeight, 7089453); /* Depth Title */ - stack.drawString(this.font, this.depthTitle, (int)(BG_X + (float) (TEXTURE_WIDTH / 2) - (float) (this.font.width(this.widthTitle) / 2)), BG_Y + 65 + this.font.lineHeight, 7089453, false); + this.font.draw(stack, this.depthTitle, BG_X + (float) (TEXTURE_WIDTH / 2) - (float) (this.font.width(this.widthTitle) / 2), BG_Y + 65 + this.font.lineHeight, 7089453); /* Height Title */ - stack.drawString(this.font, this.heightTitle, (int)(BG_X + (float) (TEXTURE_WIDTH / 2) - (float) (this.font.width(this.widthTitle) / 2)), BG_Y + 110 + this.font.lineHeight, 7089453, false); + this.font.draw(stack, this.heightTitle, BG_X + (float) (TEXTURE_WIDTH / 2) - (float) (this.font.width(this.widthTitle) / 2), BG_Y + 110 + this.font.lineHeight, 7089453); super.render(stack, mouseX, mouseY, partialTicks); } @@ -231,4 +226,9 @@ public class ExplosionConfigScreen extends Screen { public boolean isPauseScreen() { return false; } + + @Override + public void renderBackground(@NotNull PoseStack stack, int _unused) { + this.fillGradient(stack, 0, 0, this.width, this.height, -1072689136, -804253680); + } } diff --git a/src/main/java/com/oitsjustjose/charged_explosives/client/render/BlockDestroyRenderer.java b/src/main/java/com/oitsjustjose/charged_explosives/client/render/BlockDestroyRenderer.java index 341aa78..6a12179 100644 --- a/src/main/java/com/oitsjustjose/charged_explosives/client/render/BlockDestroyRenderer.java +++ b/src/main/java/com/oitsjustjose/charged_explosives/client/render/BlockDestroyRenderer.java @@ -4,6 +4,7 @@ import com.google.common.collect.Sets; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.math.Matrix4f; import com.oitsjustjose.charged_explosives.client.config.ClientConfig; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; @@ -12,7 +13,6 @@ import net.minecraft.util.Tuple; import net.minecraft.world.phys.Vec3; import net.minecraftforge.client.event.RenderLevelStageEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; -import org.joml.Matrix4f; import java.util.Set; diff --git a/src/main/java/com/oitsjustjose/charged_explosives/common/Util.java b/src/main/java/com/oitsjustjose/charged_explosives/common/Util.java index e3df055..7d0cac1 100644 --- a/src/main/java/com/oitsjustjose/charged_explosives/common/Util.java +++ b/src/main/java/com/oitsjustjose/charged_explosives/common/Util.java @@ -9,7 +9,7 @@ import net.minecraft.network.chat.contents.TranslatableContents; public class Util { public static Component translateOrFallback(String transKey) { try { - return new TranslatableContents(transKey, null, new Object[]{}).resolve(null, null, 0); + return new TranslatableContents(transKey).resolve(null, null, 0); } catch (CommandSyntaxException e) { MutableComponent m = MutableComponent.create(ComponentContents.EMPTY); m.append("Failed to resolve key "); diff --git a/src/main/java/com/oitsjustjose/charged_explosives/common/blocks/ChargedExplosiveBlock.java b/src/main/java/com/oitsjustjose/charged_explosives/common/blocks/ChargedExplosiveBlock.java index b8438b8..822d5b5 100644 --- a/src/main/java/com/oitsjustjose/charged_explosives/common/blocks/ChargedExplosiveBlock.java +++ b/src/main/java/com/oitsjustjose/charged_explosives/common/blocks/ChargedExplosiveBlock.java @@ -11,6 +11,7 @@ import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; +import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; @@ -22,12 +23,14 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock; import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.AttachFace; import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.level.entity.EntityTypeTest; -import net.minecraft.world.level.material.MapColor; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; @@ -54,7 +57,7 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc public static final BooleanProperty ACTIVATED = BooleanProperty.create("activated"); public ChargedExplosiveBlock() { - super(Properties.of().mapColor(MapColor.COLOR_GREEN).dynamicShape().noOcclusion().isValidSpawn((w, x, y, z) -> false).isRedstoneConductor((x, y, z) -> false).isSuffocating((x, y, z) -> false).isViewBlocking((x, y, z) -> false)); + super(BlockBehaviour.Properties.of(Material.EXPLOSIVE, MaterialColor.COLOR_GREEN).dynamicShape().noOcclusion().isValidSpawn((w, x, y, z) -> false).isRedstoneConductor((x, y, z) -> false).isSuffocating((x, y, z) -> false).isViewBlocking((x, y, z) -> false)); this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(FACE, AttachFace.WALL).setValue(ACTIVATED, false)); } @@ -120,13 +123,13 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc return; } - if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity ent) { - ChargedExplosives.getInstance().PROXY.endPreviewExplosion(ent.getCorners()); + if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity cebe) { + ChargedExplosives.getInstance().PROXY.endPreviewExplosion(cebe.getCorners()); ItemStack stack = new ItemStack(ChargedExplosives.getInstance().REGISTRY.CeItem.get()); - ent.saveToItem(stack); - ItemEntity itemEntity = new ItemEntity(level, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, stack); - itemEntity.setDefaultPickUpDelay(); - level.addFreshEntity(itemEntity); + cebe.saveToItem(stack); + ItemEntity ent = new ItemEntity(level, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, stack); + ent.setDefaultPickUpDelay(); + level.addFreshEntity(ent); } level.removeBlockEntity(pos); @@ -152,7 +155,7 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc @Override public void neighborChanged(@NotNull BlockState state, Level level, @NotNull BlockPos pos, @NotNull Block block, @NotNull BlockPos fromPos, boolean isMoving) { if (level.hasNeighborSignal(pos)) { - if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity) { + if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity cebe) { if (!state.getValue(ACTIVATED)) { this.explode(level, pos); } @@ -161,7 +164,7 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc } private void explode(Level level, BlockPos pos) { - if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity ent) { + if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity cebe) { BlockState state = level.getBlockState(pos); if (state.getValue(ACTIVATED)) { return; @@ -170,9 +173,9 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc } - ent.addScheduledTask(ChargedExplosives.getInstance().SCHEDULER.addTask(new TickScheduler.ScheduledTask(() -> this.explodeTask(level, pos), CommonConfig.EXPLOSION_COUNTDOWN_TIME.get()))); + cebe.addScheduledTask(ChargedExplosives.getInstance().SCHEDULER.addTask(new TickScheduler.ScheduledTask(() -> this.explodeTask(level, pos), CommonConfig.EXPLOSION_COUNTDOWN_TIME.get()))); for (int i = 0; i < CommonConfig.NUM_BEEPS.get(); i++) { - ent.addScheduledTask(ChargedExplosives.getInstance().SCHEDULER.addTask(new TickScheduler.ScheduledTask(() -> { + cebe.addScheduledTask(ChargedExplosives.getInstance().SCHEDULER.addTask(new TickScheduler.ScheduledTask(() -> { if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity) { // check that it's still there level.playSound(null, pos, ChargedExplosives.getInstance().REGISTRY.BeepSound.get(), SoundSource.BLOCKS, 0.75F, 1.0F); } @@ -184,14 +187,14 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc private void explodeTask(Level level, BlockPos pos) { - if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity ent) { + if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity cebe) { level.playSound(null, pos, SoundEvents.GENERIC_EXPLODE, SoundSource.BLOCKS, 1.0F, 1.0F); - ChargedExplosives.getInstance().PROXY.endPreviewExplosion(ent.getCorners()); + ChargedExplosives.getInstance().PROXY.endPreviewExplosion(cebe.getCorners()); level.removeBlockEntity(pos); level.removeBlock(pos, false); - ent.getExplosions().forEach(p -> { + cebe.getExplosions().forEach(p -> { BlockState state = level.getBlockState(p); if (!state.hasBlockEntity()) { /* indestructible blocks will return -1.0F */ @@ -205,7 +208,7 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc } }); - AABB aabb = new AABB(ent.getCorners().getA(), ent.getCorners().getB()).inflate(CommonConfig.CONCUSSIVE_DAMAGE_PADDING.get()); + AABB aabb = new AABB(cebe.getCorners().getA(), cebe.getCorners().getB()).inflate(CommonConfig.CONCUSSIVE_DAMAGE_PADDING.get()); for (int x = (int) aabb.minX; x < (int) aabb.maxX; x++) { for (int y = (int) aabb.minY; y < (int) aabb.maxY; y++) { for (int z = (int) aabb.minZ; z < (int) aabb.maxZ; z++) { @@ -216,9 +219,9 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc } } - float dmgAmt = ent.calculateConcussiveDamage(); + float dmgAmt = cebe.calculateConcussiveDamage(); List entities = level.getEntities(EntityTypeTest.forClass(LivingEntity.class), aabb, Objects::nonNull); - entities.forEach(x -> x.hurt(level.damageSources().generic(), dmgAmt)); + entities.forEach(x -> x.hurt(DamageSource.GENERIC, dmgAmt)); } } diff --git a/src/main/java/com/oitsjustjose/charged_explosives/common/items/ChargedExplosiveItem.java b/src/main/java/com/oitsjustjose/charged_explosives/common/items/ChargedExplosiveItem.java index 6b825eb..3aa3d33 100644 --- a/src/main/java/com/oitsjustjose/charged_explosives/common/items/ChargedExplosiveItem.java +++ b/src/main/java/com/oitsjustjose/charged_explosives/common/items/ChargedExplosiveItem.java @@ -12,7 +12,11 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.*; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; @@ -26,7 +30,7 @@ import java.util.Objects; public class ChargedExplosiveItem extends BlockItem { public ChargedExplosiveItem(Block block) { - super(block, new Item.Properties()); + super(block, new Item.Properties().tab(CreativeModeTab.TAB_REDSTONE)); } @Override @@ -96,11 +100,11 @@ public class ChargedExplosiveItem extends BlockItem { int d = tag.getInt("explosionDepth"); int h = tag.getInt("explosionHeight"); try { - TranslatableContents wc = new TranslatableContents(ChargedExplosives.MODID + ".width_tooltip", null, new Object[]{w}); + TranslatableContents wc = new TranslatableContents(ChargedExplosives.MODID + ".width_tooltip", w); components.add(wc.resolve(null, null, 0)); - TranslatableContents dc = new TranslatableContents(ChargedExplosives.MODID + ".depth_tooltip", null, new Object[]{d}); + TranslatableContents dc = new TranslatableContents(ChargedExplosives.MODID + ".depth_tooltip", d); components.add(dc.resolve(null, null, 0)); - TranslatableContents hc = new TranslatableContents(ChargedExplosives.MODID + ".height_tooltip", null, new Object[]{h}); + TranslatableContents hc = new TranslatableContents(ChargedExplosives.MODID + ".height_tooltip", h); components.add(hc.resolve(null, null, 0)); } catch (CommandSyntaxException ignored) { } diff --git a/src/main/java/com/oitsjustjose/charged_explosives/common/registry/Registry.java b/src/main/java/com/oitsjustjose/charged_explosives/common/registry/Registry.java index 58c5e8e..6d55d2a 100644 --- a/src/main/java/com/oitsjustjose/charged_explosives/common/registry/Registry.java +++ b/src/main/java/com/oitsjustjose/charged_explosives/common/registry/Registry.java @@ -23,6 +23,6 @@ public class Registry { public final RegistryObject CeBlock = BlockRegistry.register("charged_explosive", ChargedExplosiveBlock::new); public final RegistryObject CeItem = ItemRegistry.register("charged_explosive", () -> new ChargedExplosiveItem(CeBlock.get())); public final RegistryObject> CeBlockEntityType = BlockEntityTypeRegistry.register("charged_explosive", () -> BlockEntityType.Builder.of(ChargedExplosiveBlockEntity::new, Blocks.AIR).build(null)); - public final RegistryObject BeepSound = SoundEventRegistry.register("beep", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ChargedExplosives.MODID, "beep"))); - public final RegistryObject FailureSound = SoundEventRegistry.register("fail", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ChargedExplosives.MODID, "fail"))); + public final RegistryObject BeepSound = SoundEventRegistry.register("beep", () -> new SoundEvent(new ResourceLocation(ChargedExplosives.MODID, "beep"))); + public final RegistryObject FailureSound = SoundEventRegistry.register("fail", () -> new SoundEvent(new ResourceLocation(ChargedExplosives.MODID, "fail"))); }