mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 19:58:34 +01:00
Compare commits
No commits in common. "e50d3fc69a1fd1fda5c95dff13ca876b7e9d41d0" and "34c9bb63de97a3a5a9fa5b4564ee33327e52b6b9" have entirely different histories.
e50d3fc69a
...
34c9bb63de
128 changed files with 1921 additions and 1915 deletions
36
build.gradle
36
build.gradle
|
@ -3,16 +3,7 @@ plugins {
|
||||||
id 'eclipse'
|
id 'eclipse'
|
||||||
id 'idea'
|
id 'idea'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id 'net.neoforged.gradle.userdev' version '7.0.163'
|
id 'net.neoforged.gradle.userdev' version '7.0.80'
|
||||||
}
|
|
||||||
|
|
||||||
tasks.named('wrapper', Wrapper).configure {
|
|
||||||
// Define wrapper values here so as to not have to always do so when updating gradlew.properties.
|
|
||||||
// Switching this to Wrapper.DistributionType.ALL will download the full gradle sources that comes with
|
|
||||||
// documentation attached on cursor hover of gradle classes and methods. However, this comes with increased
|
|
||||||
// file size for Gradle. If you do switch this to ALL, run the Gradle wrapper task twice afterwards.
|
|
||||||
// (Verify by checking gradle/wrapper/gradle-wrapper.properties to see if distributionUrl now points to `-all`)
|
|
||||||
distributionType = Wrapper.DistributionType.BIN
|
|
||||||
}
|
}
|
||||||
|
|
||||||
version = mod_version
|
version = mod_version
|
||||||
|
@ -33,8 +24,8 @@ base {
|
||||||
archivesName = mod_name
|
archivesName = mod_name
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mojang ships Java 21 to end users starting in 1.20.5, so mods should target Java 21.
|
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
|
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'}"
|
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
|
||||||
runs {
|
runs {
|
||||||
|
@ -62,7 +53,7 @@ runs {
|
||||||
|
|
||||||
server {
|
server {
|
||||||
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
|
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
|
||||||
argument '--nogui'
|
programArgument '--nogui'
|
||||||
}
|
}
|
||||||
|
|
||||||
// This run config launches GameTestServer and runs all registered gametests, then exits.
|
// This run config launches GameTestServer and runs all registered gametests, then exits.
|
||||||
|
@ -77,7 +68,7 @@ runs {
|
||||||
// workingDirectory project.file('run-data')
|
// workingDirectory project.file('run-data')
|
||||||
|
|
||||||
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
||||||
arguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
|
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,8 +89,8 @@ dependencies {
|
||||||
compileOnly "mezz.jei:jei-${minecraft_version}-neoforge-api:${jei_version}"
|
compileOnly "mezz.jei:jei-${minecraft_version}-neoforge-api:${jei_version}"
|
||||||
runtimeOnly "mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}"
|
runtimeOnly "mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}"
|
||||||
|
|
||||||
// runtimeOnly "top.theillusivec4.curios:curios-neoforge:${curios_version}"
|
runtimeOnly "top.theillusivec4.curios:curios-neoforge:${curios_version}"
|
||||||
// compileOnly "top.theillusivec4.curios:curios-neoforge:${curios_version}:api"
|
compileOnly "top.theillusivec4.curios:curios-neoforge:${curios_version}:api"
|
||||||
|
|
||||||
compileOnly "vazkii.patchouli:Patchouli:${patchouli_version}:api"
|
compileOnly "vazkii.patchouli:Patchouli:${patchouli_version}:api"
|
||||||
runtimeOnly "vazkii.patchouli:Patchouli:${patchouli_version}"
|
runtimeOnly "vazkii.patchouli:Patchouli:${patchouli_version}"
|
||||||
|
@ -125,11 +116,12 @@ tasks.withType(ProcessResources).configureEach {
|
||||||
loader_version_range: loader_version_range,
|
loader_version_range: loader_version_range,
|
||||||
mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
|
mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
|
||||||
mod_authors : mod_authors, mod_description: mod_description,
|
mod_authors : mod_authors, mod_description: mod_description,
|
||||||
|
patchouli_version : patchouli_version
|
||||||
]
|
]
|
||||||
inputs.properties replaceProperties
|
inputs.properties replaceProperties
|
||||||
|
|
||||||
filesMatching(['META-INF/neoforge.mods.toml']) {
|
filesMatching(['META-INF/mods.toml']) {
|
||||||
expand replaceProperties
|
expand replaceProperties + [project: project]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,11 +147,3 @@ publishing {
|
||||||
tasks.withType(JavaCompile).configureEach {
|
tasks.withType(JavaCompile).configureEach {
|
||||||
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
||||||
}
|
}
|
||||||
|
|
||||||
// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
|
|
||||||
idea {
|
|
||||||
module {
|
|
||||||
downloadSources = true
|
|
||||||
downloadJavadoc = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
org.gradle.jvmargs=-Xmx1G
|
|
||||||
org.gradle.daemon=false
|
|
||||||
org.gradle.debug=false
|
org.gradle.debug=false
|
||||||
|
|
||||||
#read more on this at https://github.com/neoforged/NeoGradle/blob/NG_7.0/README.md#apply-parchment-mappings
|
#read more on this at https://github.com/neoforged/NeoGradle/blob/NG_7.0/README.md#apply-parchment-mappings
|
||||||
# you can also find the latest versions at: https://parchmentmc.org/docs/getting-started
|
# you can also find the latest versions at: https://parchmentmc.org/docs/getting-started
|
||||||
neogradle.subsystems.parchment.minecraftVersion=1.21
|
neogradle.subsystems.parchment.minecraftVersion=1.20.3
|
||||||
neogradle.subsystems.parchment.mappingsVersion=2024.07.28
|
neogradle.subsystems.parchment.mappingsVersion=2023.12.31
|
||||||
# Environment Properties
|
# Environment Properties
|
||||||
# You can find the latest versions here: https://projects.neoforged.net/neoforged/neoforge
|
# You can find the latest versions here: https://projects.neoforged.net/neoforged/neoforge
|
||||||
# The Minecraft version must agree with the Neo version to get a valid artifact
|
# The Minecraft version must agree with the Neo version to get a valid artifact
|
||||||
minecraft_version=1.21.1
|
minecraft_version=1.20.4
|
||||||
minecraft_version_range=[1.21.1,1.22)
|
# The Minecraft version range can use any release version of Minecraft as bounds.
|
||||||
|
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
|
||||||
|
# as they do not follow standard versioning conventions.
|
||||||
|
minecraft_version_range=[1.20.4,1.21)
|
||||||
# The Neo version must agree with the Minecraft version to get a valid artifact
|
# The Neo version must agree with the Minecraft version to get a valid artifact
|
||||||
neo_version=21.1.45
|
neo_version=20.4.198
|
||||||
# The Neo version range can use any version of Neo as bounds
|
# The Neo version range can use any version of Neo as bounds
|
||||||
neo_version_range=[21.1.0,)
|
neo_version_range=[20.4,)
|
||||||
# The loader version range can only use the major version of FML as bounds
|
# The loader version range can only use the major version of FML as bounds
|
||||||
loader_version_range=[4,)
|
loader_version_range=[2,)
|
||||||
|
|
||||||
jei_version=19.18.3.204
|
jei_version=17.3.0.48
|
||||||
# TODO what to do about curios being discontinued? try out https://www.curseforge.com/minecraft/mc-mods/adorned?
|
curios_version=7.2.0+1.20.4
|
||||||
# curios_version=7.2.0+1.20.4
|
patchouli_version=1.20.4-85-NEOFORGE
|
||||||
patchouli_version=1.21-87-NEOFORGE
|
|
||||||
|
|
||||||
## Mod Properties
|
## Mod Properties
|
||||||
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
|
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
|
||||||
|
@ -32,7 +32,7 @@ mod_name=NaturesAura
|
||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=MIT
|
mod_license=MIT
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=40.1
|
mod_version=40.2
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||||
# This should match the base package used for the mod sources.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
|
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,7 +1,6 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
|
@ -6,6 +6,7 @@ import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
|
||||||
import de.ellpeck.naturesaura.api.misc.ILevelData;
|
import de.ellpeck.naturesaura.api.misc.ILevelData;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl;
|
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl;
|
||||||
import de.ellpeck.naturesaura.chunk.AuraChunk;
|
import de.ellpeck.naturesaura.chunk.AuraChunk;
|
||||||
|
import de.ellpeck.naturesaura.compat.Compat;
|
||||||
import de.ellpeck.naturesaura.misc.LevelData;
|
import de.ellpeck.naturesaura.misc.LevelData;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
|
@ -14,15 +15,13 @@ import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.nbt.IntArrayTag;
|
|
||||||
import net.minecraft.nbt.Tag;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerChunkCache;
|
import net.minecraft.server.level.ServerChunkCache;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
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.ItemInteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.decoration.ItemFrame;
|
import net.minecraft.world.entity.decoration.ItemFrame;
|
||||||
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;
|
||||||
|
@ -38,7 +37,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.block.state.properties.Property;
|
import net.minecraft.world.level.block.state.properties.Property;
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
@ -47,6 +46,8 @@ import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
import net.neoforged.neoforge.capabilities.ICapabilityProvider;
|
import net.neoforged.neoforge.capabilities.ICapabilityProvider;
|
||||||
import net.neoforged.neoforge.items.IItemHandler;
|
import net.neoforged.neoforge.items.IItemHandler;
|
||||||
import net.neoforged.neoforge.items.IItemHandlerModifiable;
|
import net.neoforged.neoforge.items.IItemHandlerModifiable;
|
||||||
|
import top.theillusivec4.curios.api.CuriosApi;
|
||||||
|
import top.theillusivec4.curios.api.SlotResult;
|
||||||
|
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -115,7 +116,7 @@ public final class Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean areItemsEqual(ItemStack first, ItemStack second, boolean nbt) {
|
public static boolean areItemsEqual(ItemStack first, ItemStack second, boolean nbt) {
|
||||||
return nbt ? ItemStack.isSameItemSameComponents(first, second) : ItemStack.isSameItem(first, second);
|
return nbt ? ItemStack.isSameItemSameTags(first, second) : ItemStack.isSameItem(first, second);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
@ -131,34 +132,34 @@ public final class Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public static void renderWeirdBox(VertexConsumer buffer, float x, float y, float z, float width, float height, float depth, float r, float g, float b, float a) {
|
public static void renderWeirdBox(VertexConsumer buffer, double x, double y, double z, double width, double height, double depth, float r, float g, float b, float a) {
|
||||||
buffer.addVertex(x, y + height, z).setColor(r, g, b, a);
|
buffer.vertex(x, y + height, z).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x + width, y + height, z).setColor(r, g, b, a);
|
buffer.vertex(x + width, y + height, z).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x + width, y, z).setColor(r, g, b, a);
|
buffer.vertex(x + width, y, z).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x, y, z).setColor(r, g, b, a);
|
buffer.vertex(x, y, z).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x + width, y, z + depth).setColor(r, g, b, a);
|
buffer.vertex(x + width, y, z + depth).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x + width, y, z).setColor(r, g, b, a);
|
buffer.vertex(x + width, y, z).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x + width, y + height, z).setColor(r, g, b, a);
|
buffer.vertex(x + width, y + height, z).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x + width, y + height, z + depth).setColor(r, g, b, a);
|
buffer.vertex(x + width, y + height, z + depth).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x + width, y + height, z + depth).setColor(r, g, b, a);
|
buffer.vertex(x + width, y + height, z + depth).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x, y + height, z + depth).setColor(r, g, b, a);
|
buffer.vertex(x, y + height, z + depth).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x, y, z + depth).setColor(r, g, b, a);
|
buffer.vertex(x, y, z + depth).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x + width, y, z + depth).setColor(r, g, b, a);
|
buffer.vertex(x + width, y, z + depth).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x, y + height, z + depth).setColor(r, g, b, a);
|
buffer.vertex(x, y + height, z + depth).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x, y + height, z).setColor(r, g, b, a);
|
buffer.vertex(x, y + height, z).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x, y, z).setColor(r, g, b, a);
|
buffer.vertex(x, y, z).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x, y, z + depth).setColor(r, g, b, a);
|
buffer.vertex(x, y, z + depth).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x, y + height, z).setColor(r, g, b, a);
|
buffer.vertex(x, y + height, z).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x, y + height, z + depth).setColor(r, g, b, a);
|
buffer.vertex(x, y + height, z + depth).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x + width, y + height, z + depth).setColor(r, g, b, a);
|
buffer.vertex(x + width, y + height, z + depth).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x + width, y + height, z).setColor(r, g, b, a);
|
buffer.vertex(x + width, y + height, z).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x + width, y, z).setColor(r, g, b, a);
|
buffer.vertex(x + width, y, z).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x + width, y, z + depth).setColor(r, g, b, a);
|
buffer.vertex(x + width, y, z + depth).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x, y, z + depth).setColor(r, g, b, a);
|
buffer.vertex(x, y, z + depth).color(r, g, b, a).endVertex();
|
||||||
buffer.addVertex(x, y, z).setColor(r, g, b, a);
|
buffer.vertex(x, y, z).color(r, g, b, a).endVertex();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemInteractionResult putStackOnTile(Player player, InteractionHand hand, BlockPos pos, int slot, boolean sound) {
|
public static InteractionResult putStackOnTile(Player player, InteractionHand hand, BlockPos pos, int slot, boolean sound) {
|
||||||
var tile = player.level().getBlockEntity(pos);
|
var tile = player.level().getBlockEntity(pos);
|
||||||
if (tile instanceof BlockEntityImpl) {
|
if (tile instanceof BlockEntityImpl) {
|
||||||
var handler = (IItemHandlerModifiable) tile.getLevel().getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, null);
|
var handler = (IItemHandlerModifiable) tile.getLevel().getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, null);
|
||||||
|
@ -169,17 +170,17 @@ public final class Helper {
|
||||||
if (!ItemStack.matches(remain, handStack)) {
|
if (!ItemStack.matches(remain, handStack)) {
|
||||||
if (sound)
|
if (sound)
|
||||||
player.level().playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
|
player.level().playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
|
||||||
SoundEvents.ITEM_FRAME_ADD_ITEM, SoundSource.PLAYERS, 0.75F, 1F);
|
SoundEvents.ITEM_FRAME_ADD_ITEM, SoundSource.PLAYERS, 0.75F, 1F);
|
||||||
if (!player.level().isClientSide)
|
if (!player.level().isClientSide)
|
||||||
player.setItemInHand(hand, remain);
|
player.setItemInHand(hand, remain);
|
||||||
return ItemInteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!handler.getStackInSlot(slot).isEmpty()) {
|
if (!handler.getStackInSlot(slot).isEmpty()) {
|
||||||
if (sound)
|
if (sound)
|
||||||
player.level().playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
|
player.level().playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
|
||||||
SoundEvents.ITEM_FRAME_REMOVE_ITEM, SoundSource.PLAYERS, 0.75F, 1F);
|
SoundEvents.ITEM_FRAME_REMOVE_ITEM, SoundSource.PLAYERS, 0.75F, 1F);
|
||||||
if (!player.level().isClientSide) {
|
if (!player.level().isClientSide) {
|
||||||
var stack = handler.getStackInSlot(slot);
|
var stack = handler.getStackInSlot(slot);
|
||||||
if (!player.addItem(stack)) {
|
if (!player.addItem(stack)) {
|
||||||
|
@ -188,11 +189,11 @@ public final class Helper {
|
||||||
}
|
}
|
||||||
handler.setStackInSlot(slot, ItemStack.EMPTY);
|
handler.setStackInSlot(slot, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
return ItemInteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
return InteractionResult.CONSUME;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICapabilityProvider<ItemStack, Void, IAuraRecharge> makeRechargeProvider(boolean needsSelected) {
|
public static ICapabilityProvider<ItemStack, Void, IAuraRecharge> makeRechargeProvider(boolean needsSelected) {
|
||||||
|
@ -214,7 +215,7 @@ public final class Helper {
|
||||||
|
|
||||||
public static BlockState getStateFromString(String raw) {
|
public static BlockState getStateFromString(String raw) {
|
||||||
var split = raw.split("\\[");
|
var split = raw.split("\\[");
|
||||||
var block = BuiltInRegistries.BLOCK.get(ResourceLocation.parse(split[0]));
|
var block = BuiltInRegistries.BLOCK.get(new ResourceLocation(split[0]));
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
var state = block.defaultBlockState();
|
var state = block.defaultBlockState();
|
||||||
if (split.length > 1) {
|
if (split.length > 1) {
|
||||||
|
@ -283,7 +284,7 @@ public final class Helper {
|
||||||
for (var entry : clazz.getFields()) {
|
for (var entry : clazz.getFields()) {
|
||||||
if (!Modifier.isStatic(entry.getModifiers()))
|
if (!Modifier.isStatic(entry.getModifiers()))
|
||||||
continue;
|
continue;
|
||||||
var location = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, entry.getName().toLowerCase(Locale.ROOT));
|
var location = new ResourceLocation(NaturesAura.MOD_ID, entry.getName().toLowerCase(Locale.ROOT));
|
||||||
if (!registry.containsKey(location)) {
|
if (!registry.containsKey(location)) {
|
||||||
NaturesAura.LOGGER.fatal("Couldn't find entry named " + location + " in registry");
|
NaturesAura.LOGGER.fatal("Couldn't find entry named " + location + " in registry");
|
||||||
continue;
|
continue;
|
||||||
|
@ -297,15 +298,14 @@ public final class Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack getEquippedItem(Predicate<ItemStack> predicate, Player player, boolean hotbarOnly) {
|
public static ItemStack getEquippedItem(Predicate<ItemStack> predicate, Player player, boolean hotbarOnly) {
|
||||||
// TODO curios?
|
if (Compat.hasCompat("curios")) {
|
||||||
/* if (Compat.hasCompat("curios")) {
|
|
||||||
var inventory = CuriosApi.getCuriosInventory(player);
|
var inventory = CuriosApi.getCuriosInventory(player);
|
||||||
if (inventory.isPresent()) {
|
if (inventory.isPresent()) {
|
||||||
var stack = inventory.get().findFirstCurio(predicate).map(SlotResult::stack);
|
var stack = inventory.get().findFirstCurio(predicate).map(SlotResult::stack);
|
||||||
if (stack.isPresent())
|
if (stack.isPresent())
|
||||||
return stack.get();
|
return stack.get();
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
var invSize = hotbarOnly ? 9 : player.getInventory().getContainerSize();
|
var invSize = hotbarOnly ? 9 : player.getInventory().getContainerSize();
|
||||||
for (var i = 0; i < invSize; i++) {
|
for (var i = 0; i < invSize; i++) {
|
||||||
var slot = player.getInventory().getItem(i);
|
var slot = player.getInventory().getItem(i);
|
||||||
|
@ -368,13 +368,4 @@ public final class Helper {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BlockPos readBlockPos(Tag tag) {
|
|
||||||
if (tag instanceof IntArrayTag i) {
|
|
||||||
var arr = i.getAsIntArray();
|
|
||||||
if (arr.length == 3)
|
|
||||||
return new BlockPos(arr[0], arr[1], arr[2]);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,135 +54,135 @@ public final class ModConfig {
|
||||||
public ModConfig(ModConfigSpec.Builder builder) {
|
public ModConfig(ModConfigSpec.Builder builder) {
|
||||||
builder.push("general");
|
builder.push("general");
|
||||||
this.additionalBotanistPickaxeConversions = builder
|
this.additionalBotanistPickaxeConversions = builder
|
||||||
.comment("Additional conversion recipes for the Botanist's Pickaxe right click function. Each entry needs to be formatted as modid:input_block[prop1=value1,...]->modid:output_block[prop1=value1,...] where block state properties are optional, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).")
|
.comment("Additional conversion recipes for the Botanist's Pickaxe right click function. Each entry needs to be formatted as modid:input_block[prop1=value1,...]->modid:output_block[prop1=value1,...] where block state properties are optional, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".additionalBotanistPickaxeConversions")
|
.translation("config." + NaturesAura.MOD_ID + ".additionalBotanistPickaxeConversions")
|
||||||
.defineList("additionalBotanistPickaxeConversions", Collections.emptyList(), () -> "", s -> true);
|
.defineList("additionalBotanistPickaxeConversions", Collections.emptyList(), s -> true);
|
||||||
this.auraTypeOverrides = builder
|
this.auraTypeOverrides = builder
|
||||||
.comment("Additional dimensions that map to Aura types that should be present in them. This is useful if you have a modpack with custom dimensions that should have Aura act similarly to an existing dimension in them. Each entry needs to be formatted as dimension_name->aura_type, where aura_type can be any of naturesaura:overworld, naturesaura:nether and naturesaura:end, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).")
|
.comment("Additional dimensions that map to Aura types that should be present in them. This is useful if you have a modpack with custom dimensions that should have Aura act similarly to an existing dimension in them. Each entry needs to be formatted as dimension_name->aura_type, where aura_type can be any of naturesaura:overworld, naturesaura:nether and naturesaura:end, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".auraTypeOverrides")
|
.translation("config." + NaturesAura.MOD_ID + ".auraTypeOverrides")
|
||||||
.defineList("auraTypeOverrides", Collections.emptyList(), () -> "", s -> true);
|
.defineList("auraTypeOverrides", Collections.emptyList(), s -> true);
|
||||||
this.additionalOres = builder
|
this.additionalOres = builder
|
||||||
.comment("Additional blocks that are recognized as generatable ores for the passive ore generation effect. Each entry needs to be formatted as tag_name->oreWeight->dimension where a higher weight makes the ore more likely to spawn with 5000 being the weight of coal, the default ore with the highest weight, and dimension being any of overworld and nether, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).")
|
.comment("Additional blocks that are recognized as generatable ores for the passive ore generation effect. Each entry needs to be formatted as tag_name->oreWeight->dimension where a higher weight makes the ore more likely to spawn with 5000 being the weight of coal, the default ore with the highest weight, and dimension being any of overworld and nether, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".additionalOres")
|
.translation("config." + NaturesAura.MOD_ID + ".additionalOres")
|
||||||
.defineList("additionalOres", Collections.emptyList(), () -> "", s -> true);
|
.defineList("additionalOres", Collections.emptyList(), s -> true);
|
||||||
this.oreExceptions = builder
|
this.oreExceptions = builder
|
||||||
.comment("Blocks that are exempt from being recognized as generatable ores for the passive ore generation effect. Each entry needs to be formatted as modid:block[prop1=value1,...] where block state properties are optional, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).")
|
.comment("Blocks that are exempt from being recognized as generatable ores for the passive ore generation effect. Each entry needs to be formatted as modid:block[prop1=value1,...] where block state properties are optional, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".oreExceptions")
|
.translation("config." + NaturesAura.MOD_ID + ".oreExceptions")
|
||||||
.defineList("oreExceptions", Collections.emptyList(), () -> "", s -> true);
|
.defineList("oreExceptions", Collections.emptyList(), s -> true);
|
||||||
this.plantBoostExceptions = builder
|
this.plantBoostExceptions = builder
|
||||||
.comment("Blocks that are exept from being fertilized by the plant boost effect. Each entry needs to be formatted as modid:block, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).")
|
.comment("Blocks that are exept from being fertilized by the plant boost effect. Each entry needs to be formatted as modid:block, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".plantBoostExceptions")
|
.translation("config." + NaturesAura.MOD_ID + ".plantBoostExceptions")
|
||||||
.defineList("plantBoostExceptions", Collections.emptyList(), () -> "", s -> true);
|
.defineList("plantBoostExceptions", Collections.emptyList(), s -> true);
|
||||||
this.additionalProjectiles = builder
|
this.additionalProjectiles = builder
|
||||||
.comment("Additional projectile types that are allowed to be consumed by the projectile generator. Each entry needs to be formatted as entity_registry_name->aura_amount, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).")
|
.comment("Additional projectile types that are allowed to be consumed by the projectile generator. Each entry needs to be formatted as entity_registry_name->aura_amount, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".additionalProjectiles")
|
.translation("config." + NaturesAura.MOD_ID + ".additionalProjectiles")
|
||||||
.defineList("additionalProjectiles", Collections.emptyList(), () -> "", s -> true);
|
.defineList("additionalProjectiles", Collections.emptyList(), s -> true);
|
||||||
this.fieldCreatorRange = builder
|
this.fieldCreatorRange = builder
|
||||||
.comment("The amount of blocks that can be between two Aura Field Creators for them to be connectable and work together")
|
.comment("The amount of blocks that can be between two Aura Field Creators for them to be connectable and work together")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".fieldCreatorRange")
|
.translation("config." + NaturesAura.MOD_ID + ".fieldCreatorRange")
|
||||||
.define("fieldCreatorRange", 24);
|
.define("fieldCreatorRange", 24);
|
||||||
this.auraToRFRatio = builder
|
this.auraToRFRatio = builder
|
||||||
.comment("The Aura to RF ratio used by the RF converter, read as aura*ratio = rf")
|
.comment("The Aura to RF ratio used by the RF converter, read as aura*ratio = rf")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".auraToRFRatio")
|
.translation("config." + NaturesAura.MOD_ID + ".auraToRFRatio")
|
||||||
.define("auraToRFRatio", 0.05);
|
.define("auraToRFRatio", 0.05);
|
||||||
this.maxAnimalsAroundPowder = builder
|
this.maxAnimalsAroundPowder = builder
|
||||||
.comment("The maximum amount of animals that can be around the powder of fertility before it stops working")
|
.comment("The maximum amount of animals that can be around the powder of fertility before it stops working")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".maxAnimalsAroundPowder")
|
.translation("config." + NaturesAura.MOD_ID + ".maxAnimalsAroundPowder")
|
||||||
.define("maxAnimalsAroundPowder", 200);
|
.define("maxAnimalsAroundPowder", 200);
|
||||||
this.maxAuraSpreadRange = builder
|
this.maxAuraSpreadRange = builder
|
||||||
.comment("The maximum amount of blocks that aura can spread from an initial position before it starts fizzling out. It's recommended to lower this value on a large server to avoid lag caused by players chunk-loading their bases for extended amounts of time without an Aura Detector present.")
|
.comment("The maximum amount of blocks that aura can spread from an initial position before it starts fizzling out. It's recommended to lower this value on a large server to avoid lag caused by players chunk-loading their bases for extended amounts of time without an Aura Detector present.")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".maxAuraSpreadRange")
|
.translation("config." + NaturesAura.MOD_ID + ".maxAuraSpreadRange")
|
||||||
.define("maxAuraSpreadRange", 150);
|
.define("maxAuraSpreadRange", 150);
|
||||||
builder.pop();
|
builder.pop();
|
||||||
|
|
||||||
builder.push("features");
|
builder.push("features");
|
||||||
this.rfConverter = builder
|
this.rfConverter = builder
|
||||||
.comment("If the RF converter block should be enabled")
|
.comment("If the RF converter block should be enabled")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".rfConverter")
|
.translation("config." + NaturesAura.MOD_ID + ".rfConverter")
|
||||||
.define("rfConverter", true);
|
.define("rfConverter", true);
|
||||||
this.chunkLoader = builder
|
this.chunkLoader = builder
|
||||||
.comment("If the chunk loader block should be enabled")
|
.comment("If the chunk loader block should be enabled")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".chunkLoader")
|
.translation("config." + NaturesAura.MOD_ID + ".chunkLoader")
|
||||||
.define("chunkLoader", true);
|
.define("chunkLoader", true);
|
||||||
this.grassDieEffect = builder
|
this.grassDieEffect = builder
|
||||||
.comment("If the Aura Imbalance effect of grass and trees dying in the area if the Aura levels are too low should occur")
|
.comment("If the Aura Imbalance effect of grass and trees dying in the area if the Aura levels are too low should occur")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".grassDieEffect")
|
.translation("config." + NaturesAura.MOD_ID + ".grassDieEffect")
|
||||||
.define("grassDieEffect", true);
|
.define("grassDieEffect", true);
|
||||||
this.netherDecayEffect = builder
|
this.netherDecayEffect = builder
|
||||||
.comment("If the Aura Imbalance effect of nether blocks degrading in the area if the Aura levels are too low should occur")
|
.comment("If the Aura Imbalance effect of nether blocks degrading in the area if the Aura levels are too low should occur")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".netherDecayEffect")
|
.translation("config." + NaturesAura.MOD_ID + ".netherDecayEffect")
|
||||||
.define("netherDecayEffect", true);
|
.define("netherDecayEffect", true);
|
||||||
this.plantBoostEffect = builder
|
this.plantBoostEffect = builder
|
||||||
.comment("If the Aura Imbalance effect of plant growth being boosted if the Aura levels are high enough should occur")
|
.comment("If the Aura Imbalance effect of plant growth being boosted if the Aura levels are high enough should occur")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".plantBoostEffect")
|
.translation("config." + NaturesAura.MOD_ID + ".plantBoostEffect")
|
||||||
.define("plantBoostEffect", true);
|
.define("plantBoostEffect", true);
|
||||||
this.cacheRechargeEffect = builder
|
this.cacheRechargeEffect = builder
|
||||||
.comment("If the Aura Imbalance effect of aura containers in players' inventories being filled if the Aura levels are high enough should occur")
|
.comment("If the Aura Imbalance effect of aura containers in players' inventories being filled if the Aura levels are high enough should occur")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".cacheRechargeEffect")
|
.translation("config." + NaturesAura.MOD_ID + ".cacheRechargeEffect")
|
||||||
.define("cacheRechargeEffect", true);
|
.define("cacheRechargeEffect", true);
|
||||||
this.explosionEffect = builder
|
this.explosionEffect = builder
|
||||||
.comment("If the Aura Imbalance effect of explosions happening randomly if Aura levels are too low should occur")
|
.comment("If the Aura Imbalance effect of explosions happening randomly if Aura levels are too low should occur")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".explosionEffect")
|
.translation("config." + NaturesAura.MOD_ID + ".explosionEffect")
|
||||||
.define("explosionEffect", true);
|
.define("explosionEffect", true);
|
||||||
this.breathlessEffect = builder
|
this.breathlessEffect = builder
|
||||||
.comment("If the Aura Imbalance effect of breathlessness if Aura levels are too low should occur")
|
.comment("If the Aura Imbalance effect of breathlessness if Aura levels are too low should occur")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".breathlessEffect")
|
.translation("config." + NaturesAura.MOD_ID + ".breathlessEffect")
|
||||||
.define("breathlessEffect", true);
|
.define("breathlessEffect", true);
|
||||||
this.angerEffect = builder
|
this.angerEffect = builder
|
||||||
.comment("If the Aura Imbalance effect of passive mobs being angered if Aura levels are too low should occur")
|
.comment("If the Aura Imbalance effect of passive mobs being angered if Aura levels are too low should occur")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".angerEffect")
|
.translation("config." + NaturesAura.MOD_ID + ".angerEffect")
|
||||||
.define("angerEffect", true);
|
.define("angerEffect", true);
|
||||||
this.animalEffect = builder
|
this.animalEffect = builder
|
||||||
.comment("If the Aura Imbalance effect of farm animals being affected in positive ways if Aura levels are too high should occur")
|
.comment("If the Aura Imbalance effect of farm animals being affected in positive ways if Aura levels are too high should occur")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".animalEffect")
|
.translation("config." + NaturesAura.MOD_ID + ".animalEffect")
|
||||||
.define("animalEffect", true);
|
.define("animalEffect", true);
|
||||||
this.oreEffect = builder
|
this.oreEffect = builder
|
||||||
.comment("If the Aura Imbalance effect of ores spawning in the area if Aura levels are too high should occur")
|
.comment("If the Aura Imbalance effect of ores spawning in the area if Aura levels are too high should occur")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".oreEffect")
|
.translation("config." + NaturesAura.MOD_ID + ".oreEffect")
|
||||||
.define("oreEffect", true);
|
.define("oreEffect", true);
|
||||||
this.auraBlooms = builder
|
this.auraBlooms = builder
|
||||||
.comment("If Aura Blooms and Aura Cacti should generate in the level")
|
.comment("If Aura Blooms and Aura Cacti should generate in the level")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".auraBlooms")
|
.translation("config." + NaturesAura.MOD_ID + ".auraBlooms")
|
||||||
.define("auraBlooms", true);
|
.define("auraBlooms", true);
|
||||||
this.netherGrassEffect = builder
|
this.netherGrassEffect = builder
|
||||||
.comment("If the Aura Imbalance effect of grass growing on netherrack if the Aura levels are high enough should occur")
|
.comment("If the Aura Imbalance effect of grass growing on netherrack if the Aura levels are high enough should occur")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".netherGrassEffect")
|
.translation("config." + NaturesAura.MOD_ID + ".netherGrassEffect")
|
||||||
.define("netherGrassEffect", true);
|
.define("netherGrassEffect", true);
|
||||||
builder.pop();
|
builder.pop();
|
||||||
|
|
||||||
builder.push("client");
|
builder.push("client");
|
||||||
this.particleAmount = builder
|
this.particleAmount = builder
|
||||||
.comment("The percentage of particles that should be displayed, where 1 is 100% and 0 is 0%")
|
.comment("The percentage of particles that should be displayed, where 1 is 100% and 0 is 0%")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".particleAmount")
|
.translation("config." + NaturesAura.MOD_ID + ".particleAmount")
|
||||||
.defineInRange("particleAmount", 1D, 0, 1);
|
.defineInRange("particleAmount", 1D, 0, 1);
|
||||||
this.respectVanillaParticleSettings = builder
|
this.respectVanillaParticleSettings = builder
|
||||||
.comment("If particle spawning should respect the particle setting in Minecraft's video settings screen")
|
.comment("If particle spawning should respect the particle setting in Minecraft's video settings screen")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".respectVanillaParticleSettings")
|
.translation("config." + NaturesAura.MOD_ID + ".respectVanillaParticleSettings")
|
||||||
.define("respectVanillaParticleSettings", false);
|
.define("respectVanillaParticleSettings", false);
|
||||||
this.excessParticleAmount = builder
|
this.excessParticleAmount = builder
|
||||||
.comment("The percentage of particles that should spawn when there is an excess amount of Aura in the environment, where 1 is 100% and 0 is 0%")
|
.comment("The percentage of particles that should spawn when there is an excess amount of Aura in the environment, where 1 is 100% and 0 is 0%")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".excessParticleAmount")
|
.translation("config." + NaturesAura.MOD_ID + ".excessParticleAmount")
|
||||||
.define("excessParticleAmount", 1D);
|
.define("excessParticleAmount", 1D);
|
||||||
this.auraBarLocation = builder
|
this.auraBarLocation = builder
|
||||||
.comment("The location of the aura bar, where 0 is top left, 1 is top right, 2 is bottom left and 3 is bottom right")
|
.comment("The location of the aura bar, where 0 is top left, 1 is top right, 2 is bottom left and 3 is bottom right")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".auraBarLocation")
|
.translation("config." + NaturesAura.MOD_ID + ".auraBarLocation")
|
||||||
.defineInRange("auraBarLocation", 0, 0, 3);
|
.defineInRange("auraBarLocation", 0, 0, 3);
|
||||||
this.cacheBarLocation = builder
|
this.cacheBarLocation = builder
|
||||||
.comment("The location of the aura cache bar, where 0 is to the left of the hotbar and 1 is to the right of the hotbar")
|
.comment("The location of the aura cache bar, where 0 is to the left of the hotbar and 1 is to the right of the hotbar")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".cacheBarLocation")
|
.translation("config." + NaturesAura.MOD_ID + ".cacheBarLocation")
|
||||||
.defineInRange("cacheBarLocation", 0, 0, 1);
|
.defineInRange("cacheBarLocation", 0, 0, 1);
|
||||||
this.debugText = builder
|
this.debugText = builder
|
||||||
.comment("If debug information about Aura around the player should be displayed in the F3 debug menu if the player is in creative mode")
|
.comment("If debug information about Aura around the player should be displayed in the F3 debug menu if the player is in creative mode")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".debugText")
|
.translation("config." + NaturesAura.MOD_ID + ".debugText")
|
||||||
.define("debugText", true);
|
.define("debugText", true);
|
||||||
this.debugLevel = builder
|
this.debugLevel = builder
|
||||||
.comment("If, when the F3 debug menu is open and the player is in creative mode, every Aura spot should be highlighted in the level for debug purposes")
|
.comment("If, when the F3 debug menu is open and the player is in creative mode, every Aura spot should be highlighted in the level for debug purposes")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".debugLevel")
|
.translation("config." + NaturesAura.MOD_ID + ".debugLevel")
|
||||||
.define("debugLevel", false);
|
.define("debugLevel", false);
|
||||||
this.renderItemsOnPlayer = builder
|
this.renderItemsOnPlayer = builder
|
||||||
.comment("If certain equippable items, like the Environmental Eye, should be rendered on the player")
|
.comment("If certain equippable items, like the Environmental Eye, should be rendered on the player")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".renderItemsOnPlayer")
|
.translation("config." + NaturesAura.MOD_ID + ".renderItemsOnPlayer")
|
||||||
.define("renderItemsOnPlayer", true);
|
.define("renderItemsOnPlayer", true);
|
||||||
builder.pop();
|
builder.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,21 +191,21 @@ public final class ModConfig {
|
||||||
throw new IllegalStateException("Nature's Aura has detected that all negative Aura Imbalance effects are disabled in the config file. This is disallowed behavior. Please enable at least one negative effect.");
|
throw new IllegalStateException("Nature's Aura has detected that all negative Aura Imbalance effects are disabled in the config file. This is disallowed behavior. Please enable at least one negative effect.");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (var s : this.additionalBotanistPickaxeConversions.get()) {
|
for (String s : this.additionalBotanistPickaxeConversions.get()) {
|
||||||
var split = s.split("->");
|
var split = s.split("->");
|
||||||
NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.put(
|
NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.put(
|
||||||
Objects.requireNonNull(Helper.getStateFromString(split[0]), "state1"),
|
Objects.requireNonNull(Helper.getStateFromString(split[0]), "state1"),
|
||||||
Objects.requireNonNull(Helper.getStateFromString(split[1]), "state2"));
|
Objects.requireNonNull(Helper.getStateFromString(split[1]), "state2"));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
NaturesAura.LOGGER.warn("Error parsing additionalBotanistPickaxeConversions", e);
|
NaturesAura.LOGGER.warn("Error parsing additionalBotanistPickaxeConversions", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (var s : this.auraTypeOverrides.get()) {
|
for (String s : this.auraTypeOverrides.get()) {
|
||||||
var split = s.split("->");
|
var split = s.split("->");
|
||||||
var dim = ResourceLocation.parse(split[0]);
|
var dim = new ResourceLocation(split[0]);
|
||||||
var type = Objects.requireNonNull((BasicAuraType) NaturesAuraAPI.AURA_TYPES.get(ResourceLocation.parse(split[1])), "type");
|
var type = Objects.requireNonNull((BasicAuraType) NaturesAuraAPI.AURA_TYPES.get(new ResourceLocation(split[1])), "type");
|
||||||
type.addDimensionType(dim);
|
type.addDimensionType(dim);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -213,9 +213,9 @@ public final class ModConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (var s : this.additionalOres.get()) {
|
for (String s : this.additionalOres.get()) {
|
||||||
var split = s.split("->");
|
var split = s.split("->");
|
||||||
var ore = new WeightedOre(ResourceLocation.parse(split[0]), Integer.parseInt(split[1]));
|
var ore = new WeightedOre(new ResourceLocation(split[0]), Integer.parseInt(split[1]));
|
||||||
var dimension = split[2];
|
var dimension = split[2];
|
||||||
if ("nether".equalsIgnoreCase(dimension)) {
|
if ("nether".equalsIgnoreCase(dimension)) {
|
||||||
NaturesAuraAPI.NETHER_ORES.removeIf(o -> o.tag.equals(ore.tag));
|
NaturesAuraAPI.NETHER_ORES.removeIf(o -> o.tag.equals(ore.tag));
|
||||||
|
@ -232,7 +232,7 @@ public final class ModConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (var s : this.oreExceptions.get())
|
for (String s : this.oreExceptions.get())
|
||||||
OreSpawnEffect.SPAWN_EXCEPTIONS.add(Objects.requireNonNull(Helper.getStateFromString(s)));
|
OreSpawnEffect.SPAWN_EXCEPTIONS.add(Objects.requireNonNull(Helper.getStateFromString(s)));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
NaturesAura.LOGGER.warn("Error parsing oreExceptions", e);
|
NaturesAura.LOGGER.warn("Error parsing oreExceptions", e);
|
||||||
|
@ -240,7 +240,7 @@ public final class ModConfig {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (var s : this.plantBoostExceptions.get())
|
for (var s : this.plantBoostExceptions.get())
|
||||||
PlantBoostEffect.EXCEPTIONS.add(Objects.requireNonNull(BuiltInRegistries.BLOCK.get(ResourceLocation.parse(s))));
|
PlantBoostEffect.EXCEPTIONS.add(Objects.requireNonNull(BuiltInRegistries.BLOCK.get(new ResourceLocation(s))));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
NaturesAura.LOGGER.warn("Error parsing plantBoostExceptions", e);
|
NaturesAura.LOGGER.warn("Error parsing plantBoostExceptions", e);
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ public final class ModConfig {
|
||||||
try {
|
try {
|
||||||
for (var s : this.additionalProjectiles.get()) {
|
for (var s : this.additionalProjectiles.get()) {
|
||||||
var split = s.split("->");
|
var split = s.split("->");
|
||||||
var name = ResourceLocation.parse(split[0]);
|
var name = new ResourceLocation(split[0]);
|
||||||
var type = Objects.requireNonNull(BuiltInRegistries.ENTITY_TYPE.get(name));
|
var type = Objects.requireNonNull(BuiltInRegistries.ENTITY_TYPE.get(name));
|
||||||
var amount = Integer.parseInt(split[1]);
|
var amount = Integer.parseInt(split[1]);
|
||||||
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(type, amount);
|
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(type, amount);
|
||||||
|
|
|
@ -10,7 +10,8 @@ import de.ellpeck.naturesaura.proxy.ClientProxy;
|
||||||
import de.ellpeck.naturesaura.proxy.IProxy;
|
import de.ellpeck.naturesaura.proxy.IProxy;
|
||||||
import de.ellpeck.naturesaura.proxy.ServerProxy;
|
import de.ellpeck.naturesaura.proxy.ServerProxy;
|
||||||
import de.ellpeck.naturesaura.recipes.ModRecipes;
|
import de.ellpeck.naturesaura.recipes.ModRecipes;
|
||||||
import net.neoforged.fml.ModContainer;
|
import net.neoforged.bus.api.IEventBus;
|
||||||
|
import net.neoforged.fml.ModLoadingContext;
|
||||||
import net.neoforged.fml.common.Mod;
|
import net.neoforged.fml.common.Mod;
|
||||||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.neoforged.fml.loading.FMLEnvironment;
|
import net.neoforged.fml.loading.FMLEnvironment;
|
||||||
|
@ -29,16 +30,15 @@ public final class NaturesAura {
|
||||||
public static NaturesAura instance;
|
public static NaturesAura instance;
|
||||||
public static IProxy proxy;
|
public static IProxy proxy;
|
||||||
|
|
||||||
public NaturesAura(ModContainer container) {
|
public NaturesAura(IEventBus eventBus) {
|
||||||
NaturesAura.instance = this;
|
NaturesAura.instance = this;
|
||||||
NaturesAura.proxy = FMLEnvironment.dist.isClient() ? new ClientProxy() : new ServerProxy();
|
NaturesAura.proxy = FMLEnvironment.dist.isClient() ? new ClientProxy() : new ServerProxy();
|
||||||
|
|
||||||
container.getEventBus().addListener(this::setup);
|
eventBus.addListener(this::setup);
|
||||||
container.getEventBus().register(NaturesAura.proxy);
|
|
||||||
|
|
||||||
var builder = new ModConfigSpec.Builder();
|
var builder = new ModConfigSpec.Builder();
|
||||||
ModConfig.instance = new ModConfig(builder);
|
ModConfig.instance = new ModConfig(builder);
|
||||||
container.registerConfig(net.neoforged.fml.config.ModConfig.Type.COMMON, builder.build());
|
ModLoadingContext.get().registerConfig(net.neoforged.fml.config.ModConfig.Type.COMMON, builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setup(FMLCommonSetupEvent event) {
|
public void setup(FMLCommonSetupEvent event) {
|
||||||
|
|
|
@ -52,10 +52,10 @@ public final class NaturesAuraAPI {
|
||||||
* A map of all {@link IAuraType} instances which are types of Aura present in different types of levels. {@link BasicAuraType} instances can be easily registered using {@link BasicAuraType#register()}.
|
* A map of all {@link IAuraType} instances which are types of Aura present in different types of levels. {@link BasicAuraType} instances can be easily registered using {@link BasicAuraType#register()}.
|
||||||
*/
|
*/
|
||||||
public static final Map<ResourceLocation, IAuraType> AURA_TYPES = new HashMap<>();
|
public static final Map<ResourceLocation, IAuraType> AURA_TYPES = new HashMap<>();
|
||||||
public static final BasicAuraType TYPE_OVERWORLD = new BasicAuraType(ResourceLocation.fromNamespaceAndPath(NaturesAuraAPI.MOD_ID, "overworld"), Level.OVERWORLD, 0x89cc37, 0).register();
|
public static final BasicAuraType TYPE_OVERWORLD = new BasicAuraType(new ResourceLocation(NaturesAuraAPI.MOD_ID, "overworld"), Level.OVERWORLD, 0x89cc37, 0).register();
|
||||||
public static final BasicAuraType TYPE_NETHER = new BasicAuraType(ResourceLocation.fromNamespaceAndPath(NaturesAuraAPI.MOD_ID, "nether"), Level.NETHER, 0x871c0c, 0).register();
|
public static final BasicAuraType TYPE_NETHER = new BasicAuraType(new ResourceLocation(NaturesAuraAPI.MOD_ID, "nether"), Level.NETHER, 0x871c0c, 0).register();
|
||||||
public static final BasicAuraType TYPE_END = new BasicAuraType(ResourceLocation.fromNamespaceAndPath(NaturesAuraAPI.MOD_ID, "end"), Level.END, 0x302624, 0).register();
|
public static final BasicAuraType TYPE_END = new BasicAuraType(new ResourceLocation(NaturesAuraAPI.MOD_ID, "end"), Level.END, 0x302624, 0).register();
|
||||||
public static final BasicAuraType TYPE_OTHER = new BasicAuraType(ResourceLocation.fromNamespaceAndPath(NaturesAuraAPI.MOD_ID, "other"), null, 0x2fa8a0, Integer.MIN_VALUE).register();
|
public static final BasicAuraType TYPE_OTHER = new BasicAuraType(new ResourceLocation(NaturesAuraAPI.MOD_ID, "other"), null, 0x2fa8a0, Integer.MIN_VALUE).register();
|
||||||
/**
|
/**
|
||||||
* A map of all {@link IDrainSpotEffect} suppliers which are effects that happen passively at every spot that Aura has been drained from in the level. These effects include things like vegetational increase and natural decay. To register your own drain spot effects, just add a supplier for them to this map, and they will automatically be executed once a second for every drain spot currently loaded.
|
* A map of all {@link IDrainSpotEffect} suppliers which are effects that happen passively at every spot that Aura has been drained from in the level. These effects include things like vegetational increase and natural decay. To register your own drain spot effects, just add a supplier for them to this map, and they will automatically be executed once a second for every drain spot currently loaded.
|
||||||
*/
|
*/
|
||||||
|
@ -87,15 +87,15 @@ public final class NaturesAuraAPI {
|
||||||
/**
|
/**
|
||||||
* The capability for any item that stores Aura in the form of an {@link IAuraContainer}
|
* The capability for any item that stores Aura in the form of an {@link IAuraContainer}
|
||||||
*/
|
*/
|
||||||
public static final ItemCapability<IAuraContainer, Void> AURA_CONTAINER_ITEM_CAPABILITY = ItemCapability.createVoid(ResourceLocation.fromNamespaceAndPath(NaturesAuraAPI.MOD_ID, "aura_container_item"), IAuraContainer.class);
|
public static final ItemCapability<IAuraContainer, Void> AURA_CONTAINER_ITEM_CAPABILITY = ItemCapability.createVoid(new ResourceLocation(NaturesAuraAPI.MOD_ID, "aura_container_item"), IAuraContainer.class);
|
||||||
/**
|
/**
|
||||||
* The capability for any block that stores Aura in the form of an {@link IAuraContainer}
|
* The capability for any block that stores Aura in the form of an {@link IAuraContainer}
|
||||||
*/
|
*/
|
||||||
public static final BlockCapability<IAuraContainer, Direction> AURA_CONTAINER_BLOCK_CAPABILITY = BlockCapability.create(ResourceLocation.fromNamespaceAndPath(NaturesAuraAPI.MOD_ID, "aura_container_block"), IAuraContainer.class, Direction.class);
|
public static final BlockCapability<IAuraContainer, Direction> AURA_CONTAINER_BLOCK_CAPABILITY = BlockCapability.create(new ResourceLocation(NaturesAuraAPI.MOD_ID, "aura_container_block"), IAuraContainer.class, Direction.class);
|
||||||
/**
|
/**
|
||||||
* The capability for any item that can be recharged from an Aura storage container like the Aura Cache in the form of {@link IAuraRecharge} by a player holding it in their hand
|
* The capability for any item that can be recharged from an Aura storage container like the Aura Cache in the form of {@link IAuraRecharge} by a player holding it in their hand
|
||||||
*/
|
*/
|
||||||
public static final ItemCapability<IAuraRecharge, Void> AURA_RECHARGE_CAPABILITY = ItemCapability.createVoid(ResourceLocation.fromNamespaceAndPath(NaturesAuraAPI.MOD_ID, "aura_recharge"), IAuraRecharge.class);
|
public static final ItemCapability<IAuraRecharge, Void> AURA_RECHARGE_CAPABILITY = ItemCapability.createVoid(new ResourceLocation(NaturesAuraAPI.MOD_ID, "aura_recharge"), IAuraRecharge.class);
|
||||||
/**
|
/**
|
||||||
* The capability that any chunk in a level has to store Aura in it. As this is only applicable to chunks and all chunks in the level automatically get assigned this capability, using it directly is not necessary for addon developers. To retrieve this capability from any chunk, use the helper method {@link IAuraChunk#getAuraChunk(net.minecraft.world.level.Level, BlockPos)}.
|
* The capability that any chunk in a level has to store Aura in it. As this is only applicable to chunks and all chunks in the level automatically get assigned this capability, using it directly is not necessary for addon developers. To retrieve this capability from any chunk, use the helper method {@link IAuraChunk#getAuraChunk(net.minecraft.world.level.Level, BlockPos)}.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -9,6 +9,7 @@ import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
||||||
import de.ellpeck.naturesaura.reg.IModItem;
|
import de.ellpeck.naturesaura.reg.IModItem;
|
||||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.util.RandomSource;
|
import net.minecraft.util.RandomSource;
|
||||||
|
@ -18,9 +19,11 @@ import net.minecraft.world.level.LevelReader;
|
||||||
import net.minecraft.world.level.block.*;
|
import net.minecraft.world.level.block.*;
|
||||||
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.levelgen.feature.ConfiguredFeature;
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import net.neoforged.neoforge.event.EventHooks;
|
import net.neoforged.neoforge.event.EventHooks;
|
||||||
|
import net.neoforged.bus.api.Event;
|
||||||
|
|
||||||
public class BlockAncientSapling extends BushBlock implements BonemealableBlock, IModItem, ICustomBlockState, ICustomItemModel {
|
public class BlockAncientSapling extends BushBlock implements BonemealableBlock, IModItem, ICustomBlockState, ICustomItemModel {
|
||||||
|
|
||||||
|
@ -72,12 +75,9 @@ public class BlockAncientSapling extends BushBlock implements BonemealableBlock,
|
||||||
public void performBonemeal(ServerLevel level, RandomSource rand, BlockPos pos, BlockState state) {
|
public void performBonemeal(ServerLevel level, RandomSource rand, BlockPos pos, BlockState state) {
|
||||||
if (state.getValue(SaplingBlock.STAGE) == 0) {
|
if (state.getValue(SaplingBlock.STAGE) == 0) {
|
||||||
level.setBlock(pos, state.cycle(SaplingBlock.STAGE), 4);
|
level.setBlock(pos, state.cycle(SaplingBlock.STAGE), 4);
|
||||||
} else {
|
} else if (!EventHooks.blockGrowFeature(level, rand, pos, null).getResult().equals(Event.Result.DENY)) {
|
||||||
var event = EventHooks.fireBlockGrowFeature(level, rand, pos, null);
|
Registry<ConfiguredFeature<?, ?>> registry = level.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE);
|
||||||
if (!event.isCanceled()) {
|
registry.getHolderOrThrow(ModFeatures.Configured.ANCIENT_TREE).value().place(level, level.getChunkSource().getGenerator(), rand, pos);
|
||||||
var registry = level.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE);
|
|
||||||
registry.getHolderOrThrow(ModFeatures.Configured.ANCIENT_TREE).value().place(level, level.getChunkSource().getGenerator(), rand, pos);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,11 @@ import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
import net.neoforged.neoforge.event.entity.living.LivingDeathEvent;
|
import net.neoforged.neoforge.event.entity.living.*;
|
||||||
import net.neoforged.neoforge.event.entity.living.LivingDropsEvent;
|
|
||||||
import net.neoforged.neoforge.event.entity.living.LivingExperienceDropEvent;
|
import net.neoforged.neoforge.event.entity.living.LivingExperienceDropEvent;
|
||||||
import net.neoforged.neoforge.event.tick.EntityTickEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
|
import net.neoforged.neoforge.event.entity.living.LivingEvent;
|
||||||
|
|
||||||
public class BlockAnimalGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
public class BlockAnimalGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
||||||
|
|
||||||
|
@ -33,7 +32,7 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onLivingUpdate(EntityTickEvent event) {
|
public void onLivingUpdate(LivingEvent.LivingTickEvent event) {
|
||||||
var entity = event.getEntity();
|
var entity = event.getEntity();
|
||||||
if (entity.level().isClientSide || entity.level().getGameTime() % 40 != 0 || !(entity instanceof Animal) || entity instanceof Npc)
|
if (entity.level().isClientSide || entity.level().getGameTime() % 40 != 0 || !(entity instanceof Animal) || entity instanceof Npc)
|
||||||
return;
|
return;
|
||||||
|
@ -71,10 +70,10 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali
|
||||||
|
|
||||||
var genPos = gen.getBlockPos();
|
var genPos = gen.getBlockPos();
|
||||||
PacketHandler.sendToAllAround(entity.level(), pos, 32, new PacketParticles(
|
PacketHandler.sendToAllAround(entity.level(), pos, 32, new PacketParticles(
|
||||||
(float) entity.getX(), (float) entity.getY(), (float) entity.getZ(), PacketParticles.Type.ANIMAL_GEN_CONSUME,
|
(float) entity.getX(), (float) entity.getY(), (float) entity.getZ(), PacketParticles.Type.ANIMAL_GEN_CONSUME,
|
||||||
child ? 1 : 0,
|
child ? 1 : 0,
|
||||||
(int) (entity.getEyeHeight() * 10F),
|
(int) (entity.getEyeHeight() * 10F),
|
||||||
genPos.getX(), genPos.getY(), genPos.getZ()));
|
genPos.getX(), genPos.getY(), genPos.getZ()));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
@ -109,9 +108,8 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali
|
||||||
@Override
|
@Override
|
||||||
public void generateCustomBlockState(BlockStateGenerator generator) {
|
public void generateCustomBlockState(BlockStateGenerator generator) {
|
||||||
generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(),
|
generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(),
|
||||||
generator.modLoc("block/" + this.getBaseName()),
|
generator.modLoc("block/" + this.getBaseName()),
|
||||||
generator.modLoc("block/" + this.getBaseName() + "_bottom"),
|
generator.modLoc("block/" + this.getBaseName() + "_bottom"),
|
||||||
generator.modLoc("block/" + this.getBaseName() + "_top")));
|
generator.modLoc("block/" + this.getBaseName() + "_top")));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,8 @@ import net.minecraft.core.Direction;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.util.RandomSource;
|
import net.minecraft.util.RandomSource;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.ItemInteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.BlockGetter;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
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;
|
||||||
|
@ -53,8 +52,9 @@ public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockSt
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
|
@SuppressWarnings("deprecation")
|
||||||
return Helper.putStackOnTile(player, hand, pos, 0, true);
|
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult p_225533_6_) {
|
||||||
|
return Helper.putStackOnTile(player, handIn, pos, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -80,5 +80,4 @@ public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockSt
|
||||||
public void registerTESR() {
|
public void registerTESR() {
|
||||||
BlockEntityRenderers.register(ModBlockEntities.AURA_TIMER, RenderAuraTimer::new);
|
BlockEntityRenderers.register(ModBlockEntities.AURA_TIMER, RenderAuraTimer::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,11 +20,9 @@ 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.ItemInteractionResult;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.entity.vehicle.AbstractMinecart;
|
import net.minecraft.world.entity.vehicle.AbstractMinecart;
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.BlockGetter;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.BaseRailBlock;
|
import net.minecraft.world.level.block.BaseRailBlock;
|
||||||
|
@ -37,8 +35,10 @@ import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||||
import net.minecraft.world.level.block.state.properties.Property;
|
import net.minecraft.world.level.block.state.properties.Property;
|
||||||
import net.minecraft.world.level.block.state.properties.RailShape;
|
import net.minecraft.world.level.block.state.properties.RailShape;
|
||||||
import net.minecraft.world.level.levelgen.Heightmap;
|
import net.minecraft.world.level.levelgen.Heightmap;
|
||||||
import net.minecraft.world.level.portal.DimensionTransition;
|
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
|
import net.neoforged.neoforge.common.util.ITeleporter;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class BlockDimensionRail extends BaseRailBlock implements IModItem, ICustomBlockState, ICustomItemModel {
|
public class BlockDimensionRail extends BaseRailBlock implements IModItem, ICustomBlockState, ICustomItemModel {
|
||||||
|
|
||||||
|
@ -66,18 +66,20 @@ public class BlockDimensionRail extends BaseRailBlock implements IModItem, ICust
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
|
@SuppressWarnings("deprecation")
|
||||||
|
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||||
|
var stack = player.getItemInHand(hand);
|
||||||
if (stack.getItem() == ModItems.RANGE_VISUALIZER) {
|
if (stack.getItem() == ModItems.RANGE_VISUALIZER) {
|
||||||
if (!level.isClientSide) {
|
if (!levelIn.isClientSide) {
|
||||||
var goalPos = this.getGoalCoords(level, pos);
|
var goalPos = this.getGoalCoords(levelIn, pos);
|
||||||
var data = new CompoundTag();
|
var data = new CompoundTag();
|
||||||
data.putString("dim", this.goalDim.location().toString());
|
data.putString("dim", this.goalDim.location().toString());
|
||||||
data.putLong("pos", goalPos.asLong());
|
data.putLong("pos", goalPos.asLong());
|
||||||
PacketHandler.sendTo(player, new PacketClient(0, data));
|
PacketHandler.sendTo(player, new PacketClient(0, data));
|
||||||
}
|
}
|
||||||
return ItemInteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
return ItemInteractionResult.FAIL;
|
return InteractionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -93,9 +95,21 @@ public class BlockDimensionRail extends BaseRailBlock implements IModItem, ICust
|
||||||
PacketHandler.sendToAllAround(level, pos, 32, new PacketParticles((float) box.minX, (float) box.minY, (float) box.minZ, PacketParticles.Type.DIMENSION_RAIL, (int) ((box.maxX - box.minX) * 100F), (int) ((box.maxY - box.minY) * 100F), (int) ((box.maxZ - box.minZ) * 100F)));
|
PacketHandler.sendToAllAround(level, pos, 32, new PacketParticles((float) box.minX, (float) box.minY, (float) box.minZ, PacketParticles.Type.DIMENSION_RAIL, (int) ((box.maxX - box.minX) * 100F), (int) ((box.maxY - box.minY) * 100F), (int) ((box.maxZ - box.minZ) * 100F)));
|
||||||
level.playSound(null, pos, SoundEvents.ENDERMAN_TELEPORT, SoundSource.BLOCKS, 1F, 1F);
|
level.playSound(null, pos, SoundEvents.ENDERMAN_TELEPORT, SoundSource.BLOCKS, 1F, 1F);
|
||||||
|
|
||||||
// TODO test if this new dimension change works!
|
var goalCoords = this.getGoalCoords(level, pos);
|
||||||
var goalCoords = this.getGoalCoords(level, pos).getCenter();
|
cart.changeDimension(level.getServer().getLevel(this.goalDim), new ITeleporter() {
|
||||||
cart.changeDimension(new DimensionTransition(level.getServer().getLevel(this.goalDim), goalCoords, cart.getDeltaMovement(), cart.getYRot(), cart.getXRot(), DimensionTransition.PLAY_PORTAL_SOUND));
|
@Override
|
||||||
|
public Entity placeEntity(Entity entity, ServerLevel currentLevel, ServerLevel destLevel, float yaw, Function<Boolean, Entity> repositionEntity) {
|
||||||
|
// repositionEntity always causes a NPE because why wouldn't it, so this is a fixed copy
|
||||||
|
entity.level().getProfiler().popPush("reloading");
|
||||||
|
var result = entity.getType().create(destLevel);
|
||||||
|
if (result != null) {
|
||||||
|
result.restoreFrom(entity);
|
||||||
|
destLevel.addDuringTeleport(result);
|
||||||
|
result.moveTo(goalCoords, yaw, result.getXRot());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var spot = IAuraChunk.getHighestSpot(level, pos, 35, pos);
|
var spot = IAuraChunk.getHighestSpot(level, pos, 35, pos);
|
||||||
IAuraChunk.getAuraChunk(level, spot).drainAura(spot, 50000);
|
IAuraChunk.getAuraChunk(level, spot).drainAura(spot, 50000);
|
||||||
|
@ -163,5 +177,4 @@ public class BlockDimensionRail extends BaseRailBlock implements IModItem, ICust
|
||||||
public void generateCustomItemModel(ItemModelGenerator generator) {
|
public void generateCustomItemModel(ItemModelGenerator generator) {
|
||||||
generator.withExistingParent(this.getBaseName(), "item/generated").texture("layer0", "block/" + this.getBaseName());
|
generator.withExistingParent(this.getBaseName(), "item/generated").texture("layer0", "block/" + this.getBaseName());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
import net.neoforged.neoforge.event.entity.living.LivingEvent;
|
import net.neoforged.neoforge.event.entity.living.LivingEvent;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.neoforge.event.tick.EntityTickEvent;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -53,7 +52,7 @@ public class BlockEndFlower extends BushBlock implements IModItem, ICustomBlockS
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onDragonTick(EntityTickEvent.Pre event) {
|
public void onDragonTick(LivingEvent.LivingTickEvent event) {
|
||||||
var living = event.getEntity();
|
var living = event.getEntity();
|
||||||
if (living.level().isClientSide || !(living instanceof EnderDragon dragon))
|
if (living.level().isClientSide || !(living instanceof EnderDragon dragon))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -20,7 +20,6 @@ import net.minecraft.util.RandomSource;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.item.TooltipFlag;
|
import net.minecraft.world.item.TooltipFlag;
|
||||||
|
@ -86,9 +85,10 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) {
|
@SuppressWarnings("deprecation")
|
||||||
if (!level.isClientSide) {
|
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||||
var tile = level.getBlockEntity(pos);
|
if (!levelIn.isClientSide) {
|
||||||
|
var tile = levelIn.getBlockEntity(pos);
|
||||||
if (tile instanceof BlockEntityEnderCrate crate && crate.canOpen() && crate.canUseRightNow(2500)) {
|
if (tile instanceof BlockEntityEnderCrate crate && crate.canOpen() && crate.canUseRightNow(2500)) {
|
||||||
crate.drainAura(2500);
|
crate.drainAura(2500);
|
||||||
player.openMenu(crate, pos);
|
player.openMenu(crate, pos);
|
||||||
|
@ -98,8 +98,9 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
|
@OnlyIn(Dist.CLIENT)
|
||||||
BlockEnderCrate.addEnderNameInfo(stack, tooltipComponents);
|
public void appendHoverText(ItemStack stack, @Nullable BlockGetter levelIn, List<Component> tooltip, TooltipFlag flagIn) {
|
||||||
|
BlockEnderCrate.addEnderNameInfo(stack, tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -121,9 +122,9 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
|
||||||
@Override
|
@Override
|
||||||
public void generateCustomBlockState(BlockStateGenerator generator) {
|
public void generateCustomBlockState(BlockStateGenerator generator) {
|
||||||
generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(),
|
generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(),
|
||||||
generator.modLoc("block/" + this.getBaseName()),
|
generator.modLoc("block/" + this.getBaseName()),
|
||||||
generator.modLoc("block/" + this.getBaseName() + "_bottom"),
|
generator.modLoc("block/" + this.getBaseName() + "_bottom"),
|
||||||
generator.modLoc("block/" + this.getBaseName() + "_top")));
|
generator.modLoc("block/" + this.getBaseName() + "_top")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -9,9 +9,8 @@ import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.util.RandomSource;
|
import net.minecraft.util.RandomSource;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.ItemInteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.SoundType;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
@ -26,10 +25,11 @@ public class BlockFieldCreator extends BlockContainerImpl implements ICustomBloc
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
|
@SuppressWarnings("deprecation")
|
||||||
var tile = level.getBlockEntity(pos);
|
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult result) {
|
||||||
|
var tile = levelIn.getBlockEntity(pos);
|
||||||
if (tile instanceof BlockEntityFieldCreator) {
|
if (tile instanceof BlockEntityFieldCreator) {
|
||||||
if (!level.isClientSide) {
|
if (!levelIn.isClientSide) {
|
||||||
var key = NaturesAura.MOD_ID + ":field_creator_pos";
|
var key = NaturesAura.MOD_ID + ":field_creator_pos";
|
||||||
var compound = player.getPersistentData();
|
var compound = player.getPersistentData();
|
||||||
if (!player.isShiftKeyDown() && compound.contains(key)) {
|
if (!player.isShiftKeyDown() && compound.contains(key)) {
|
||||||
|
@ -37,7 +37,7 @@ public class BlockFieldCreator extends BlockContainerImpl implements ICustomBloc
|
||||||
var creator = (BlockEntityFieldCreator) tile;
|
var creator = (BlockEntityFieldCreator) tile;
|
||||||
if (!pos.equals(stored)) {
|
if (!pos.equals(stored)) {
|
||||||
if (creator.isCloseEnough(stored)) {
|
if (creator.isCloseEnough(stored)) {
|
||||||
var otherTile = level.getBlockEntity(stored);
|
var otherTile = levelIn.getBlockEntity(stored);
|
||||||
if (otherTile instanceof BlockEntityFieldCreator otherCreator) {
|
if (otherTile instanceof BlockEntityFieldCreator otherCreator) {
|
||||||
creator.connectionOffset = stored.subtract(pos);
|
creator.connectionOffset = stored.subtract(pos);
|
||||||
creator.isMain = true;
|
creator.isMain = true;
|
||||||
|
@ -60,9 +60,9 @@ public class BlockFieldCreator extends BlockContainerImpl implements ICustomBloc
|
||||||
player.displayClientMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".stored_pos"), true);
|
player.displayClientMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".stored_pos"), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ItemInteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
} else
|
} else
|
||||||
return ItemInteractionResult.FAIL;
|
return InteractionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -73,13 +73,13 @@ public class BlockFieldCreator extends BlockContainerImpl implements ICustomBloc
|
||||||
var connected = creator.getConnectedPos();
|
var connected = creator.getConnectedPos();
|
||||||
if (connected != null)
|
if (connected != null)
|
||||||
NaturesAuraAPI.instance().spawnParticleStream(
|
NaturesAuraAPI.instance().spawnParticleStream(
|
||||||
pos.getX() + 0.25F + rand.nextFloat() * 0.5F,
|
pos.getX() + 0.25F + rand.nextFloat() * 0.5F,
|
||||||
pos.getY() + 0.25F + rand.nextFloat() * 0.5F,
|
pos.getY() + 0.25F + rand.nextFloat() * 0.5F,
|
||||||
pos.getZ() + 0.25F + rand.nextFloat() * 0.5F,
|
pos.getZ() + 0.25F + rand.nextFloat() * 0.5F,
|
||||||
connected.getX() + 0.25F + rand.nextFloat() * 0.5F,
|
connected.getX() + 0.25F + rand.nextFloat() * 0.5F,
|
||||||
connected.getY() + 0.25F + rand.nextFloat() * 0.5F,
|
connected.getY() + 0.25F + rand.nextFloat() * 0.5F,
|
||||||
connected.getZ() + 0.25F + rand.nextFloat() * 0.5F,
|
connected.getZ() + 0.25F + rand.nextFloat() * 0.5F,
|
||||||
0.65F, 0x4245f4, 1F
|
0.65F, 0x4245f4, 1F
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||||
|
@ -17,6 +18,7 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.HopperBlock;
|
import net.minecraft.world.level.block.HopperBlock;
|
||||||
import net.minecraft.world.level.block.RenderShape;
|
import net.minecraft.world.level.block.RenderShape;
|
||||||
import net.minecraft.world.level.block.SoundType;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
|
import net.minecraft.world.level.block.entity.Hopper;
|
||||||
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.DirectionProperty;
|
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||||
|
@ -26,27 +28,27 @@ import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.Shapes;
|
import net.minecraft.world.phys.shapes.Shapes;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
|
import net.neoforged.neoforge.items.IItemHandler;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class BlockGratedChute extends BlockContainerImpl implements ICustomBlockState, ICustomItemModel {
|
public class BlockGratedChute extends BlockContainerImpl implements ICustomBlockState, ICustomItemModel {
|
||||||
|
|
||||||
public static final DirectionProperty FACING = HopperBlock.FACING;
|
public static final DirectionProperty FACING = HopperBlock.FACING;
|
||||||
private static final VoxelShape INSIDE = Block.box(2.0, 11.0, 2.0, 14.0, 16.0, 14.0);
|
|
||||||
private static final VoxelShape INPUT_SHAPE = Block.box(0.0D, 10.0D, 0.0D, 16.0D, 16.0D, 16.0D);
|
private static final VoxelShape INPUT_SHAPE = Block.box(0.0D, 10.0D, 0.0D, 16.0D, 16.0D, 16.0D);
|
||||||
private static final VoxelShape MIDDLE_SHAPE = Block.box(4.0D, 4.0D, 4.0D, 12.0D, 10.0D, 12.0D);
|
private static final VoxelShape MIDDLE_SHAPE = Block.box(4.0D, 4.0D, 4.0D, 12.0D, 10.0D, 12.0D);
|
||||||
private static final VoxelShape INPUT_MIDDLE_SHAPE = Shapes.or(BlockGratedChute.MIDDLE_SHAPE, BlockGratedChute.INPUT_SHAPE);
|
private static final VoxelShape INPUT_MIDDLE_SHAPE = Shapes.or(BlockGratedChute.MIDDLE_SHAPE, BlockGratedChute.INPUT_SHAPE);
|
||||||
private static final VoxelShape COMBINED_SHAPE = Shapes.join(BlockGratedChute.INPUT_MIDDLE_SHAPE, BlockGratedChute.INSIDE, BooleanOp.ONLY_FIRST);
|
private static final VoxelShape COMBINED_SHAPE = Shapes.join(BlockGratedChute.INPUT_MIDDLE_SHAPE, Hopper.INSIDE, BooleanOp.ONLY_FIRST);
|
||||||
private static final VoxelShape DOWN_SHAPE = Shapes.or(BlockGratedChute.COMBINED_SHAPE, Block.box(6.0D, 0.0D, 6.0D, 10.0D, 4.0D, 10.0D));
|
private static final VoxelShape DOWN_SHAPE = Shapes.or(BlockGratedChute.COMBINED_SHAPE, Block.box(6.0D, 0.0D, 6.0D, 10.0D, 4.0D, 10.0D));
|
||||||
private static final VoxelShape EAST_SHAPE = Shapes.or(BlockGratedChute.COMBINED_SHAPE, Block.box(12.0D, 4.0D, 6.0D, 16.0D, 8.0D, 10.0D));
|
private static final VoxelShape EAST_SHAPE = Shapes.or(BlockGratedChute.COMBINED_SHAPE, Block.box(12.0D, 4.0D, 6.0D, 16.0D, 8.0D, 10.0D));
|
||||||
private static final VoxelShape NORTH_SHAPE = Shapes.or(BlockGratedChute.COMBINED_SHAPE, Block.box(6.0D, 4.0D, 0.0D, 10.0D, 8.0D, 4.0D));
|
private static final VoxelShape NORTH_SHAPE = Shapes.or(BlockGratedChute.COMBINED_SHAPE, Block.box(6.0D, 4.0D, 0.0D, 10.0D, 8.0D, 4.0D));
|
||||||
private static final VoxelShape SOUTH_SHAPE = Shapes.or(BlockGratedChute.COMBINED_SHAPE, Block.box(6.0D, 4.0D, 12.0D, 10.0D, 8.0D, 16.0D));
|
private static final VoxelShape SOUTH_SHAPE = Shapes.or(BlockGratedChute.COMBINED_SHAPE, Block.box(6.0D, 4.0D, 12.0D, 10.0D, 8.0D, 16.0D));
|
||||||
private static final VoxelShape WEST_SHAPE = Shapes.or(BlockGratedChute.COMBINED_SHAPE, Block.box(0.0D, 4.0D, 6.0D, 4.0D, 8.0D, 10.0D));
|
private static final VoxelShape WEST_SHAPE = Shapes.or(BlockGratedChute.COMBINED_SHAPE, Block.box(0.0D, 4.0D, 6.0D, 4.0D, 8.0D, 10.0D));
|
||||||
private static final VoxelShape DOWN_RAYTRACE_SHAPE = BlockGratedChute.INSIDE;
|
private static final VoxelShape DOWN_RAYTRACE_SHAPE = Hopper.INSIDE;
|
||||||
private static final VoxelShape EAST_RAYTRACE_SHAPE = Shapes.or(BlockGratedChute.INSIDE, Block.box(12.0D, 8.0D, 6.0D, 16.0D, 10.0D, 10.0D));
|
private static final VoxelShape EAST_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, Block.box(12.0D, 8.0D, 6.0D, 16.0D, 10.0D, 10.0D));
|
||||||
private static final VoxelShape NORTH_RAYTRACE_SHAPE = Shapes.or(BlockGratedChute.INSIDE, Block.box(6.0D, 8.0D, 0.0D, 10.0D, 10.0D, 4.0D));
|
private static final VoxelShape NORTH_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, Block.box(6.0D, 8.0D, 0.0D, 10.0D, 10.0D, 4.0D));
|
||||||
private static final VoxelShape SOUTH_RAYTRACE_SHAPE = Shapes.or(BlockGratedChute.INSIDE, Block.box(6.0D, 8.0D, 12.0D, 10.0D, 10.0D, 16.0D));
|
private static final VoxelShape SOUTH_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, Block.box(6.0D, 8.0D, 12.0D, 10.0D, 10.0D, 16.0D));
|
||||||
private static final VoxelShape WEST_RAYTRACE_SHAPE = Shapes.or(BlockGratedChute.INSIDE, Block.box(0.0D, 8.0D, 6.0D, 4.0D, 10.0D, 10.0D));
|
private static final VoxelShape WEST_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, Block.box(0.0D, 8.0D, 6.0D, 4.0D, 10.0D, 10.0D));
|
||||||
|
|
||||||
public BlockGratedChute() {
|
public BlockGratedChute() {
|
||||||
super("grated_chute", BlockEntityGratedChute.class, Properties.of().strength(3.0F, 8.0F).sound(SoundType.METAL));
|
super("grated_chute", BlockEntityGratedChute.class, Properties.of().strength(3.0F, 8.0F).sound(SoundType.METAL));
|
||||||
|
@ -79,16 +81,17 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock
|
||||||
case SOUTH -> BlockGratedChute.SOUTH_RAYTRACE_SHAPE;
|
case SOUTH -> BlockGratedChute.SOUTH_RAYTRACE_SHAPE;
|
||||||
case WEST -> BlockGratedChute.WEST_RAYTRACE_SHAPE;
|
case WEST -> BlockGratedChute.WEST_RAYTRACE_SHAPE;
|
||||||
case EAST -> BlockGratedChute.EAST_RAYTRACE_SHAPE;
|
case EAST -> BlockGratedChute.EAST_RAYTRACE_SHAPE;
|
||||||
default -> BlockGratedChute.INSIDE;
|
default -> Hopper.INSIDE;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) {
|
@SuppressWarnings("deprecation")
|
||||||
var tile = level.getBlockEntity(pos);
|
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||||
|
var tile = levelIn.getBlockEntity(pos);
|
||||||
if (!(tile instanceof BlockEntityGratedChute chute))
|
if (!(tile instanceof BlockEntityGratedChute chute))
|
||||||
return InteractionResult.FAIL;
|
return InteractionResult.FAIL;
|
||||||
if (!level.isClientSide) {
|
if (!levelIn.isClientSide) {
|
||||||
chute.isBlacklist = !chute.isBlacklist;
|
chute.isBlacklist = !chute.isBlacklist;
|
||||||
chute.sendToClients();
|
chute.sendToClients();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import de.ellpeck.naturesaura.blocks.tiles.BlockEntityItemDistributor;
|
||||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
@ -18,13 +19,14 @@ public class BlockItemDistributor extends BlockContainerImpl implements ICustomB
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) {
|
@SuppressWarnings("deprecation")
|
||||||
|
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||||
if (!player.isShiftKeyDown())
|
if (!player.isShiftKeyDown())
|
||||||
return InteractionResult.FAIL;
|
return InteractionResult.FAIL;
|
||||||
var tile = level.getBlockEntity(pos);
|
var tile = levelIn.getBlockEntity(pos);
|
||||||
if (!(tile instanceof BlockEntityItemDistributor))
|
if (!(tile instanceof BlockEntityItemDistributor))
|
||||||
return InteractionResult.FAIL;
|
return InteractionResult.FAIL;
|
||||||
if (!level.isClientSide) {
|
if (!levelIn.isClientSide) {
|
||||||
var distributor = (BlockEntityItemDistributor) tile;
|
var distributor = (BlockEntityItemDistributor) tile;
|
||||||
distributor.isRandomMode = !distributor.isRandomMode;
|
distributor.isRandomMode = !distributor.isRandomMode;
|
||||||
distributor.sendToClients();
|
distributor.sendToClients();
|
||||||
|
@ -35,9 +37,8 @@ public class BlockItemDistributor extends BlockContainerImpl implements ICustomB
|
||||||
@Override
|
@Override
|
||||||
public void generateCustomBlockState(BlockStateGenerator generator) {
|
public void generateCustomBlockState(BlockStateGenerator generator) {
|
||||||
generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(),
|
generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(),
|
||||||
generator.modLoc("block/" + this.getBaseName()),
|
generator.modLoc("block/" + this.getBaseName()),
|
||||||
generator.modLoc("block/" + this.getBaseName() + "_bottom"),
|
generator.modLoc("block/" + this.getBaseName() + "_bottom"),
|
||||||
generator.modLoc("block/" + this.getBaseName() + "_top")));
|
generator.modLoc("block/" + this.getBaseName() + "_top")));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,8 @@ import de.ellpeck.naturesaura.reg.ITESRProvider;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.ItemInteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.BlockGetter;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
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;
|
||||||
|
@ -42,8 +41,9 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
|
@SuppressWarnings("deprecation")
|
||||||
return Helper.putStackOnTile(player, hand, pos, 0, true);
|
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||||
|
return Helper.putStackOnTile(player, handIn, pos, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraft.world.phys.AABB;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
import net.neoforged.neoforge.event.level.BlockGrowFeatureEvent;
|
import net.neoforged.neoforge.event.level.SaplingGrowTreeEvent;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
|
|
||||||
public class BlockOakGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
public class BlockOakGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
||||||
|
@ -31,11 +31,11 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onTreeGrow(BlockGrowFeatureEvent event) {
|
public void onTreeGrow(SaplingGrowTreeEvent event) {
|
||||||
var level = event.getLevel();
|
var level = event.getLevel();
|
||||||
var pos = event.getPos();
|
var pos = event.getPos();
|
||||||
if (level instanceof Level && !level.isClientSide() && IAuraType.forLevel((Level) level).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD)
|
if (level instanceof Level && !level.isClientSide() && IAuraType.forLevel((Level) level).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD)
|
||||||
&& level.getBlockState(pos).getBlock() instanceof SaplingBlock) {
|
&& level.getBlockState(pos).getBlock() instanceof SaplingBlock) {
|
||||||
Helper.getBlockEntitiesInArea(level, pos, 10, tile -> {
|
Helper.getBlockEntitiesInArea(level, pos, 10, tile -> {
|
||||||
if (!(tile instanceof BlockEntityOakGenerator oak))
|
if (!(tile instanceof BlockEntityOakGenerator oak))
|
||||||
return false;
|
return false;
|
||||||
|
@ -64,13 +64,13 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab
|
||||||
@Override
|
@Override
|
||||||
public void generateCustomBlockState(BlockStateGenerator generator) {
|
public void generateCustomBlockState(BlockStateGenerator generator) {
|
||||||
generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(),
|
generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(),
|
||||||
generator.modLoc("block/" + this.getBaseName()),
|
generator.modLoc("block/" + this.getBaseName()),
|
||||||
generator.modLoc("block/" + this.getBaseName() + "_bottom"),
|
generator.modLoc("block/" + this.getBaseName() + "_bottom"),
|
||||||
generator.modLoc("block/" + this.getBaseName() + "_top")));
|
generator.modLoc("block/" + this.getBaseName() + "_top")));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ResourceKey<ConfiguredFeature<?, ?>> getReplacement(Holder<ConfiguredFeature<?, ?>> holder) {
|
private static ResourceKey<ConfiguredFeature<?, ?>> getReplacement(Holder<ConfiguredFeature<?, ?>> holder) {
|
||||||
if (holder == null || !holder.unwrapKey().isPresent())
|
if(holder == null || !holder.unwrapKey().isPresent())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
ResourceKey<ConfiguredFeature<?, ?>> feature = holder.unwrapKey().get();
|
ResourceKey<ConfiguredFeature<?, ?>> feature = holder.unwrapKey().get();
|
||||||
|
@ -86,5 +86,4 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,8 @@ import de.ellpeck.naturesaura.reg.ITESRProvider;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.ItemInteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.BlockGetter;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.SoundType;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
|
@ -36,8 +35,9 @@ public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
|
@SuppressWarnings("deprecation")
|
||||||
return Helper.putStackOnTile(player, hand, pos, 0, true);
|
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||||
|
return Helper.putStackOnTile(player, handIn, pos, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,5 +55,4 @@ public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvi
|
||||||
public void registerTESR() {
|
public void registerTESR() {
|
||||||
BlockEntityRenderers.register(ModBlockEntities.OFFERING_TABLE, RenderOfferingTable::new);
|
BlockEntityRenderers.register(ModBlockEntities.OFFERING_TABLE, RenderOfferingTable::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,8 @@ import net.minecraft.world.phys.AABB;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
|
import net.neoforged.neoforge.event.entity.player.EntityItemPickupEvent;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.neoforge.common.util.TriState;
|
|
||||||
import net.neoforged.neoforge.event.entity.player.ItemEntityPickupEvent;
|
|
||||||
|
|
||||||
public class BlockPickupStopper extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
public class BlockPickupStopper extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
||||||
|
|
||||||
|
@ -27,10 +26,10 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onPickup(ItemEntityPickupEvent.Pre event) {
|
public void onPickup(EntityItemPickupEvent event) {
|
||||||
var player = event.getPlayer();
|
var player = event.getEntity();
|
||||||
if (player != null && !player.isShiftKeyDown()) {
|
if (player != null && !player.isShiftKeyDown()) {
|
||||||
var item = event.getItemEntity();
|
var item = event.getItem();
|
||||||
var pos = item.blockPosition();
|
var pos = item.blockPosition();
|
||||||
Helper.getBlockEntitiesInArea(item.level(), pos, 8, tile -> {
|
Helper.getBlockEntitiesInArea(item.level(), pos, 8, tile -> {
|
||||||
if (!(tile instanceof BlockEntityPickupStopper stopper))
|
if (!(tile instanceof BlockEntityPickupStopper stopper))
|
||||||
|
@ -42,11 +41,11 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza
|
||||||
if (!new AABB(stopperPos).inflate(radius).intersects(item.getBoundingBox()))
|
if (!new AABB(stopperPos).inflate(radius).intersects(item.getBoundingBox()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
event.setCanPickup(TriState.FALSE);
|
event.setCanceled(true);
|
||||||
|
|
||||||
if (item.level().getGameTime() % 3 == 0)
|
if (item.level().getGameTime() % 3 == 0)
|
||||||
PacketHandler.sendToAllAround(item.level(), pos, 32,
|
PacketHandler.sendToAllAround(item.level(), pos, 32,
|
||||||
new PacketParticles((float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.PICKUP_STOPPER));
|
new PacketParticles((float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.PICKUP_STOPPER));
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -73,9 +72,8 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza
|
||||||
@Override
|
@Override
|
||||||
public void generateCustomBlockState(BlockStateGenerator generator) {
|
public void generateCustomBlockState(BlockStateGenerator generator) {
|
||||||
generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(),
|
generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(),
|
||||||
generator.modLoc("block/" + this.getBaseName()),
|
generator.modLoc("block/" + this.getBaseName()),
|
||||||
generator.modLoc("block/" + this.getBaseName() + "_top"),
|
generator.modLoc("block/" + this.getBaseName() + "_top"),
|
||||||
generator.modLoc("block/" + this.getBaseName() + "_top")));
|
generator.modLoc("block/" + this.getBaseName() + "_top")));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,25 +10,25 @@ import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
||||||
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||||
import net.minecraft.core.dispenser.BlockSource;
|
import net.minecraft.core.Position;
|
||||||
import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
|
import net.minecraft.core.dispenser.AbstractProjectileDispenseBehavior;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.world.entity.projectile.AbstractArrow;
|
import net.minecraft.world.entity.projectile.AbstractArrow;
|
||||||
|
import net.minecraft.world.entity.projectile.Projectile;
|
||||||
import net.minecraft.world.entity.projectile.ThrownEnderpearl;
|
import net.minecraft.world.entity.projectile.ThrownEnderpearl;
|
||||||
import net.minecraft.world.entity.projectile.ThrownTrident;
|
import net.minecraft.world.entity.projectile.ThrownTrident;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.item.ProjectileItem.DispenseConfig;
|
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.DispenserBlock;
|
import net.minecraft.world.level.block.DispenserBlock;
|
||||||
import net.minecraft.world.level.block.SoundType;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
|
||||||
import net.neoforged.fml.util.ObfuscationReflectionHelper;
|
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
import net.neoforged.neoforge.event.entity.ProjectileImpactEvent;
|
import net.neoforged.neoforge.event.entity.ProjectileImpactEvent;
|
||||||
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
|
import net.neoforged.fml.util.ObfuscationReflectionHelper;
|
||||||
|
|
||||||
public class BlockProjectileGenerator extends BlockContainerImpl implements ITESRProvider<BlockEntityProjectileGenerator>, ICustomBlockState {
|
public class BlockProjectileGenerator extends BlockContainerImpl implements ITESRProvider<BlockEntityProjectileGenerator>, ICustomBlockState {
|
||||||
|
|
||||||
|
@ -36,34 +36,23 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
|
||||||
super("projectile_generator", BlockEntityProjectileGenerator.class, Properties.of().strength(2.5F).sound(SoundType.STONE));
|
super("projectile_generator", BlockEntityProjectileGenerator.class, Properties.of().strength(2.5F).sound(SoundType.STONE));
|
||||||
|
|
||||||
NeoForge.EVENT_BUS.register(this);
|
NeoForge.EVENT_BUS.register(this);
|
||||||
DispenserBlock.registerBehavior(Items.ENDER_PEARL, new DefaultDispenseItemBehavior() {
|
DispenserBlock.registerBehavior(Items.ENDER_PEARL, new AbstractProjectileDispenseBehavior() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ItemStack execute(BlockSource blockSource, ItemStack item) {
|
protected Projectile getProjectile(Level levelIn, Position position, ItemStack stackIn) {
|
||||||
Level level = blockSource.level();
|
var ret = new ThrownEnderpearl(EntityType.ENDER_PEARL, levelIn);
|
||||||
var direction = blockSource.state().getValue(DispenserBlock.FACING);
|
ret.setPos(position.x(), position.y(), position.z());
|
||||||
var position = DispenseConfig.DEFAULT.positionFunction().getDispensePosition(blockSource, direction);
|
return ret;
|
||||||
var projectile = new ThrownEnderpearl(EntityType.ENDER_PEARL, level);
|
|
||||||
projectile.setPos(position.x(), position.y(), position.z());
|
|
||||||
projectile.shoot(direction.getStepX(), direction.getStepY(), direction.getStepZ(), DispenseConfig.DEFAULT.power(), DispenseConfig.DEFAULT.uncertainty());
|
|
||||||
level.addFreshEntity(projectile);
|
|
||||||
item.shrink(1);
|
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
DispenserBlock.registerBehavior(Items.TRIDENT, new DefaultDispenseItemBehavior() {
|
DispenserBlock.registerBehavior(Items.TRIDENT, new AbstractProjectileDispenseBehavior() {
|
||||||
@Override
|
@Override
|
||||||
protected ItemStack execute(BlockSource blockSource, ItemStack item) {
|
protected Projectile getProjectile(Level levelIn, Position position, ItemStack stackIn) {
|
||||||
Level level = blockSource.level();
|
var ret = new ThrownTrident(EntityType.TRIDENT, levelIn);
|
||||||
var direction = blockSource.state().getValue(DispenserBlock.FACING);
|
ret.setPos(position.x(), position.y(), position.z());
|
||||||
var position = DispenseConfig.DEFAULT.positionFunction().getDispensePosition(blockSource, direction);
|
ObfuscationReflectionHelper.setPrivateValue(ThrownTrident.class, ret, stackIn.copy(), "pickupItemStack");
|
||||||
var projectile = new ThrownTrident(EntityType.TRIDENT, level);
|
ret.pickup = AbstractArrow.Pickup.ALLOWED;
|
||||||
ObfuscationReflectionHelper.setPrivateValue(ThrownTrident.class, projectile, item.copy(), "pickupItemStack");
|
return ret;
|
||||||
projectile.pickup = AbstractArrow.Pickup.ALLOWED;
|
|
||||||
projectile.setPos(position.x(), position.y(), position.z());
|
|
||||||
projectile.shoot(direction.getStepX(), direction.getStepY(), direction.getStepZ(), DispenseConfig.DEFAULT.power(), DispenseConfig.DEFAULT.uncertainty());
|
|
||||||
level.addFreshEntity(projectile);
|
|
||||||
item.shrink(1);
|
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -92,7 +81,7 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
|
||||||
generator.generateAura(amount);
|
generator.generateAura(amount);
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(entity.level(), pos, 32,
|
PacketHandler.sendToAllAround(entity.level(), pos, 32,
|
||||||
new PacketParticles((float) entity.getX(), (float) entity.getY(), (float) entity.getZ(), PacketParticles.Type.PROJECTILE_GEN, pos.getX(), pos.getY(), pos.getZ()));
|
new PacketParticles((float) entity.getX(), (float) entity.getY(), (float) entity.getZ(), PacketParticles.Type.PROJECTILE_GEN, pos.getX(), pos.getY(), pos.getZ()));
|
||||||
entity.level().playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENDER_EYE_LAUNCH, SoundSource.BLOCKS, 0.8F, 1F);
|
entity.level().playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENDER_EYE_LAUNCH, SoundSource.BLOCKS, 0.8F, 1F);
|
||||||
|
|
||||||
generator.nextSide = generator.nextSide.getClockWise();
|
generator.nextSide = generator.nextSide.getClockWise();
|
||||||
|
@ -105,14 +94,13 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
|
||||||
@Override
|
@Override
|
||||||
public void generateCustomBlockState(BlockStateGenerator generator) {
|
public void generateCustomBlockState(BlockStateGenerator generator) {
|
||||||
generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(),
|
generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(),
|
||||||
generator.modLoc("block/" + this.getBaseName()),
|
generator.modLoc("block/" + this.getBaseName()),
|
||||||
generator.modLoc("block/" + this.getBaseName() + "_top"),
|
generator.modLoc("block/" + this.getBaseName() + "_top"),
|
||||||
generator.modLoc("block/" + this.getBaseName() + "_top")));
|
generator.modLoc("block/" + this.getBaseName() + "_top")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerTESR() {
|
public void registerTESR() {
|
||||||
BlockEntityRenderers.register(ModBlockEntities.PROJECTILE_GENERATOR, RenderProjectileGenerator::new);
|
BlockEntityRenderers.register(ModBlockEntities.PROJECTILE_GENERATOR, RenderProjectileGenerator::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,10 @@ import net.minecraft.world.phys.shapes.Shapes;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
import net.neoforged.neoforge.event.entity.living.MobSpawnEvent;
|
import net.neoforged.neoforge.event.entity.living.MobSpawnEvent;
|
||||||
|
import net.neoforged.bus.api.Event;
|
||||||
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
|
|
||||||
public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
||||||
|
|
||||||
|
@ -68,10 +69,10 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
|
||||||
IAuraChunk.getAuraChunk(level, spot).drainAura(spot, amountToUse);
|
IAuraChunk.getAuraChunk(level, spot).drainAura(spot, amountToUse);
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(level, lampPos, 32,
|
PacketHandler.sendToAllAround(level, lampPos, 32,
|
||||||
new PacketParticles(lampPos.getX(), lampPos.getY(), lampPos.getZ(), PacketParticles.Type.SPAWN_LAMP));
|
new PacketParticles(lampPos.getX(), lampPos.getY(), lampPos.getZ(), PacketParticles.Type.SPAWN_LAMP));
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setResult(MobSpawnEvent.PositionCheck.Result.FAIL);
|
event.setResult(Event.Result.DENY);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,5 +105,4 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
|
||||||
public void generateCustomBlockState(BlockStateGenerator generator) {
|
public void generateCustomBlockState(BlockStateGenerator generator) {
|
||||||
generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName())));
|
generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName())));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,14 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.StairBlock;
|
import net.minecraft.world.level.block.StairBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class BlockStairsNA extends StairBlock implements IModItem, ICustomBlockState {
|
public class BlockStairsNA extends StairBlock implements IModItem, ICustomBlockState {
|
||||||
|
|
||||||
public final String textureName;
|
public final String textureName;
|
||||||
private final String baseName;
|
private final String baseName;
|
||||||
|
|
||||||
public BlockStairsNA(String baseName, String textureName, BlockState modelState, Block.Properties properties) {
|
public BlockStairsNA(String baseName, String textureName, Supplier<BlockState> modelState, Block.Properties properties) {
|
||||||
super(modelState, properties.dynamicShape());
|
super(modelState, properties.dynamicShape());
|
||||||
this.baseName = baseName;
|
this.baseName = baseName;
|
||||||
this.textureName = textureName;
|
this.textureName = textureName;
|
||||||
|
@ -29,5 +31,4 @@ public class BlockStairsNA extends StairBlock implements IModItem, ICustomBlockS
|
||||||
public void generateCustomBlockState(BlockStateGenerator generator) {
|
public void generateCustomBlockState(BlockStateGenerator generator) {
|
||||||
generator.stairsBlock(this, generator.modLoc("block/" + this.textureName));
|
generator.stairsBlock(this, generator.modLoc("block/" + this.textureName));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import de.ellpeck.naturesaura.reg.ITESRProvider;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.ItemInteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.crafting.Ingredient;
|
import net.minecraft.world.item.crafting.Ingredient;
|
||||||
|
@ -26,7 +26,7 @@ import net.minecraft.world.phys.shapes.Shapes;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
import net.neoforged.neoforge.event.level.BlockGrowFeatureEvent;
|
import net.neoforged.neoforge.event.level.SaplingGrowTreeEvent;
|
||||||
import org.apache.commons.lang3.mutable.MutableObject;
|
import org.apache.commons.lang3.mutable.MutableObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -53,7 +53,7 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onTreeGrow(BlockGrowFeatureEvent event) {
|
public void onTreeGrow(SaplingGrowTreeEvent event) {
|
||||||
var level = event.getLevel();
|
var level = event.getLevel();
|
||||||
var pos = event.getPos();
|
var pos = event.getPos();
|
||||||
if (!level.isClientSide() && level instanceof Level) {
|
if (!level.isClientSide() && level instanceof Level) {
|
||||||
|
@ -99,8 +99,9 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
|
@SuppressWarnings("deprecation")
|
||||||
return Helper.putStackOnTile(player, hand, pos, 0, true);
|
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||||
|
return Helper.putStackOnTile(player, handIn, pos, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,88 +16,88 @@ import net.minecraft.world.level.block.SaplingBlock;
|
||||||
public final class Multiblocks {
|
public final class Multiblocks {
|
||||||
|
|
||||||
public static final IMultiblock ALTAR = NaturesAuraAPI.instance().createMultiblock(
|
public static final IMultiblock ALTAR = NaturesAuraAPI.instance().createMultiblock(
|
||||||
ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "altar"),
|
new ResourceLocation(NaturesAura.MOD_ID, "altar"),
|
||||||
new String[][]{
|
new String[][]{
|
||||||
{" M ", " ", " ", " ", "M M", " ", " ", " ", " M "},
|
{" M ", " ", " ", " ", "M M", " ", " ", " ", " M "},
|
||||||
{" B ", " ", " ", " ", "B B", " ", " ", " ", " B "},
|
{" B ", " ", " ", " ", "B B", " ", " ", " ", " B "},
|
||||||
{" B ", " ", " M M ", " ", "B 0 B", " ", " M M ", " ", " B "},
|
{" B ", " ", " M M ", " ", "B 0 B", " ", " M M ", " ", " B "},
|
||||||
{" ", " WBW ", " WBW ", " WWCWCWW ", " BBW WBB ", " WWCWCWW ", " WBW ", " WBW ", " "}},
|
{" ", " WBW ", " WBW ", " WWCWCWW ", " BBW WBB ", " WWCWCWW ", " WBW ", " WBW ", " "}},
|
||||||
'C', Matcher.tag(Blocks.CHISELED_STONE_BRICKS, BlockTagProvider.ALTAR_FANCY_BRICK),
|
'C', Matcher.tag(Blocks.CHISELED_STONE_BRICKS, BlockTagProvider.ALTAR_FANCY_BRICK),
|
||||||
'B', Matcher.tag(Blocks.STONE_BRICKS, BlockTagProvider.ALTAR_STONE),
|
'B', Matcher.tag(Blocks.STONE_BRICKS, BlockTagProvider.ALTAR_STONE),
|
||||||
'W', Matcher.tag(Blocks.OAK_PLANKS, BlockTagProvider.ALTAR_WOOD),
|
'W', Matcher.tag(Blocks.OAK_PLANKS, BlockTagProvider.ALTAR_WOOD),
|
||||||
'M', Matcher.tag(ModBlocks.GOLD_BRICK, BlockTagProvider.ALTAR_GOLD_BRICK),
|
'M', Matcher.tag(ModBlocks.GOLD_BRICK, BlockTagProvider.ALTAR_GOLD_BRICK),
|
||||||
'0', ModBlocks.NATURE_ALTAR,
|
'0', ModBlocks.NATURE_ALTAR,
|
||||||
' ', Matcher.any());
|
' ', Matcher.any());
|
||||||
public static final IMultiblock TREE_RITUAL = NaturesAuraAPI.instance().createMultiblock(
|
public static final IMultiblock TREE_RITUAL = NaturesAuraAPI.instance().createMultiblock(
|
||||||
ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "tree_ritual"),
|
new ResourceLocation(NaturesAura.MOD_ID, "tree_ritual"),
|
||||||
new String[][]{
|
new String[][]{
|
||||||
{" W ", " W W ", " GGG ", " GG GG ", "W G 0 G W", " GG GG ", " GGG ", " W W ", " W "}},
|
{" W ", " W W ", " GGG ", " GG GG ", "W G 0 G W", " GG GG ", " GGG ", " W W ", " W "}},
|
||||||
'W', new Matcher(ModBlocks.WOOD_STAND.defaultBlockState(),
|
'W', new Matcher(ModBlocks.WOOD_STAND.defaultBlockState(),
|
||||||
(level, start, offset, pos, state, c) -> level != null || state.getBlock() == ModBlocks.WOOD_STAND),
|
(level, start, offset, pos, state, c) -> level != null || state.getBlock() == ModBlocks.WOOD_STAND),
|
||||||
'G', ModBlocks.GOLD_POWDER,
|
'G', ModBlocks.GOLD_POWDER,
|
||||||
'0', new Matcher(Blocks.OAK_SAPLING.defaultBlockState(),
|
'0', new Matcher(Blocks.OAK_SAPLING.defaultBlockState(),
|
||||||
(level, start, offset, pos, state, c) -> {
|
(level, start, offset, pos, state, c) -> {
|
||||||
if (state.getBlock() instanceof SaplingBlock || state.is(BlockTags.LOGS))
|
if (state.getBlock() instanceof SaplingBlock || state.is(BlockTags.LOGS))
|
||||||
return true;
|
return true;
|
||||||
// try-catch to prevent blocks that need to have been placed crashing here
|
// try-catch to prevent blocks that need to have been placed crashing here
|
||||||
try {
|
try {
|
||||||
var stack = new ItemStack(state.getBlock());
|
var stack = new ItemStack(state.getBlock());
|
||||||
return !stack.isEmpty() && level.getRecipeManager().getRecipesFor(ModRecipes.TREE_RITUAL_TYPE, null, level).stream().anyMatch(r -> r.value().saplingType.test(stack));
|
return !stack.isEmpty() && level.getRecipeManager().getRecipesFor(ModRecipes.TREE_RITUAL_TYPE, null, level).stream().anyMatch(r -> r.value().saplingType.test(stack));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
' ', Matcher.any());
|
' ', Matcher.any());
|
||||||
public static final IMultiblock POTION_GENERATOR = NaturesAuraAPI.instance().createMultiblock(
|
public static final IMultiblock POTION_GENERATOR = NaturesAuraAPI.instance().createMultiblock(
|
||||||
ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "potion_generator"),
|
new ResourceLocation(NaturesAura.MOD_ID, "potion_generator"),
|
||||||
new String[][]{
|
new String[][]{
|
||||||
{"R R", " ", " ", " ", " ", " ", "R R"},
|
{"R R", " ", " ", " ", " ", " ", "R R"},
|
||||||
{"N N", " ", " ", " ", " ", " ", "N N"},
|
{"N N", " ", " ", " ", " ", " ", "N N"},
|
||||||
{"N N", " ", " ", " 0 ", " ", " ", "N N"},
|
{"N N", " ", " ", " 0 ", " ", " ", "N N"},
|
||||||
{" N N ", "NNN NNN", " NRRRN ", " R R ", " NRRRN ", "NNN NNN", " N N "}},
|
{" N N ", "NNN NNN", " NRRRN ", " R R ", " NRRRN ", "NNN NNN", " N N "}},
|
||||||
'N', Blocks.NETHER_BRICKS,
|
'N', Blocks.NETHER_BRICKS,
|
||||||
'R', Blocks.RED_NETHER_BRICKS,
|
'R', Blocks.RED_NETHER_BRICKS,
|
||||||
'0', ModBlocks.POTION_GENERATOR,
|
'0', ModBlocks.POTION_GENERATOR,
|
||||||
' ', Matcher.any());
|
' ', Matcher.any());
|
||||||
public static final IMultiblock OFFERING_TABLE = NaturesAuraAPI.instance().createMultiblock(
|
public static final IMultiblock OFFERING_TABLE = NaturesAuraAPI.instance().createMultiblock(
|
||||||
ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "offering_table"),
|
new ResourceLocation(NaturesAura.MOD_ID, "offering_table"),
|
||||||
new String[][]{
|
new String[][]{
|
||||||
{" RRRRR ", " R R ", "R RRR R", "R R R R", "R R 0 R R", "R R R R", "R RRR R", " R R ", " RRRRR "}},
|
{" RRRRR ", " R R ", "R RRR R", "R R R R", "R R 0 R R", "R R R R", "R RRR R", " R R ", " RRRRR "}},
|
||||||
'R', new Matcher(Blocks.POPPY.defaultBlockState(),
|
'R', new Matcher(Blocks.POPPY.defaultBlockState(),
|
||||||
(level, start, offset, pos, state, c) -> state.is(BlockTags.SMALL_FLOWERS)),
|
(level, start, offset, pos, state, c) -> state.is(BlockTags.SMALL_FLOWERS)),
|
||||||
'0', ModBlocks.OFFERING_TABLE,
|
'0', ModBlocks.OFFERING_TABLE,
|
||||||
' ', Matcher.any());
|
' ', Matcher.any());
|
||||||
public static final IMultiblock ANIMAL_SPAWNER = NaturesAuraAPI.instance().createMultiblock(
|
public static final IMultiblock ANIMAL_SPAWNER = NaturesAuraAPI.instance().createMultiblock(
|
||||||
ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "animal_spawner"),
|
new ResourceLocation(NaturesAura.MOD_ID, "animal_spawner"),
|
||||||
new String[][]{
|
new String[][]{
|
||||||
{" ", " ", " ", " 0 ", " ", " ", " "},
|
{" ", " ", " ", " 0 ", " ", " ", " "},
|
||||||
{" HHH ", " HRRRH ", "HRWRWRH", "HRR RRH", "HRWRWRH", " HRRRH ", " HHH "}},
|
{" HHH ", " HRRRH ", "HRWRWRH", "HRR RRH", "HRWRWRH", " HRRRH ", " HHH "}},
|
||||||
'H', Blocks.HAY_BLOCK,
|
'H', Blocks.HAY_BLOCK,
|
||||||
'R', ModBlocks.INFUSED_BRICK,
|
'R', ModBlocks.INFUSED_BRICK,
|
||||||
'W', ModBlocks.ANCIENT_PLANKS,
|
'W', ModBlocks.ANCIENT_PLANKS,
|
||||||
'0', ModBlocks.ANIMAL_SPAWNER,
|
'0', ModBlocks.ANIMAL_SPAWNER,
|
||||||
' ', Matcher.any());
|
' ', Matcher.any());
|
||||||
public static final IMultiblock AUTO_CRAFTER = NaturesAuraAPI.instance().createMultiblock(
|
public static final IMultiblock AUTO_CRAFTER = NaturesAuraAPI.instance().createMultiblock(
|
||||||
ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "auto_crafter"),
|
new ResourceLocation(NaturesAura.MOD_ID, "auto_crafter"),
|
||||||
new String[][]{
|
new String[][]{
|
||||||
{"PPPPPPP", "PLPLPLP", "PPPPPPP", "PLP0PLP", "PPPPPPP", "PLPLPLP", "PPPPPPP"}},
|
{"PPPPPPP", "PLPLPLP", "PPPPPPP", "PLP0PLP", "PPPPPPP", "PLPLPLP", "PPPPPPP"}},
|
||||||
'P', ModBlocks.ANCIENT_PLANKS,
|
'P', ModBlocks.ANCIENT_PLANKS,
|
||||||
'L', ModBlocks.ANCIENT_LOG,
|
'L', ModBlocks.ANCIENT_LOG,
|
||||||
'0', ModBlocks.AUTO_CRAFTER,
|
'0', ModBlocks.AUTO_CRAFTER,
|
||||||
' ', Matcher.any());
|
' ', Matcher.any());
|
||||||
public static final IMultiblock RF_CONVERTER = NaturesAuraAPI.instance().createMultiblock(
|
public static final IMultiblock RF_CONVERTER = NaturesAuraAPI.instance().createMultiblock(
|
||||||
ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "rf_converter"),
|
new ResourceLocation(NaturesAura.MOD_ID, "rf_converter"),
|
||||||
new String[][]{
|
new String[][]{
|
||||||
{" ", " ", " ", " R ", " ", " ", " "},
|
{" ", " ", " ", " R ", " ", " ", " "},
|
||||||
{" ", " R ", " ", " R R ", " ", " R ", " "},
|
{" ", " R ", " ", " R R ", " ", " R ", " "},
|
||||||
{" ", " ", " ", " ", " ", " ", " "},
|
{" ", " ", " ", " ", " ", " ", " "},
|
||||||
{" R ", " R R ", " ", "R 0 R", " ", " R R ", " R "},
|
{" R ", " R R ", " ", "R 0 R", " ", " R R ", " R "},
|
||||||
{" ", " ", " ", " ", " ", " ", " "},
|
{" ", " ", " ", " ", " ", " ", " "},
|
||||||
{" ", " R ", " ", " R R ", " ", " R ", " "},
|
{" ", " R ", " ", " R R ", " ", " R ", " "},
|
||||||
{" ", " ", " ", " R ", " ", " ", " "}},
|
{" ", " ", " ", " R ", " ", " ", " "}},
|
||||||
'R', Blocks.REDSTONE_BLOCK,
|
'R', Blocks.REDSTONE_BLOCK,
|
||||||
'0', ModBlocks.RF_CONVERTER,
|
'0', ModBlocks.RF_CONVERTER,
|
||||||
' ', Matcher.any());
|
' ', Matcher.any());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.container.NaturalAuraContainer;
|
import de.ellpeck.naturesaura.api.aura.container.NaturalAuraContainer;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
|
@ -30,15 +29,15 @@ public class BlockEntityAncientLeaves extends BlockEntityImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK)
|
if (type != SaveType.BLOCK)
|
||||||
this.container.writeNBT(compound);
|
this.container.writeNBT(compound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK)
|
if (type != SaveType.BLOCK)
|
||||||
this.container.readNBT(compound);
|
this.container.readNBT(compound);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe;
|
import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe;
|
||||||
import de.ellpeck.naturesaura.recipes.ModRecipes;
|
import de.ellpeck.naturesaura.recipes.ModRecipes;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -22,6 +21,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickableBlockEntity {
|
public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickableBlockEntity {
|
||||||
|
@ -69,7 +69,7 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var items = this.level.getEntitiesOfClass(ItemEntity.class,
|
var items = this.level.getEntitiesOfClass(ItemEntity.class,
|
||||||
new AABB(this.worldPosition).inflate(2));
|
new AABB(this.worldPosition).inflate(2));
|
||||||
|
|
||||||
for (var recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.ANIMAL_SPAWNER_TYPE, null, this.level)) {
|
for (var recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.ANIMAL_SPAWNER_TYPE, null, this.level)) {
|
||||||
if (recipe.value().ingredients.size() != items.size())
|
if (recipe.value().ingredients.size() != items.size())
|
||||||
|
@ -94,7 +94,7 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab
|
||||||
for (var item : items) {
|
for (var item : items) {
|
||||||
item.remove(Entity.RemovalReason.KILLED);
|
item.remove(Entity.RemovalReason.KILLED);
|
||||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
||||||
new PacketParticles((float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.ANIMAL_SPAWNER));
|
new PacketParticles((float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.ANIMAL_SPAWNER));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentRecipe = recipe;
|
this.currentRecipe = recipe;
|
||||||
|
@ -113,15 +113,15 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab
|
||||||
}
|
}
|
||||||
|
|
||||||
NaturesAuraAPI.instance().spawnParticleStream(
|
NaturesAuraAPI.instance().spawnParticleStream(
|
||||||
this.worldPosition.getX() + (float) this.level.random.nextGaussian() * 5F,
|
this.worldPosition.getX() + (float) this.level.random.nextGaussian() * 5F,
|
||||||
this.worldPosition.getY() + 1 + this.level.random.nextFloat() * 5F,
|
this.worldPosition.getY() + 1 + this.level.random.nextFloat() * 5F,
|
||||||
this.worldPosition.getZ() + (float) this.level.random.nextGaussian() * 5F,
|
this.worldPosition.getZ() + (float) this.level.random.nextGaussian() * 5F,
|
||||||
this.worldPosition.getX() + this.level.random.nextFloat(),
|
this.worldPosition.getX() + this.level.random.nextFloat(),
|
||||||
this.worldPosition.getY() + this.level.random.nextFloat(),
|
this.worldPosition.getY() + this.level.random.nextFloat(),
|
||||||
this.worldPosition.getZ() + this.level.random.nextFloat(),
|
this.worldPosition.getZ() + this.level.random.nextFloat(),
|
||||||
this.level.random.nextFloat() * 0.07F + 0.07F,
|
this.level.random.nextFloat() * 0.07F + 0.07F,
|
||||||
IAuraType.forLevel(this.level).getColor(),
|
IAuraType.forLevel(this.level).getColor(),
|
||||||
this.level.random.nextFloat() + 0.5F);
|
this.level.random.nextFloat() + 0.5F);
|
||||||
|
|
||||||
if (this.entityClient == null) {
|
if (this.entityClient == null) {
|
||||||
this.entityClient = this.currentRecipe.value().makeEntity(this.level, BlockPos.ZERO);
|
this.entityClient = this.currentRecipe.value().makeEntity(this.level, BlockPos.ZERO);
|
||||||
|
@ -130,16 +130,16 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab
|
||||||
var bounds = this.entityClient.getBoundingBox();
|
var bounds = this.entityClient.getBoundingBox();
|
||||||
for (var i = this.level.random.nextInt(5) + 5; i >= 0; i--)
|
for (var i = this.level.random.nextInt(5) + 5; i >= 0; i--)
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
bounds.minX + this.level.random.nextFloat() * (bounds.maxX - bounds.minX),
|
bounds.minX + this.level.random.nextFloat() * (bounds.maxX - bounds.minX),
|
||||||
bounds.minY + this.level.random.nextFloat() * (bounds.maxY - bounds.minY),
|
bounds.minY + this.level.random.nextFloat() * (bounds.maxY - bounds.minY),
|
||||||
bounds.minZ + this.level.random.nextFloat() * (bounds.maxZ - bounds.minZ),
|
bounds.minZ + this.level.random.nextFloat() * (bounds.maxZ - bounds.minZ),
|
||||||
0F, 0F, 0F, 0x2fd8d3, 2F, 60, 0F, false, true);
|
0F, 0F, 0F, 0x2fd8d3, 2F, 60, 0F, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
if (this.currentRecipe != null) {
|
if (this.currentRecipe != null) {
|
||||||
compound.putString("recipe", this.currentRecipe.id().toString());
|
compound.putString("recipe", this.currentRecipe.id().toString());
|
||||||
|
@ -152,12 +152,12 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
if (compound.contains("recipe")) {
|
if (compound.contains("recipe")) {
|
||||||
if (this.hasLevel()) {
|
if (this.hasLevel()) {
|
||||||
var name = ResourceLocation.parse(compound.getString("recipe"));
|
var name = new ResourceLocation(compound.getString("recipe"));
|
||||||
this.currentRecipe = (RecipeHolder<AnimalSpawnerRecipe>) this.level.getRecipeManager().byKey(name).orElse(null);
|
this.currentRecipe = (RecipeHolder<AnimalSpawnerRecipe>) this.level.getRecipeManager().byKey(name).orElse(null);
|
||||||
}
|
}
|
||||||
this.spawnX = compound.getDouble("spawn_x");
|
this.spawnX = compound.getDouble("spawn_x");
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles;
|
package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
@ -28,15 +27,15 @@ public class BlockEntityAuraBloom extends BlockEntityImpl implements ITickableBl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
if (type == SaveType.TILE)
|
if (type == SaveType.TILE)
|
||||||
compound.putBoolean("just_generated", this.justGenerated);
|
compound.putBoolean("just_generated", this.justGenerated);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
if (type == SaveType.TILE)
|
if (type == SaveType.TILE)
|
||||||
this.justGenerated = compound.getBoolean("just_generated");
|
this.justGenerated = compound.getBoolean("just_generated");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
@ -19,9 +18,9 @@ import java.util.Map;
|
||||||
public class BlockEntityAuraTimer extends BlockEntityImpl implements ITickableBlockEntity {
|
public class BlockEntityAuraTimer extends BlockEntityImpl implements ITickableBlockEntity {
|
||||||
|
|
||||||
private static final Map<IAuraType, Integer> TIMES = ImmutableMap.<IAuraType, Integer>builder()
|
private static final Map<IAuraType, Integer> TIMES = ImmutableMap.<IAuraType, Integer>builder()
|
||||||
.put(NaturesAuraAPI.TYPE_OVERWORLD, 20)
|
.put(NaturesAuraAPI.TYPE_OVERWORLD, 20)
|
||||||
.put(NaturesAuraAPI.TYPE_NETHER, 20 * 60)
|
.put(NaturesAuraAPI.TYPE_NETHER, 20 * 60)
|
||||||
.put(NaturesAuraAPI.TYPE_END, 20 * 60 * 60).build();
|
.put(NaturesAuraAPI.TYPE_END, 20 * 60 * 60).build();
|
||||||
public final ItemStackHandlerNA itemHandler = new ItemStackHandlerNA(1, this, true) {
|
public final ItemStackHandlerNA itemHandler = new ItemStackHandlerNA(1, this, true) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean canInsert(ItemStack stack, int slot) {
|
protected boolean canInsert(ItemStack stack, int slot) {
|
||||||
|
@ -57,10 +56,10 @@ public class BlockEntityAuraTimer extends BlockEntityImpl implements ITickableBl
|
||||||
if (this.level.getGameTime() % 8 == 0) {
|
if (this.level.getGameTime() % 8 == 0) {
|
||||||
var color = ItemAuraBottle.getType(this.itemHandler.getStackInSlot(0)).getColor();
|
var color = ItemAuraBottle.getType(this.itemHandler.getStackInSlot(0)).getColor();
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
this.worldPosition.getX() + 1 / 16F + this.level.random.nextFloat() * 14 / 16F,
|
this.worldPosition.getX() + 1 / 16F + this.level.random.nextFloat() * 14 / 16F,
|
||||||
this.worldPosition.getY() + 1 / 16F + this.level.random.nextFloat() * 14 / 16F,
|
this.worldPosition.getY() + 1 / 16F + this.level.random.nextFloat() * 14 / 16F,
|
||||||
this.worldPosition.getZ() + 1 / 16F + this.level.random.nextFloat() * 14 / 16F,
|
this.worldPosition.getZ() + 1 / 16F + this.level.random.nextFloat() * 14 / 16F,
|
||||||
0, 0, 0, color, 1, 80 + this.level.random.nextInt(50), 0, false, true);
|
0, 0, 0, color, 1, 80 + this.level.random.nextInt(50), 0, false, true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -99,21 +98,20 @@ public class BlockEntityAuraTimer extends BlockEntityImpl implements ITickableBl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
compound.put("items", this.itemHandler.serializeNBT(registries));
|
compound.put("items", this.itemHandler.serializeNBT());
|
||||||
compound.putInt("timer", this.timer);
|
compound.putInt("timer", this.timer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
this.itemHandler.deserializeNBT(registries, compound.getCompound("items"));
|
this.itemHandler.deserializeNBT(compound.getCompound("items"));
|
||||||
this.timer = compound.getInt("timer");
|
this.timer = compound.getInt("timer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,26 +49,26 @@ public class BlockEntityAutoCrafter extends BlockEntityImpl implements ITickable
|
||||||
var topPos = middlePos.relative(facing, 2);
|
var topPos = middlePos.relative(facing, 2);
|
||||||
var bottomPos = middlePos.relative(facing.getOpposite(), 2);
|
var bottomPos = middlePos.relative(facing.getOpposite(), 2);
|
||||||
var poses = new BlockPos[]{
|
var poses = new BlockPos[]{
|
||||||
topPos.relative(facing.getCounterClockWise(), 2),
|
topPos.relative(facing.getCounterClockWise(), 2),
|
||||||
topPos,
|
topPos,
|
||||||
topPos.relative(facing.getClockWise(), 2),
|
topPos.relative(facing.getClockWise(), 2),
|
||||||
middlePos.relative(facing.getCounterClockWise(), 2),
|
middlePos.relative(facing.getCounterClockWise(), 2),
|
||||||
middlePos,
|
middlePos,
|
||||||
middlePos.relative(facing.getClockWise(), 2),
|
middlePos.relative(facing.getClockWise(), 2),
|
||||||
bottomPos.relative(facing.getCounterClockWise(), 2),
|
bottomPos.relative(facing.getCounterClockWise(), 2),
|
||||||
bottomPos,
|
bottomPos,
|
||||||
bottomPos.relative(facing.getClockWise(), 2)
|
bottomPos.relative(facing.getClockWise(), 2)
|
||||||
};
|
};
|
||||||
|
|
||||||
var items = new ItemEntity[9];
|
var items = new ItemEntity[9];
|
||||||
for (var i = 0; i < poses.length; i++) {
|
for (var i = 0; i < poses.length; i++) {
|
||||||
var entities = this.level.getEntitiesOfClass(
|
var entities = this.level.getEntitiesOfClass(
|
||||||
ItemEntity.class, new AABB(poses[i]).inflate(0.25), EntitySelector.ENTITY_STILL_ALIVE);
|
ItemEntity.class, new AABB(poses[i]).inflate(0.25), EntitySelector.ENTITY_STILL_ALIVE);
|
||||||
if (entities.size() > 1)
|
if (entities.size() > 1)
|
||||||
return;
|
return;
|
||||||
if (entities.isEmpty())
|
if (entities.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
var entity = entities.getFirst();
|
var entity = entities.get(0);
|
||||||
if (entity.hasPickUpDelay())
|
if (entity.hasPickUpDelay())
|
||||||
return;
|
return;
|
||||||
var stack = entity.getItem();
|
var stack = entity.getItem();
|
||||||
|
@ -78,19 +78,19 @@ public class BlockEntityAutoCrafter extends BlockEntityImpl implements ITickable
|
||||||
this.crafting.setItem(i, stack.copy());
|
this.crafting.setItem(i, stack.copy());
|
||||||
}
|
}
|
||||||
|
|
||||||
var recipe = this.level.getRecipeManager().getRecipeFor(RecipeType.CRAFTING, this.crafting.asCraftInput(), this.level).orElse(null);
|
var recipe = this.level.getRecipeManager().getRecipeFor(RecipeType.CRAFTING, this.crafting, this.level).orElse(null);
|
||||||
if (recipe == null)
|
if (recipe == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var result = recipe.value().assemble(this.crafting.asCraftInput(), this.level.registryAccess());
|
var result = recipe.value().assemble(this.crafting, this.level.registryAccess());
|
||||||
if (result.isEmpty())
|
if (result.isEmpty())
|
||||||
return;
|
return;
|
||||||
var resultItem = new ItemEntity(this.level,
|
var resultItem = new ItemEntity(this.level,
|
||||||
this.worldPosition.getX() + 0.5F, this.worldPosition.getY() - 0.35F, this.worldPosition.getZ() + 0.5F, result.copy());
|
this.worldPosition.getX() + 0.5F, this.worldPosition.getY() - 0.35F, this.worldPosition.getZ() + 0.5F, result.copy());
|
||||||
resultItem.setDeltaMovement(0, 0, 0);
|
resultItem.setDeltaMovement(0, 0, 0);
|
||||||
this.level.addFreshEntity(resultItem);
|
this.level.addFreshEntity(resultItem);
|
||||||
|
|
||||||
var remainingItems = recipe.value().getRemainingItems(this.crafting.asCraftInput());
|
var remainingItems = recipe.value().getRemainingItems(this.crafting);
|
||||||
for (var i = 0; i < items.length; i++) {
|
for (var i = 0; i < items.length; i++) {
|
||||||
var item = items[i];
|
var item = items[i];
|
||||||
if (item == null)
|
if (item == null)
|
||||||
|
@ -111,9 +111,8 @@ public class BlockEntityAutoCrafter extends BlockEntityImpl implements ITickable
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
||||||
new PacketParticles((float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.ANIMAL_SPAWNER));
|
new PacketParticles((float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.ANIMAL_SPAWNER));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.crafting.Ingredient;
|
import net.minecraft.world.item.crafting.Ingredient;
|
||||||
import net.minecraft.world.item.crafting.Recipe;
|
import net.minecraft.world.item.crafting.Recipe;
|
||||||
import net.minecraft.world.item.crafting.SingleRecipeInput;
|
|
||||||
import net.minecraft.world.level.block.entity.BlastFurnaceBlockEntity;
|
import net.minecraft.world.level.block.entity.BlastFurnaceBlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
|
@ -36,8 +35,7 @@ public class BlockEntityBlastFurnaceBooster extends BlockEntityImpl implements I
|
||||||
var below = this.level.getBlockEntity(this.worldPosition.below());
|
var below = this.level.getBlockEntity(this.worldPosition.below());
|
||||||
if (!(below instanceof BlastFurnaceBlockEntity tile))
|
if (!(below instanceof BlastFurnaceBlockEntity tile))
|
||||||
return;
|
return;
|
||||||
var input = new SingleRecipeInput(tile.getItem(0));
|
Recipe<?> recipe = this.level.getRecipeManager().getRecipeFor(BlockEntityFurnaceHeater.getRecipeType(tile), tile, this.level).orElse(null).value();
|
||||||
Recipe<?> recipe = this.level.getRecipeManager().getRecipeFor(BlockEntityFurnaceHeater.getRecipeType(tile), input, this.level).orElse(null).value();
|
|
||||||
if (recipe == null)
|
if (recipe == null)
|
||||||
return;
|
return;
|
||||||
if (!this.isApplicable(recipe.getIngredients()))
|
if (!this.isApplicable(recipe.getIngredients()))
|
||||||
|
@ -50,7 +48,7 @@ public class BlockEntityBlastFurnaceBooster extends BlockEntityImpl implements I
|
||||||
|
|
||||||
if (this.level.random.nextFloat() > 0.45F) {
|
if (this.level.random.nextFloat() > 0.45F) {
|
||||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
||||||
new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.BLAST_FURNACE_BOOSTER, 0));
|
new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.BLAST_FURNACE_BOOSTER, 0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +67,7 @@ public class BlockEntityBlastFurnaceBooster extends BlockEntityImpl implements I
|
||||||
IAuraChunk.getAuraChunk(this.level, pos).drainAura(pos, toUse);
|
IAuraChunk.getAuraChunk(this.level, pos).drainAura(pos, toUse);
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
||||||
new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.BLAST_FURNACE_BOOSTER, 1));
|
new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.BLAST_FURNACE_BOOSTER, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isApplicable(List<Ingredient> ingredients) {
|
private boolean isApplicable(List<Ingredient> ingredients) {
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles;
|
package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.Helper;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.ListTag;
|
||||||
import net.minecraft.nbt.NbtUtils;
|
import net.minecraft.nbt.NbtUtils;
|
||||||
|
@ -45,7 +43,7 @@ public class BlockEntityChorusGenerator extends BlockEntityImpl implements ITick
|
||||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.CHORUS_GENERATOR, pos.getX(), pos.getY(), pos.getZ()));
|
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.CHORUS_GENERATOR, pos.getX(), pos.getY(), pos.getZ()));
|
||||||
this.level.removeBlock(pos, false);
|
this.level.removeBlock(pos, false);
|
||||||
this.level.playSound(null, this.worldPosition.getX() + 0.5, this.worldPosition.getY() + 0.5, this.worldPosition.getZ() + 0.5,
|
this.level.playSound(null, this.worldPosition.getX() + 0.5, this.worldPosition.getY() + 0.5, this.worldPosition.getZ() + 0.5,
|
||||||
SoundEvents.CHORUS_FRUIT_TELEPORT, SoundSource.BLOCKS, 0.5F, 1F);
|
SoundEvents.CHORUS_FRUIT_TELEPORT, SoundSource.BLOCKS, 0.5F, 1F);
|
||||||
this.generateAura(this.auraPerBlock);
|
this.generateAura(this.auraPerBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,8 +97,8 @@ public class BlockEntityChorusGenerator extends BlockEntityImpl implements ITick
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
if (type == SaveType.TILE) {
|
if (type == SaveType.TILE) {
|
||||||
var list = new ListTag();
|
var list = new ListTag();
|
||||||
for (var pos : this.currentlyBreaking)
|
for (var pos : this.currentlyBreaking)
|
||||||
|
@ -111,15 +109,14 @@ public class BlockEntityChorusGenerator extends BlockEntityImpl implements ITick
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
if (type == SaveType.TILE) {
|
if (type == SaveType.TILE) {
|
||||||
this.currentlyBreaking.clear();
|
this.currentlyBreaking.clear();
|
||||||
var list = compound.getList("breaking", ListTag.TAG_INT_ARRAY);
|
var list = compound.getList("breaking", 10);
|
||||||
for (var tag : list)
|
for (var i = 0; i < list.size(); i++)
|
||||||
this.currentlyBreaking.add(Helper.readBlockPos(tag));
|
this.currentlyBreaking.add(NbtUtils.readBlockPos(list.getCompound(i)));
|
||||||
this.auraPerBlock = compound.getInt("aura");
|
this.auraPerBlock = compound.getInt("aura");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
import de.ellpeck.naturesaura.ModConfig;
|
import de.ellpeck.naturesaura.ModConfig;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -109,15 +108,15 @@ public class BlockEntityChunkLoader extends BlockEntityImpl implements ITickable
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
if (type == SaveType.TILE)
|
if (type == SaveType.TILE)
|
||||||
compound.putLongArray("forced_chunks", this.forcedChunks.stream().map(ChunkPos::toLong).collect(Collectors.toList()));
|
compound.putLongArray("forced_chunks", this.forcedChunks.stream().map(ChunkPos::toLong).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
|
|
||||||
if (type == SaveType.TILE) {
|
if (type == SaveType.TILE) {
|
||||||
this.forcedChunks.clear();
|
this.forcedChunks.clear();
|
||||||
|
|
|
@ -5,7 +5,6 @@ import de.ellpeck.naturesaura.api.aura.container.BasicAuraContainer;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.item.ItemEntity;
|
import net.minecraft.world.entity.item.ItemEntity;
|
||||||
|
@ -95,8 +94,8 @@ public class BlockEntityEndFlower extends BlockEntityImpl implements ITickableBl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
this.container.writeNBT(compound);
|
this.container.writeNBT(compound);
|
||||||
compound.putBoolean("drain_mode", this.isDrainMode);
|
compound.putBoolean("drain_mode", this.isDrainMode);
|
||||||
|
@ -104,8 +103,8 @@ public class BlockEntityEndFlower extends BlockEntityImpl implements ITickableBl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
this.container.readNBT(compound);
|
this.container.readNBT(compound);
|
||||||
this.isDrainMode = compound.getBoolean("drain_mode");
|
this.isDrainMode = compound.getBoolean("drain_mode");
|
||||||
|
|
|
@ -8,7 +8,6 @@ import de.ellpeck.naturesaura.gui.ContainerEnderCrate;
|
||||||
import de.ellpeck.naturesaura.gui.ModContainers;
|
import de.ellpeck.naturesaura.gui.ModContainers;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.MenuProvider;
|
import net.minecraft.world.MenuProvider;
|
||||||
|
@ -111,8 +110,8 @@ public class BlockEntityEnderCrate extends BlockEntityImpl implements MenuProvid
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
if (this.name != null)
|
if (this.name != null)
|
||||||
compound.putString("name", this.name);
|
compound.putString("name", this.name);
|
||||||
|
@ -120,8 +119,8 @@ public class BlockEntityEnderCrate extends BlockEntityImpl implements MenuProvid
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
if (compound.contains("name"))
|
if (compound.contains("name"))
|
||||||
this.name = compound.getString("name");
|
this.name = compound.getString("name");
|
||||||
|
|
|
@ -7,7 +7,6 @@ import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticleStream;
|
import de.ellpeck.naturesaura.packet.PacketParticleStream;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -176,8 +175,8 @@ public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickabl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
if (this.connectionOffset != null)
|
if (this.connectionOffset != null)
|
||||||
compound.putLong("connection", this.connectionOffset.asLong());
|
compound.putLong("connection", this.connectionOffset.asLong());
|
||||||
|
@ -190,8 +189,8 @@ public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickabl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
if (compound.contains("connection"))
|
if (compound.contains("connection"))
|
||||||
this.connectionOffset = BlockPos.of(compound.getLong("connection"));
|
this.connectionOffset = BlockPos.of(compound.getLong("connection"));
|
||||||
|
|
|
@ -7,7 +7,6 @@ import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticleStream;
|
import de.ellpeck.naturesaura.packet.PacketParticleStream;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.ListTag;
|
||||||
|
@ -97,8 +96,8 @@ public class BlockEntityFlowerGenerator extends BlockEntityImpl implements ITick
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
|
|
||||||
if (type != SaveType.SYNC && !this.consumedRecently.isEmpty()) {
|
if (type != SaveType.SYNC && !this.consumedRecently.isEmpty()) {
|
||||||
var list = new ListTag();
|
var list = new ListTag();
|
||||||
|
@ -116,14 +115,14 @@ public class BlockEntityFlowerGenerator extends BlockEntityImpl implements ITick
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.SYNC) {
|
if (type != SaveType.SYNC) {
|
||||||
this.consumedRecently.clear();
|
this.consumedRecently.clear();
|
||||||
var list = compound.getList("consumed_recently", 10);
|
var list = compound.getList("consumed_recently", 10);
|
||||||
for (var base : list) {
|
for (var base : list) {
|
||||||
var tag = (CompoundTag) base;
|
var tag = (CompoundTag) base;
|
||||||
var block = BuiltInRegistries.BLOCK.get(ResourceLocation.parse(tag.getString("block")));
|
var block = BuiltInRegistries.BLOCK.get(new ResourceLocation(tag.getString("block")));
|
||||||
if (block != null)
|
if (block != null)
|
||||||
this.consumedRecently.put(block.defaultBlockState(), new MutableInt(tag.getInt("amount")));
|
this.consumedRecently.put(block.defaultBlockState(), new MutableInt(tag.getInt("amount")));
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,11 @@ import de.ellpeck.naturesaura.blocks.BlockFurnaceHeater;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticleStream;
|
import de.ellpeck.naturesaura.packet.PacketParticleStream;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.inventory.ContainerData;
|
import net.minecraft.world.inventory.ContainerData;
|
||||||
import net.minecraft.world.item.crafting.AbstractCookingRecipe;
|
import net.minecraft.world.item.crafting.AbstractCookingRecipe;
|
||||||
import net.minecraft.world.item.crafting.RecipeType;
|
import net.minecraft.world.item.crafting.RecipeType;
|
||||||
import net.minecraft.world.item.crafting.SingleRecipeInput;
|
|
||||||
import net.minecraft.world.level.block.AbstractFurnaceBlock;
|
import net.minecraft.world.level.block.AbstractFurnaceBlock;
|
||||||
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
|
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlastFurnaceBlockEntity;
|
import net.minecraft.world.level.block.entity.BlastFurnaceBlockEntity;
|
||||||
|
@ -79,13 +77,13 @@ public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickab
|
||||||
|
|
||||||
if (this.level.getGameTime() % 15 == 0) {
|
if (this.level.getGameTime() % 15 == 0) {
|
||||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticleStream(
|
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticleStream(
|
||||||
this.worldPosition.getX() + (float) this.level.random.nextGaussian() * 5F,
|
this.worldPosition.getX() + (float) this.level.random.nextGaussian() * 5F,
|
||||||
this.worldPosition.getY() + 1 + this.level.random.nextFloat() * 5F,
|
this.worldPosition.getY() + 1 + this.level.random.nextFloat() * 5F,
|
||||||
this.worldPosition.getZ() + (float) this.level.random.nextGaussian() * 5F,
|
this.worldPosition.getZ() + (float) this.level.random.nextGaussian() * 5F,
|
||||||
tilePos.getX() + this.level.random.nextFloat(),
|
tilePos.getX() + this.level.random.nextFloat(),
|
||||||
tilePos.getY() + this.level.random.nextFloat(),
|
tilePos.getY() + this.level.random.nextFloat(),
|
||||||
tilePos.getZ() + this.level.random.nextFloat(),
|
tilePos.getZ() + this.level.random.nextFloat(),
|
||||||
this.level.random.nextFloat() * 0.07F + 0.07F, IAuraType.forLevel(this.level).getColor(), this.level.random.nextFloat() + 0.5F
|
this.level.random.nextFloat() * 0.07F + 0.07F, IAuraType.forLevel(this.level).getColor(), this.level.random.nextFloat() + 0.5F
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +102,7 @@ public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickab
|
||||||
|
|
||||||
var input = furnace.getItem(0);
|
var input = furnace.getItem(0);
|
||||||
if (!input.isEmpty()) {
|
if (!input.isEmpty()) {
|
||||||
var recipe = this.level.getRecipeManager().getRecipeFor(BlockEntityFurnaceHeater.getRecipeType(furnace), new SingleRecipeInput(input), this.level).orElse(null);
|
var recipe = this.level.getRecipeManager().getRecipeFor(BlockEntityFurnaceHeater.getRecipeType(furnace), furnace, this.level).orElse(null);
|
||||||
if (recipe == null)
|
if (recipe == null)
|
||||||
return false;
|
return false;
|
||||||
var output = recipe.value().getResultItem(this.level.registryAccess());
|
var output = recipe.value().getResultItem(this.level.registryAccess());
|
||||||
|
@ -115,16 +113,16 @@ public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickab
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
|
|
||||||
if (type == SaveType.SYNC)
|
if (type == SaveType.SYNC)
|
||||||
compound.putBoolean("active", this.isActive);
|
compound.putBoolean("active", this.isActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
|
|
||||||
if (type == SaveType.SYNC)
|
if (type == SaveType.SYNC)
|
||||||
this.isActive = compound.getBoolean("active");
|
this.isActive = compound.getBoolean("active");
|
||||||
|
@ -134,5 +132,4 @@ public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickab
|
||||||
public boolean allowsLowerLimiter() {
|
public boolean allowsLowerLimiter() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.blocks.BlockGratedChute;
|
import de.ellpeck.naturesaura.blocks.BlockGratedChute;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.entity.item.ItemEntity;
|
import net.minecraft.world.entity.item.ItemEntity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
@ -65,8 +64,8 @@ public class BlockEntityGratedChute extends BlockEntityImpl implements ITickable
|
||||||
pull:
|
pull:
|
||||||
if (curr.isEmpty() || curr.getCount() < curr.getMaxStackSize()) {
|
if (curr.isEmpty() || curr.getCount() < curr.getMaxStackSize()) {
|
||||||
var items = this.level.getEntitiesOfClass(ItemEntity.class, new AABB(
|
var items = this.level.getEntitiesOfClass(ItemEntity.class, new AABB(
|
||||||
this.worldPosition.getX(), this.worldPosition.getY() + 0.5, this.worldPosition.getZ(),
|
this.worldPosition.getX(), this.worldPosition.getY() + 0.5, this.worldPosition.getZ(),
|
||||||
this.worldPosition.getX() + 1, this.worldPosition.getY() + 2, this.worldPosition.getZ() + 1));
|
this.worldPosition.getX() + 1, this.worldPosition.getY() + 2, this.worldPosition.getZ() + 1));
|
||||||
for (var item : items) {
|
for (var item : items) {
|
||||||
if (!item.isAlive())
|
if (!item.isAlive())
|
||||||
continue;
|
continue;
|
||||||
|
@ -120,23 +119,24 @@ public class BlockEntityGratedChute extends BlockEntityImpl implements ITickable
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
compound.putInt("cooldown", this.cooldown);
|
compound.putInt("cooldown", this.cooldown);
|
||||||
compound.put("items", this.items.serializeNBT(registries));
|
compound.put("items", this.items.serializeNBT());
|
||||||
compound.putBoolean("blacklist", this.isBlacklist);
|
compound.putBoolean("blacklist", this.isBlacklist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
this.cooldown = compound.getInt("cooldown");
|
this.cooldown = compound.getInt("cooldown");
|
||||||
this.items.deserializeNBT(registries, compound.getCompound("items"));
|
this.items.deserializeNBT(compound.getCompound("items"));
|
||||||
this.isBlacklist = compound.getBoolean("blacklist");
|
this.isBlacklist = compound.getBoolean("blacklist");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.Connection;
|
import net.minecraft.network.Connection;
|
||||||
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||||
|
@ -26,25 +25,25 @@ public class BlockEntityImpl extends BlockEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveAdditional(CompoundTag compound, HolderLookup.Provider registries) {
|
public void saveAdditional(CompoundTag compound) {
|
||||||
this.writeNBT(compound, SaveType.TILE, registries);
|
this.writeNBT(compound, SaveType.TILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
public void load(CompoundTag compound) {
|
||||||
this.readNBT(tag, SaveType.TILE, registries);
|
this.readNBT(compound, SaveType.TILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
super.saveAdditional(compound, registries);
|
super.saveAdditional(compound);
|
||||||
compound.putInt("redstone", this.redstonePower);
|
compound.putInt("redstone", this.redstonePower);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
super.loadWithComponents(compound, registries);
|
super.load(compound);
|
||||||
this.redstonePower = compound.getInt("redstone");
|
this.redstonePower = compound.getInt("redstone");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,28 +54,29 @@ public class BlockEntityImpl extends BlockEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final ClientboundBlockEntityDataPacket getUpdatePacket() {
|
public final ClientboundBlockEntityDataPacket getUpdatePacket() {
|
||||||
return ClientboundBlockEntityDataPacket.create(this, (e, r) -> {
|
return ClientboundBlockEntityDataPacket.create(this, e -> {
|
||||||
var compound = new CompoundTag();
|
var compound = new CompoundTag();
|
||||||
this.writeNBT(compound, SaveType.SYNC, r);
|
this.writeNBT(compound, SaveType.SYNC);
|
||||||
return compound;
|
return compound;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final CompoundTag getUpdateTag(HolderLookup.Provider registries) {
|
public final CompoundTag getUpdateTag() {
|
||||||
var compound = new CompoundTag();
|
var compound = new CompoundTag();
|
||||||
this.writeNBT(compound, SaveType.SYNC, registries);
|
this.writeNBT(compound, SaveType.SYNC);
|
||||||
return compound;
|
return compound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleUpdateTag(CompoundTag tag, HolderLookup.Provider registries) {
|
public void handleUpdateTag(CompoundTag tag) {
|
||||||
this.readNBT(tag, SaveType.SYNC, registries);
|
this.readNBT(tag, SaveType.SYNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt, HolderLookup.Provider registries) {
|
public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) {
|
||||||
this.readNBT(pkt.getTag(), SaveType.SYNC, registries);
|
super.onDataPacket(net, pkt);
|
||||||
|
this.readNBT(pkt.getTag(), SaveType.SYNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendToClients() {
|
public void sendToClients() {
|
||||||
|
@ -102,7 +102,7 @@ public class BlockEntityImpl extends BlockEntity {
|
||||||
|
|
||||||
public void modifyDrop(ItemStack regularItem) {
|
public void modifyDrop(ItemStack regularItem) {
|
||||||
var compound = new CompoundTag();
|
var compound = new CompoundTag();
|
||||||
this.writeNBT(compound, SaveType.BLOCK, this.getLevel().registryAccess());
|
this.writeNBT(compound, SaveType.BLOCK);
|
||||||
if (!compound.isEmpty()) {
|
if (!compound.isEmpty()) {
|
||||||
if (!regularItem.hasTag())
|
if (!regularItem.hasTag())
|
||||||
regularItem.setTag(new CompoundTag());
|
regularItem.setTag(new CompoundTag());
|
||||||
|
@ -114,7 +114,7 @@ public class BlockEntityImpl extends BlockEntity {
|
||||||
if (stack.hasTag()) {
|
if (stack.hasTag()) {
|
||||||
var compound = stack.getTag().getCompound("data");
|
var compound = stack.getTag().getCompound("data");
|
||||||
if (compound != null)
|
if (compound != null)
|
||||||
this.readNBT(compound, SaveType.BLOCK, this.level.registryAccess());
|
this.readNBT(compound, SaveType.BLOCK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
@ -84,8 +83,8 @@ public class BlockEntityItemDistributor extends BlockEntityImpl implements ITick
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
if (type == SaveType.TILE) {
|
if (type == SaveType.TILE) {
|
||||||
compound.putInt("cooldown", this.cooldown);
|
compound.putInt("cooldown", this.cooldown);
|
||||||
compound.putInt("side", this.currentSide.ordinal());
|
compound.putInt("side", this.currentSide.ordinal());
|
||||||
|
@ -95,8 +94,8 @@ public class BlockEntityItemDistributor extends BlockEntityImpl implements ITick
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
if (type == SaveType.TILE) {
|
if (type == SaveType.TILE) {
|
||||||
this.cooldown = compound.getInt("cooldown");
|
this.cooldown = compound.getInt("cooldown");
|
||||||
this.currentSide = Direction.values()[compound.getInt("side")];
|
this.currentSide = Direction.values()[compound.getInt("side")];
|
||||||
|
|
|
@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.api.aura.container.BasicAuraContainer;
|
import de.ellpeck.naturesaura.api.aura.container.BasicAuraContainer;
|
||||||
|
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
||||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||||
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
|
@ -11,7 +12,7 @@ import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import de.ellpeck.naturesaura.recipes.AltarRecipe;
|
import de.ellpeck.naturesaura.recipes.AltarRecipe;
|
||||||
import de.ellpeck.naturesaura.recipes.ModRecipes;
|
import de.ellpeck.naturesaura.recipes.ModRecipes;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.HolderLookup;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
|
@ -23,6 +24,7 @@ import net.minecraft.world.item.crafting.RecipeHolder;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
import net.neoforged.neoforge.items.IItemHandlerModifiable;
|
||||||
import net.neoforged.neoforge.items.ItemStackHandler;
|
import net.neoforged.neoforge.items.ItemStackHandler;
|
||||||
|
|
||||||
public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickableBlockEntity {
|
public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickableBlockEntity {
|
||||||
|
@ -108,11 +110,11 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
|
||||||
|
|
||||||
if (this.level.getGameTime() % 3 == 0)
|
if (this.level.getGameTime() % 3 == 0)
|
||||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticleStream(
|
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticleStream(
|
||||||
this.worldPosition.getX() + (float) rand.nextGaussian() * 10F,
|
this.worldPosition.getX() + (float) rand.nextGaussian() * 10F,
|
||||||
this.worldPosition.getY() + rand.nextFloat() * 10F,
|
this.worldPosition.getY() + rand.nextFloat() * 10F,
|
||||||
this.worldPosition.getZ() + (float) rand.nextGaussian() * 10F,
|
this.worldPosition.getZ() + (float) rand.nextGaussian() * 10F,
|
||||||
this.worldPosition.getX() + 0.5F, this.worldPosition.getY() + 0.5F, this.worldPosition.getZ() + 0.5F,
|
this.worldPosition.getX() + 0.5F, this.worldPosition.getY() + 0.5F, this.worldPosition.getZ() + 0.5F,
|
||||||
rand.nextFloat() * 0.1F + 0.1F, this.container.getAuraColor(), rand.nextFloat() + 1F
|
rand.nextFloat() * 0.1F + 0.1F, this.container.getAuraColor(), rand.nextFloat() + 1F
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,23 +173,23 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
|
||||||
var fourths = this.container.getMaxAura() / 4;
|
var fourths = this.container.getMaxAura() / 4;
|
||||||
if (this.container.getStoredAura() > 0) {
|
if (this.container.getStoredAura() > 0) {
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
this.worldPosition.getX() - 4F + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() + rand.nextFloat(),
|
this.worldPosition.getX() - 4F + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() + rand.nextFloat(),
|
||||||
0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true);
|
0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true);
|
||||||
}
|
}
|
||||||
if (this.container.getStoredAura() >= fourths) {
|
if (this.container.getStoredAura() >= fourths) {
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
this.worldPosition.getX() + 4F + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() + rand.nextFloat(),
|
this.worldPosition.getX() + 4F + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() + rand.nextFloat(),
|
||||||
0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true);
|
0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true);
|
||||||
}
|
}
|
||||||
if (this.container.getStoredAura() >= fourths * 2) {
|
if (this.container.getStoredAura() >= fourths * 2) {
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
this.worldPosition.getX() + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() - 4F + rand.nextFloat(),
|
this.worldPosition.getX() + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() - 4F + rand.nextFloat(),
|
||||||
0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true);
|
0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true);
|
||||||
}
|
}
|
||||||
if (this.container.getStoredAura() >= fourths * 3) {
|
if (this.container.getStoredAura() >= fourths * 3) {
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
this.worldPosition.getX() + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() + 4F + rand.nextFloat(),
|
this.worldPosition.getX() + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() + 4F + rand.nextFloat(),
|
||||||
0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true);
|
0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -213,10 +215,10 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
compound.put("items", this.items.serializeNBT(registries));
|
compound.put("items", this.items.serializeNBT());
|
||||||
compound.putBoolean("complete", this.isComplete);
|
compound.putBoolean("complete", this.isComplete);
|
||||||
this.container.writeNBT(compound);
|
this.container.writeNBT(compound);
|
||||||
}
|
}
|
||||||
|
@ -230,17 +232,17 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
this.items.deserializeNBT(registries, compound.getCompound("items"));
|
this.items.deserializeNBT(compound.getCompound("items"));
|
||||||
this.isComplete = compound.getBoolean("complete");
|
this.isComplete = compound.getBoolean("complete");
|
||||||
this.container.readNBT(compound);
|
this.container.readNBT(compound);
|
||||||
}
|
}
|
||||||
if (type == SaveType.TILE) {
|
if (type == SaveType.TILE) {
|
||||||
if (compound.contains("recipe")) {
|
if (compound.contains("recipe")) {
|
||||||
if (this.hasLevel())
|
if (this.hasLevel())
|
||||||
this.currentRecipe = (RecipeHolder<AltarRecipe>) this.level.getRecipeManager().byKey(ResourceLocation.parse(compound.getString("recipe"))).orElse(null);
|
this.currentRecipe = (RecipeHolder<AltarRecipe>) this.level.getRecipeManager().byKey(new ResourceLocation(compound.getString("recipe"))).orElse(null);
|
||||||
this.timer = compound.getInt("timer");
|
this.timer = compound.getInt("timer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import de.ellpeck.naturesaura.recipes.ModRecipes;
|
import de.ellpeck.naturesaura.recipes.ModRecipes;
|
||||||
import de.ellpeck.naturesaura.recipes.OfferingRecipe;
|
import de.ellpeck.naturesaura.recipes.OfferingRecipe;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.ListTag;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
@ -93,8 +92,8 @@ public class BlockEntityOfferingTable extends BlockEntityImpl implements ITickab
|
||||||
lightningboltentity.moveTo(Vec3.atCenterOf(this.worldPosition));
|
lightningboltentity.moveTo(Vec3.atCenterOf(this.worldPosition));
|
||||||
this.level.addFreshEntity(lightningboltentity);
|
this.level.addFreshEntity(lightningboltentity);
|
||||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(
|
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(
|
||||||
(float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.OFFERING_TABLE,
|
(float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.OFFERING_TABLE,
|
||||||
this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ()));
|
this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ()));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -106,31 +105,31 @@ public class BlockEntityOfferingTable extends BlockEntityImpl implements ITickab
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
compound.put("items", this.items.serializeNBT(registries));
|
compound.put("items", this.items.serializeNBT());
|
||||||
|
|
||||||
if (type != SaveType.SYNC) {
|
if (type != SaveType.SYNC) {
|
||||||
var list = new ListTag();
|
var list = new ListTag();
|
||||||
for (var stack : this.itemsToSpawn)
|
for (var stack : this.itemsToSpawn)
|
||||||
list.add(stack.save(registries, new CompoundTag()));
|
list.add(stack.save(new CompoundTag()));
|
||||||
compound.put("items_to_spawn", list);
|
compound.put("items_to_spawn", list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
this.items.deserializeNBT(registries, compound.getCompound("items"));
|
this.items.deserializeNBT(compound.getCompound("items"));
|
||||||
|
|
||||||
if (type != SaveType.SYNC) {
|
if (type != SaveType.SYNC) {
|
||||||
this.itemsToSpawn.clear();
|
this.itemsToSpawn.clear();
|
||||||
var list = compound.getList("items_to_spawn", 10);
|
var list = compound.getList("items_to_spawn", 10);
|
||||||
for (var base : list)
|
for (var base : list)
|
||||||
this.itemsToSpawn.add(ItemStack.parseOptional(registries, (CompoundTag) base));
|
this.itemsToSpawn.add(ItemStack.of((CompoundTag) base));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,16 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles;
|
package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
|
||||||
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.entity.AreaEffectCloud;
|
import net.minecraft.world.entity.AreaEffectCloud;
|
||||||
import net.minecraft.world.item.alchemy.PotionContents;
|
import net.minecraft.world.item.alchemy.PotionUtils;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.neoforged.fml.util.ObfuscationReflectionHelper;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
public class BlockEntityPotionGenerator extends BlockEntityImpl implements ITickableBlockEntity {
|
public class BlockEntityPotionGenerator extends BlockEntityImpl implements ITickableBlockEntity {
|
||||||
|
|
||||||
private static final Field POTION_CONTENTS_FIELD = ObfuscationReflectionHelper.findField(AreaEffectCloud.class, "potionContents");
|
|
||||||
|
|
||||||
public BlockEntityPotionGenerator(BlockPos pos, BlockState state) {
|
public BlockEntityPotionGenerator(BlockPos pos, BlockState state) {
|
||||||
super(ModBlockEntities.POTION_GENERATOR, pos, state);
|
super(ModBlockEntities.POTION_GENERATOR, pos, state);
|
||||||
}
|
}
|
||||||
|
@ -33,17 +27,12 @@ public class BlockEntityPotionGenerator extends BlockEntityImpl implements ITick
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!addedOne) {
|
if (!addedOne) {
|
||||||
PotionContents type;
|
var type = cloud.getPotion();
|
||||||
try {
|
if (type == null)
|
||||||
// TODO check if this new private value getter works
|
|
||||||
type = (PotionContents) BlockEntityPotionGenerator.POTION_CONTENTS_FIELD.get(cloud);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
NaturesAura.LOGGER.fatal("Couldn't reflect furnace field", e);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
for (var effect : type.getAllEffects()) {
|
for (var effect : type.getEffects()) {
|
||||||
var potion = effect.getEffect().value();
|
var potion = effect.getEffect();
|
||||||
if (!potion.isBeneficial() || potion.isInstantenous()) {
|
if (!potion.isBeneficial() || potion.isInstantenous()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -54,8 +43,8 @@ public class BlockEntityPotionGenerator extends BlockEntityImpl implements ITick
|
||||||
this.generateAura(toAdd);
|
this.generateAura(toAdd);
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(
|
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(
|
||||||
this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.POTION_GEN,
|
this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.POTION_GEN,
|
||||||
type.getColor(), canGen ? 1 : 0));
|
PotionUtils.getColor(type), canGen ? 1 : 0));
|
||||||
|
|
||||||
addedOne = true;
|
addedOne = true;
|
||||||
break;
|
break;
|
||||||
|
@ -77,5 +66,4 @@ public class BlockEntityPotionGenerator extends BlockEntityImpl implements ITick
|
||||||
public boolean wantsLimitRemover() {
|
public boolean wantsLimitRemover() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
|
@ -15,15 +14,15 @@ public class BlockEntityProjectileGenerator extends BlockEntityImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK)
|
if (type != SaveType.BLOCK)
|
||||||
compound.putInt("next_side", this.nextSide.ordinal());
|
compound.putInt("next_side", this.nextSide.ordinal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK)
|
if (type != SaveType.BLOCK)
|
||||||
this.nextSide = Direction.values()[compound.getInt("next_side")];
|
this.nextSide = Direction.values()[compound.getInt("next_side")];
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
@ -24,14 +23,14 @@ public class BlockEntityRFConverter extends BlockEntityImpl implements ITickable
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
compound.putInt("energy", this.storage.getEnergyStored());
|
compound.putInt("energy", this.storage.getEnergyStored());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
this.storage.setEnergy(compound.getInt("energy"));
|
this.storage.setEnergy(compound.getInt("energy"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.entity.monster.MagmaCube;
|
import net.minecraft.world.entity.monster.MagmaCube;
|
||||||
import net.minecraft.world.entity.monster.Slime;
|
import net.minecraft.world.entity.monster.Slime;
|
||||||
|
@ -53,8 +52,8 @@ public class BlockEntitySlimeSplitGenerator extends BlockEntityImpl implements I
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
if (type == SaveType.TILE) {
|
if (type == SaveType.TILE) {
|
||||||
compound.putInt("timer", this.generationTimer);
|
compound.putInt("timer", this.generationTimer);
|
||||||
compound.putInt("amount", this.amountToRelease);
|
compound.putInt("amount", this.amountToRelease);
|
||||||
|
@ -63,8 +62,8 @@ public class BlockEntitySlimeSplitGenerator extends BlockEntityImpl implements I
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
if (type == SaveType.TILE) {
|
if (type == SaveType.TILE) {
|
||||||
this.generationTimer = compound.getInt("timer");
|
this.generationTimer = compound.getInt("timer");
|
||||||
this.amountToRelease = compound.getInt("amount");
|
this.amountToRelease = compound.getInt("amount");
|
||||||
|
|
|
@ -5,7 +5,6 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
@ -97,15 +96,15 @@ public class BlockEntitySnowCreator extends BlockEntityImpl implements ITickable
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
if (type == SaveType.TILE)
|
if (type == SaveType.TILE)
|
||||||
compound.putInt("snowman_count", this.snowmanCount);
|
compound.putInt("snowman_count", this.snowmanCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
if (type == SaveType.TILE)
|
if (type == SaveType.TILE)
|
||||||
this.snowmanCount = compound.getInt("snowman_count");
|
this.snowmanCount = compound.getInt("snowman_count");
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||||
import de.ellpeck.naturesaura.items.ModItems;
|
import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetTimePacket;
|
import net.minecraft.network.protocol.game.ClientboundSetTimePacket;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
@ -107,15 +106,15 @@ public class BlockEntityTimeChanger extends BlockEntityImpl implements ITickable
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK)
|
if (type != SaveType.BLOCK)
|
||||||
compound.putLong("goal", this.goalTime);
|
compound.putLong("goal", this.goalTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK)
|
if (type != SaveType.BLOCK)
|
||||||
this.goalTime = compound.getLong("goal");
|
this.goalTime = compound.getLong("goal");
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.api.misc.WeatherType;
|
import de.ellpeck.naturesaura.api.misc.WeatherType;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -89,8 +88,8 @@ public class BlockEntityWeatherChanger extends BlockEntityImpl implements ITicka
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
compound.putInt("time", this.processTime);
|
compound.putInt("time", this.processTime);
|
||||||
if (this.type != null)
|
if (this.type != null)
|
||||||
|
@ -100,8 +99,8 @@ public class BlockEntityWeatherChanger extends BlockEntityImpl implements ITicka
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
this.processTime = compound.getInt("time");
|
this.processTime = compound.getInt("time");
|
||||||
this.type = WeatherType.values()[compound.getInt("weather")];
|
this.type = WeatherType.values()[compound.getInt("weather")];
|
||||||
|
|
|
@ -7,7 +7,6 @@ import de.ellpeck.naturesaura.packet.PacketParticleStream;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import de.ellpeck.naturesaura.recipes.TreeRitualRecipe;
|
import de.ellpeck.naturesaura.recipes.TreeRitualRecipe;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
|
@ -62,18 +61,18 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
|
||||||
var tile = this.level.getBlockEntity(pos);
|
var tile = this.level.getBlockEntity(pos);
|
||||||
if (tile instanceof BlockEntityWoodStand && !((BlockEntityWoodStand) tile).items.getStackInSlot(0).isEmpty()) {
|
if (tile instanceof BlockEntityWoodStand && !((BlockEntityWoodStand) tile).items.getStackInSlot(0).isEmpty()) {
|
||||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticleStream(
|
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticleStream(
|
||||||
(float) pos.getX() + 0.2F + this.level.random.nextFloat() * 0.6F,
|
(float) pos.getX() + 0.2F + this.level.random.nextFloat() * 0.6F,
|
||||||
(float) pos.getY() + 0.85F,
|
(float) pos.getY() + 0.85F,
|
||||||
(float) pos.getZ() + 0.2F + this.level.random.nextFloat() * 0.6F,
|
(float) pos.getZ() + 0.2F + this.level.random.nextFloat() * 0.6F,
|
||||||
this.ritualPos.getX() + 0.5F, this.ritualPos.getY() + this.level.random.nextFloat() * 3F + 2F, this.ritualPos.getZ() + 0.5F,
|
this.ritualPos.getX() + 0.5F, this.ritualPos.getY() + this.level.random.nextFloat() * 3F + 2F, this.ritualPos.getZ() + 0.5F,
|
||||||
this.level.random.nextFloat() * 0.04F + 0.04F, 0x89cc37, this.level.random.nextFloat() + 1F
|
this.level.random.nextFloat() * 0.04F + 0.04F, 0x89cc37, this.level.random.nextFloat() + 1F
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(this.level, this.ritualPos, 32,
|
PacketHandler.sendToAllAround(this.level, this.ritualPos, 32,
|
||||||
new PacketParticles(this.ritualPos.getX(), this.ritualPos.getY(), this.ritualPos.getZ(), PacketParticles.Type.TR_GOLD_POWDER));
|
new PacketParticles(this.ritualPos.getX(), this.ritualPos.getY(), this.ritualPos.getZ(), PacketParticles.Type.TR_GOLD_POWDER));
|
||||||
|
|
||||||
if (this.timer >= this.recipe.value().time) {
|
if (this.timer >= this.recipe.value().time) {
|
||||||
Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'G', (pos, matcher) -> {
|
Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'G', (pos, matcher) -> {
|
||||||
|
@ -83,14 +82,14 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
|
||||||
Helper.mineRecursively(this.level, this.ritualPos, this.ritualPos, ItemStack.EMPTY, 6, 32, s -> s.is(BlockTags.LOGS) || s.getBlock() instanceof LeavesBlock);
|
Helper.mineRecursively(this.level, this.ritualPos, this.ritualPos, ItemStack.EMPTY, 6, 32, s -> s.is(BlockTags.LOGS) || s.getBlock() instanceof LeavesBlock);
|
||||||
|
|
||||||
var item = new ItemEntity(this.level,
|
var item = new ItemEntity(this.level,
|
||||||
this.ritualPos.getX() + 0.5, this.ritualPos.getY() + 4.5, this.ritualPos.getZ() + 0.5,
|
this.ritualPos.getX() + 0.5, this.ritualPos.getY() + 4.5, this.ritualPos.getZ() + 0.5,
|
||||||
this.recipe.value().output.copy());
|
this.recipe.value().output.copy());
|
||||||
this.level.addFreshEntity(item);
|
this.level.addFreshEntity(item);
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
||||||
new PacketParticles((float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.TR_SPAWN_RESULT));
|
new PacketParticles((float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.TR_SPAWN_RESULT));
|
||||||
this.level.playSound(null, this.worldPosition.getX() + 0.5, this.worldPosition.getY() + 0.5, this.worldPosition.getZ() + 0.5,
|
this.level.playSound(null, this.worldPosition.getX() + 0.5, this.worldPosition.getY() + 0.5, this.worldPosition.getZ() + 0.5,
|
||||||
SoundEvents.ENDERMAN_TELEPORT, SoundSource.BLOCKS, 0.65F, 1F);
|
SoundEvents.ENDERMAN_TELEPORT, SoundSource.BLOCKS, 0.65F, 1F);
|
||||||
|
|
||||||
this.ritualPos = null;
|
this.ritualPos = null;
|
||||||
this.recipe = null;
|
this.recipe = null;
|
||||||
|
@ -100,9 +99,9 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
|
||||||
var tile = this.level.getBlockEntity(pos);
|
var tile = this.level.getBlockEntity(pos);
|
||||||
if (tile instanceof BlockEntityWoodStand stand && !stand.items.getStackInSlot(0).isEmpty()) {
|
if (tile instanceof BlockEntityWoodStand stand && !stand.items.getStackInSlot(0).isEmpty()) {
|
||||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
||||||
new PacketParticles(stand.worldPosition.getX(), stand.worldPosition.getY(), stand.worldPosition.getZ(), PacketParticles.Type.TR_CONSUME_ITEM));
|
new PacketParticles(stand.worldPosition.getX(), stand.worldPosition.getY(), stand.worldPosition.getZ(), PacketParticles.Type.TR_CONSUME_ITEM));
|
||||||
this.level.playSound(null, stand.worldPosition.getX() + 0.5, stand.worldPosition.getY() + 0.5, stand.worldPosition.getZ() + 0.5,
|
this.level.playSound(null, stand.worldPosition.getX() + 0.5, stand.worldPosition.getY() + 0.5, stand.worldPosition.getZ() + 0.5,
|
||||||
SoundEvents.WOOD_STEP, SoundSource.BLOCKS, 0.5F, 1F);
|
SoundEvents.WOOD_STEP, SoundSource.BLOCKS, 0.5F, 1F);
|
||||||
|
|
||||||
stand.items.setStackInSlot(0, ItemStack.EMPTY);
|
stand.items.setStackInSlot(0, ItemStack.EMPTY);
|
||||||
stand.sendToClients();
|
stand.sendToClients();
|
||||||
|
@ -155,10 +154,10 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||||
super.writeNBT(compound, type, registries);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK)
|
if (type != SaveType.BLOCK)
|
||||||
compound.put("items", this.items.serializeNBT(registries));
|
compound.put("items", this.items.serializeNBT());
|
||||||
|
|
||||||
if (type == SaveType.TILE) {
|
if (type == SaveType.TILE) {
|
||||||
if (this.ritualPos != null && this.recipe != null) {
|
if (this.ritualPos != null && this.recipe != null) {
|
||||||
|
@ -171,17 +170,17 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) {
|
public void readNBT(CompoundTag compound, SaveType type) {
|
||||||
super.readNBT(compound, type, registries);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK)
|
if (type != SaveType.BLOCK)
|
||||||
this.items.deserializeNBT(registries, compound.getCompound("items"));
|
this.items.deserializeNBT(compound.getCompound("items"));
|
||||||
|
|
||||||
if (type == SaveType.TILE) {
|
if (type == SaveType.TILE) {
|
||||||
if (compound.contains("recipe")) {
|
if (compound.contains("recipe")) {
|
||||||
this.ritualPos = BlockPos.of(compound.getLong("ritual_pos"));
|
this.ritualPos = BlockPos.of(compound.getLong("ritual_pos"));
|
||||||
this.timer = compound.getInt("timer");
|
this.timer = compound.getInt("timer");
|
||||||
if (this.hasLevel())
|
if (this.hasLevel())
|
||||||
this.recipe = (RecipeHolder<TreeRitualRecipe>) this.level.getRecipeManager().byKey(ResourceLocation.parse(compound.getString("recipe"))).orElse(null);
|
this.recipe = (RecipeHolder<TreeRitualRecipe>) this.level.getRecipeManager().byKey(new ResourceLocation(compound.getString("recipe"))).orElse(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,11 @@ import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.FastColor;
|
|
||||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
|
|
||||||
public class RenderAuraTimer implements BlockEntityRenderer<BlockEntityAuraTimer> {
|
public class RenderAuraTimer implements BlockEntityRenderer<BlockEntityAuraTimer> {
|
||||||
|
|
||||||
private static final ResourceLocation RES = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/models/aura_timer_aura.png");
|
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/aura_timer_aura.png");
|
||||||
private final AuraModel model = new AuraModel();
|
private final AuraModel model = new AuraModel();
|
||||||
|
|
||||||
public RenderAuraTimer(BlockEntityRendererProvider.Context context) {
|
public RenderAuraTimer(BlockEntityRendererProvider.Context context) {
|
||||||
|
@ -42,7 +41,7 @@ public class RenderAuraTimer implements BlockEntityRenderer<BlockEntityAuraTimer
|
||||||
var r = (type.getColor() >> 16 & 255) / 255F;
|
var r = (type.getColor() >> 16 & 255) / 255F;
|
||||||
var g = (type.getColor() >> 8 & 255) / 255F;
|
var g = (type.getColor() >> 8 & 255) / 255F;
|
||||||
var b = (type.getColor() & 255) / 255F;
|
var b = (type.getColor() & 255) / 255F;
|
||||||
this.model.renderToBuffer(stack, buffer.getBuffer(this.model.renderType(RenderAuraTimer.RES)), combinedLightIn, combinedOverlayIn, FastColor.ARGB32.colorFromFloat(r, g, b, 0.75F));
|
this.model.renderToBuffer(stack, buffer.getBuffer(this.model.renderType(RenderAuraTimer.RES)), combinedLightIn, combinedOverlayIn, r, g, b, 0.75F);
|
||||||
stack.popPose();
|
stack.popPose();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -60,8 +59,8 @@ public class RenderAuraTimer implements BlockEntityRenderer<BlockEntityAuraTimer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderToBuffer(PoseStack poseStack, VertexConsumer buffer, int packedLight, int packedOverlay, int color) {
|
public void renderToBuffer(PoseStack matrixStackIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
|
||||||
this.model.render(poseStack, buffer, packedLight, packedOverlay, color);
|
this.model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,10 @@ public class RenderEnderCrate implements BlockEntityRenderer<BlockEntityEnderCra
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void renderFace(Matrix4f p_173696_, VertexConsumer p_173697_, float p_173700_, float p_173701_) {
|
private static void renderFace(Matrix4f p_173696_, VertexConsumer p_173697_, float p_173700_, float p_173701_) {
|
||||||
p_173697_.addVertex(p_173696_, (float) 1 / 16F, p_173700_, (float) 15 / 16F);
|
p_173697_.vertex(p_173696_, (float) 1 / 16F, p_173700_, (float) 15 / 16F).endVertex();
|
||||||
p_173697_.addVertex(p_173696_, (float) 15 / 16F, p_173700_, (float) 15 / 16F);
|
p_173697_.vertex(p_173696_, (float) 15 / 16F, p_173700_, (float) 15 / 16F).endVertex();
|
||||||
p_173697_.addVertex(p_173696_, (float) 15 / 16F, p_173701_, (float) 1 / 16F);
|
p_173697_.vertex(p_173696_, (float) 15 / 16F, p_173701_, (float) 1 / 16F).endVertex();
|
||||||
p_173697_.addVertex(p_173696_, (float) 1 / 16F, p_173701_, (float) 1 / 16F);
|
p_173697_.vertex(p_173696_, (float) 1 / 16F, p_173701_, (float) 1 / 16F).endVertex();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float getOffsetUp() {
|
private static float getOffsetUp() {
|
||||||
|
@ -39,5 +39,4 @@ public class RenderEnderCrate implements BlockEntityRenderer<BlockEntityEnderCra
|
||||||
private static RenderType renderType() {
|
private static RenderType renderType() {
|
||||||
return RenderType.endPortal();
|
return RenderType.endPortal();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,14 +17,13 @@ import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.FastColor;
|
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public class RenderGeneratorLimitRemover implements BlockEntityRenderer<BlockEntityGeneratorLimitRemover> {
|
public class RenderGeneratorLimitRemover implements BlockEntityRenderer<BlockEntityGeneratorLimitRemover> {
|
||||||
|
|
||||||
private static final ResourceLocation RES = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/models/generator_limit_remover_glint.png");
|
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/generator_limit_remover_glint.png");
|
||||||
private final ModelLimitRemoverGlint model = new ModelLimitRemoverGlint();
|
private final ModelLimitRemoverGlint model = new ModelLimitRemoverGlint();
|
||||||
|
|
||||||
public RenderGeneratorLimitRemover(BlockEntityRendererProvider.Context context) {
|
public RenderGeneratorLimitRemover(BlockEntityRendererProvider.Context context) {
|
||||||
|
@ -47,7 +46,7 @@ public class RenderGeneratorLimitRemover implements BlockEntityRenderer<BlockEnt
|
||||||
stack.translate(-0.002F + xOff, 1 + 0.002F + yOff, 1 + 0.002F + zOff);
|
stack.translate(-0.002F + xOff, 1 + 0.002F + yOff, 1 + 0.002F + zOff);
|
||||||
stack.mulPose(Axis.XP.rotationDegrees(180F));
|
stack.mulPose(Axis.XP.rotationDegrees(180F));
|
||||||
stack.scale(1.004F, 1.004F, 1.004F);
|
stack.scale(1.004F, 1.004F, 1.004F);
|
||||||
model.renderToBuffer(stack, buffer.getBuffer(model.renderType(texture)), brightness, combinedOverlayIn, FastColor.ARGB32.colorFromFloat(1, 1, 1, alpha * maxAlpha));
|
model.renderToBuffer(stack, buffer.getBuffer(model.renderType(texture)), brightness, combinedOverlayIn, 1, 1, 1, alpha * maxAlpha);
|
||||||
stack.popPose();
|
stack.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,10 +63,8 @@ public class RenderGeneratorLimitRemover implements BlockEntityRenderer<BlockEnt
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderToBuffer(PoseStack matrixStackIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, int color) {
|
public void renderToBuffer(PoseStack matrixStackIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
|
||||||
this.model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, color);
|
this.model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import static de.ellpeck.naturesaura.blocks.tiles.render.RenderGeneratorLimitRem
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public class RenderLowerLimiter implements BlockEntityRenderer<BlockEntityLowerLimiter> {
|
public class RenderLowerLimiter implements BlockEntityRenderer<BlockEntityLowerLimiter> {
|
||||||
|
|
||||||
private static final ResourceLocation RES = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/models/lower_limiter_glint.png");
|
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/lower_limiter_glint.png");
|
||||||
private final ModelLimitRemoverGlint model = new ModelLimitRemoverGlint();
|
private final ModelLimitRemoverGlint model = new ModelLimitRemoverGlint();
|
||||||
|
|
||||||
public RenderLowerLimiter(BlockEntityRendererProvider.Context context) {}
|
public RenderLowerLimiter(BlockEntityRendererProvider.Context context) {}
|
||||||
|
|
|
@ -17,14 +17,13 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.FastColor;
|
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public class RenderProjectileGenerator implements BlockEntityRenderer<BlockEntityProjectileGenerator> {
|
public class RenderProjectileGenerator implements BlockEntityRenderer<BlockEntityProjectileGenerator> {
|
||||||
|
|
||||||
private static final ResourceLocation RES = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/models/projectile_generator_overlay.png");
|
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/projectile_generator_overlay.png");
|
||||||
private final ModelOverlay model = new ModelOverlay();
|
private final ModelOverlay model = new ModelOverlay();
|
||||||
|
|
||||||
public RenderProjectileGenerator(BlockEntityRendererProvider.Context context) {
|
public RenderProjectileGenerator(BlockEntityRendererProvider.Context context) {
|
||||||
|
@ -47,7 +46,7 @@ public class RenderProjectileGenerator implements BlockEntityRenderer<BlockEntit
|
||||||
stack.translate(-0.002F, 0, 0);
|
stack.translate(-0.002F, 0, 0);
|
||||||
}
|
}
|
||||||
var brightness = 15 << 20 | 15 << 4;
|
var brightness = 15 << 20 | 15 << 4;
|
||||||
this.model.renderToBuffer(stack, buffer.getBuffer(this.model.renderType(RenderProjectileGenerator.RES)), brightness, combinedOverlayIn, FastColor.ARGB32.colorFromFloat(1, 1, 1, 1));
|
this.model.renderToBuffer(stack, buffer.getBuffer(this.model.renderType(RenderProjectileGenerator.RES)), brightness, combinedOverlayIn, 1, 1, 1, 1);
|
||||||
stack.popPose();
|
stack.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,10 +63,8 @@ public class RenderProjectileGenerator implements BlockEntityRenderer<BlockEntit
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderToBuffer(PoseStack matrixStackIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, int color) {
|
public void renderToBuffer(PoseStack matrixStackIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
|
||||||
this.model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, color);
|
this.model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,10 +132,10 @@ public class AuraChunk implements IAuraChunk {
|
||||||
this.drainSpots.put(spot.pos, spot);
|
this.drainSpots.put(spot.pos, spot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSpots(Collection<CompoundTag> spots) {
|
public void setSpots(Collection<DrainSpot> spots) {
|
||||||
this.drainSpots.clear();
|
this.drainSpots.clear();
|
||||||
for (var spot : spots)
|
for (var spot : spots)
|
||||||
this.addDrainSpot(new DrainSpot(spot));
|
this.addDrainSpot(spot);
|
||||||
this.addOrRemoveAsActive();
|
this.addOrRemoveAsActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraft.world.phys.AABB;
|
||||||
|
|
||||||
public class AngerEffect implements IDrainSpotEffect {
|
public class AngerEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "anger");
|
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "anger");
|
||||||
|
|
||||||
private AABB bb;
|
private AABB bb;
|
||||||
|
|
||||||
|
@ -77,5 +77,4 @@ public class AngerEffect implements IDrainSpotEffect {
|
||||||
public ResourceLocation getName() {
|
public ResourceLocation getName() {
|
||||||
return AngerEffect.NAME;
|
return AngerEffect.NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Comparator;
|
||||||
|
|
||||||
public class AnimalEffect implements IDrainSpotEffect {
|
public class AnimalEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "animal");
|
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "animal");
|
||||||
|
|
||||||
private int chance;
|
private int chance;
|
||||||
private AABB bb;
|
private AABB bb;
|
||||||
|
@ -113,8 +113,8 @@ public class AnimalEffect implements IDrainSpotEffect {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var secondOptional = animals.stream()
|
var secondOptional = animals.stream()
|
||||||
.filter(e -> e != first && !e.isInLove() && !e.isBaby())
|
.filter(e -> e != first && !e.isInLove() && !e.isBaby())
|
||||||
.min(Comparator.comparingDouble(e -> e.distanceToSqr(first)));
|
.min(Comparator.comparingDouble(e -> e.distanceToSqr(first)));
|
||||||
if (secondOptional.isEmpty())
|
if (secondOptional.isEmpty())
|
||||||
return;
|
return;
|
||||||
var second = secondOptional.get();
|
var second = secondOptional.get();
|
||||||
|
@ -133,12 +133,12 @@ public class AnimalEffect implements IDrainSpotEffect {
|
||||||
animal.setInLove(null);
|
animal.setInLove(null);
|
||||||
for (var j = 0; j < 7; j++)
|
for (var j = 0; j < 7; j++)
|
||||||
animal.level().addParticle(ParticleTypes.HEART,
|
animal.level().addParticle(ParticleTypes.HEART,
|
||||||
animal.getX() + (double) (animal.level().random.nextFloat() * animal.getBbWidth() * 2.0F) - animal.getBbWidth(),
|
animal.getX() + (double) (animal.level().random.nextFloat() * animal.getBbWidth() * 2.0F) - animal.getBbWidth(),
|
||||||
animal.getY() + 0.5D + (double) (animal.level().random.nextFloat() * animal.getBbHeight()),
|
animal.getY() + 0.5D + (double) (animal.level().random.nextFloat() * animal.getBbHeight()),
|
||||||
animal.getZ() + (double) (animal.level().random.nextFloat() * animal.getBbWidth() * 2.0F) - animal.getBbWidth(),
|
animal.getZ() + (double) (animal.level().random.nextFloat() * animal.getBbWidth() * 2.0F) - animal.getBbWidth(),
|
||||||
animal.level().random.nextGaussian() * 0.02D,
|
animal.level().random.nextGaussian() * 0.02D,
|
||||||
animal.level().random.nextGaussian() * 0.02D,
|
animal.level().random.nextGaussian() * 0.02D,
|
||||||
animal.level().random.nextGaussian() * 0.02D);
|
animal.level().random.nextGaussian() * 0.02D);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -150,5 +150,4 @@ public class AnimalEffect implements IDrainSpotEffect {
|
||||||
public ResourceLocation getName() {
|
public ResourceLocation getName() {
|
||||||
return AnimalEffect.NAME;
|
return AnimalEffect.NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import org.apache.commons.lang3.mutable.MutableInt;
|
||||||
|
|
||||||
public class BalanceEffect implements IDrainSpotEffect {
|
public class BalanceEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "balance");
|
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "balance");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot, AuraChunk.DrainSpot actualSpot) {
|
public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot, AuraChunk.DrainSpot actualSpot) {
|
||||||
|
|
|
@ -8,7 +8,6 @@ import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||||
import de.ellpeck.naturesaura.chunk.AuraChunk;
|
import de.ellpeck.naturesaura.chunk.AuraChunk;
|
||||||
import de.ellpeck.naturesaura.potion.ModPotions;
|
import de.ellpeck.naturesaura.potion.ModPotions;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Holder;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
|
@ -22,7 +21,7 @@ import net.minecraft.world.phys.AABB;
|
||||||
|
|
||||||
public class BreathlessEffect implements IDrainSpotEffect {
|
public class BreathlessEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "breathless");
|
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "breathless");
|
||||||
|
|
||||||
private int amp;
|
private int amp;
|
||||||
private AABB bb;
|
private AABB bb;
|
||||||
|
@ -63,7 +62,7 @@ public class BreathlessEffect implements IDrainSpotEffect {
|
||||||
return;
|
return;
|
||||||
var entities = level.getEntitiesOfClass(LivingEntity.class, this.bb);
|
var entities = level.getEntitiesOfClass(LivingEntity.class, this.bb);
|
||||||
for (var entity : entities)
|
for (var entity : entities)
|
||||||
entity.addEffect(new MobEffectInstance(Holder.direct(ModPotions.BREATHLESS), 300, this.amp));
|
entity.addEffect(new MobEffectInstance(ModPotions.BREATHLESS, 300, this.amp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -75,5 +74,4 @@ public class BreathlessEffect implements IDrainSpotEffect {
|
||||||
public ResourceLocation getName() {
|
public ResourceLocation getName() {
|
||||||
return BreathlessEffect.NAME;
|
return BreathlessEffect.NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraft.world.phys.AABB;
|
||||||
|
|
||||||
public class CacheRechargeEffect implements IDrainSpotEffect {
|
public class CacheRechargeEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "cache_recharge");
|
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "cache_recharge");
|
||||||
|
|
||||||
private int amount;
|
private int amount;
|
||||||
private AABB bb;
|
private AABB bb;
|
||||||
|
@ -77,5 +77,4 @@ public class CacheRechargeEffect implements IDrainSpotEffect {
|
||||||
public ResourceLocation getName() {
|
public ResourceLocation getName() {
|
||||||
return CacheRechargeEffect.NAME;
|
return CacheRechargeEffect.NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import net.neoforged.neoforge.event.EventHooks;
|
||||||
|
|
||||||
public class ExplosionEffect implements IDrainSpotEffect {
|
public class ExplosionEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "explosions");
|
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "explosions");
|
||||||
|
|
||||||
private float strength;
|
private float strength;
|
||||||
private int dist;
|
private int dist;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import net.minecraft.world.level.chunk.LevelChunk;
|
||||||
|
|
||||||
public class GrassDieEffect implements IDrainSpotEffect {
|
public class GrassDieEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "grass_die");
|
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "grass_die");
|
||||||
|
|
||||||
private int amount;
|
private int amount;
|
||||||
private int dist;
|
private int dist;
|
||||||
|
@ -63,9 +63,9 @@ public class GrassDieEffect implements IDrainSpotEffect {
|
||||||
return;
|
return;
|
||||||
for (var i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) {
|
for (var i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) {
|
||||||
var grassPos = BlockPos.containing(
|
var grassPos = BlockPos.containing(
|
||||||
pos.getX() + level.random.nextGaussian() * this.dist,
|
pos.getX() + level.random.nextGaussian() * this.dist,
|
||||||
pos.getY() + level.random.nextGaussian() * this.dist,
|
pos.getY() + level.random.nextGaussian() * this.dist,
|
||||||
pos.getZ() + level.random.nextGaussian() * this.dist
|
pos.getZ() + level.random.nextGaussian() * this.dist
|
||||||
);
|
);
|
||||||
if (grassPos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(grassPos)) {
|
if (grassPos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(grassPos)) {
|
||||||
var state = level.getBlockState(grassPos);
|
var state = level.getBlockState(grassPos);
|
||||||
|
@ -96,5 +96,4 @@ public class GrassDieEffect implements IDrainSpotEffect {
|
||||||
public ResourceLocation getName() {
|
public ResourceLocation getName() {
|
||||||
return GrassDieEffect.NAME;
|
return GrassDieEffect.NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import net.minecraft.world.level.chunk.LevelChunk;
|
||||||
|
|
||||||
public class NetherDecayEffect implements IDrainSpotEffect {
|
public class NetherDecayEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "nether_decay");
|
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "nether_decay");
|
||||||
|
|
||||||
private int amount;
|
private int amount;
|
||||||
private int dist;
|
private int dist;
|
||||||
|
@ -62,9 +62,9 @@ public class NetherDecayEffect implements IDrainSpotEffect {
|
||||||
return;
|
return;
|
||||||
for (var i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) {
|
for (var i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) {
|
||||||
var offset = BlockPos.containing(
|
var offset = BlockPos.containing(
|
||||||
pos.getX() + level.random.nextGaussian() * this.dist,
|
pos.getX() + level.random.nextGaussian() * this.dist,
|
||||||
pos.getY() + level.random.nextGaussian() * this.dist,
|
pos.getY() + level.random.nextGaussian() * this.dist,
|
||||||
pos.getZ() + level.random.nextGaussian() * this.dist);
|
pos.getZ() + level.random.nextGaussian() * this.dist);
|
||||||
if (offset.distSqr(pos) > this.dist * this.dist || !level.isLoaded(offset))
|
if (offset.distSqr(pos) > this.dist * this.dist || !level.isLoaded(offset))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -101,5 +101,4 @@ public class NetherDecayEffect implements IDrainSpotEffect {
|
||||||
public ResourceLocation getName() {
|
public ResourceLocation getName() {
|
||||||
return NetherDecayEffect.NAME;
|
return NetherDecayEffect.NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import net.neoforged.neoforge.common.Tags;
|
||||||
|
|
||||||
public class NetherGrassEffect implements IDrainSpotEffect {
|
public class NetherGrassEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "nether_grass");
|
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "nether_grass");
|
||||||
|
|
||||||
private int amount;
|
private int amount;
|
||||||
private int dist;
|
private int dist;
|
||||||
|
@ -78,14 +78,14 @@ public class NetherGrassEffect implements IDrainSpotEffect {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var state = level.getBlockState(goalPos);
|
var state = level.getBlockState(goalPos);
|
||||||
if (state.is(Tags.Blocks.NETHERRACKS)) {
|
if (state.is(Tags.Blocks.NETHERRACK)) {
|
||||||
level.setBlockAndUpdate(goalPos, ModBlocks.NETHER_GRASS.defaultBlockState());
|
level.setBlockAndUpdate(goalPos, ModBlocks.NETHER_GRASS.defaultBlockState());
|
||||||
|
|
||||||
var closestSpot = IAuraChunk.getHighestSpot(level, goalPos, 25, pos);
|
var closestSpot = IAuraChunk.getHighestSpot(level, goalPos, 25, pos);
|
||||||
IAuraChunk.getAuraChunk(level, closestSpot).drainAura(closestSpot, 500);
|
IAuraChunk.getAuraChunk(level, closestSpot).drainAura(closestSpot, 500);
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(level, goalPos, 32,
|
PacketHandler.sendToAllAround(level, goalPos, 32,
|
||||||
new PacketParticles(goalPos.getX(), goalPos.getY() + 0.5F, goalPos.getZ(), PacketParticles.Type.PLANT_BOOST));
|
new PacketParticles(goalPos.getX(), goalPos.getY() + 0.5F, goalPos.getZ(), PacketParticles.Type.PLANT_BOOST));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,5 +102,4 @@ public class NetherGrassEffect implements IDrainSpotEffect {
|
||||||
public ResourceLocation getName() {
|
public ResourceLocation getName() {
|
||||||
return NetherGrassEffect.NAME;
|
return NetherGrassEffect.NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ import java.util.Set;
|
||||||
public class OreSpawnEffect implements IDrainSpotEffect {
|
public class OreSpawnEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
public static final Set<BlockState> SPAWN_EXCEPTIONS = new HashSet<>();
|
public static final Set<BlockState> SPAWN_EXCEPTIONS = new HashSet<>();
|
||||||
public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "ore_spawn");
|
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "ore_spawn");
|
||||||
|
|
||||||
private int amount;
|
private int amount;
|
||||||
private int dist;
|
private int dist;
|
||||||
|
@ -93,7 +93,7 @@ public class OreSpawnEffect implements IDrainSpotEffect {
|
||||||
var totalWeight = WeightedRandom.getTotalWeight(ores);
|
var totalWeight = WeightedRandom.getTotalWeight(ores);
|
||||||
|
|
||||||
var powders = NaturesAuraAPI.instance().getActiveEffectPowders(level,
|
var powders = NaturesAuraAPI.instance().getActiveEffectPowders(level,
|
||||||
new AABB(pos).inflate(this.dist), OreSpawnEffect.NAME);
|
new AABB(pos).inflate(this.dist), OreSpawnEffect.NAME);
|
||||||
if (powders.isEmpty())
|
if (powders.isEmpty())
|
||||||
return;
|
return;
|
||||||
for (var i = 0; i < this.amount; i++) {
|
for (var i = 0; i < this.amount; i++) {
|
||||||
|
@ -105,7 +105,7 @@ public class OreSpawnEffect implements IDrainSpotEffect {
|
||||||
var z = Mth.floor(powderPos.z + level.random.nextGaussian() * range);
|
var z = Mth.floor(powderPos.z + level.random.nextGaussian() * range);
|
||||||
var orePos = new BlockPos(x, y, z);
|
var orePos = new BlockPos(x, y, z);
|
||||||
if (orePos.distToCenterSqr(powderPos.x, powderPos.y, powderPos.z) <= range * range
|
if (orePos.distToCenterSqr(powderPos.x, powderPos.y, powderPos.z) <= range * range
|
||||||
&& orePos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(orePos)) {
|
&& orePos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(orePos)) {
|
||||||
var state = level.getBlockState(orePos);
|
var state = level.getBlockState(orePos);
|
||||||
if (state.getBlock() != requiredBlock)
|
if (state.getBlock() != requiredBlock)
|
||||||
continue;
|
continue;
|
||||||
|
@ -149,7 +149,7 @@ public class OreSpawnEffect implements IDrainSpotEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean appliesHere(LevelChunk chunk, IAuraChunk auraChunk, IAuraType type) {
|
public boolean appliesHere(LevelChunk chunk, IAuraChunk auraChunk, IAuraType type) {
|
||||||
return ModConfig.instance.oreEffect.get() &&
|
return ModConfig.instance.oreEffect.get() &&
|
||||||
(type.isSimilar(NaturesAuraAPI.TYPE_OVERWORLD) || type.isSimilar(NaturesAuraAPI.TYPE_NETHER));
|
(type.isSimilar(NaturesAuraAPI.TYPE_OVERWORLD) || type.isSimilar(NaturesAuraAPI.TYPE_NETHER));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,7 +28,7 @@ import java.util.Set;
|
||||||
public class PlantBoostEffect implements IDrainSpotEffect {
|
public class PlantBoostEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
public static final Set<Block> EXCEPTIONS = new HashSet<>(List.of(Blocks.GRASS_BLOCK, Blocks.MOSS_BLOCK, Blocks.GLOW_LICHEN, Blocks.SMALL_DRIPLEAF, Blocks.BIG_DRIPLEAF, Blocks.BIG_DRIPLEAF_STEM));
|
public static final Set<Block> EXCEPTIONS = new HashSet<>(List.of(Blocks.GRASS_BLOCK, Blocks.MOSS_BLOCK, Blocks.GLOW_LICHEN, Blocks.SMALL_DRIPLEAF, Blocks.BIG_DRIPLEAF, Blocks.BIG_DRIPLEAF_STEM));
|
||||||
public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "plant_boost");
|
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "plant_boost");
|
||||||
|
|
||||||
private int amount;
|
private int amount;
|
||||||
private int dist;
|
private int dist;
|
||||||
|
@ -90,7 +90,7 @@ public class PlantBoostEffect implements IDrainSpotEffect {
|
||||||
IAuraChunk.getAuraChunk(level, closestSpot).drainAura(closestSpot, 3500);
|
IAuraChunk.getAuraChunk(level, closestSpot).drainAura(closestSpot, 3500);
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(level, plantPos, 32,
|
PacketHandler.sendToAllAround(level, plantPos, 32,
|
||||||
new PacketParticles(plantPos.getX(), plantPos.getY(), plantPos.getZ(), PacketParticles.Type.PLANT_BOOST));
|
new PacketParticles(plantPos.getX(), plantPos.getY(), plantPos.getZ(), PacketParticles.Type.PLANT_BOOST));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,5 +106,4 @@ public class PlantBoostEffect implements IDrainSpotEffect {
|
||||||
public ResourceLocation getName() {
|
public ResourceLocation getName() {
|
||||||
return PlantBoostEffect.NAME;
|
return PlantBoostEffect.NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import java.util.List;
|
||||||
|
|
||||||
public class ReplenishingEffect implements IDrainSpotEffect {
|
public class ReplenishingEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "replenishing");
|
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "replenishing");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot, AuraChunk.DrainSpot actualSpot) {
|
public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot, AuraChunk.DrainSpot actualSpot) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ import net.minecraft.world.level.chunk.LevelChunk;
|
||||||
|
|
||||||
public class SpreadEffect implements IDrainSpotEffect {
|
public class SpreadEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "spread");
|
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "spread");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot, AuraChunk.DrainSpot actualSpot) {
|
public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot, AuraChunk.DrainSpot actualSpot) {
|
||||||
|
|
|
@ -18,11 +18,10 @@ public final class Compat {
|
||||||
|
|
||||||
@SuppressWarnings("Convert2MethodRef") // bleh classloading compat issues
|
@SuppressWarnings("Convert2MethodRef") // bleh classloading compat issues
|
||||||
private static final Map<String, Supplier<ICompat>> MODULE_TYPES = ImmutableMap.<String, Supplier<ICompat>>builder()
|
private static final Map<String, Supplier<ICompat>> MODULE_TYPES = ImmutableMap.<String, Supplier<ICompat>>builder()
|
||||||
.put("patchouli", () -> new PatchouliCompat())
|
.put("patchouli", () -> new PatchouliCompat())
|
||||||
// TODO curios?
|
.put("curios", () -> new CuriosCompat())
|
||||||
//.put("curios", () -> new CuriosCompat())
|
//.put("enchantability", EnchantibilityCompat::new)
|
||||||
//.put("enchantability", EnchantibilityCompat::new)
|
.build();
|
||||||
.build();
|
|
||||||
private static final Map<String, ICompat> MODULES = new HashMap<>();
|
private static final Map<String, ICompat> MODULES = new HashMap<>();
|
||||||
|
|
||||||
public static void setup(FMLCommonSetupEvent event) {
|
public static void setup(FMLCommonSetupEvent event) {
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
// TODO curios?
|
|
||||||
/*
|
|
||||||
package de.ellpeck.naturesaura.compat;
|
package de.ellpeck.naturesaura.compat;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
@ -90,4 +88,3 @@ public class CuriosCompat implements ICompat {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class AltarCategory implements IRecipeCategory<AltarRecipe> {
|
||||||
private final ItemStack altar = new ItemStack(ModBlocks.NATURE_ALTAR);
|
private final ItemStack altar = new ItemStack(ModBlocks.NATURE_ALTAR);
|
||||||
|
|
||||||
public AltarCategory(IGuiHelper helper) {
|
public AltarCategory(IGuiHelper helper) {
|
||||||
this.background = helper.createDrawable(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/gui/jei/altar.png"), 0, 0, 103, 57);
|
this.background = helper.createDrawable(new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/jei/altar.png"), 0, 0, 103, 57);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -53,5 +53,4 @@ public class AltarCategory implements IRecipeCategory<AltarRecipe> {
|
||||||
builder.addSlot(RecipeIngredientRole.OUTPUT, 81, 19).addItemStack(recipe.output);
|
builder.addSlot(RecipeIngredientRole.OUTPUT, 81, 19).addItemStack(recipe.output);
|
||||||
builder.addSlot(RecipeIngredientRole.CATALYST, 38, 19).addItemStacks(recipe.catalyst == Ingredient.EMPTY ? Collections.singletonList(this.altar) : Arrays.asList(recipe.catalyst.getItems()));
|
builder.addSlot(RecipeIngredientRole.CATALYST, 38, 19).addItemStacks(recipe.catalyst == Ingredient.EMPTY ? Collections.singletonList(this.altar) : Arrays.asList(recipe.catalyst.getItems()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.SpawnEggItem;
|
import net.minecraft.world.item.SpawnEggItem;
|
||||||
|
import net.neoforged.neoforge.common.DeferredSpawnEggItem;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -35,15 +36,15 @@ public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecip
|
||||||
private final Map<EntityType<?>, Entity> entityCache = new HashMap<>();
|
private final Map<EntityType<?>, Entity> entityCache = new HashMap<>();
|
||||||
|
|
||||||
public AnimalSpawnerCategory(IGuiHelper helper) {
|
public AnimalSpawnerCategory(IGuiHelper helper) {
|
||||||
this.background = helper.createDrawable(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/gui/jei/animal_spawner.png"), 0, 0, 72, 86);
|
this.background = helper.createDrawable(new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/jei/animal_spawner.png"), 0, 0, 72, 86);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void renderEntity(PoseStack matrixstack, int x, int y, float scale, float yaw, float pitch, LivingEntity entity) {
|
private static void renderEntity(PoseStack matrixstack, int x, int y, float scale, float yaw, float pitch, LivingEntity entity) {
|
||||||
var f = (float) Math.atan(yaw / 40.0F);
|
var f = (float) Math.atan(yaw / 40.0F);
|
||||||
var f1 = (float) Math.atan(pitch / 40.0F);
|
var f1 = (float) Math.atan(pitch / 40.0F);
|
||||||
var posestack = RenderSystem.getModelViewStack();
|
var posestack = RenderSystem.getModelViewStack();
|
||||||
posestack.pushMatrix();
|
posestack.pushPose();
|
||||||
posestack.translate(x, y, 1050.0F);
|
posestack.translate(x, y, 1050.0D);
|
||||||
posestack.scale(1.0F, 1.0F, -1.0F);
|
posestack.scale(1.0F, 1.0F, -1.0F);
|
||||||
RenderSystem.applyModelViewMatrix();
|
RenderSystem.applyModelViewMatrix();
|
||||||
matrixstack.translate(0.0D, 0.0D, 1000.0D);
|
matrixstack.translate(0.0D, 0.0D, 1000.0D);
|
||||||
|
@ -76,7 +77,7 @@ public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecip
|
||||||
entity.setXRot(f4);
|
entity.setXRot(f4);
|
||||||
entity.yHeadRotO = f5;
|
entity.yHeadRotO = f5;
|
||||||
entity.yHeadRot = f6;
|
entity.yHeadRot = f6;
|
||||||
posestack.popMatrix();
|
posestack.popPose();
|
||||||
RenderSystem.applyModelViewMatrix();
|
RenderSystem.applyModelViewMatrix();
|
||||||
Lighting.setupFor3DItems();
|
Lighting.setupFor3DItems();
|
||||||
}
|
}
|
||||||
|
@ -126,5 +127,4 @@ public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecip
|
||||||
graphics.drawString(minecraft.font, name, 36 - minecraft.font.width(name) / 2F, 55, 0xFFFFFF, true);
|
graphics.drawString(minecraft.font, name, 36 - minecraft.font.width(name) / 2F, 55, 0xFFFFFF, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,7 @@ import de.ellpeck.naturesaura.recipes.*;
|
||||||
import mezz.jei.api.IModPlugin;
|
import mezz.jei.api.IModPlugin;
|
||||||
import mezz.jei.api.JeiPlugin;
|
import mezz.jei.api.JeiPlugin;
|
||||||
import mezz.jei.api.constants.VanillaTypes;
|
import mezz.jei.api.constants.VanillaTypes;
|
||||||
import mezz.jei.api.ingredients.subtypes.ISubtypeInterpreter;
|
import mezz.jei.api.ingredients.subtypes.IIngredientSubtypeInterpreter;
|
||||||
import mezz.jei.api.ingredients.subtypes.UidContext;
|
|
||||||
import mezz.jei.api.recipe.RecipeType;
|
import mezz.jei.api.recipe.RecipeType;
|
||||||
import mezz.jei.api.registration.IRecipeCatalystRegistration;
|
import mezz.jei.api.registration.IRecipeCatalystRegistration;
|
||||||
import mezz.jei.api.registration.IRecipeCategoryRegistration;
|
import mezz.jei.api.registration.IRecipeCategoryRegistration;
|
||||||
|
@ -21,7 +20,6 @@ import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
@JeiPlugin
|
@JeiPlugin
|
||||||
public class JEINaturesAuraPlugin implements IModPlugin {
|
public class JEINaturesAuraPlugin implements IModPlugin {
|
||||||
|
@ -33,60 +31,33 @@ public class JEINaturesAuraPlugin implements IModPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation getPluginUid() {
|
public ResourceLocation getPluginUid() {
|
||||||
return ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "jei_plugin");
|
return new ResourceLocation(NaturesAura.MOD_ID, "jei_plugin");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerCategories(IRecipeCategoryRegistration registry) {
|
public void registerCategories(IRecipeCategoryRegistration registry) {
|
||||||
var helper = registry.getJeiHelpers().getGuiHelper();
|
var helper = registry.getJeiHelpers().getGuiHelper();
|
||||||
registry.addRecipeCategories(
|
registry.addRecipeCategories(
|
||||||
new TreeRitualCategory(helper),
|
new TreeRitualCategory(helper),
|
||||||
new AltarCategory(helper),
|
new AltarCategory(helper),
|
||||||
new OfferingCategory(helper),
|
new OfferingCategory(helper),
|
||||||
new AnimalSpawnerCategory(helper)
|
new AnimalSpawnerCategory(helper)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerItemSubtypes(ISubtypeRegistration registration) {
|
public void registerItemSubtypes(ISubtypeRegistration registration) {
|
||||||
registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.EFFECT_POWDER, new ISubtypeInterpreter<>() {
|
registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.EFFECT_POWDER, (stack, context) -> ItemEffectPowder.getEffect(stack).toString());
|
||||||
@Override
|
registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.AURA_BOTTLE, (stack, context) -> ItemAuraBottle.getType(stack).getName().toString());
|
||||||
public @Nullable Object getSubtypeData(ItemStack ingredient, UidContext context) {
|
|
||||||
return ItemEffectPowder.getEffect(ingredient);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
var auraInterpreter = (IIngredientSubtypeInterpreter<ItemStack>) (stack, context) -> {
|
||||||
public String getLegacyStringSubtypeInfo(ItemStack ingredient, UidContext context) {
|
var container = stack.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY);
|
||||||
return ItemEffectPowder.getEffect(ingredient).toString();
|
if (container != null)
|
||||||
}
|
return String.valueOf(container.getStoredAura());
|
||||||
});
|
return IIngredientSubtypeInterpreter.NONE;
|
||||||
registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.AURA_BOTTLE, new ISubtypeInterpreter<>() {
|
|
||||||
@Override
|
|
||||||
public @Nullable Object getSubtypeData(ItemStack ingredient, UidContext context) {
|
|
||||||
return ItemAuraBottle.getType(ingredient).getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getLegacyStringSubtypeInfo(ItemStack ingredient, UidContext context) {
|
|
||||||
return ItemAuraBottle.getType(ingredient).getName().toString();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var auraInterpreter = new ISubtypeInterpreter<ItemStack>() {
|
|
||||||
@Override
|
|
||||||
public @Nullable Object getSubtypeData(ItemStack ingredient, UidContext context) {
|
|
||||||
var container = ingredient.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY);
|
|
||||||
return container != null ? container.getStoredAura() : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getLegacyStringSubtypeInfo(ItemStack ingredient, UidContext context) {
|
|
||||||
var container = ingredient.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY);
|
|
||||||
return container != null ? String.valueOf(container.getStoredAura()) : "";
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
registration.registerSubtypeInterpreter(ModItems.AURA_CACHE, auraInterpreter);
|
registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.AURA_CACHE, auraInterpreter);
|
||||||
registration.registerSubtypeInterpreter(ModItems.AURA_TROVE, auraInterpreter);
|
registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.AURA_TROVE, auraInterpreter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class OfferingCategory implements IRecipeCategory<OfferingRecipe> {
|
||||||
private final IDrawable background;
|
private final IDrawable background;
|
||||||
|
|
||||||
public OfferingCategory(IGuiHelper helper) {
|
public OfferingCategory(IGuiHelper helper) {
|
||||||
this.background = helper.createDrawable(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/gui/jei/offering.png"), 0, 0, 87, 36);
|
this.background = helper.createDrawable(new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/jei/offering.png"), 0, 0, 87, 36);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -48,5 +48,4 @@ public class OfferingCategory implements IRecipeCategory<OfferingRecipe> {
|
||||||
builder.addSlot(RecipeIngredientRole.OUTPUT, 66, 15).addItemStack(recipe.output);
|
builder.addSlot(RecipeIngredientRole.OUTPUT, 66, 15).addItemStack(recipe.output);
|
||||||
builder.addSlot(RecipeIngredientRole.INPUT, 28, 1).addItemStacks(Arrays.asList(recipe.startItem.getItems()));
|
builder.addSlot(RecipeIngredientRole.INPUT, 28, 1).addItemStacks(Arrays.asList(recipe.startItem.getItems()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class TreeRitualCategory implements IRecipeCategory<TreeRitualRecipe> {
|
||||||
private final IDrawable background;
|
private final IDrawable background;
|
||||||
|
|
||||||
public TreeRitualCategory(IGuiHelper helper) {
|
public TreeRitualCategory(IGuiHelper helper) {
|
||||||
this.background = helper.createDrawable(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/gui/jei/tree_ritual.png"), 0, 0, 146, 86);
|
this.background = helper.createDrawable(new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/jei/tree_ritual.png"), 0, 0, 146, 86);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,11 +5,11 @@ import de.ellpeck.naturesaura.ModConfig;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.api.multiblock.Matcher;
|
import de.ellpeck.naturesaura.api.multiblock.Matcher;
|
||||||
import de.ellpeck.naturesaura.compat.ICompat;
|
import de.ellpeck.naturesaura.compat.ICompat;
|
||||||
|
import de.ellpeck.naturesaura.data.ItemTagProvider;
|
||||||
import de.ellpeck.naturesaura.events.ClientEvents;
|
import de.ellpeck.naturesaura.events.ClientEvents;
|
||||||
import de.ellpeck.naturesaura.renderers.SupporterFancyHandler;
|
import de.ellpeck.naturesaura.renderers.SupporterFancyHandler;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.Style;
|
import net.minecraft.network.chat.Style;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -17,9 +17,9 @@ import net.minecraft.world.item.crafting.Ingredient;
|
||||||
import net.minecraft.world.item.crafting.Recipe;
|
import net.minecraft.world.item.crafting.Recipe;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
|
||||||
import vazkii.patchouli.api.BookDrawScreenEvent;
|
import vazkii.patchouli.api.BookDrawScreenEvent;
|
||||||
import vazkii.patchouli.api.IMultiblock;
|
import vazkii.patchouli.api.IMultiblock;
|
||||||
import vazkii.patchouli.api.IVariable;
|
import vazkii.patchouli.api.IVariable;
|
||||||
|
@ -32,7 +32,7 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class PatchouliCompat implements ICompat {
|
public class PatchouliCompat implements ICompat {
|
||||||
|
|
||||||
public static final ResourceLocation BOOK = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "book");
|
public static final ResourceLocation BOOK = new ResourceLocation(NaturesAura.MOD_ID, "book");
|
||||||
private static final Map<ResourceLocation, IMultiblock> MULTIBLOCKS = new HashMap<>();
|
private static final Map<ResourceLocation, IMultiblock> MULTIBLOCKS = new HashMap<>();
|
||||||
|
|
||||||
public static void addPatchouliMultiblock(ResourceLocation name, String[][] pattern, Object... rawMatchers) {
|
public static void addPatchouliMultiblock(ResourceLocation name, String[][] pattern, Object... rawMatchers) {
|
||||||
|
@ -43,7 +43,7 @@ public class PatchouliCompat implements ICompat {
|
||||||
rawMatchers[i] = PatchouliAPI.get().anyMatcher();
|
rawMatchers[i] = PatchouliAPI.get().anyMatcher();
|
||||||
else
|
else
|
||||||
rawMatchers[i] = PatchouliAPI.get().predicateMatcher(matcher.defaultState(),
|
rawMatchers[i] = PatchouliAPI.get().predicateMatcher(matcher.defaultState(),
|
||||||
state -> check.matches(null, null, null, null, state, (char) 0));
|
state -> check.matches(null, null, null, null, state, (char) 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PatchouliCompat.MULTIBLOCKS.put(name, PatchouliAPI.get().makeMultiblock(pattern, rawMatchers));
|
PatchouliCompat.MULTIBLOCKS.put(name, PatchouliAPI.get().makeMultiblock(pattern, rawMatchers));
|
||||||
|
@ -52,13 +52,14 @@ public class PatchouliCompat implements ICompat {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T extends Recipe<?>> T getRecipe(String type, String name) {
|
public static <T extends Recipe<?>> T getRecipe(String type, String name) {
|
||||||
var manager = Minecraft.getInstance().level.getRecipeManager();
|
var manager = Minecraft.getInstance().level.getRecipeManager();
|
||||||
var res = ResourceLocation.parse(name);
|
var res = new ResourceLocation(name);
|
||||||
var pre = ResourceLocation.fromNamespaceAndPath(res.getNamespace(), type + "/" + res.getPath());
|
var pre = new ResourceLocation(res.getNamespace(), type + "/" + res.getPath());
|
||||||
return (T) manager.byKey(pre).orElse(null).value();
|
return (T) manager.byKey(pre).orElse(null).value();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IVariable ingredientVariable(Ingredient ingredient, HolderLookup.Provider registries) {
|
public static IVariable ingredientVariable(Ingredient ingredient) {
|
||||||
return IVariable.wrapList(Arrays.stream(ingredient.getItems()).map(i -> IVariable.from(i, registries)).collect(Collectors.toList()), registries);
|
return IVariable.wrapList(Arrays.stream(ingredient.getItems())
|
||||||
|
.map(IVariable::from).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,6 +78,11 @@ public class PatchouliCompat implements ICompat {
|
||||||
NeoForge.EVENT_BUS.register(this);
|
NeoForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addItemTags(ItemTagProvider provider) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void onBookDraw(BookDrawScreenEvent event) {
|
public void onBookDraw(BookDrawScreenEvent event) {
|
||||||
|
@ -93,9 +99,9 @@ public class PatchouliCompat implements ICompat {
|
||||||
|
|
||||||
if (event.getMouseX() >= x && event.getMouseY() >= y && event.getMouseX() < x + 43 && event.getMouseY() < y + 42)
|
if (event.getMouseX() >= x && event.getMouseY() >= y && event.getMouseX() < x + 43 && event.getMouseY() < y + 42)
|
||||||
event.getGraphics().renderTooltip(Minecraft.getInstance().font,
|
event.getGraphics().renderTooltip(Minecraft.getInstance().font,
|
||||||
Collections.singletonList(Component.literal("It's the author Ellpeck's birthday!").setStyle(Style.EMPTY.applyFormat(ChatFormatting.GOLD))),
|
Collections.singletonList(Component.literal("It's the author Ellpeck's birthday!").setStyle(Style.EMPTY.applyFormat(ChatFormatting.GOLD))),
|
||||||
Optional.empty(),
|
Optional.empty(),
|
||||||
event.getMouseX(), event.getMouseY());
|
event.getMouseX(), event.getMouseY());
|
||||||
} else if (now.getMonth() == Month.JUNE) {
|
} else if (now.getMonth() == Month.JUNE) {
|
||||||
var x = gui.width / 2 + 272 / 2;
|
var x = gui.width / 2 + 272 / 2;
|
||||||
var y = gui.height / 2 + 32;
|
var y = gui.height / 2 + 32;
|
||||||
|
@ -105,8 +111,8 @@ public class PatchouliCompat implements ICompat {
|
||||||
if (event.getMouseX() >= x && event.getMouseY() >= y && event.getMouseX() < x + 45 && event.getMouseY() < y + 26)
|
if (event.getMouseX() >= x && event.getMouseY() >= y && event.getMouseX() < x + 45 && event.getMouseY() < y + 26)
|
||||||
//noinspection UnnecessaryUnicodeEscape
|
//noinspection UnnecessaryUnicodeEscape
|
||||||
event.getGraphics().renderTooltip(gui.getMinecraft().font,
|
event.getGraphics().renderTooltip(gui.getMinecraft().font,
|
||||||
Collections.singletonList(Component.literal("\u00A76Happy \u00A74P\u00A76r\u00A7ei\u00A72d\u00A79e\u00A75!")), Optional.empty(),
|
Collections.singletonList(Component.literal("\u00A76Happy \u00A74P\u00A76r\u00A7ei\u00A72d\u00A79e\u00A75!")), Optional.empty(),
|
||||||
event.getMouseX(), event.getMouseY());
|
event.getMouseX(), event.getMouseY());
|
||||||
}
|
}
|
||||||
|
|
||||||
var name = gui.getMinecraft().player.getName().getString();
|
var name = gui.getMinecraft().player.getName().getString();
|
||||||
|
@ -128,10 +134,9 @@ public class PatchouliCompat implements ICompat {
|
||||||
|
|
||||||
if (event.getMouseX() >= x && event.getMouseY() >= y && event.getMouseX() < x + 16 && event.getMouseY() < y + 18)
|
if (event.getMouseX() >= x && event.getMouseY() >= y && event.getMouseX() < x + 16 && event.getMouseY() < y + 18)
|
||||||
event.getGraphics().renderTooltip(gui.getMinecraft().font,
|
event.getGraphics().renderTooltip(gui.getMinecraft().font,
|
||||||
Collections.singletonList(Component.literal("Thanks for your support, " + name + "!").setStyle(Style.EMPTY.applyFormat(ChatFormatting.YELLOW))), Optional.empty(),
|
Collections.singletonList(Component.literal("Thanks for your support, " + name + "!").setStyle(Style.EMPTY.applyFormat(ChatFormatting.YELLOW))), Optional.empty(),
|
||||||
event.getMouseX(), event.getMouseY());
|
event.getMouseX(), event.getMouseY());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class ProcessorAltar implements IComponentProcessor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setup(Level level, IVariableProvider provider) {
|
public void setup(Level level, IVariableProvider provider) {
|
||||||
this.recipe = PatchouliCompat.getRecipe("altar", provider.get("recipe", level.registryAccess()).asString());
|
this.recipe = PatchouliCompat.getRecipe("altar", provider.get("recipe").asString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,10 +21,10 @@ public class ProcessorAltar implements IComponentProcessor {
|
||||||
if (this.recipe == null)
|
if (this.recipe == null)
|
||||||
return null;
|
return null;
|
||||||
return switch (key) {
|
return switch (key) {
|
||||||
case "input" -> PatchouliCompat.ingredientVariable(this.recipe.input, level.registryAccess());
|
case "input" -> PatchouliCompat.ingredientVariable(this.recipe.input);
|
||||||
case "output" -> IVariable.from(this.recipe.output, level.registryAccess());
|
case "output" -> IVariable.from(this.recipe.output);
|
||||||
case "catalyst" -> this.recipe.catalyst != Ingredient.EMPTY ? PatchouliCompat.ingredientVariable(this.recipe.catalyst, level.registryAccess()) : null;
|
case "catalyst" -> this.recipe.catalyst != Ingredient.EMPTY ? PatchouliCompat.ingredientVariable(this.recipe.catalyst) : null;
|
||||||
case "name" -> IVariable.wrap(this.recipe.output.getHoverName().getString(), level.registryAccess());
|
case "name" -> IVariable.wrap(this.recipe.output.getHoverName().getString());
|
||||||
default -> null;
|
default -> null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class ProcessorAnimalSpawner implements IComponentProcessor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setup(Level level, IVariableProvider provider) {
|
public void setup(Level level, IVariableProvider provider) {
|
||||||
this.recipe = PatchouliCompat.getRecipe("animal_spawner", provider.get("recipe", level.registryAccess()).asString());
|
this.recipe = PatchouliCompat.getRecipe("animal_spawner", provider.get("recipe").asString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -24,12 +24,12 @@ public class ProcessorAnimalSpawner implements IComponentProcessor {
|
||||||
return null;
|
return null;
|
||||||
if (key.startsWith("input")) {
|
if (key.startsWith("input")) {
|
||||||
var id = Integer.parseInt(key.substring(5)) - 1;
|
var id = Integer.parseInt(key.substring(5)) - 1;
|
||||||
return this.recipe.ingredients.size() > id ? PatchouliCompat.ingredientVariable(this.recipe.ingredients.get(id), level.registryAccess()) : null;
|
return this.recipe.ingredients.size() > id ? PatchouliCompat.ingredientVariable(this.recipe.ingredients.get(id)) : null;
|
||||||
} else {
|
} else {
|
||||||
return switch (key) {
|
return switch (key) {
|
||||||
case "name" -> IVariable.wrap(this.recipe.entity.getDescription().getString(), level.registryAccess());
|
case "name" -> IVariable.wrap(this.recipe.entity.getDescription().getString());
|
||||||
case "entity" -> IVariable.wrap(BuiltInRegistries.ENTITY_TYPE.getKey(this.recipe.entity).toString(), level.registryAccess());
|
case "entity" -> IVariable.wrap(BuiltInRegistries.ENTITY_TYPE.getKey(this.recipe.entity).toString());
|
||||||
case "egg" -> IVariable.from(new ItemStack(SpawnEggItem.byId(this.recipe.entity)), level.registryAccess());
|
case "egg" -> IVariable.from(new ItemStack(SpawnEggItem.byId(this.recipe.entity)));
|
||||||
default -> null;
|
default -> null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ public class ProcessorOffering implements IComponentProcessor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setup(Level level, IVariableProvider provider) {
|
public void setup(Level level, IVariableProvider provider) {
|
||||||
this.recipe = PatchouliCompat.getRecipe("offering", provider.get("recipe", level.registryAccess()).asString());
|
this.recipe = PatchouliCompat.getRecipe("offering", provider.get("recipe").asString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,10 +20,10 @@ public class ProcessorOffering implements IComponentProcessor {
|
||||||
if (this.recipe == null)
|
if (this.recipe == null)
|
||||||
return null;
|
return null;
|
||||||
return switch (key) {
|
return switch (key) {
|
||||||
case "input" -> PatchouliCompat.ingredientVariable(this.recipe.input, level.registryAccess());
|
case "input" -> PatchouliCompat.ingredientVariable(this.recipe.input);
|
||||||
case "output" -> IVariable.from(this.recipe.output, level.registryAccess());
|
case "output" -> IVariable.from(this.recipe.output);
|
||||||
case "start" -> PatchouliCompat.ingredientVariable(this.recipe.startItem, level.registryAccess());
|
case "start" -> PatchouliCompat.ingredientVariable(this.recipe.startItem);
|
||||||
case "name" -> IVariable.wrap(this.recipe.output.getHoverName().getString(), level.registryAccess());
|
case "name" -> IVariable.wrap(this.recipe.output.getHoverName().getString());
|
||||||
default -> null;
|
default -> null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ public class ProcessorTreeRitual implements IComponentProcessor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setup(Level level, IVariableProvider provider) {
|
public void setup(Level level, IVariableProvider provider) {
|
||||||
this.recipe = PatchouliCompat.getRecipe("tree_ritual", provider.get("recipe", level.registryAccess()).asString());
|
this.recipe = PatchouliCompat.getRecipe("tree_ritual", provider.get("recipe").asString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,15 +21,14 @@ public class ProcessorTreeRitual implements IComponentProcessor {
|
||||||
return null;
|
return null;
|
||||||
if (key.startsWith("input")) {
|
if (key.startsWith("input")) {
|
||||||
var id = Integer.parseInt(key.substring(5)) - 1;
|
var id = Integer.parseInt(key.substring(5)) - 1;
|
||||||
return this.recipe.ingredients.size() > id ? PatchouliCompat.ingredientVariable(this.recipe.ingredients.get(id), level.registryAccess()) : null;
|
return this.recipe.ingredients.size() > id ? PatchouliCompat.ingredientVariable(this.recipe.ingredients.get(id)) : null;
|
||||||
} else {
|
} else {
|
||||||
return switch (key) {
|
return switch (key) {
|
||||||
case "output" -> IVariable.from(this.recipe.output, level.registryAccess());
|
case "output" -> IVariable.from(this.recipe.output);
|
||||||
case "sapling" -> PatchouliCompat.ingredientVariable(this.recipe.saplingType, level.registryAccess());
|
case "sapling" -> PatchouliCompat.ingredientVariable(this.recipe.saplingType);
|
||||||
case "name" -> IVariable.wrap(this.recipe.output.getHoverName().getString(), level.registryAccess());
|
case "name" -> IVariable.wrap(this.recipe.output.getHoverName().getString());
|
||||||
default -> null;
|
default -> null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.gen.ModFeatures;
|
import de.ellpeck.naturesaura.gen.ModFeatures;
|
||||||
import net.minecraft.core.HolderSet;
|
import net.minecraft.core.HolderSet;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.data.worldgen.BootstrapContext;
|
import net.minecraft.data.worldgen.BootstapContext;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.tags.BiomeTags;
|
import net.minecraft.tags.BiomeTags;
|
||||||
|
@ -23,37 +23,37 @@ public class BiomeModifiers {
|
||||||
public static final ResourceKey<BiomeModifier> AURA_MUSHROOM = BiomeModifiers.createKey("aura_mushroom");
|
public static final ResourceKey<BiomeModifier> AURA_MUSHROOM = BiomeModifiers.createKey("aura_mushroom");
|
||||||
|
|
||||||
private static ResourceKey<BiomeModifier> createKey(String id) {
|
private static ResourceKey<BiomeModifier> createKey(String id) {
|
||||||
return ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS, ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, id));
|
return ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS, new ResourceLocation(NaturesAura.MOD_ID, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void bootstrap(BootstrapContext<BiomeModifier> context) {
|
public static void bootstrap(BootstapContext<BiomeModifier> context) {
|
||||||
var biomeGetter = context.lookup(Registries.BIOME);
|
var biomeGetter = context.lookup(Registries.BIOME);
|
||||||
var placedGetter = context.lookup(Registries.PLACED_FEATURE);
|
var placedGetter = context.lookup(Registries.PLACED_FEATURE);
|
||||||
|
|
||||||
context.register(BiomeModifiers.AURA_BLOOM, new AddFeaturesBiomeModifier(
|
context.register(BiomeModifiers.AURA_BLOOM, new AddFeaturesBiomeModifier(
|
||||||
biomeGetter.getOrThrow(BiomeTags.IS_OVERWORLD),
|
biomeGetter.getOrThrow(BiomeTags.IS_OVERWORLD),
|
||||||
HolderSet.direct(placedGetter.getOrThrow(ModFeatures.Placed.AURA_BLOOM)),
|
HolderSet.direct(placedGetter.getOrThrow(ModFeatures.Placed.AURA_BLOOM)),
|
||||||
GenerationStep.Decoration.VEGETAL_DECORATION));
|
GenerationStep.Decoration.VEGETAL_DECORATION));
|
||||||
|
|
||||||
context.register(BiomeModifiers.AURA_CACTUS, new AddFeaturesBiomeModifier(
|
context.register(BiomeModifiers.AURA_CACTUS, new AddFeaturesBiomeModifier(
|
||||||
biomeGetter.getOrThrow(Tags.Biomes.IS_SANDY),
|
biomeGetter.getOrThrow(Tags.Biomes.IS_SANDY),
|
||||||
HolderSet.direct(placedGetter.getOrThrow(ModFeatures.Placed.AURA_CACTUS)),
|
HolderSet.direct(placedGetter.getOrThrow(ModFeatures.Placed.AURA_CACTUS)),
|
||||||
GenerationStep.Decoration.VEGETAL_DECORATION));
|
GenerationStep.Decoration.VEGETAL_DECORATION));
|
||||||
|
|
||||||
context.register(BiomeModifiers.AURA_MUSHROOM, new AddFeaturesBiomeModifier(
|
context.register(BiomeModifiers.AURA_MUSHROOM, new AddFeaturesBiomeModifier(
|
||||||
biomeGetter.getOrThrow(Tags.Biomes.IS_MUSHROOM),
|
biomeGetter.getOrThrow(Tags.Biomes.IS_MUSHROOM),
|
||||||
HolderSet.direct(placedGetter.getOrThrow(ModFeatures.Placed.AURA_MUSHROOM)),
|
HolderSet.direct(placedGetter.getOrThrow(ModFeatures.Placed.AURA_MUSHROOM)),
|
||||||
GenerationStep.Decoration.VEGETAL_DECORATION));
|
GenerationStep.Decoration.VEGETAL_DECORATION));
|
||||||
|
|
||||||
context.register(BiomeModifiers.CRIMSON_AURA_MUSHROOM, new AddFeaturesBiomeModifier(
|
context.register(BiomeModifiers.CRIMSON_AURA_MUSHROOM, new AddFeaturesBiomeModifier(
|
||||||
biomeGetter.getOrThrow(BiomeTags.IS_NETHER),
|
biomeGetter.getOrThrow(BiomeTags.IS_NETHER),
|
||||||
HolderSet.direct(placedGetter.getOrThrow(ModFeatures.Placed.CRIMSON_AURA_MUSHROOM)),
|
HolderSet.direct(placedGetter.getOrThrow(ModFeatures.Placed.CRIMSON_AURA_MUSHROOM)),
|
||||||
GenerationStep.Decoration.VEGETAL_DECORATION));
|
GenerationStep.Decoration.VEGETAL_DECORATION));
|
||||||
|
|
||||||
context.register(BiomeModifiers.WARPED_AURA_MUSHROOM, new AddFeaturesBiomeModifier(
|
context.register(BiomeModifiers.WARPED_AURA_MUSHROOM, new AddFeaturesBiomeModifier(
|
||||||
biomeGetter.getOrThrow(BiomeTags.IS_NETHER),
|
biomeGetter.getOrThrow(BiomeTags.IS_NETHER),
|
||||||
HolderSet.direct(placedGetter.getOrThrow(ModFeatures.Placed.WARPED_AURA_MUSHROOM)),
|
HolderSet.direct(placedGetter.getOrThrow(ModFeatures.Placed.WARPED_AURA_MUSHROOM)),
|
||||||
GenerationStep.Decoration.VEGETAL_DECORATION));
|
GenerationStep.Decoration.VEGETAL_DECORATION));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import de.ellpeck.naturesaura.blocks.Slab;
|
||||||
import de.ellpeck.naturesaura.items.ModItems;
|
import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||||
import net.minecraft.advancements.critereon.StatePropertiesPredicate;
|
import net.minecraft.advancements.critereon.StatePropertiesPredicate;
|
||||||
import net.minecraft.core.HolderLookup;
|
|
||||||
import net.minecraft.data.loot.BlockLootSubProvider;
|
import net.minecraft.data.loot.BlockLootSubProvider;
|
||||||
import net.minecraft.world.flag.FeatureFlags;
|
import net.minecraft.world.flag.FeatureFlags;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
|
@ -26,8 +25,8 @@ import java.util.Set;
|
||||||
|
|
||||||
public class BlockLootProvider extends BlockLootSubProvider {
|
public class BlockLootProvider extends BlockLootSubProvider {
|
||||||
|
|
||||||
public BlockLootProvider(HolderLookup.Provider registries) {
|
public BlockLootProvider() {
|
||||||
super(Set.of(), FeatureFlags.REGISTRY.allFlags(), registries);
|
super(Set.of(), FeatureFlags.REGISTRY.allFlags());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -44,16 +43,15 @@ public class BlockLootProvider extends BlockLootSubProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.add(ModBlocks.ANCIENT_LEAVES, this::createSilkTouchOnlyTable);
|
this.add(ModBlocks.ANCIENT_LEAVES, BlockLootProvider::createSilkTouchOnlyTable);
|
||||||
this.add(ModBlocks.DECAYED_LEAVES, this::createSilkTouchOnlyTable);
|
this.add(ModBlocks.DECAYED_LEAVES, BlockLootProvider::createSilkTouchOnlyTable);
|
||||||
this.add(ModBlocks.GOLDEN_LEAVES, b -> LootTable.lootTable().withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1)).add(this.applyExplosionCondition(b, LootItem.lootTableItem(ModItems.GOLD_LEAF)).when(LootItemBlockStatePropertyCondition.hasBlockStateProperties(b).setProperties(StatePropertiesPredicate.Builder.properties().hasProperty(BlockGoldenLeaves.STAGE, BlockGoldenLeaves.HIGHEST_STAGE)))).when(LootItemRandomChanceCondition.randomChance(0.75F))));
|
this.add(ModBlocks.GOLDEN_LEAVES, b -> LootTable.lootTable().withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1)).add(this.applyExplosionCondition(b, LootItem.lootTableItem(ModItems.GOLD_LEAF)).when(LootItemBlockStatePropertyCondition.hasBlockStateProperties(b).setProperties(StatePropertiesPredicate.Builder.properties().hasProperty(BlockGoldenLeaves.STAGE, BlockGoldenLeaves.HIGHEST_STAGE)))).when(LootItemRandomChanceCondition.randomChance(0.75F))));
|
||||||
this.add(ModBlocks.NETHER_WART_MUSHROOM, b -> this.createSilkTouchDispatchTable(b, LootItem.lootTableItem(Items.NETHER_WART).apply(SetItemCountFunction.setCount(UniformGenerator.between(1, 2)))));
|
this.add(ModBlocks.NETHER_WART_MUSHROOM, b -> BlockLootSubProvider.createSilkTouchDispatchTable(b, LootItem.lootTableItem(Items.NETHER_WART).apply(SetItemCountFunction.setCount(UniformGenerator.between(1, 2)))));
|
||||||
this.add(ModBlocks.NETHER_GRASS, b -> this.createSilkTouchDispatchTable(b, LootItem.lootTableItem(Blocks.NETHERRACK)));
|
this.add(ModBlocks.NETHER_GRASS, b -> BlockLootSubProvider.createSilkTouchDispatchTable(b, LootItem.lootTableItem(Blocks.NETHERRACK)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Iterable<Block> getKnownBlocks() {
|
protected Iterable<Block> getKnownBlocks() {
|
||||||
return ModRegistry.ALL_ITEMS.stream().filter(i -> i instanceof Block).map(i -> (Block) i).toList();
|
return ModRegistry.ALL_ITEMS.stream().filter(i -> i instanceof Block).map(i -> (Block) i).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,10 @@ import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class BlockTagProvider extends BlockTagsProvider {
|
public class BlockTagProvider extends BlockTagsProvider {
|
||||||
|
|
||||||
public static final TagKey<Block> ALTAR_WOOD = BlockTags.create(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "altar_wood"));
|
public static final TagKey<Block> ALTAR_WOOD = BlockTags.create(new ResourceLocation(NaturesAura.MOD_ID, "altar_wood"));
|
||||||
public static final TagKey<Block> ALTAR_STONE = BlockTags.create(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "altar_stone"));
|
public static final TagKey<Block> ALTAR_STONE = BlockTags.create(new ResourceLocation(NaturesAura.MOD_ID, "altar_stone"));
|
||||||
public static final TagKey<Block> ALTAR_GOLD_BRICK = BlockTags.create(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "altar_gold_brick"));
|
public static final TagKey<Block> ALTAR_GOLD_BRICK = BlockTags.create(new ResourceLocation(NaturesAura.MOD_ID, "altar_gold_brick"));
|
||||||
public static final TagKey<Block> ALTAR_FANCY_BRICK = BlockTags.create(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "altar_fancy_brick"));
|
public static final TagKey<Block> ALTAR_FANCY_BRICK = BlockTags.create(new ResourceLocation(NaturesAura.MOD_ID, "altar_fancy_brick"));
|
||||||
|
|
||||||
public BlockTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, @Nullable ExistingFileHelper existingFileHelper) {
|
public BlockTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, @Nullable ExistingFileHelper existingFileHelper) {
|
||||||
super(output, lookupProvider, NaturesAura.MOD_ID, existingFileHelper);
|
super(output, lookupProvider, NaturesAura.MOD_ID, existingFileHelper);
|
||||||
|
@ -42,22 +42,21 @@ public class BlockTagProvider extends BlockTagsProvider {
|
||||||
this.tag(BlockTagProvider.ALTAR_FANCY_BRICK).add(Blocks.RED_NETHER_BRICKS, Blocks.CHISELED_STONE_BRICKS);
|
this.tag(BlockTagProvider.ALTAR_FANCY_BRICK).add(Blocks.RED_NETHER_BRICKS, Blocks.CHISELED_STONE_BRICKS);
|
||||||
|
|
||||||
this.tag(BlockTags.MINEABLE_WITH_PICKAXE).add(ModBlocks.ANIMAL_CONTAINER, ModBlocks.ANIMAL_GENERATOR,
|
this.tag(BlockTags.MINEABLE_WITH_PICKAXE).add(ModBlocks.ANIMAL_CONTAINER, ModBlocks.ANIMAL_GENERATOR,
|
||||||
ModBlocks.ANIMAL_SPAWNER, ModBlocks.AURA_DETECTOR, ModBlocks.AURA_TIMER, ModBlocks.BLAST_FURNACE_BOOSTER,
|
ModBlocks.ANIMAL_SPAWNER, ModBlocks.AURA_DETECTOR, ModBlocks.AURA_TIMER, ModBlocks.BLAST_FURNACE_BOOSTER,
|
||||||
ModBlocks.CHORUS_GENERATOR, ModBlocks.CHUNK_LOADER, ModBlocks.CONVERSION_CATALYST, ModBlocks.CRUSHING_CATALYST,
|
ModBlocks.CHORUS_GENERATOR, ModBlocks.CHUNK_LOADER, ModBlocks.CONVERSION_CATALYST, ModBlocks.CRUSHING_CATALYST,
|
||||||
ModBlocks.DEPTH_INGOT_BLOCK, ModBlocks.ENDER_CRATE, ModBlocks.FIELD_CREATOR, ModBlocks.FIREWORK_GENERATOR,
|
ModBlocks.DEPTH_INGOT_BLOCK, ModBlocks.ENDER_CRATE, ModBlocks.FIELD_CREATOR, ModBlocks.FIREWORK_GENERATOR,
|
||||||
ModBlocks.FURNACE_HEATER, ModBlocks.GENERATOR_LIMIT_REMOVER, ModBlocks.GOLD_BRICK, ModBlocks.GOLD_NETHER_BRICK,
|
ModBlocks.FURNACE_HEATER, ModBlocks.GENERATOR_LIMIT_REMOVER, ModBlocks.GOLD_BRICK, ModBlocks.GOLD_NETHER_BRICK,
|
||||||
ModBlocks.GRATED_CHUTE, ModBlocks.HOPPER_UPGRADE, ModBlocks.INFUSED_BRICK, ModBlocks.INFUSED_BRICK_SLAB,
|
ModBlocks.GRATED_CHUTE, ModBlocks.HOPPER_UPGRADE, ModBlocks.INFUSED_BRICK, ModBlocks.INFUSED_BRICK_SLAB,
|
||||||
ModBlocks.INFUSED_BRICK_STAIRS, ModBlocks.INFUSED_IRON_BLOCK, ModBlocks.INFUSED_SLAB, ModBlocks.INFUSED_STAIRS,
|
ModBlocks.INFUSED_BRICK_STAIRS, ModBlocks.INFUSED_IRON_BLOCK, ModBlocks.INFUSED_SLAB, ModBlocks.INFUSED_STAIRS,
|
||||||
ModBlocks.INFUSED_STONE, ModBlocks.ITEM_DISTRIBUTOR, ModBlocks.LOWER_LIMITER, ModBlocks.MOSS_GENERATOR,
|
ModBlocks.INFUSED_STONE, ModBlocks.ITEM_DISTRIBUTOR, ModBlocks.LOWER_LIMITER, ModBlocks.MOSS_GENERATOR,
|
||||||
ModBlocks.NATURE_ALTAR, ModBlocks.NETHER_GRASS, ModBlocks.PICKUP_STOPPER, ModBlocks.PLACER, ModBlocks.POTION_GENERATOR,
|
ModBlocks.NATURE_ALTAR, ModBlocks.NETHER_GRASS, ModBlocks.PICKUP_STOPPER, ModBlocks.PLACER, ModBlocks.POTION_GENERATOR,
|
||||||
ModBlocks.POWDER_PLACER, ModBlocks.PROJECTILE_GENERATOR, ModBlocks.RF_CONVERTER, ModBlocks.SKY_INGOT_BLOCK,
|
ModBlocks.POWDER_PLACER, ModBlocks.PROJECTILE_GENERATOR, ModBlocks.RF_CONVERTER, ModBlocks.SKY_INGOT_BLOCK,
|
||||||
ModBlocks.SNOW_CREATOR, ModBlocks.SPAWN_LAMP, ModBlocks.SPRING, ModBlocks.TAINTED_GOLD_BLOCK,
|
ModBlocks.SNOW_CREATOR, ModBlocks.SPAWN_LAMP, ModBlocks.SPRING, ModBlocks.TAINTED_GOLD_BLOCK,
|
||||||
ModBlocks.TIME_CHANGER, ModBlocks.WEATHER_CHANGER);
|
ModBlocks.TIME_CHANGER, ModBlocks.WEATHER_CHANGER);
|
||||||
|
|
||||||
this.tag(BlockTags.MINEABLE_WITH_AXE).add(ModBlocks.ANCIENT_BARK, ModBlocks.ANCIENT_LOG,
|
this.tag(BlockTags.MINEABLE_WITH_AXE).add(ModBlocks.ANCIENT_BARK, ModBlocks.ANCIENT_LOG,
|
||||||
ModBlocks.ANCIENT_PLANKS, ModBlocks.ANCIENT_SLAB, ModBlocks.ANCIENT_STAIRS,
|
ModBlocks.ANCIENT_PLANKS, ModBlocks.ANCIENT_SLAB, ModBlocks.ANCIENT_STAIRS,
|
||||||
ModBlocks.AUTO_CRAFTER, ModBlocks.FLOWER_GENERATOR, ModBlocks.NETHER_WART_MUSHROOM,
|
ModBlocks.AUTO_CRAFTER, ModBlocks.FLOWER_GENERATOR, ModBlocks.NETHER_WART_MUSHROOM,
|
||||||
ModBlocks.OAK_GENERATOR, ModBlocks.OFFERING_TABLE, ModBlocks.WOOD_STAND);
|
ModBlocks.OAK_GENERATOR, ModBlocks.OFFERING_TABLE, ModBlocks.WOOD_STAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import net.minecraft.data.loot.LootTableProvider;
|
||||||
import net.minecraft.data.registries.VanillaRegistries;
|
import net.minecraft.data.registries.VanillaRegistries;
|
||||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.common.EventBusSubscriber;
|
import net.neoforged.fml.common.Mod;
|
||||||
import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider;
|
import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider;
|
||||||
import net.neoforged.neoforge.data.event.GatherDataEvent;
|
import net.neoforged.neoforge.data.event.GatherDataEvent;
|
||||||
import net.neoforged.neoforge.registries.DataPackRegistriesHooks;
|
import net.neoforged.neoforge.registries.DataPackRegistriesHooks;
|
||||||
|
@ -22,7 +22,7 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD)
|
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
public final class ModData {
|
public final class ModData {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
@ -37,7 +37,7 @@ public final class ModData {
|
||||||
var blockTags = new BlockTagProvider(out, lookup, existing);
|
var blockTags = new BlockTagProvider(out, lookup, existing);
|
||||||
gen.addProvider(event.includeServer(), blockTags);
|
gen.addProvider(event.includeServer(), blockTags);
|
||||||
gen.addProvider(event.includeServer(), new ItemTagProvider(out, lookup, blockTags.contentsGetter(), existing));
|
gen.addProvider(event.includeServer(), new ItemTagProvider(out, lookup, blockTags.contentsGetter(), existing));
|
||||||
gen.addProvider(event.includeServer(), new LootTableProvider(out, Set.of(), List.of(new LootTableProvider.SubProviderEntry(BlockLootProvider::new, LootContextParamSets.BLOCK)), lookup));
|
gen.addProvider(event.includeServer(), new LootTableProvider(out, Set.of(), List.of(new LootTableProvider.SubProviderEntry(BlockLootProvider::new, LootContextParamSets.BLOCK))));
|
||||||
gen.addProvider(event.includeServer(), new BlockStateGenerator(out, existing));
|
gen.addProvider(event.includeServer(), new BlockStateGenerator(out, existing));
|
||||||
gen.addProvider(event.includeServer(), new ItemModelGenerator(out, existing));
|
gen.addProvider(event.includeServer(), new ItemModelGenerator(out, existing));
|
||||||
gen.addProvider(event.includeServer(), new DatapackBuiltinEntriesProvider(out, CompletableFuture.supplyAsync(ModData::getProvider), Set.of(NaturesAura.MOD_ID)));
|
gen.addProvider(event.includeServer(), new DatapackBuiltinEntriesProvider(out, CompletableFuture.supplyAsync(ModData::getProvider), Set.of(NaturesAura.MOD_ID)));
|
||||||
|
|
|
@ -3,8 +3,8 @@ package de.ellpeck.naturesaura.enchant;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Rarity;
|
|
||||||
import net.minecraft.world.item.enchantment.Enchantment;
|
import net.minecraft.world.item.enchantment.Enchantment;
|
||||||
|
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||||
import net.minecraft.world.item.enchantment.Enchantments;
|
import net.minecraft.world.item.enchantment.Enchantments;
|
||||||
|
|
||||||
public class AuraMendingEnchantment extends ModEnchantment {
|
public class AuraMendingEnchantment extends ModEnchantment {
|
||||||
|
|
|
@ -51,23 +51,23 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAddedToLevel() {
|
public void onAddedToWorld() {
|
||||||
super.onAddedToLevel();
|
super.onAddedToWorld();
|
||||||
this.powderListDirty = true;
|
this.powderListDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRemovedFromLevel() {
|
public void onRemovedFromWorld() {
|
||||||
super.onRemovedFromLevel();
|
super.onRemovedFromWorld();
|
||||||
// we pass a null effect because we want to remove our effect from the world
|
// we pass a null effect because we want to remove our effect from the world
|
||||||
this.updatePowderListStatus(null);
|
this.updatePowderListStatus(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void defineSynchedData(SynchedEntityData.Builder builder) {
|
protected void defineSynchedData() {
|
||||||
builder.define(EntityEffectInhibitor.INHIBITED_EFFECT, "");
|
this.entityData.define(EntityEffectInhibitor.INHIBITED_EFFECT, "");
|
||||||
builder.define(EntityEffectInhibitor.COLOR, 0);
|
this.entityData.define(EntityEffectInhibitor.COLOR, 0);
|
||||||
builder.define(EntityEffectInhibitor.AMOUNT, 0);
|
this.entityData.define(EntityEffectInhibitor.AMOUNT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -94,13 +94,13 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
|
||||||
if (this.level().isClientSide) {
|
if (this.level().isClientSide) {
|
||||||
if (this.level().getGameTime() % 5 == 0) {
|
if (this.level().getGameTime() % 5 == 0) {
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
this.getX() + this.level().random.nextGaussian() * 0.1F,
|
this.getX() + this.level().random.nextGaussian() * 0.1F,
|
||||||
this.getY(),
|
this.getY(),
|
||||||
this.getZ() + this.level().random.nextGaussian() * 0.1F,
|
this.getZ() + this.level().random.nextGaussian() * 0.1F,
|
||||||
this.level().random.nextGaussian() * 0.005F,
|
this.level().random.nextGaussian() * 0.005F,
|
||||||
this.level().random.nextFloat() * 0.03F,
|
this.level().random.nextFloat() * 0.03F,
|
||||||
this.level().random.nextGaussian() * 0.005F,
|
this.level().random.nextGaussian() * 0.005F,
|
||||||
this.getColor(), this.level().random.nextFloat() * 3F + 1F, 120, 0F, true, true);
|
this.getColor(), this.level().random.nextFloat() * 3F + 1F, 120, 0F, true, true);
|
||||||
}
|
}
|
||||||
this.renderTicks++;
|
this.renderTicks++;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void readAdditionalSaveData(CompoundTag compound) {
|
protected void readAdditionalSaveData(CompoundTag compound) {
|
||||||
this.setInhibitedEffect(ResourceLocation.parse(compound.getString("effect")));
|
this.setInhibitedEffect(new ResourceLocation(compound.getString("effect")));
|
||||||
this.setColor(compound.getInt("color"));
|
this.setColor(compound.getInt("color"));
|
||||||
this.setAmount(compound.contains("amount") ? compound.getInt("amount") : 24);
|
this.setAmount(compound.contains("amount") ? compound.getInt("amount") : 24);
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
|
||||||
var effect = this.entityData.get(EntityEffectInhibitor.INHIBITED_EFFECT);
|
var effect = this.entityData.get(EntityEffectInhibitor.INHIBITED_EFFECT);
|
||||||
if (effect == null || effect.isEmpty())
|
if (effect == null || effect.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
return ResourceLocation.parse(effect);
|
return new ResourceLocation(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInhibitedEffect(ResourceLocation effect) {
|
public void setInhibitedEffect(ResourceLocation effect) {
|
||||||
|
|
|
@ -2,7 +2,6 @@ package de.ellpeck.naturesaura.entities;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
@ -23,7 +22,7 @@ public class EntityLightProjectile extends ThrowableProjectile {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void defineSynchedData(SynchedEntityData.Builder builder) {
|
protected void defineSynchedData() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,11 +32,11 @@ public class EntityLightProjectile extends ThrowableProjectile {
|
||||||
if (this.level().isClientSide && this.tickCount > 1) {
|
if (this.level().isClientSide && this.tickCount > 1) {
|
||||||
for (float i = 0; i <= 1; i += 0.2F) {
|
for (float i = 0; i <= 1; i += 0.2F) {
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
Mth.lerp(i, this.xOld, this.getX()),
|
Mth.lerp(i, this.xOld, this.getX()),
|
||||||
Mth.lerp(i, this.yOld, this.getY()),
|
Mth.lerp(i, this.yOld, this.getY()),
|
||||||
Mth.lerp(i, this.zOld, this.getZ()),
|
Mth.lerp(i, this.zOld, this.getZ()),
|
||||||
this.random.nextGaussian() * 0.01F, this.random.nextGaussian() * 0.01F, this.random.nextGaussian() * 0.01F,
|
this.random.nextGaussian() * 0.01F, this.random.nextGaussian() * 0.01F, this.random.nextGaussian() * 0.01F,
|
||||||
0xffcb5c, this.random.nextFloat() * 0.5F + 1, 20, 0, false, true);
|
0xffcb5c, this.random.nextFloat() * 0.5F + 1, 20, 0, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +50,7 @@ public class EntityLightProjectile extends ThrowableProjectile {
|
||||||
if (state.canBeReplaced())
|
if (state.canBeReplaced())
|
||||||
this.level().setBlockAndUpdate(pos, ModBlocks.LIGHT.defaultBlockState());
|
this.level().setBlockAndUpdate(pos, ModBlocks.LIGHT.defaultBlockState());
|
||||||
} else if (result instanceof EntityHitResult entity) {
|
} else if (result instanceof EntityHitResult entity) {
|
||||||
entity.getEntity().setRemainingFireTicks(5 * 20);
|
entity.getEntity().setSecondsOnFire(5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.discard();
|
this.discard();
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.ListTag;
|
||||||
import net.minecraft.nbt.LongTag;
|
import net.minecraft.nbt.LongTag;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
|
@ -22,9 +23,10 @@ import net.minecraft.world.level.GameRules;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.portal.DimensionTransition;
|
|
||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
|
import net.neoforged.neoforge.common.util.ITeleporter;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -55,8 +57,8 @@ public class EntityMoverMinecart extends Minecart {
|
||||||
|
|
||||||
if (!this.spotOffsets.isEmpty() && this.level().getGameTime() % 10 == 0)
|
if (!this.spotOffsets.isEmpty() && this.level().getGameTime() % 10 == 0)
|
||||||
PacketHandler.sendToAllAround(this.level(), pos, 32, new PacketParticles(
|
PacketHandler.sendToAllAround(this.level(), pos, 32, new PacketParticles(
|
||||||
(float) this.getX(), (float) this.getY(), (float) this.getZ(), PacketParticles.Type.MOVER_CART,
|
(float) this.getX(), (float) this.getY(), (float) this.getZ(), PacketParticles.Type.MOVER_CART,
|
||||||
Mth.floor(this.getDeltaMovement().x * 100F), Mth.floor(this.getDeltaMovement().y * 100F), Mth.floor(this.getDeltaMovement().z * 100F)));
|
Mth.floor(this.getDeltaMovement().x * 100F), Mth.floor(this.getDeltaMovement().y * 100F), Mth.floor(this.getDeltaMovement().z * 100F)));
|
||||||
|
|
||||||
if (pos.distSqr(this.lastPosition) < 8 * 8)
|
if (pos.distSqr(this.lastPosition) < 8 * 8)
|
||||||
return;
|
return;
|
||||||
|
@ -111,8 +113,8 @@ public class EntityMoverMinecart extends Minecart {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addAdditionalSaveData(CompoundTag compound) {
|
public CompoundTag serializeNBT() {
|
||||||
super.addAdditionalSaveData(compound);
|
var compound = super.serializeNBT();
|
||||||
compound.putBoolean("active", this.isActive);
|
compound.putBoolean("active", this.isActive);
|
||||||
compound.putLong("last_pos", this.lastPosition.asLong());
|
compound.putLong("last_pos", this.lastPosition.asLong());
|
||||||
|
|
||||||
|
@ -120,11 +122,12 @@ public class EntityMoverMinecart extends Minecart {
|
||||||
for (var offset : this.spotOffsets)
|
for (var offset : this.spotOffsets)
|
||||||
list.add(LongTag.valueOf(offset.asLong()));
|
list.add(LongTag.valueOf(offset.asLong()));
|
||||||
compound.put("offsets", list);
|
compound.put("offsets", list);
|
||||||
|
return compound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void readAdditionalSaveData(CompoundTag compound) {
|
public void deserializeNBT(CompoundTag compound) {
|
||||||
super.readAdditionalSaveData(compound);
|
super.deserializeNBT(compound);
|
||||||
this.isActive = compound.getBoolean("active");
|
this.isActive = compound.getBoolean("active");
|
||||||
this.lastPosition = BlockPos.of(compound.getLong("last_pos"));
|
this.lastPosition = BlockPos.of(compound.getLong("last_pos"));
|
||||||
|
|
||||||
|
@ -134,9 +137,10 @@ public class EntityMoverMinecart extends Minecart {
|
||||||
this.spotOffsets.add(BlockPos.of(((LongTag) base).getAsLong()));
|
this.spotOffsets.add(BlockPos.of(((LongTag) base).getAsLong()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public @org.jetbrains.annotations.Nullable Entity changeDimension(DimensionTransition transition) {
|
public Entity changeDimension(ServerLevel destination, ITeleporter teleporter) {
|
||||||
var entity = super.changeDimension(transition);
|
var entity = super.changeDimension(destination, teleporter);
|
||||||
if (entity instanceof EntityMoverMinecart) {
|
if (entity instanceof EntityMoverMinecart) {
|
||||||
var pos = entity.blockPosition();
|
var pos = entity.blockPosition();
|
||||||
this.moveAura(this.level(), this.lastPosition, entity.level(), pos);
|
this.moveAura(this.level(), this.lastPosition, entity.level(), pos);
|
||||||
|
@ -175,5 +179,4 @@ public class EntityMoverMinecart extends Minecart {
|
||||||
public InteractionResult interact(Player p_38483_, InteractionHand p_38484_) {
|
public InteractionResult interact(Player p_38483_, InteractionHand p_38484_) {
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,9 @@ public class EntityStructureFinder extends EyeOfEnder {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void defineSynchedData(SynchedEntityData.Builder builder) {
|
protected void defineSynchedData() {
|
||||||
super.defineSynchedData(builder);
|
super.defineSynchedData();
|
||||||
builder.define(EntityStructureFinder.COLOR, 0);
|
this.entityData.define(EntityStructureFinder.COLOR, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -18,12 +18,11 @@ import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||||
import net.minecraft.client.renderer.entity.MinecartRenderer;
|
import net.minecraft.client.renderer.entity.MinecartRenderer;
|
||||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.FastColor;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
public class RenderMoverMinecart extends MinecartRenderer<EntityMoverMinecart> {
|
public class RenderMoverMinecart extends MinecartRenderer<EntityMoverMinecart> {
|
||||||
|
|
||||||
private static final ResourceLocation RES = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/models/mover_cart.png");
|
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/mover_cart.png");
|
||||||
|
|
||||||
public RenderMoverMinecart(EntityRendererProvider.Context p_174300_) {
|
public RenderMoverMinecart(EntityRendererProvider.Context p_174300_) {
|
||||||
super(p_174300_, ModelLayers.MINECART);
|
super(p_174300_, ModelLayers.MINECART);
|
||||||
|
@ -37,7 +36,7 @@ public class RenderMoverMinecart extends MinecartRenderer<EntityMoverMinecart> {
|
||||||
matrixStackIn.translate(0, 22 / 16F, 0);
|
matrixStackIn.translate(0, 22 / 16F, 0);
|
||||||
matrixStackIn.translate(0, 0, 1);
|
matrixStackIn.translate(0, 0, 1);
|
||||||
matrixStackIn.mulPose(Axis.XP.rotationDegrees(180));
|
matrixStackIn.mulPose(Axis.XP.rotationDegrees(180));
|
||||||
this.model.renderToBuffer(matrixStackIn, bufferIn.getBuffer(this.model.renderType(RenderMoverMinecart.RES)), packedLightIn, OverlayTexture.NO_OVERLAY, FastColor.ARGB32.colorFromFloat(1, 1, 1, 1));
|
this.model.renderToBuffer(matrixStackIn, bufferIn.getBuffer(this.model.renderType(RenderMoverMinecart.RES)), packedLightIn, OverlayTexture.NO_OVERLAY, 1, 1, 1, 1);
|
||||||
matrixStackIn.popPose();
|
matrixStackIn.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,10 +53,8 @@ public class RenderMoverMinecart extends MinecartRenderer<EntityMoverMinecart> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderToBuffer(PoseStack matrixStackIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, int color) {
|
public void renderToBuffer(PoseStack matrixStackIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
|
||||||
this.model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, color);
|
this.model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,10 @@ package de.ellpeck.naturesaura.events;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.Window;
|
import com.mojang.blaze3d.platform.Window;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.*;
|
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||||
|
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||||
|
import com.mojang.blaze3d.vertex.Tesselator;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
import de.ellpeck.naturesaura.Helper;
|
import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.ModConfig;
|
import de.ellpeck.naturesaura.ModConfig;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
|
@ -37,14 +40,15 @@ import net.minecraft.world.level.block.MyceliumBlock;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
|
||||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
import net.neoforged.neoforge.client.event.ClientTickEvent;
|
|
||||||
import net.neoforged.neoforge.client.event.CustomizeGuiOverlayEvent;
|
import net.neoforged.neoforge.client.event.CustomizeGuiOverlayEvent;
|
||||||
import net.neoforged.neoforge.client.event.RenderGuiLayerEvent;
|
import net.neoforged.neoforge.client.event.RenderGuiOverlayEvent;
|
||||||
import net.neoforged.neoforge.client.event.RenderLevelStageEvent;
|
import net.neoforged.neoforge.client.event.RenderLevelStageEvent;
|
||||||
import net.neoforged.neoforge.client.gui.VanillaGuiLayers;
|
import net.neoforged.neoforge.client.gui.overlay.VanillaGuiOverlay;
|
||||||
|
import net.neoforged.neoforge.common.IPlantable;
|
||||||
import net.neoforged.neoforge.energy.EnergyStorage;
|
import net.neoforged.neoforge.energy.EnergyStorage;
|
||||||
|
import net.neoforged.neoforge.event.TickEvent;
|
||||||
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import org.apache.commons.lang3.mutable.MutableInt;
|
import org.apache.commons.lang3.mutable.MutableInt;
|
||||||
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
@ -56,8 +60,8 @@ import java.util.Map;
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public class ClientEvents {
|
public class ClientEvents {
|
||||||
|
|
||||||
public static final ResourceLocation OVERLAYS = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/gui/overlays.png");
|
public static final ResourceLocation OVERLAYS = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/overlays.png");
|
||||||
public static final ResourceLocation BOOK_GUI = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/gui/book.png");
|
public static final ResourceLocation BOOK_GUI = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/book.png");
|
||||||
public static final List<PacketAuraChunk> PENDING_AURA_CHUNKS = new ArrayList<>();
|
public static final List<PacketAuraChunk> PENDING_AURA_CHUNKS = new ArrayList<>();
|
||||||
private static final ItemStack ITEM_FRAME = new ItemStack(Items.ITEM_FRAME);
|
private static final ItemStack ITEM_FRAME = new ItemStack(Items.ITEM_FRAME);
|
||||||
private static final ItemStack DISPENSER = new ItemStack(Blocks.DISPENSER);
|
private static final ItemStack DISPENSER = new ItemStack(Blocks.DISPENSER);
|
||||||
|
@ -91,72 +95,74 @@ public class ClientEvents {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onClientTick(ClientTickEvent.Post event) {
|
public void onClientTick(TickEvent.ClientTickEvent event) {
|
||||||
ClientEvents.heldCache = ItemStack.EMPTY;
|
if (event.phase != TickEvent.Phase.END) {
|
||||||
ClientEvents.heldEye = ItemStack.EMPTY;
|
ClientEvents.heldCache = ItemStack.EMPTY;
|
||||||
ClientEvents.heldOcular = ItemStack.EMPTY;
|
ClientEvents.heldEye = ItemStack.EMPTY;
|
||||||
|
ClientEvents.heldOcular = ItemStack.EMPTY;
|
||||||
|
|
||||||
var mc = Minecraft.getInstance();
|
var mc = Minecraft.getInstance();
|
||||||
if (mc.level == null) {
|
if (mc.level == null) {
|
||||||
ItemRangeVisualizer.clear();
|
ItemRangeVisualizer.clear();
|
||||||
ClientEvents.PENDING_AURA_CHUNKS.clear();
|
ClientEvents.PENDING_AURA_CHUNKS.clear();
|
||||||
} else {
|
} else {
|
||||||
ClientEvents.PENDING_AURA_CHUNKS.removeIf(next -> next.tryHandle(mc.level));
|
ClientEvents.PENDING_AURA_CHUNKS.removeIf(next -> next.tryHandle(mc.level));
|
||||||
|
|
||||||
if (!mc.isPaused()) {
|
if (!mc.isPaused()) {
|
||||||
if (mc.level.getGameTime() % 20 == 0) {
|
if (mc.level.getGameTime() % 20 == 0) {
|
||||||
var amount = Mth.floor(190 * ModConfig.instance.excessParticleAmount.get());
|
var amount = Mth.floor(190 * ModConfig.instance.excessParticleAmount.get());
|
||||||
for (var i = 0; i < amount; i++) {
|
for (var i = 0; i < amount; i++) {
|
||||||
var x = Mth.floor(mc.player.getX()) + mc.level.random.nextInt(64) - 32;
|
var x = Mth.floor(mc.player.getX()) + mc.level.random.nextInt(64) - 32;
|
||||||
var y = Mth.floor(mc.player.getY()) + mc.level.random.nextInt(32) - 16;
|
var y = Mth.floor(mc.player.getY()) + mc.level.random.nextInt(32) - 16;
|
||||||
var z = Mth.floor(mc.player.getZ()) + mc.level.random.nextInt(64) - 32;
|
var z = Mth.floor(mc.player.getZ()) + mc.level.random.nextInt(64) - 32;
|
||||||
var pos = Helper.getClosestAirAboveGround(mc.level, new BlockPos(x, y, z), 16).below();
|
var pos = Helper.getClosestAirAboveGround(mc.level, new BlockPos(x, y, z), 16).below();
|
||||||
var state = mc.level.getBlockState(pos);
|
var state = mc.level.getBlockState(pos);
|
||||||
var block = state.getBlock();
|
var block = state.getBlock();
|
||||||
if (block instanceof BonemealableBlock || block instanceof LeavesBlock || block instanceof MyceliumBlock) {
|
if (block instanceof BonemealableBlock || block instanceof IPlantable || block instanceof LeavesBlock || block instanceof MyceliumBlock) {
|
||||||
var excess = IAuraChunk.triangulateAuraInArea(mc.level, pos, 45) - IAuraChunk.DEFAULT_AURA;
|
var excess = IAuraChunk.triangulateAuraInArea(mc.level, pos, 45) - IAuraChunk.DEFAULT_AURA;
|
||||||
if (excess > 0) {
|
if (excess > 0) {
|
||||||
var chance = Math.max(10, 50 - excess / 25000);
|
var chance = Math.max(10, 50 - excess / 25000);
|
||||||
if (mc.level.random.nextInt(chance) <= 0)
|
if (mc.level.random.nextInt(chance) <= 0)
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
pos.getX() + mc.level.random.nextFloat(),
|
pos.getX() + mc.level.random.nextFloat(),
|
||||||
pos.getY() + 0.5F,
|
pos.getY() + 0.5F,
|
||||||
pos.getZ() + mc.level.random.nextFloat(),
|
pos.getZ() + mc.level.random.nextFloat(),
|
||||||
mc.level.random.nextGaussian() * 0.01F,
|
mc.level.random.nextGaussian() * 0.01F,
|
||||||
mc.level.random.nextFloat() * 0.025F,
|
mc.level.random.nextFloat() * 0.025F,
|
||||||
mc.level.random.nextGaussian() * 0.01F,
|
mc.level.random.nextGaussian() * 0.01F,
|
||||||
block instanceof MyceliumBlock ? 0x875ca1 : BiomeColors.getAverageGrassColor(mc.level, pos),
|
block instanceof MyceliumBlock ? 0x875ca1 : BiomeColors.getAverageGrassColor(mc.level, pos),
|
||||||
Math.min(2F, 1F + mc.level.random.nextFloat() * (excess / 30000F)),
|
Math.min(2F, 1F + mc.level.random.nextFloat() * (excess / 30000F)),
|
||||||
Math.min(300, 100 + mc.level.random.nextInt(excess / 3000 + 1)),
|
Math.min(300, 100 + mc.level.random.nextInt(excess / 3000 + 1)),
|
||||||
0F, false, true);
|
0F, false, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (Helper.isHoldingItem(mc.player, ModItems.RANGE_VISUALIZER) && mc.level.getGameTime() % 5 == 0) {
|
if (Helper.isHoldingItem(mc.player, ModItems.RANGE_VISUALIZER) && mc.level.getGameTime() % 5 == 0) {
|
||||||
var inst = NaturesAuraAPI.instance();
|
var inst = NaturesAuraAPI.instance();
|
||||||
inst.setParticleSpawnRange(512);
|
inst.setParticleSpawnRange(512);
|
||||||
inst.setParticleDepth(false);
|
inst.setParticleDepth(false);
|
||||||
for (var pos : ItemRangeVisualizer.VISUALIZED_RAILS.get(mc.level.dimension().location())) {
|
for (var pos : ItemRangeVisualizer.VISUALIZED_RAILS.get(mc.level.dimension().location())) {
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
pos.getX() + mc.level.random.nextFloat(),
|
pos.getX() + mc.level.random.nextFloat(),
|
||||||
pos.getY() + mc.level.random.nextFloat(),
|
pos.getY() + mc.level.random.nextFloat(),
|
||||||
pos.getZ() + mc.level.random.nextFloat(),
|
pos.getZ() + mc.level.random.nextFloat(),
|
||||||
0F, 0F, 0F, 0xe0faff, mc.level.random.nextFloat() * 5 + 1, 100, 0F, false, true);
|
0F, 0F, 0F, 0xe0faff, mc.level.random.nextFloat() * 5 + 1, 100, 0F, false, true);
|
||||||
|
}
|
||||||
|
inst.setParticleDepth(true);
|
||||||
|
inst.setParticleSpawnRange(32);
|
||||||
}
|
}
|
||||||
inst.setParticleDepth(true);
|
|
||||||
inst.setParticleSpawnRange(32);
|
|
||||||
}
|
|
||||||
|
|
||||||
ClientEvents.heldCache = Helper.getEquippedItem(s -> s.getItem() instanceof ItemAuraCache, mc.player, false);
|
ClientEvents.heldCache = Helper.getEquippedItem(s -> s.getItem() instanceof ItemAuraCache, mc.player, false);
|
||||||
ClientEvents.heldEye = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE, mc.player, true);
|
ClientEvents.heldEye = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE, mc.player, true);
|
||||||
ClientEvents.heldOcular = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE_IMPROVED, mc.player, false);
|
ClientEvents.heldOcular = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE_IMPROVED, mc.player, false);
|
||||||
|
|
||||||
if (!ClientEvents.heldOcular.isEmpty() && mc.level.getGameTime() % 20 == 0) {
|
if (!ClientEvents.heldOcular.isEmpty() && mc.level.getGameTime() % 20 == 0) {
|
||||||
ClientEvents.SHOWING_EFFECTS.clear();
|
ClientEvents.SHOWING_EFFECTS.clear();
|
||||||
Helper.getAuraChunksWithSpotsInArea(mc.level, mc.player.blockPosition(), 100,
|
Helper.getAuraChunksWithSpotsInArea(mc.level, mc.player.blockPosition(), 100,
|
||||||
chunk -> chunk.getActiveEffectIcons(mc.player, ClientEvents.SHOWING_EFFECTS));
|
chunk -> chunk.getActiveEffectIcons(mc.player, ClientEvents.SHOWING_EFFECTS));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,14 +175,15 @@ public class ClientEvents {
|
||||||
var mc = Minecraft.getInstance();
|
var mc = Minecraft.getInstance();
|
||||||
var view = mc.gameRenderer.getMainCamera().getPosition();
|
var view = mc.gameRenderer.getMainCamera().getPosition();
|
||||||
var tesselator = Tesselator.getInstance();
|
var tesselator = Tesselator.getInstance();
|
||||||
|
var buffer = tesselator.getBuilder();
|
||||||
|
|
||||||
mc.getProfiler().push(NaturesAura.MOD_ID + ":onLevelRender");
|
mc.getProfiler().push(NaturesAura.MOD_ID + ":onLevelRender");
|
||||||
|
|
||||||
RenderSystem.enableDepthTest();
|
RenderSystem.enableDepthTest();
|
||||||
var mv = RenderSystem.getModelViewStack();
|
var mv = RenderSystem.getModelViewStack();
|
||||||
mv.pushMatrix();
|
mv.pushPose();
|
||||||
mv.mul(event.getPoseStack().last().pose());
|
mv.mulPoseMatrix(event.getPoseStack().last().pose());
|
||||||
mv.translate((float) -view.x, (float) -view.y, (float) -view.z);
|
mv.translate(-view.x, -view.y, -view.z);
|
||||||
RenderSystem.applyModelViewMatrix();
|
RenderSystem.applyModelViewMatrix();
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
RenderSystem.setShader(GameRenderer::getPositionColorShader);
|
RenderSystem.setShader(GameRenderer::getPositionColorShader);
|
||||||
|
@ -185,12 +192,12 @@ public class ClientEvents {
|
||||||
// aura spot debug
|
// aura spot debug
|
||||||
ClientEvents.hoveringAuraSpot = null;
|
ClientEvents.hoveringAuraSpot = null;
|
||||||
if (mc.getDebugOverlay().showDebugScreen() && (mc.player.isCreative() || mc.player.isSpectator()) && ModConfig.instance.debugLevel.get()) {
|
if (mc.getDebugOverlay().showDebugScreen() && (mc.player.isCreative() || mc.player.isSpectator()) && ModConfig.instance.debugLevel.get()) {
|
||||||
var playerEye = mc.player.getEyePosition(event.getPartialTick().getGameTimeDeltaPartialTick(true));
|
var playerEye = mc.player.getEyePosition(event.getPartialTick());
|
||||||
var playerView = mc.player.getViewVector(event.getPartialTick().getGameTimeDeltaPartialTick(true)).normalize();
|
var playerView = mc.player.getViewVector(event.getPartialTick()).normalize();
|
||||||
var range = mc.gameMode.getDestroyStage();
|
var range = mc.gameMode.getPickRange();
|
||||||
var builder = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
|
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
|
||||||
IAuraChunk.getSpotsInArea(mc.level, mc.player.blockPosition(), 64, (pos, spot) -> {
|
IAuraChunk.getSpotsInArea(mc.level, mc.player.blockPosition(), 64, (pos, spot) -> {
|
||||||
Helper.renderWeirdBox(builder, pos.getX(), pos.getY(), pos.getZ(), 1, 1, 1, spot > 0 ? 0F : 1F, spot > 0 ? 1F : 0F, 0F, 0.35F);
|
Helper.renderWeirdBox(buffer, pos.getX(), pos.getY(), pos.getZ(), 1, 1, 1, spot > 0 ? 0F : 1F, spot > 0 ? 1F : 0F, 0F, 0.35F);
|
||||||
// dirty raytrace to see if we're looking at roughly this spot
|
// dirty raytrace to see if we're looking at roughly this spot
|
||||||
if (playerEye.distanceToSqr(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5) <= range * range) {
|
if (playerEye.distanceToSqr(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5) <= range * range) {
|
||||||
for (var d = 0F; d <= range; d += 0.5F) {
|
for (var d = 0F; d <= range; d += 0.5F) {
|
||||||
|
@ -202,14 +209,14 @@ public class ClientEvents {
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
BufferUploader.drawWithShader(builder.build());
|
tesselator.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
// range visualizer
|
// range visualizer
|
||||||
if (Helper.isHoldingItem(mc.player, ModItems.RANGE_VISUALIZER)) {
|
if (Helper.isHoldingItem(mc.player, ModItems.RANGE_VISUALIZER)) {
|
||||||
RenderSystem.disableCull();
|
RenderSystem.disableCull();
|
||||||
var dim = mc.level.dimension().location();
|
var dim = mc.level.dimension().location();
|
||||||
var builder = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
|
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
|
||||||
for (var pos : ItemRangeVisualizer.VISUALIZED_BLOCKS.get(dim)) {
|
for (var pos : ItemRangeVisualizer.VISUALIZED_BLOCKS.get(dim)) {
|
||||||
if (!mc.level.isLoaded(pos))
|
if (!mc.level.isLoaded(pos))
|
||||||
continue;
|
continue;
|
||||||
|
@ -217,18 +224,18 @@ public class ClientEvents {
|
||||||
var block = state.getBlock();
|
var block = state.getBlock();
|
||||||
if (!(block instanceof IVisualizable))
|
if (!(block instanceof IVisualizable))
|
||||||
continue;
|
continue;
|
||||||
this.renderVisualize(builder, (IVisualizable) block, mc.level, pos);
|
this.renderVisualize(buffer, (IVisualizable) block, mc.level, pos);
|
||||||
}
|
}
|
||||||
for (var entity : ItemRangeVisualizer.VISUALIZED_ENTITIES.get(dim)) {
|
for (var entity : ItemRangeVisualizer.VISUALIZED_ENTITIES.get(dim)) {
|
||||||
if (!entity.isAlive() || !(entity instanceof IVisualizable))
|
if (!entity.isAlive() || !(entity instanceof IVisualizable))
|
||||||
continue;
|
continue;
|
||||||
this.renderVisualize(builder, (IVisualizable) entity, mc.level, entity.blockPosition());
|
this.renderVisualize(buffer, (IVisualizable) entity, mc.level, entity.blockPosition());
|
||||||
}
|
}
|
||||||
BufferUploader.drawWithShader(builder.build());
|
tesselator.end();
|
||||||
RenderSystem.enableCull();
|
RenderSystem.enableCull();
|
||||||
}
|
}
|
||||||
|
|
||||||
mv.popMatrix();
|
mv.popPose();
|
||||||
RenderSystem.applyModelViewMatrix();
|
RenderSystem.applyModelViewMatrix();
|
||||||
RenderSystem.disableBlend();
|
RenderSystem.disableBlend();
|
||||||
|
|
||||||
|
@ -240,17 +247,17 @@ public class ClientEvents {
|
||||||
if (box != null) {
|
if (box != null) {
|
||||||
box = box.inflate(0.05F);
|
box = box.inflate(0.05F);
|
||||||
var color = visualize.getVisualizationColor(level, pos);
|
var color = visualize.getVisualizationColor(level, pos);
|
||||||
Helper.renderWeirdBox(buffer, (float) box.minX, (float) box.minY, (float) box.minZ, (float) (box.maxX - box.minX), (float) (box.maxY - box.minY), (float) (box.maxZ - box.minZ), (color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 0.5F);
|
Helper.renderWeirdBox(buffer, box.minX, box.minY, box.minZ, box.maxX - box.minX, box.maxY - box.minY, box.maxZ - box.minZ, (color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 0.5F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onOverlayRender(RenderGuiLayerEvent.Post event) {
|
public void onOverlayRender(RenderGuiOverlayEvent.Post event) {
|
||||||
var mc = Minecraft.getInstance();
|
var mc = Minecraft.getInstance();
|
||||||
var graphics = event.getGuiGraphics();
|
var graphics = event.getGuiGraphics();
|
||||||
var stack = graphics.pose();
|
var stack = graphics.pose();
|
||||||
if (event.getName() == VanillaGuiLayers.HOTBAR) {
|
if (event.getOverlay() == VanillaGuiOverlay.HOTBAR.type()) {
|
||||||
var res = mc.getWindow();
|
var res = event.getWindow();
|
||||||
if (mc.player != null) {
|
if (mc.player != null) {
|
||||||
if (!ClientEvents.heldCache.isEmpty()) {
|
if (!ClientEvents.heldCache.isEmpty()) {
|
||||||
var container = ClientEvents.heldCache.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY, null);
|
var container = ClientEvents.heldCache.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY, null);
|
||||||
|
@ -361,7 +368,7 @@ public class ClientEvents {
|
||||||
var state = mc.level.getBlockState(pos);
|
var state = mc.level.getBlockState(pos);
|
||||||
var blockStack = state.getBlock().getCloneItemStack(state, blockHitResult, mc.level, pos, mc.player);
|
var blockStack = state.getBlock().getCloneItemStack(state, blockHitResult, mc.level, pos, mc.player);
|
||||||
this.drawContainerInfo(graphics, container.getStoredAura(), container.getMaxAura(), container.getAuraColor(),
|
this.drawContainerInfo(graphics, container.getStoredAura(), container.getMaxAura(), container.getAuraColor(),
|
||||||
mc, res, 35, blockStack.getHoverName().getString(), null);
|
mc, res, 35, blockStack.getHoverName().getString(), null);
|
||||||
|
|
||||||
if (tile instanceof BlockEntityNatureAltar) {
|
if (tile instanceof BlockEntityNatureAltar) {
|
||||||
var itemHandler = tile.getLevel().getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, null);
|
var itemHandler = tile.getLevel().getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, null);
|
||||||
|
@ -370,23 +377,23 @@ public class ClientEvents {
|
||||||
var stackCont = tileStack.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY);
|
var stackCont = tileStack.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY);
|
||||||
if (stackCont != null) {
|
if (stackCont != null) {
|
||||||
this.drawContainerInfo(graphics, stackCont.getStoredAura(), stackCont.getMaxAura(), stackCont.getAuraColor(),
|
this.drawContainerInfo(graphics, stackCont.getStoredAura(), stackCont.getMaxAura(), stackCont.getAuraColor(),
|
||||||
mc, res, 55, tileStack.getHoverName().getString(), null);
|
mc, res, 55, tileStack.getHoverName().getString(), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (tile instanceof BlockEntityRFConverter) {
|
} else if (tile instanceof BlockEntityRFConverter) {
|
||||||
EnergyStorage storage = ((BlockEntityRFConverter) tile).storage;
|
EnergyStorage storage = ((BlockEntityRFConverter) tile).storage;
|
||||||
this.drawContainerInfo(graphics, storage.getEnergyStored(), storage.getMaxEnergyStored(), 0xcc4916,
|
this.drawContainerInfo(graphics, storage.getEnergyStored(), storage.getMaxEnergyStored(), 0xcc4916,
|
||||||
mc, res, 35, I18n.get("block.naturesaura.rf_converter"),
|
mc, res, 35, I18n.get("block.naturesaura.rf_converter"),
|
||||||
storage.getEnergyStored() + " / " + storage.getMaxEnergyStored() + " RF");
|
storage.getEnergyStored() + " / " + storage.getMaxEnergyStored() + " RF");
|
||||||
} else if (tile instanceof BlockEntityGratedChute chute) {
|
} else if (tile instanceof BlockEntityGratedChute chute) {
|
||||||
var itemHandler = tile.getLevel().getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, null);
|
var itemHandler = tile.getLevel().getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, null);
|
||||||
var itemStack = itemHandler.getStackInSlot(0);
|
var itemStack = itemHandler.getStackInSlot(0);
|
||||||
|
|
||||||
if (itemStack.isEmpty()) {
|
if (itemStack.isEmpty()) {
|
||||||
graphics.drawString(mc.font,
|
graphics.drawString(mc.font,
|
||||||
ChatFormatting.GRAY.toString() + ChatFormatting.ITALIC + I18n.get("info.naturesaura.empty"),
|
ChatFormatting.GRAY.toString() + ChatFormatting.ITALIC + I18n.get("info.naturesaura.empty"),
|
||||||
x + 5, y - 11, 0xFFFFFF);
|
x + 5, y - 11, 0xFFFFFF);
|
||||||
} else {
|
} else {
|
||||||
Helper.renderItemInGui(graphics, itemStack, x + 2, y - 18, 1F);
|
Helper.renderItemInGui(graphics, itemStack, x + 2, y - 18, 1F);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,13 @@ import net.minecraft.server.level.ServerChunkCache;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.level.ChunkPos;
|
import net.minecraft.world.level.ChunkPos;
|
||||||
import net.minecraft.world.level.chunk.LevelChunk;
|
import net.minecraft.world.level.chunk.LevelChunk;
|
||||||
|
import net.neoforged.neoforge.event.TickEvent;
|
||||||
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
||||||
import net.neoforged.neoforge.event.level.ChunkEvent;
|
import net.neoforged.neoforge.event.level.ChunkEvent;
|
||||||
import net.neoforged.neoforge.event.level.ChunkWatchEvent;
|
import net.neoforged.neoforge.event.level.ChunkWatchEvent;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.util.ObfuscationReflectionHelper;
|
import net.neoforged.fml.util.ObfuscationReflectionHelper;
|
||||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||||
import net.neoforged.neoforge.event.tick.LevelTickEvent;
|
|
||||||
import net.neoforged.neoforge.event.tick.PlayerTickEvent;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
@ -66,12 +65,12 @@ public class CommonEvents {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void onLevelTick(LevelTickEvent.Post event) {
|
public void onLevelTick(TickEvent.LevelTickEvent event) {
|
||||||
if (!event.getLevel().isClientSide) {
|
if (!event.level.isClientSide && event.phase == TickEvent.Phase.END) {
|
||||||
if (event.getLevel().getGameTime() % 20 == 0) {
|
if (event.level.getGameTime() % 20 == 0) {
|
||||||
event.getLevel().getProfiler().push(NaturesAura.MOD_ID + ":onLevelTick");
|
event.level.getProfiler().push(NaturesAura.MOD_ID + ":onLevelTick");
|
||||||
try {
|
try {
|
||||||
var manager = ((ServerChunkCache) event.getLevel().getChunkSource()).chunkMap;
|
var manager = ((ServerChunkCache) event.level.getChunkSource()).chunkMap;
|
||||||
var chunks = (Iterable<ChunkHolder>) CommonEvents.GET_LOADED_CHUNKS_METHOD.invoke(manager);
|
var chunks = (Iterable<ChunkHolder>) CommonEvents.GET_LOADED_CHUNKS_METHOD.invoke(manager);
|
||||||
for (var holder : chunks) {
|
for (var holder : chunks) {
|
||||||
var chunk = holder.getTickingChunk();
|
var chunk = holder.getTickingChunk();
|
||||||
|
@ -84,27 +83,27 @@ public class CommonEvents {
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
NaturesAura.LOGGER.fatal(e);
|
NaturesAura.LOGGER.fatal(e);
|
||||||
}
|
}
|
||||||
event.getLevel().getProfiler().pop();
|
event.level.getProfiler().pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onPlayerTick(PlayerTickEvent.Post event) {
|
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
||||||
if (!event.getEntity().level().isClientSide) {
|
if (!event.player.level().isClientSide && event.phase == TickEvent.Phase.END) {
|
||||||
if (event.getEntity().level().getGameTime() % 10 == 0) {
|
if (event.player.level().getGameTime() % 10 == 0) {
|
||||||
var pending = CommonEvents.PENDING_AURA_CHUNKS.get(event.getEntity().getUUID());
|
var pending = CommonEvents.PENDING_AURA_CHUNKS.get(event.player.getUUID());
|
||||||
pending.removeIf(p -> this.handleChunkWatchDeferred(event.getEntity(), p));
|
pending.removeIf(p -> this.handleChunkWatchDeferred(event.player, p));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getEntity().level().getGameTime() % 200 != 0)
|
if (event.player.level().getGameTime() % 200 != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var aura = IAuraChunk.triangulateAuraInArea(event.getEntity().level(), event.getEntity().blockPosition(), 25);
|
var aura = IAuraChunk.triangulateAuraInArea(event.player.level(), event.player.blockPosition(), 25);
|
||||||
if (aura <= 0)
|
if (aura <= 0)
|
||||||
Helper.addAdvancement(event.getEntity(), ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "negative_imbalance"), "triggered_in_code");
|
Helper.addAdvancement(event.player, new ResourceLocation(NaturesAura.MOD_ID, "negative_imbalance"), "triggered_in_code");
|
||||||
else if (aura >= 1500000)
|
else if (aura >= 1500000)
|
||||||
Helper.addAdvancement(event.getEntity(), ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "positive_imbalance"), "triggered_in_code");
|
Helper.addAdvancement(event.player, new ResourceLocation(NaturesAura.MOD_ID, "positive_imbalance"), "triggered_in_code");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package de.ellpeck.naturesaura.gen;
|
package de.ellpeck.naturesaura.gen;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
|
import net.minecraft.core.HolderGetter;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.data.worldgen.BootstrapContext;
|
import net.minecraft.data.worldgen.BootstapContext;
|
||||||
import net.minecraft.data.worldgen.features.FeatureUtils;
|
import net.minecraft.data.worldgen.features.FeatureUtils;
|
||||||
import net.minecraft.data.worldgen.placement.PlacementUtils;
|
import net.minecraft.data.worldgen.placement.PlacementUtils;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
|
@ -12,7 +13,7 @@ import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConf
|
||||||
import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration;
|
import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration;
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||||
|
|
||||||
@SuppressWarnings({"NonConstantFieldWithUpperCaseName", "FieldNamingConvention"})
|
@SuppressWarnings("NonConstantFieldWithUpperCaseName")
|
||||||
public final class ModFeatures {
|
public final class ModFeatures {
|
||||||
|
|
||||||
public static Feature<TreeConfiguration> ANCIENT_TREE;
|
public static Feature<TreeConfiguration> ANCIENT_TREE;
|
||||||
|
@ -25,15 +26,16 @@ public final class ModFeatures {
|
||||||
|
|
||||||
public static final class Configured {
|
public static final class Configured {
|
||||||
|
|
||||||
public static final ResourceKey<ConfiguredFeature<?, ?>> ANCIENT_TREE = FeatureUtils.createKey(NaturesAura.MOD_ID + ":ancient_tree");
|
public static ResourceKey<ConfiguredFeature<?, ?>> ANCIENT_TREE = FeatureUtils.createKey(NaturesAura.MOD_ID + ":ancient_tree");
|
||||||
public static final ResourceKey<ConfiguredFeature<?, ?>> NETHER_WART_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":nether_wart_mushroom");
|
public static ResourceKey<ConfiguredFeature<?, ?>> NETHER_WART_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":nether_wart_mushroom");
|
||||||
public static final ResourceKey<ConfiguredFeature<?, ?>> AURA_BLOOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":aura_bloom");
|
public static ResourceKey<ConfiguredFeature<?, ?>> AURA_BLOOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":aura_bloom");
|
||||||
public static final ResourceKey<ConfiguredFeature<?, ?>> AURA_CACTUS = FeatureUtils.createKey(NaturesAura.MOD_ID + ":aura_cactus");
|
public static ResourceKey<ConfiguredFeature<?, ?>> AURA_CACTUS = FeatureUtils.createKey(NaturesAura.MOD_ID + ":aura_cactus");
|
||||||
public static final ResourceKey<ConfiguredFeature<?, ?>> WARPED_AURA_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":warped_aura_mushroom");
|
public static ResourceKey<ConfiguredFeature<?, ?>> WARPED_AURA_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":warped_aura_mushroom");
|
||||||
public static final ResourceKey<ConfiguredFeature<?, ?>> CRIMSON_AURA_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":crimson_aura_mushroom");
|
public static ResourceKey<ConfiguredFeature<?, ?>> CRIMSON_AURA_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":crimson_aura_mushroom");
|
||||||
public static final ResourceKey<ConfiguredFeature<?, ?>> AURA_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":aura_mushroom");
|
public static ResourceKey<ConfiguredFeature<?, ?>> AURA_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":aura_mushroom");
|
||||||
|
|
||||||
public static void bootstrap(BootstrapContext<ConfiguredFeature<?, ?>> context) {
|
|
||||||
|
public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context) {
|
||||||
FeatureUtils.register(context, ModFeatures.Configured.AURA_BLOOM, ModFeatures.AURA_BLOOM, NoneFeatureConfiguration.INSTANCE);
|
FeatureUtils.register(context, ModFeatures.Configured.AURA_BLOOM, ModFeatures.AURA_BLOOM, NoneFeatureConfiguration.INSTANCE);
|
||||||
FeatureUtils.register(context, ModFeatures.Configured.AURA_CACTUS, ModFeatures.AURA_CACTUS, NoneFeatureConfiguration.INSTANCE);
|
FeatureUtils.register(context, ModFeatures.Configured.AURA_CACTUS, ModFeatures.AURA_CACTUS, NoneFeatureConfiguration.INSTANCE);
|
||||||
FeatureUtils.register(context, ModFeatures.Configured.WARPED_AURA_MUSHROOM, ModFeatures.WARPED_AURA_MUSHROOM, NoneFeatureConfiguration.INSTANCE);
|
FeatureUtils.register(context, ModFeatures.Configured.WARPED_AURA_MUSHROOM, ModFeatures.WARPED_AURA_MUSHROOM, NoneFeatureConfiguration.INSTANCE);
|
||||||
|
@ -43,28 +45,25 @@ public final class ModFeatures {
|
||||||
FeatureUtils.register(context, ModFeatures.Configured.NETHER_WART_MUSHROOM, ModFeatures.NETHER_WART_MUSHROOM, NoneFeatureConfiguration.INSTANCE);
|
FeatureUtils.register(context, ModFeatures.Configured.NETHER_WART_MUSHROOM, ModFeatures.NETHER_WART_MUSHROOM, NoneFeatureConfiguration.INSTANCE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class Placed {
|
public static final class Placed {
|
||||||
|
|
||||||
public static final ResourceKey<PlacedFeature> AURA_BLOOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":aura_bloom");
|
public static ResourceKey<PlacedFeature> AURA_BLOOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":aura_bloom");
|
||||||
public static final ResourceKey<PlacedFeature> AURA_CACTUS = PlacementUtils.createKey(NaturesAura.MOD_ID + ":aura_cactus");
|
public static ResourceKey<PlacedFeature> AURA_CACTUS = PlacementUtils.createKey(NaturesAura.MOD_ID + ":aura_cactus");
|
||||||
public static final ResourceKey<PlacedFeature> WARPED_AURA_MUSHROOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":warped_aura_mushroom");
|
public static ResourceKey<PlacedFeature> WARPED_AURA_MUSHROOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":warped_aura_mushroom");
|
||||||
public static final ResourceKey<PlacedFeature> CRIMSON_AURA_MUSHROOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":crimson_aura_mushroom");
|
public static ResourceKey<PlacedFeature> CRIMSON_AURA_MUSHROOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":crimson_aura_mushroom");
|
||||||
public static final ResourceKey<PlacedFeature> AURA_MUSHROOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":aura_mushroom");
|
public static ResourceKey<PlacedFeature> AURA_MUSHROOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":aura_mushroom");
|
||||||
|
|
||||||
public static void bootstrap(BootstrapContext<PlacedFeature> context) {
|
public static void bootstrap(BootstapContext<PlacedFeature> context) {
|
||||||
var holdergetter = context.lookup(Registries.CONFIGURED_FEATURE);
|
HolderGetter<ConfiguredFeature<?, ?>> holdergetter = context.lookup(Registries.CONFIGURED_FEATURE);
|
||||||
|
|
||||||
PlacementUtils.register(context, Placed.AURA_BLOOM, holdergetter.getOrThrow(ModFeatures.Configured.AURA_BLOOM));
|
PlacementUtils.register(context, AURA_BLOOM, holdergetter.getOrThrow(ModFeatures.Configured.AURA_BLOOM));
|
||||||
PlacementUtils.register(context, Placed.AURA_CACTUS, holdergetter.getOrThrow(ModFeatures.Configured.AURA_CACTUS));
|
PlacementUtils.register(context, AURA_CACTUS, holdergetter.getOrThrow(ModFeatures.Configured.AURA_CACTUS));
|
||||||
PlacementUtils.register(context, Placed.WARPED_AURA_MUSHROOM, holdergetter.getOrThrow(ModFeatures.Configured.WARPED_AURA_MUSHROOM));
|
PlacementUtils.register(context, WARPED_AURA_MUSHROOM, holdergetter.getOrThrow(ModFeatures.Configured.WARPED_AURA_MUSHROOM));
|
||||||
PlacementUtils.register(context, Placed.CRIMSON_AURA_MUSHROOM, holdergetter.getOrThrow(ModFeatures.Configured.CRIMSON_AURA_MUSHROOM));
|
PlacementUtils.register(context, CRIMSON_AURA_MUSHROOM, holdergetter.getOrThrow(ModFeatures.Configured.CRIMSON_AURA_MUSHROOM));
|
||||||
PlacementUtils.register(context, Placed.AURA_MUSHROOM, holdergetter.getOrThrow(ModFeatures.Configured.AURA_MUSHROOM));
|
PlacementUtils.register(context, AURA_MUSHROOM, holdergetter.getOrThrow(ModFeatures.Configured.AURA_MUSHROOM));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import net.neoforged.api.distmarker.OnlyIn;
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public class GuiEnderCrate extends AbstractContainerScreen<ContainerEnderCrate> {
|
public class GuiEnderCrate extends AbstractContainerScreen<ContainerEnderCrate> {
|
||||||
|
|
||||||
private static final ResourceLocation CHEST_GUI_TEXTURE = ResourceLocation.withDefaultNamespace("textures/gui/container/generic_54.png");
|
private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("textures/gui/container/generic_54.png");
|
||||||
|
|
||||||
public GuiEnderCrate(ContainerEnderCrate container, Inventory inv, Component title) {
|
public GuiEnderCrate(ContainerEnderCrate container, Inventory inv, Component title) {
|
||||||
super(container, inv, title);
|
super(container, inv, title);
|
||||||
|
|
|
@ -10,7 +10,6 @@ import de.ellpeck.naturesaura.reg.ICustomCreativeTab;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.core.Holder;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
@ -41,7 +40,7 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem, ICustomCrea
|
||||||
if (recharge != null) {
|
if (recharge != null) {
|
||||||
if (recharge.rechargeFromContainer(container, itemSlot, i, player.getInventory().selected == i))
|
if (recharge.rechargeFromContainer(container, itemSlot, i, player.getInventory().selected == i))
|
||||||
break;
|
break;
|
||||||
} else if (stack.getEnchantmentLevel(Holder.direct(ModEnchantments.AURA_MENDING)) > 0) {
|
} else if (stack.getEnchantmentLevel(ModEnchantments.AURA_MENDING) > 0) {
|
||||||
var mainSize = player.getInventory().items.size();
|
var mainSize = player.getInventory().items.size();
|
||||||
var isArmor = i >= mainSize && i < mainSize + player.getInventory().armor.size();
|
var isArmor = i >= mainSize && i < mainSize + player.getInventory().armor.size();
|
||||||
if ((isArmor || player.getInventory().selected == i) && Helper.rechargeAuraItem(stack, container, 1000))
|
if ((isArmor || player.getInventory().selected == i) && Helper.rechargeAuraItem(stack, container, 1000))
|
||||||
|
|
|
@ -4,6 +4,7 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import net.minecraft.world.InteractionHand;
|
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.SpawnPlacements;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
@ -32,13 +33,12 @@ public class ItemCaveFinder extends ItemImpl {
|
||||||
for (var z = -range; z <= range; z++) {
|
for (var z = -range; z <= range; z++) {
|
||||||
var offset = pos.offset(x, y, z);
|
var offset = pos.offset(x, y, z);
|
||||||
var state = levelIn.getBlockState(offset);
|
var state = levelIn.getBlockState(offset);
|
||||||
// TODO figure out an entity-independent way of checking if a block is a valid spawn (just checking for air & ground below?)
|
try {
|
||||||
/* try {
|
|
||||||
if (!state.getBlock().isValidSpawn(state, levelIn, offset, SpawnPlacements.Type.ON_GROUND, null))
|
if (!state.getBlock().isValidSpawn(state, levelIn, offset, SpawnPlacements.Type.ON_GROUND, null))
|
||||||
continue;
|
continue;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
continue;
|
continue;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
var offUp = offset.above();
|
var offUp = offset.above();
|
||||||
var stateUp = levelIn.getBlockState(offUp);
|
var stateUp = levelIn.getBlockState(offUp);
|
||||||
|
@ -51,8 +51,8 @@ public class ItemCaveFinder extends ItemImpl {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
inst.spawnMagicParticle(
|
inst.spawnMagicParticle(
|
||||||
offset.getX() + 0.5F, offset.getY() + 1.5F, offset.getZ() + 0.5F,
|
offset.getX() + 0.5F, offset.getY() + 1.5F, offset.getZ() + 0.5F,
|
||||||
0F, 0F, 0F, 0x992101, 2.5F, 20 * 30, 0F, false, true);
|
0F, 0F, 0F, 0x992101, 2.5F, 20 * 30, 0F, false, true);
|
||||||
}
|
}
|
||||||
inst.setParticleDepth(true);
|
inst.setParticleDepth(true);
|
||||||
inst.setParticleSpawnRange(32);
|
inst.setParticleSpawnRange(32);
|
||||||
|
@ -63,5 +63,4 @@ public class ItemCaveFinder extends ItemImpl {
|
||||||
playerIn.getCooldowns().addCooldown(this, 20 * 30);
|
playerIn.getCooldowns().addCooldown(this, 20 * 30);
|
||||||
return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack);
|
return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ import net.neoforged.neoforge.event.entity.living.LivingEvent;
|
||||||
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
||||||
import net.neoforged.bus.api.EventPriority;
|
import net.neoforged.bus.api.EventPriority;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.neoforge.event.tick.EntityTickEvent;
|
|
||||||
|
|
||||||
public class ItemPetReviver extends ItemImpl {
|
public class ItemPetReviver extends ItemImpl {
|
||||||
|
|
||||||
|
@ -32,7 +31,7 @@ public class ItemPetReviver extends ItemImpl {
|
||||||
private static class Events {
|
private static class Events {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onEntityTick(EntityTickEvent event) {
|
public void onEntityTick(LivingEvent.LivingTickEvent event) {
|
||||||
var entity = event.getEntity();
|
var entity = event.getEntity();
|
||||||
if (entity.level().isClientSide || entity.level().getGameTime() % 20 != 0 || !(entity instanceof TamableAnimal tameable))
|
if (entity.level().isClientSide || entity.level().getGameTime() % 20 != 0 || !(entity instanceof TamableAnimal tameable))
|
||||||
return;
|
return;
|
||||||
|
@ -43,10 +42,10 @@ public class ItemPetReviver extends ItemImpl {
|
||||||
return;
|
return;
|
||||||
if (entity.level().random.nextFloat() >= 0.65F) {
|
if (entity.level().random.nextFloat() >= 0.65F) {
|
||||||
((ServerLevel) entity.level()).sendParticles(ParticleTypes.HEART,
|
((ServerLevel) entity.level()).sendParticles(ParticleTypes.HEART,
|
||||||
entity.getX() + entity.level().random.nextGaussian() * 0.25F,
|
entity.getX() + entity.level().random.nextGaussian() * 0.25F,
|
||||||
entity.getEyeY() + entity.level().random.nextGaussian() * 0.25F,
|
entity.getEyeY() + entity.level().random.nextGaussian() * 0.25F,
|
||||||
entity.getZ() + entity.level().random.nextGaussian() * 0.25F,
|
entity.getZ() + entity.level().random.nextGaussian() * 0.25F,
|
||||||
entity.level().random.nextInt(2) + 1, 0, 0, 0, 0);
|
entity.level().random.nextInt(2) + 1, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +129,5 @@ public class ItemPetReviver extends ItemImpl {
|
||||||
owner.sendSystemMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".pet_reviver", spawnedPet.getDisplayName()).withStyle(ChatFormatting.ITALIC, ChatFormatting.GRAY));
|
owner.sendSystemMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".pet_reviver", spawnedPet.getDisplayName()).withStyle(ChatFormatting.ITALIC, ChatFormatting.GRAY));
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,7 @@ import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.reg.IModItem;
|
import de.ellpeck.naturesaura.reg.IModItem;
|
||||||
import de.ellpeck.naturesaura.reg.ModArmorMaterial;
|
import de.ellpeck.naturesaura.reg.ModArmorMaterial;
|
||||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||||
import net.minecraft.core.Holder;
|
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.world.effect.MobEffects;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
|
@ -20,22 +18,24 @@ import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.common.EventBusSubscriber;
|
import net.neoforged.fml.common.Mod;
|
||||||
import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent;
|
import net.neoforged.neoforge.common.NeoForgeMod;
|
||||||
import net.neoforged.neoforge.event.tick.PlayerTickEvent;
|
import net.neoforged.neoforge.event.TickEvent;
|
||||||
|
import net.neoforged.neoforge.event.entity.living.LivingAttackEvent;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class ItemArmor extends ArmorItem implements IModItem {
|
public class ItemArmor extends ArmorItem implements IModItem {
|
||||||
|
|
||||||
private static final AttributeModifier SKY_MOVEMENT_MODIFIER = new AttributeModifier(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "sky_movement_speed"), 0.15F, AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL);
|
private static final AttributeModifier SKY_MOVEMENT_MODIFIER = new AttributeModifier(UUID.fromString("c1f96acc-e117-4dc1-a351-e196a4de6071"), NaturesAura.MOD_ID + ":sky_movement_speed", 0.15F, AttributeModifier.Operation.MULTIPLY_TOTAL);
|
||||||
private static final AttributeModifier SKY_STEP_MODIFIER = new AttributeModifier(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "sky_step_modifier"), 0.5F, AttributeModifier.Operation.ADD_VALUE);
|
private static final AttributeModifier SKY_STEP_MODIFIER = new AttributeModifier(UUID.fromString("ac3ce414-7243-418c-97f8-ac84c2c102f6"), NaturesAura.MOD_ID + ":sky_step_modifier", 0.5F, AttributeModifier.Operation.ADDITION);
|
||||||
private static final Map<ArmorMaterial, Item[]> SETS = new ConcurrentHashMap<>();
|
private static final Map<ArmorMaterial, Item[]> SETS = new ConcurrentHashMap<>();
|
||||||
private final String baseName;
|
private final String baseName;
|
||||||
|
|
||||||
public ItemArmor(String baseName, Holder<ArmorMaterial> materialIn, ArmorItem.Type equipmentSlotIn) {
|
public ItemArmor(String baseName, ArmorMaterial materialIn, ArmorItem.Type equipmentSlotIn) {
|
||||||
super(materialIn, equipmentSlotIn, new Properties());
|
super(materialIn, equipmentSlotIn, new Properties());
|
||||||
this.baseName = baseName;
|
this.baseName = baseName;
|
||||||
ModRegistry.ALL_ITEMS.add(this);
|
ModRegistry.ALL_ITEMS.add(this);
|
||||||
|
@ -43,9 +43,9 @@ public class ItemArmor extends ArmorItem implements IModItem {
|
||||||
|
|
||||||
public static boolean isFullSetEquipped(LivingEntity entity, ArmorMaterial material) {
|
public static boolean isFullSetEquipped(LivingEntity entity, ArmorMaterial material) {
|
||||||
var set = ItemArmor.SETS.computeIfAbsent(material, m -> BuiltInRegistries.ITEM.stream()
|
var set = ItemArmor.SETS.computeIfAbsent(material, m -> BuiltInRegistries.ITEM.stream()
|
||||||
.filter(i -> i instanceof ItemArmor && ((ItemArmor) i).getMaterial().value() == material)
|
.filter(i -> i instanceof ItemArmor && ((ItemArmor) i).getMaterial() == material)
|
||||||
.sorted(Comparator.comparingInt(i -> ((ItemArmor) i).getEquipmentSlot().ordinal()))
|
.sorted(Comparator.comparingInt(i -> ((ItemArmor) i).getEquipmentSlot().ordinal()))
|
||||||
.toArray(Item[]::new));
|
.toArray(Item[]::new));
|
||||||
for (var i = 0; i < 4; i++) {
|
for (var i = 0; i < 4; i++) {
|
||||||
var slot = EquipmentSlot.values()[i + 2];
|
var slot = EquipmentSlot.values()[i + 2];
|
||||||
var stack = entity.getItemBySlot(slot);
|
var stack = entity.getItemBySlot(slot);
|
||||||
|
@ -60,11 +60,11 @@ public class ItemArmor extends ArmorItem implements IModItem {
|
||||||
return this.baseName;
|
return this.baseName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventBusSubscriber
|
@Mod.EventBusSubscriber
|
||||||
private static final class EventHandler {
|
private static final class EventHandler {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onAttack(LivingIncomingDamageEvent event) {
|
public static void onAttack(LivingAttackEvent event) {
|
||||||
var entity = event.getEntity();
|
var entity = event.getEntity();
|
||||||
if (!entity.level().isClientSide) {
|
if (!entity.level().isClientSide) {
|
||||||
if (ItemArmor.isFullSetEquipped(entity, ModArmorMaterial.INFUSED)) {
|
if (ItemArmor.isFullSetEquipped(entity, ModArmorMaterial.INFUSED)) {
|
||||||
|
@ -81,25 +81,25 @@ public class ItemArmor extends ArmorItem implements IModItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void update(PlayerTickEvent event) {
|
public static void update(TickEvent.PlayerTickEvent event) {
|
||||||
var player = event.getEntity();
|
var player = event.player;
|
||||||
var speed = player.getAttribute(Attributes.MOVEMENT_SPEED);
|
var speed = player.getAttribute(Attributes.MOVEMENT_SPEED);
|
||||||
var step = player.getAttribute(Attributes.STEP_HEIGHT);
|
var step = player.getAttribute(NeoForgeMod.STEP_HEIGHT.value());
|
||||||
var key = NaturesAura.MOD_ID + ":sky_equipped";
|
var key = NaturesAura.MOD_ID + ":sky_equipped";
|
||||||
var nbt = player.getPersistentData();
|
var nbt = player.getPersistentData();
|
||||||
var equipped = ItemArmor.isFullSetEquipped(player, ModArmorMaterial.SKY);
|
var equipped = ItemArmor.isFullSetEquipped(player, ModArmorMaterial.SKY);
|
||||||
if (equipped && !nbt.getBoolean(key)) {
|
if (equipped && !nbt.getBoolean(key)) {
|
||||||
// we just equipped it
|
// we just equipped it
|
||||||
nbt.putBoolean(key, true);
|
nbt.putBoolean(key, true);
|
||||||
if (!step.hasModifier(ItemArmor.SKY_STEP_MODIFIER.id()))
|
if (!step.hasModifier(ItemArmor.SKY_STEP_MODIFIER))
|
||||||
step.addPermanentModifier(ItemArmor.SKY_STEP_MODIFIER);
|
step.addPermanentModifier(ItemArmor.SKY_STEP_MODIFIER);
|
||||||
if (!speed.hasModifier(ItemArmor.SKY_MOVEMENT_MODIFIER.id()))
|
if (!speed.hasModifier(ItemArmor.SKY_MOVEMENT_MODIFIER))
|
||||||
speed.addPermanentModifier(ItemArmor.SKY_MOVEMENT_MODIFIER);
|
speed.addPermanentModifier(ItemArmor.SKY_MOVEMENT_MODIFIER);
|
||||||
} else if (!equipped && nbt.getBoolean(key)) {
|
} else if (!equipped && nbt.getBoolean(key)) {
|
||||||
// we just unequipped it
|
// we just unequipped it
|
||||||
nbt.putBoolean(key, false);
|
nbt.putBoolean(key, false);
|
||||||
step.removeModifier(ItemArmor.SKY_STEP_MODIFIER.id());
|
step.removeModifier(ItemArmor.SKY_STEP_MODIFIER.getId());
|
||||||
speed.removeModifier(ItemArmor.SKY_MOVEMENT_MODIFIER.id());
|
speed.removeModifier(ItemArmor.SKY_MOVEMENT_MODIFIER.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue