diff --git a/build.gradle b/build.gradle index 34c90f2..dfd6b8a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,130 +1,78 @@ -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" - } +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)" } -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' // http://maven.apache.org/guides/mini/guide-naming-conventions.html -archivesBaseName = "ChargedExplosives-${game_version}-${mod_version}" +group = 'com.oitsjustjose.charged_explosives' +version = "${mod_version}" +base { archivesName = "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 } } } } } -repositories { - maven { url = "https://dvs1.progwml6.com/files/maven" } -} dependencies { - minecraft "net.minecraftforge:forge:${game_version}-${forge_version}" + minecraft "net.neoforged:forge:${game_version}-${neo_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") ]) } } - -// 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 +tasks.register('publish') { + dependsOn 'curseforge' + dependsOn 'modrinth' } curseforge { - 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}" + 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}" + } } - } } -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 f695674..2872206 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,5 @@ -# Charged Explosives Changelog (1.19) +# Charged Explosives Changelog (1.20.1) ## 1.0.0 -Initial Release +Initial port to 1.20.1 and Neoforged! diff --git a/gradle.properties b/gradle.properties index 2902aa2..450f006 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ mod_version=1.0.0 -game_version=1.19.2 -forge_version=43.1.1 +game_version=1.20.1 +neo_version=47.1.25 org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180..943f0cb 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 e750102..37aef8d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 index c53aefa..65dcd68 --- 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/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/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,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # 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,12 +143,16 @@ 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 @@ -205,6 +209,12 @@ 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/src/main/java/com/oitsjustjose/charged_explosives/ChargedExplosives.java b/src/main/java/com/oitsjustjose/charged_explosives/ChargedExplosives.java index fb16376..1972628 100644 --- a/src/main/java/com/oitsjustjose/charged_explosives/ChargedExplosives.java +++ b/src/main/java/com/oitsjustjose/charged_explosives/ChargedExplosives.java @@ -6,8 +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.AddReloadListenerEvent; +import net.minecraftforge.event.BuildCreativeModeTabContentsEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.ModLoadingContext; @@ -56,7 +57,9 @@ public class ChargedExplosives { } @SubscribeEvent - public void onSlashReload(AddReloadListenerEvent evt) { + public void buildContents(BuildCreativeModeTabContentsEvent event) { + if (event.getTabKey() == CreativeModeTabs.REDSTONE_BLOCKS) { + event.accept(REGISTRY.CeItem); + } } - } \ 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 11122ee..9af8523 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,6 +5,7 @@ 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; @@ -13,11 +14,9 @@ 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 { @@ -73,58 +72,70 @@ 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 */ - this.addRenderableWidget(new Button(BG_X + ((rowWidth / 2) - 1) + FW_MOD, BG_Y + 40, DECR_W, 20, DECR, onPress -> { + var widthDecrButton = new Button.Builder(DECR, onPress -> { if (this.explosionWidth > 1) { this.explosionWidth--; this.dirty = true; - this.widthBox.setValue("" + this.explosionWidth); + this.widthBox.setValue(String.valueOf(this.explosionWidth)); } - })); - 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 -> { + }).pos(BG_X + ((rowWidth / 2) - 1) + FW_MOD, BG_Y + 40).size(DECR_W, 20).build(); + + var widthIncrButton = new Button.Builder(INCR, onPress -> { if (this.explosionWidth < CommonConfig.MAX_EXPLOSION_WIDTH.get()) { this.explosionWidth++; this.dirty = true; - this.widthBox.setValue("" + this.explosionWidth); + this.widthBox.setValue(String.valueOf(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 */ - this.addRenderableWidget(new Button(BG_X + ((rowWidth / 2) - 1) + FW_MOD, BG_Y + 85, DECR_W, 20, DECR, onPress -> { + var depthDecrButton = new Button.Builder(DECR, onPress -> { if (this.explosionDepth > 1) { this.explosionDepth--; this.dirty = true; - this.depthBox.setValue("" + this.explosionDepth); + this.depthBox.setValue(String.valueOf(this.explosionDepth)); } - })); - 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 -> { + }).pos(BG_X + ((rowWidth / 2) - 1) + FW_MOD, BG_Y + 85).size(DECR_W, 20).build(); + + var depthIncrButton = new Button.Builder(INCR, onPress -> { if (this.explosionDepth < CommonConfig.MAX_EXPLOSION_DEPTH.get()) { this.explosionDepth++; this.dirty = true; - this.depthBox.setValue("" + this.explosionDepth); + this.depthBox.setValue(String.valueOf(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 */ - this.addRenderableWidget(new Button(BG_X + ((rowWidth / 2) - 1) + FW_MOD, BG_Y + 130, DECR_W, 20, DECR, onPress -> { + var heightDecrButton = new Button.Builder(DECR, onPress -> { if (this.explosionHeight > 1) { this.explosionHeight--; this.dirty = true; - this.heightBox.setValue("" + this.explosionHeight); + this.heightBox.setValue(String.valueOf(this.explosionHeight)); } - })); - 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 -> { + }).pos(BG_X + ((rowWidth / 2) - 1) + FW_MOD, BG_Y + 130).size(DECR_W, 20).build(); + + var heightIncrButton = new Button.Builder(INCR, onPress -> { if (this.explosionHeight < CommonConfig.MAX_EXPLOSION_HEIGHT.get()) { this.explosionHeight++; this.dirty = true; - this.heightBox.setValue("" + this.explosionHeight); + this.heightBox.setValue(String.valueOf(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 @@ -194,12 +205,7 @@ public class ExplosionConfigScreen extends Screen { } @Override - public boolean shouldCloseOnEsc() { - return true; - } - - @Override - public void render(@NotNull PoseStack stack, int mouseX, int mouseY, float partialTicks) { + public void render(@NotNull GuiGraphics 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; @@ -207,17 +213,16 @@ 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 */ - 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); + 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); /* Depth Title */ - 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); + 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); /* Height Title */ - 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); + 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); super.render(stack, mouseX, mouseY, partialTicks); } @@ -226,9 +231,4 @@ 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 6a12179..341aa78 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,7 +4,6 @@ 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; @@ -13,6 +12,7 @@ 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 7d0cac1..e3df055 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).resolve(null, null, 0); + return new TranslatableContents(transKey, null, new Object[]{}).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 822d5b5..b8438b8 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,7 +11,6 @@ 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; @@ -23,14 +22,12 @@ 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.Material; -import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.material.MapColor; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; @@ -57,7 +54,7 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc public static final BooleanProperty ACTIVATED = BooleanProperty.create("activated"); public ChargedExplosiveBlock() { - 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)); + 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)); this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(FACE, AttachFace.WALL).setValue(ACTIVATED, false)); } @@ -123,13 +120,13 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc return; } - if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity cebe) { - ChargedExplosives.getInstance().PROXY.endPreviewExplosion(cebe.getCorners()); + if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity ent) { + ChargedExplosives.getInstance().PROXY.endPreviewExplosion(ent.getCorners()); ItemStack stack = new ItemStack(ChargedExplosives.getInstance().REGISTRY.CeItem.get()); - 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); + 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); } level.removeBlockEntity(pos); @@ -155,7 +152,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 cebe) { + if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity) { if (!state.getValue(ACTIVATED)) { this.explode(level, pos); } @@ -164,7 +161,7 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc } private void explode(Level level, BlockPos pos) { - if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity cebe) { + if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity ent) { BlockState state = level.getBlockState(pos); if (state.getValue(ACTIVATED)) { return; @@ -173,9 +170,9 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc } - cebe.addScheduledTask(ChargedExplosives.getInstance().SCHEDULER.addTask(new TickScheduler.ScheduledTask(() -> this.explodeTask(level, pos), CommonConfig.EXPLOSION_COUNTDOWN_TIME.get()))); + ent.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++) { - cebe.addScheduledTask(ChargedExplosives.getInstance().SCHEDULER.addTask(new TickScheduler.ScheduledTask(() -> { + ent.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); } @@ -187,14 +184,14 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc private void explodeTask(Level level, BlockPos pos) { - if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity cebe) { + if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity ent) { level.playSound(null, pos, SoundEvents.GENERIC_EXPLODE, SoundSource.BLOCKS, 1.0F, 1.0F); - ChargedExplosives.getInstance().PROXY.endPreviewExplosion(cebe.getCorners()); + ChargedExplosives.getInstance().PROXY.endPreviewExplosion(ent.getCorners()); level.removeBlockEntity(pos); level.removeBlock(pos, false); - cebe.getExplosions().forEach(p -> { + ent.getExplosions().forEach(p -> { BlockState state = level.getBlockState(p); if (!state.hasBlockEntity()) { /* indestructible blocks will return -1.0F */ @@ -208,7 +205,7 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc } }); - AABB aabb = new AABB(cebe.getCorners().getA(), cebe.getCorners().getB()).inflate(CommonConfig.CONCUSSIVE_DAMAGE_PADDING.get()); + AABB aabb = new AABB(ent.getCorners().getA(), ent.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++) { @@ -219,9 +216,9 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc } } - float dmgAmt = cebe.calculateConcussiveDamage(); + float dmgAmt = ent.calculateConcussiveDamage(); List entities = level.getEntities(EntityTypeTest.forClass(LivingEntity.class), aabb, Objects::nonNull); - entities.forEach(x -> x.hurt(DamageSource.GENERIC, dmgAmt)); + entities.forEach(x -> x.hurt(level.damageSources().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 3aa3d33..6b825eb 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,11 +12,7 @@ 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.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.*; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; @@ -30,7 +26,7 @@ import java.util.Objects; public class ChargedExplosiveItem extends BlockItem { public ChargedExplosiveItem(Block block) { - super(block, new Item.Properties().tab(CreativeModeTab.TAB_REDSTONE)); + super(block, new Item.Properties()); } @Override @@ -100,11 +96,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", w); + TranslatableContents wc = new TranslatableContents(ChargedExplosives.MODID + ".width_tooltip", null, new Object[]{w}); components.add(wc.resolve(null, null, 0)); - TranslatableContents dc = new TranslatableContents(ChargedExplosives.MODID + ".depth_tooltip", d); + TranslatableContents dc = new TranslatableContents(ChargedExplosives.MODID + ".depth_tooltip", null, new Object[]{d}); components.add(dc.resolve(null, null, 0)); - TranslatableContents hc = new TranslatableContents(ChargedExplosives.MODID + ".height_tooltip", h); + TranslatableContents hc = new TranslatableContents(ChargedExplosives.MODID + ".height_tooltip", null, new Object[]{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 6d55d2a..58c5e8e 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", () -> new SoundEvent(new ResourceLocation(ChargedExplosives.MODID, "beep"))); - public final RegistryObject FailureSound = SoundEventRegistry.register("fail", () -> new SoundEvent(new ResourceLocation(ChargedExplosives.MODID, "fail"))); + 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"))); }