Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f11de877d | ||
|
|
e711a2d872 | ||
|
|
b69eda4f90 |
14 changed files with 157 additions and 190 deletions
134
build.gradle
134
build.gradle
|
|
@ -1,130 +1,78 @@
|
||||||
buildscript {
|
plugins {
|
||||||
repositories {
|
id "com.modrinth.minotaur" version "2.+"
|
||||||
maven { url = 'https://files.minecraftforge.net/maven' }
|
id "com.matthewprenger.cursegradle" version "1.4.0+"
|
||||||
maven { url "https://plugins.gradle.org/m2/" }
|
id "net.neoforged.gradle" version "[6.0.18,6.2)"
|
||||||
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'
|
||||||
group = 'com.oitsjustjose.charged_explosives' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
version = "${mod_version}"
|
||||||
archivesBaseName = "ChargedExplosives-${game_version}-${mod_version}"
|
base { archivesName = "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.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 {
|
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') {
|
||||||
// Example configuration to allow publishing using the maven-publish task
|
dependsOn 'curseforge'
|
||||||
// we define a custom artifact that is sourced from the reobfJar output task
|
dependsOn 'modrinth'
|
||||||
// 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 {
|
||||||
apiKey = project.hasProperty("CURSEFORGE_API_KEY") ? project.CURSEFORGE_API_KEY : ""
|
apiKey = project.hasProperty("CURSEFORGE_API_KEY") ? project.CURSEFORGE_API_KEY : ""
|
||||||
project {
|
project {
|
||||||
id = '693885'
|
id = '693885'
|
||||||
changelogType = 'markdown'
|
changelogType = 'markdown'
|
||||||
changelog = file("./changelog.md")
|
changelog = file("./changelog.md")
|
||||||
releaseType = 'release'
|
releaseType = 'release'
|
||||||
addGameVersion "1.19"
|
addGameVersion "${game_version}"
|
||||||
addGameVersion "1.19.1"
|
mainArtifact(jar) {
|
||||||
mainArtifact(jar) {
|
displayName = "Charged Explosives ${game_version} ${mod_version}"
|
||||||
displayName = "Charged Explosives ${game_version} ${mod_version}"
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
modrinth {
|
||||||
publications {
|
token = project.hasProperty("MODRINTH_API_KEY") ? project.MODRINTH_API_KEY : ""
|
||||||
mavenJava(MavenPublication) {
|
projectId = "sv2l2OG2"
|
||||||
artifact reobfArtifact
|
versionName = "Charged Explosives ${game_version} ${mod_version}"
|
||||||
}
|
versionNumber = "${game_version}-${mod_version}"
|
||||||
}
|
versionType = "release"
|
||||||
repositories {
|
uploadFile = jar
|
||||||
maven {
|
gameVersions = ["${game_version}"]
|
||||||
url "file:///${project.projectDir}/mcmodsrepo"
|
loaders = ["forge"]
|
||||||
}
|
changelog = file("./changelog.md").text
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
# Charged Explosives Changelog (1.19)
|
# Charged Explosives Changelog (1.20.1)
|
||||||
|
|
||||||
## 1.0.0
|
## 1.0.0
|
||||||
|
|
||||||
Initial Release
|
Initial port to 1.20.1 and Neoforged!
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
mod_version=1.0.0
|
mod_version=1.0.0
|
||||||
game_version=1.19.2
|
game_version=1.20.1
|
||||||
forge_version=43.1.1
|
neo_version=47.1.25
|
||||||
|
|
||||||
org.gradle.jvmargs=-Xmx3G
|
org.gradle.jvmargs=-Xmx3G
|
||||||
org.gradle.daemon=false
|
org.gradle.daemon=false
|
||||||
|
|
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
|
|
@ -1,5 +1,6 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
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
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
|
||||||
28
gradlew
vendored
Normal file → Executable file
28
gradlew
vendored
Normal file → Executable 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/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.
|
# 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,10 +80,10 @@ do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=${0##*/}
|
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.
|
# 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,12 +143,16 @@ 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
|
||||||
|
|
@ -205,6 +209,12 @@ 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.
|
||||||
|
|
|
||||||
13
settings.gradle
Normal file
13
settings.gradle
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
gradlePluginPortal()
|
||||||
|
maven {
|
||||||
|
name = 'NeoForged'
|
||||||
|
url = 'https://maven.neoforged.net/releases'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
|
||||||
|
}
|
||||||
|
|
@ -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.AddReloadListenerEvent;
|
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||||
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,6 +37,7 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,8 +56,9 @@ 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"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
private void buildContents(BuildCreativeModeTabContentsEvent event) {
|
||||||
public void onSlashReload(AddReloadListenerEvent evt) {
|
if (event.getTabKey() == CreativeModeTabs.REDSTONE_BLOCKS) {
|
||||||
|
event.accept(ChargedExplosives.getInstance().REGISTRY.CeItem.get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -5,6 +5,7 @@ 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;
|
||||||
|
|
@ -13,11 +14,9 @@ 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 {
|
||||||
|
|
||||||
|
|
@ -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 */;
|
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 */
|
||||||
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) {
|
if (this.explosionWidth > 1) {
|
||||||
this.explosionWidth--;
|
this.explosionWidth--;
|
||||||
this.dirty = true;
|
this.dirty = true;
|
||||||
this.widthBox.setValue("" + this.explosionWidth);
|
this.widthBox.setValue(String.valueOf(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("")));
|
|
||||||
this.widthBox.setValue("" + this.explosionWidth);
|
var widthIncrButton = new Button.Builder(INCR, onPress -> {
|
||||||
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("" + 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 */
|
/* 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) {
|
if (this.explosionDepth > 1) {
|
||||||
this.explosionDepth--;
|
this.explosionDepth--;
|
||||||
this.dirty = true;
|
this.dirty = true;
|
||||||
this.depthBox.setValue("" + this.explosionDepth);
|
this.depthBox.setValue(String.valueOf(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("")));
|
|
||||||
this.depthBox.setValue("" + this.explosionDepth);
|
var depthIncrButton = new Button.Builder(INCR, onPress -> {
|
||||||
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("" + 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 */
|
/* 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) {
|
if (this.explosionHeight > 1) {
|
||||||
this.explosionHeight--;
|
this.explosionHeight--;
|
||||||
this.dirty = true;
|
this.dirty = true;
|
||||||
this.heightBox.setValue("" + this.explosionHeight);
|
this.heightBox.setValue(String.valueOf(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("")));
|
|
||||||
this.heightBox.setValue("" + this.explosionHeight);
|
var heightIncrButton = new Button.Builder(INCR, onPress -> {
|
||||||
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("" + 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
|
@Override
|
||||||
|
|
@ -194,12 +205,7 @@ public class ExplosionConfigScreen extends Screen {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldCloseOnEsc() {
|
public void render(@NotNull GuiGraphics stack, int mouseX, int mouseY, float partialTicks) {
|
||||||
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;
|
||||||
|
|
||||||
|
|
@ -207,17 +213,16 @@ 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 */
|
||||||
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 */
|
/* 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 */
|
/* 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);
|
super.render(stack, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
@ -226,9 +231,4 @@ 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ 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;
|
||||||
|
|
@ -13,6 +12,7 @@ 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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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).resolve(null, null, 0);
|
return new TranslatableContents(transKey, null, new Object[]{}).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 ");
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ 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;
|
||||||
|
|
@ -23,14 +22,12 @@ 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.Material;
|
import net.minecraft.world.level.material.MapColor;
|
||||||
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;
|
||||||
|
|
@ -57,7 +54,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(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));
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity cebe) {
|
if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity ent) {
|
||||||
ChargedExplosives.getInstance().PROXY.endPreviewExplosion(cebe.getCorners());
|
ChargedExplosives.getInstance().PROXY.endPreviewExplosion(ent.getCorners());
|
||||||
ItemStack stack = new ItemStack(ChargedExplosives.getInstance().REGISTRY.CeItem.get());
|
ItemStack stack = new ItemStack(ChargedExplosives.getInstance().REGISTRY.CeItem.get());
|
||||||
cebe.saveToItem(stack);
|
ent.saveToItem(stack);
|
||||||
ItemEntity ent = new ItemEntity(level, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, stack);
|
ItemEntity itemEntity = new ItemEntity(level, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, stack);
|
||||||
ent.setDefaultPickUpDelay();
|
itemEntity.setDefaultPickUpDelay();
|
||||||
level.addFreshEntity(ent);
|
level.addFreshEntity(itemEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
level.removeBlockEntity(pos);
|
level.removeBlockEntity(pos);
|
||||||
|
|
@ -155,7 +152,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 cebe) {
|
if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity) {
|
||||||
if (!state.getValue(ACTIVATED)) {
|
if (!state.getValue(ACTIVATED)) {
|
||||||
this.explode(level, pos);
|
this.explode(level, pos);
|
||||||
}
|
}
|
||||||
|
|
@ -164,7 +161,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 cebe) {
|
if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity ent) {
|
||||||
BlockState state = level.getBlockState(pos);
|
BlockState state = level.getBlockState(pos);
|
||||||
if (state.getValue(ACTIVATED)) {
|
if (state.getValue(ACTIVATED)) {
|
||||||
return;
|
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++) {
|
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
|
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);
|
||||||
}
|
}
|
||||||
|
|
@ -187,14 +184,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 cebe) {
|
if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity ent) {
|
||||||
|
|
||||||
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(cebe.getCorners());
|
ChargedExplosives.getInstance().PROXY.endPreviewExplosion(ent.getCorners());
|
||||||
level.removeBlockEntity(pos);
|
level.removeBlockEntity(pos);
|
||||||
level.removeBlock(pos, false);
|
level.removeBlock(pos, false);
|
||||||
|
|
||||||
cebe.getExplosions().forEach(p -> {
|
ent.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 */
|
||||||
|
|
@ -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 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++) {
|
||||||
|
|
@ -219,9 +216,9 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float dmgAmt = cebe.calculateConcussiveDamage();
|
float dmgAmt = ent.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(DamageSource.GENERIC, dmgAmt));
|
entities.forEach(x -> x.hurt(level.damageSources().generic(), dmgAmt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,7 @@ 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.BlockItem;
|
import net.minecraft.world.item.*;
|
||||||
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;
|
||||||
|
|
@ -30,7 +26,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().tab(CreativeModeTab.TAB_REDSTONE));
|
super(block, new Item.Properties());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -100,11 +96,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", w);
|
TranslatableContents wc = new TranslatableContents(ChargedExplosives.MODID + ".width_tooltip", null, new Object[]{w});
|
||||||
components.add(wc.resolve(null, null, 0));
|
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));
|
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));
|
components.add(hc.resolve(null, null, 0));
|
||||||
} catch (CommandSyntaxException ignored) {
|
} catch (CommandSyntaxException ignored) {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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", () -> new SoundEvent(new ResourceLocation(ChargedExplosives.MODID, "beep")));
|
public final RegistryObject<SoundEvent> BeepSound = SoundEventRegistry.register("beep", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ChargedExplosives.MODID, "beep")));
|
||||||
public final RegistryObject<SoundEvent> FailureSound = SoundEventRegistry.register("fail", () -> new SoundEvent(new ResourceLocation(ChargedExplosives.MODID, "fail")));
|
public final RegistryObject<SoundEvent> FailureSound = SoundEventRegistry.register("fail", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ChargedExplosives.MODID, "fail")));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue