Compare commits

..
14 changed files with 190 additions and 157 deletions

View file

@ -1,54 +1,104 @@
plugins { buildscript {
id "com.modrinth.minotaur" version "2.+" repositories {
id "com.matthewprenger.cursegradle" version "1.4.0+" maven { url = 'https://files.minecraftforge.net/maven' }
id "net.neoforged.gradle" version "[6.0.18,6.2)" 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}" group = 'com.oitsjustjose.charged_explosives' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
base { archivesName = "ChargedExplosives-${game_version}-${mod_version}" } archivesBaseName = "ChargedExplosives-${game_version}-${mod_version}"
java.toolchain.languageVersion = JavaLanguageVersion.of(17) 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 { minecraft {
mappings channel: 'official', version: "${game_version}" mappings channel: 'official', version: "${game_version}"
copyIdeResources = true
runs { runs {
client { client {
workingDirectory project.file('run') workingDirectory project.file('run')
property 'forge.logging.console.level', 'debug' property 'forge.logging.console.level', 'debug'
mods { charged_explosives { source sourceSets.main } }
mods {
charged_explosives {
source sourceSets.main
}
}
} }
server { server {
workingDirectory project.file('run') workingDirectory project.file('run')
property 'forge.logging.console.level', 'debug' 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 { dependencies {
minecraft "net.neoforged:forge:${game_version}-${neo_version}" minecraft "net.minecraftforge:forge:${game_version}-${forge_version}"
} }
// Example for how to get properties into the manifest for reading by the runtime..
jar { jar {
manifest { manifest {
attributes([ attributes([
"Specification-Title" : "charged_explosives", "Specification-Title": "charged_explosives",
"Specification-Vendor" : "oitsjustjose.com", "Specification-Vendor": "oitsjustjose.com",
"Specification-Version" : "1", // We are version 1 of ourselves "Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title" : project.name, "Implementation-Title": project.name,
"Implementation-Version" : "${mod_version}", "Implementation-Version": "${mod_version}",
"Implementation-Vendor" : "oitsjustjose.com", "Implementation-Vendor" :"oitsjustjose.com",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
]) ])
} }
} }
tasks.register('publish') {
dependsOn 'curseforge' // Example configuration to allow publishing using the maven-publish task
dependsOn 'modrinth' // 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 { curseforge {
@ -58,21 +108,23 @@ curseforge {
changelogType = 'markdown' changelogType = 'markdown'
changelog = file("./changelog.md") changelog = file("./changelog.md")
releaseType = 'release' releaseType = 'release'
addGameVersion "${game_version}" addGameVersion "1.19"
addGameVersion "1.19.1"
mainArtifact(jar) { mainArtifact(jar) {
displayName = "Charged Explosives ${game_version} ${mod_version}" displayName = "Charged Explosives ${game_version} ${mod_version}"
} }
} }
} }
modrinth { publishing {
token = project.hasProperty("MODRINTH_API_KEY") ? project.MODRINTH_API_KEY : "" publications {
projectId = "sv2l2OG2" mavenJava(MavenPublication) {
versionName = "Charged Explosives ${game_version} ${mod_version}" artifact reobfArtifact
versionNumber = "${game_version}-${mod_version}" }
versionType = "release" }
uploadFile = jar repositories {
gameVersions = ["${game_version}"] maven {
loaders = ["forge"] url "file:///${project.projectDir}/mcmodsrepo"
changelog = file("./changelog.md").text }
}
} }

View file

@ -1,5 +1,5 @@
# Charged Explosives Changelog (1.20.1) # Charged Explosives Changelog (1.19)
## 1.0.0 ## 1.0.0
Initial port to 1.20.1 and Neoforged! Initial Release

View file

@ -1,6 +1,6 @@
mod_version=1.0.0 mod_version=1.0.0
game_version=1.20.1 game_version=1.19.2
neo_version=47.1.25 forge_version=43.1.1
org.gradle.jvmargs=-Xmx3G org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false org.gradle.daemon=false

Binary file not shown.

View file

@ -1,6 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

28
gradlew vendored Executable file → Normal file
View file

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# #
# Copyright © 2015-2021 the original authors. # Copyright © 2015-2021 the original authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with 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 # Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features: # requires all of these POSIX shell features:
# * functions; # * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»; # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»; # * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit». # * various built-in commands including «command», «set», and «ulimit».
# #
# Important for patching: # Important for patching:
# #
@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop. # Darwin, MinGW, and NonStop.
# #
# (3) This script is generated from the Groovy template # (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. # within the Gradle project.
# #
# You can find Gradle at https://github.com/gradle/gradle/. # You can find Gradle at https://github.com/gradle/gradle/.
@ -80,11 +80,11 @@ do
esac esac
done done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 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. # 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"' DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
@ -143,16 +143,12 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #( case $MAX_FD in #(
max*) 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 ) || MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit" warn "Could not query maximum file descriptor limit"
esac esac
case $MAX_FD in #( case $MAX_FD in #(
'' | soft) :;; #( '' | 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" || ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD" warn "Could not set maximum file descriptor limit to $MAX_FD"
esac esac
@ -209,12 +205,6 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \ 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. # Use "xargs" to parse quoted args.
# #
# With -n1 it outputs one arg per line, with the quotes and backslashes removed. # With -n1 it outputs one arg per line, with the quotes and backslashes removed.

View file

@ -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'
}

View file

@ -6,9 +6,9 @@ import com.oitsjustjose.charged_explosives.common.CommonProxy;
import com.oitsjustjose.charged_explosives.common.TickScheduler; import com.oitsjustjose.charged_explosives.common.TickScheduler;
import com.oitsjustjose.charged_explosives.common.config.CommonConfig; import com.oitsjustjose.charged_explosives.common.config.CommonConfig;
import com.oitsjustjose.charged_explosives.common.registry.Registry; import com.oitsjustjose.charged_explosives.common.registry.Registry;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraftforge.common.MinecraftForge; 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.DistExecutor;
import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
@ -37,7 +37,6 @@ public class ChargedExplosives {
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
MinecraftForge.EVENT_BUS.register(SCHEDULER); MinecraftForge.EVENT_BUS.register(SCHEDULER);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::buildContents);
this.configSetup(); this.configSetup();
} }
@ -56,9 +55,8 @@ public class ChargedExplosives {
ClientConfig.loadConfig(ClientConfig.CLIENT_CONFIG, FMLPaths.CONFIGDIR.get().resolve(MODID + "-client.toml")); ClientConfig.loadConfig(ClientConfig.CLIENT_CONFIG, FMLPaths.CONFIGDIR.get().resolve(MODID + "-client.toml"));
} }
private void buildContents(BuildCreativeModeTabContentsEvent event) { @SubscribeEvent
if (event.getTabKey() == CreativeModeTabs.REDSTONE_BLOCKS) { public void onSlashReload(AddReloadListenerEvent evt) {
event.accept(ChargedExplosives.getInstance().REGISTRY.CeItem.get());
}
} }
} }

View file

@ -5,7 +5,6 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.oitsjustjose.charged_explosives.ChargedExplosives; import com.oitsjustjose.charged_explosives.ChargedExplosives;
import com.oitsjustjose.charged_explosives.common.Util; import com.oitsjustjose.charged_explosives.common.Util;
import com.oitsjustjose.charged_explosives.common.config.CommonConfig; 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.Button;
import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.screens.Screen; 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.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.client.event.ScreenEvent;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Objects; import java.util.Objects;
import java.util.function.Function;
public class ExplosionConfigScreen extends Screen { 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 */; 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 */ /* 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) { if (this.explosionWidth > 1) {
this.explosionWidth--; this.explosionWidth--;
this.dirty = true; 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(); }));
this.widthBox = this.addRenderableWidget(new EditBox(this.font, BG_X + ((rowWidth / 2) - 1) + EB_MOD, BG_Y + 40, EDIT_BOX_WIDTH, 20, Component.literal("")));
var widthIncrButton = new Button.Builder(INCR, onPress -> { 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()) { if (this.explosionWidth < CommonConfig.MAX_EXPLOSION_WIDTH.get()) {
this.explosionWidth++; this.explosionWidth++;
this.dirty = true; 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 */ /* 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) { if (this.explosionDepth > 1) {
this.explosionDepth--; this.explosionDepth--;
this.dirty = true; 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(); }));
this.depthBox = this.addRenderableWidget(new EditBox(this.font, BG_X + ((rowWidth / 2) - 1) + EB_MOD, BG_Y + 85, EDIT_BOX_WIDTH, 20, Component.literal("")));
var depthIncrButton = new Button.Builder(INCR, onPress -> { 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()) { if (this.explosionDepth < CommonConfig.MAX_EXPLOSION_DEPTH.get()) {
this.explosionDepth++; this.explosionDepth++;
this.dirty = true; 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 */ /* 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) { if (this.explosionHeight > 1) {
this.explosionHeight--; this.explosionHeight--;
this.dirty = true; 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(); }));
this.heightBox = this.addRenderableWidget(new EditBox(this.font, BG_X + ((rowWidth / 2) - 1) + EB_MOD, BG_Y + 130, EDIT_BOX_WIDTH, 20, Component.literal("")));
var heightIncrButton = new Button.Builder(INCR, onPress -> { 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()) { if (this.explosionHeight < CommonConfig.MAX_EXPLOSION_HEIGHT.get()) {
this.explosionHeight++; this.explosionHeight++;
this.dirty = true; 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 @Override
@ -205,7 +194,12 @@ public class ExplosionConfigScreen extends Screen {
} }
@Override @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_X = (this.width - TEXTURE_WIDTH) / 2;
final int BG_Y = (this.height - TEXTURE_HEIGHT) / 2; final int BG_Y = (this.height - TEXTURE_HEIGHT) / 2;
@ -213,16 +207,17 @@ public class ExplosionConfigScreen extends Screen {
RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, BACKGROUND_TEXTURE); 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 */ /* 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 */ /* 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 */ /* 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); super.render(stack, mouseX, mouseY, partialTicks);
} }
@ -231,4 +226,9 @@ public class ExplosionConfigScreen extends Screen {
public boolean isPauseScreen() { public boolean isPauseScreen() {
return false; return false;
} }
@Override
public void renderBackground(@NotNull PoseStack stack, int _unused) {
this.fillGradient(stack, 0, 0, this.width, this.height, -1072689136, -804253680);
}
} }

View file

@ -4,6 +4,7 @@ import com.google.common.collect.Sets;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Matrix4f;
import com.oitsjustjose.charged_explosives.client.config.ClientConfig; import com.oitsjustjose.charged_explosives.client.config.ClientConfig;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
@ -12,7 +13,6 @@ import net.minecraft.util.Tuple;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import net.minecraftforge.client.event.RenderLevelStageEvent; import net.minecraftforge.client.event.RenderLevelStageEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.joml.Matrix4f;
import java.util.Set; import java.util.Set;

View file

@ -9,7 +9,7 @@ import net.minecraft.network.chat.contents.TranslatableContents;
public class Util { public class Util {
public static Component translateOrFallback(String transKey) { public static Component translateOrFallback(String transKey) {
try { try {
return new TranslatableContents(transKey, null, new Object[]{}).resolve(null, null, 0); return new TranslatableContents(transKey).resolve(null, null, 0);
} catch (CommandSyntaxException e) { } catch (CommandSyntaxException e) {
MutableComponent m = MutableComponent.create(ComponentContents.EMPTY); MutableComponent m = MutableComponent.create(ComponentContents.EMPTY);
m.append("Failed to resolve key "); m.append("Failed to resolve key ");

View file

@ -11,6 +11,7 @@ import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player; 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.EntityBlock;
import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock; import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock;
import net.minecraft.world.level.block.entity.BlockEntity; 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.BlockState;
import net.minecraft.world.level.block.state.StateDefinition; 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.AttachFace;
import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.entity.EntityTypeTest; 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.AABB;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext; 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 static final BooleanProperty ACTIVATED = BooleanProperty.create("activated");
public ChargedExplosiveBlock() { 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)); 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; return;
} }
if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity ent) { if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity cebe) {
ChargedExplosives.getInstance().PROXY.endPreviewExplosion(ent.getCorners()); ChargedExplosives.getInstance().PROXY.endPreviewExplosion(cebe.getCorners());
ItemStack stack = new ItemStack(ChargedExplosives.getInstance().REGISTRY.CeItem.get()); ItemStack stack = new ItemStack(ChargedExplosives.getInstance().REGISTRY.CeItem.get());
ent.saveToItem(stack); cebe.saveToItem(stack);
ItemEntity itemEntity = new ItemEntity(level, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, stack); ItemEntity ent = new ItemEntity(level, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, stack);
itemEntity.setDefaultPickUpDelay(); ent.setDefaultPickUpDelay();
level.addFreshEntity(itemEntity); level.addFreshEntity(ent);
} }
level.removeBlockEntity(pos); level.removeBlockEntity(pos);
@ -152,7 +155,7 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc
@Override @Override
public void neighborChanged(@NotNull BlockState state, Level level, @NotNull BlockPos pos, @NotNull Block block, @NotNull BlockPos fromPos, boolean isMoving) { 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.hasNeighborSignal(pos)) {
if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity) { if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity cebe) {
if (!state.getValue(ACTIVATED)) { if (!state.getValue(ACTIVATED)) {
this.explode(level, pos); this.explode(level, pos);
} }
@ -161,7 +164,7 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc
} }
private void explode(Level level, BlockPos pos) { 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); BlockState state = level.getBlockState(pos);
if (state.getValue(ACTIVATED)) { if (state.getValue(ACTIVATED)) {
return; 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++) { 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 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); 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) { 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); 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.removeBlockEntity(pos);
level.removeBlock(pos, false); level.removeBlock(pos, false);
ent.getExplosions().forEach(p -> { cebe.getExplosions().forEach(p -> {
BlockState state = level.getBlockState(p); BlockState state = level.getBlockState(p);
if (!state.hasBlockEntity()) { if (!state.hasBlockEntity()) {
/* indestructible blocks will return -1.0F */ /* 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 x = (int) aabb.minX; x < (int) aabb.maxX; x++) {
for (int y = (int) aabb.minY; y < (int) aabb.maxY; y++) { for (int y = (int) aabb.minY; y < (int) aabb.maxY; y++) {
for (int z = (int) aabb.minZ; z < (int) aabb.maxZ; z++) { 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<LivingEntity> entities = level.getEntities(EntityTypeTest.forClass(LivingEntity.class), aabb, Objects::nonNull); List<LivingEntity> 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));
} }
} }

View file

@ -12,7 +12,11 @@ import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player; 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.item.context.BlockPlaceContext;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
@ -26,7 +30,7 @@ import java.util.Objects;
public class ChargedExplosiveItem extends BlockItem { public class ChargedExplosiveItem extends BlockItem {
public ChargedExplosiveItem(Block block) { public ChargedExplosiveItem(Block block) {
super(block, new Item.Properties()); super(block, new Item.Properties().tab(CreativeModeTab.TAB_REDSTONE));
} }
@Override @Override
@ -96,11 +100,11 @@ public class ChargedExplosiveItem extends BlockItem {
int d = tag.getInt("explosionDepth"); int d = tag.getInt("explosionDepth");
int h = tag.getInt("explosionHeight"); int h = tag.getInt("explosionHeight");
try { 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)); 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)); 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)); components.add(hc.resolve(null, null, 0));
} catch (CommandSyntaxException ignored) { } catch (CommandSyntaxException ignored) {
} }

View file

@ -23,6 +23,6 @@ public class Registry {
public final RegistryObject<Block> CeBlock = BlockRegistry.register("charged_explosive", ChargedExplosiveBlock::new); public final RegistryObject<Block> CeBlock = BlockRegistry.register("charged_explosive", ChargedExplosiveBlock::new);
public final RegistryObject<Item> CeItem = ItemRegistry.register("charged_explosive", () -> new ChargedExplosiveItem(CeBlock.get())); public final RegistryObject<Item> CeItem = ItemRegistry.register("charged_explosive", () -> new ChargedExplosiveItem(CeBlock.get()));
public final RegistryObject<BlockEntityType<ChargedExplosiveBlockEntity>> CeBlockEntityType = BlockEntityTypeRegistry.register("charged_explosive", () -> BlockEntityType.Builder.of(ChargedExplosiveBlockEntity::new, Blocks.AIR).build(null)); public final RegistryObject<BlockEntityType<ChargedExplosiveBlockEntity>> CeBlockEntityType = BlockEntityTypeRegistry.register("charged_explosive", () -> BlockEntityType.Builder.of(ChargedExplosiveBlockEntity::new, Blocks.AIR).build(null));
public final RegistryObject<SoundEvent> BeepSound = SoundEventRegistry.register("beep", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ChargedExplosives.MODID, "beep"))); public final RegistryObject<SoundEvent> BeepSound = SoundEventRegistry.register("beep", () -> new SoundEvent(new ResourceLocation(ChargedExplosives.MODID, "beep")));
public final RegistryObject<SoundEvent> FailureSound = SoundEventRegistry.register("fail", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ChargedExplosives.MODID, "fail"))); public final RegistryObject<SoundEvent> FailureSound = SoundEventRegistry.register("fail", () -> new SoundEvent(new ResourceLocation(ChargedExplosives.MODID, "fail")));
} }