1.19 port part 1

This commit is contained in:
Ell 2022-06-27 15:24:04 +02:00
parent d82640a843
commit 3b81d8eb68
123 changed files with 841 additions and 1024 deletions

View file

@ -24,7 +24,7 @@ if (System.getenv('BUILD_NUMBER') != null) {
java.toolchain.languageVersion = JavaLanguageVersion.of(17) java.toolchain.languageVersion = JavaLanguageVersion.of(17)
minecraft { minecraft {
mappings channel: 'official', version: '1.18.2' mappings channel: 'official', version: '1.19'
runs { runs {
client { client {
@ -102,16 +102,16 @@ repositories {
} }
dependencies { dependencies {
minecraft 'net.minecraftforge:forge:1.18.2-40.0.3' minecraft 'net.minecraftforge:forge:1.19-41.0.45'
compileOnly fg.deobf("mezz.jei:jei-1.18.2:9.4.1.117:api") compileOnly fg.deobf("mezz.jei:jei-1.19-common-api:11.0.0.206")
runtimeOnly fg.deobf("mezz.jei:jei-1.18.2:9.4.1.117") runtimeOnly fg.deobf("mezz.jei:jei-1.19-forge:11.0.0.206")
compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.2-66-SNAPSHOT:api") compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.19-73:api")
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.2-66-SNAPSHOT") runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.19-73")
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18.2-5.0.6.3") runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.19-5.1.0.2")
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18.2-5.0.6.3:api") compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.19-5.1.0.2:api")
// TODO Enchantability // TODO Enchantability
/* compile fg.deobf("quarris.enchantability:Enchantability:11.0.48")*/ /* compile fg.deobf("quarris.enchantability:Enchantability:11.0.48")*/

View file

@ -2,7 +2,6 @@ package de.ellpeck.naturesaura;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.datafixers.util.Either;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge; import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
@ -15,7 +14,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ChunkHolder;
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;
@ -36,7 +34,6 @@ 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.ChunkStatus; import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunk;
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.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@ -47,7 +44,6 @@ import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.IForgeRegistryEntry;
import org.apache.commons.lang3.tuple.ImmutableTriple; import org.apache.commons.lang3.tuple.ImmutableTriple;
import top.theillusivec4.curios.api.CuriosApi; import top.theillusivec4.curios.api.CuriosApi;
@ -56,7 +52,6 @@ import javax.annotation.Nullable;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
@ -66,7 +61,7 @@ public final class Helper {
public static boolean getBlockEntitiesInArea(LevelAccessor level, BlockPos pos, int radius, Function<BlockEntity, Boolean> consumer) { public static boolean getBlockEntitiesInArea(LevelAccessor level, BlockPos pos, int radius, Function<BlockEntity, Boolean> consumer) {
for (var x = pos.getX() - radius >> 4; x <= pos.getX() + radius >> 4; x++) { for (var x = pos.getX() - radius >> 4; x <= pos.getX() + radius >> 4; x++) {
for (var z = pos.getZ() - radius >> 4; z <= pos.getZ() + radius >> 4; z++) { for (var z = pos.getZ() - radius >> 4; z <= pos.getZ() + radius >> 4; z++) {
var chunk = getLoadedChunk(level, x, z); var chunk = Helper.getLoadedChunk(level, x, z);
if (chunk != null) { if (chunk != null) {
for (var tilePos : chunk.getBlockEntitiesPos()) { for (var tilePos : chunk.getBlockEntitiesPos()) {
if (tilePos.distSqr(pos) <= radius * radius) if (tilePos.distSqr(pos) <= radius * radius)
@ -206,7 +201,7 @@ public final class Helper {
return new ICapabilityProvider() { return new ICapabilityProvider() {
private final LazyOptional<IAuraRecharge> recharge = LazyOptional.of(() -> (container, containerSlot, itemSlot, isSelected) -> { private final LazyOptional<IAuraRecharge> recharge = LazyOptional.of(() -> (container, containerSlot, itemSlot, isSelected) -> {
if (isSelected || !needsSelected) if (isSelected || !needsSelected)
return rechargeAuraItem(stack, container, 300); return Helper.rechargeAuraItem(stack, container, 300);
return false; return false;
}); });
@ -238,7 +233,7 @@ public final class Helper {
for (var part : split[1].replace("]", "").split(",")) { for (var part : split[1].replace("]", "").split(",")) {
var keyValue = part.split("="); var keyValue = part.split("=");
for (var prop : state.getProperties()) { for (var prop : state.getProperties()) {
var changed = findProperty(state, prop, keyValue[0], keyValue[1]); var changed = Helper.findProperty(state, prop, keyValue[0], keyValue[1]);
if (changed != null) { if (changed != null) {
state = changed; state = changed;
break; break;
@ -296,7 +291,7 @@ public final class Helper {
} }
// This is how @ObjectHolder SHOULD work... // This is how @ObjectHolder SHOULD work...
public static <T extends IForgeRegistryEntry<T>> void populateObjectHolders(Class<?> clazz, IForgeRegistry<T> registry) { public static <T> void populateObjectHolders(Class<?> clazz, IForgeRegistry<T> registry) {
for (var entry : clazz.getFields()) { for (var entry : clazz.getFields()) {
if (!Modifier.isStatic(entry.getModifiers())) if (!Modifier.isStatic(entry.getModifiers()))
continue; continue;

View file

@ -31,8 +31,8 @@ public final class NaturesAura {
public static final String MOD_ID = NaturesAuraAPI.MOD_ID; public static final String MOD_ID = NaturesAuraAPI.MOD_ID;
public static final String MOD_NAME = "Nature's Aura"; public static final String MOD_NAME = "Nature's Aura";
public static final Logger LOGGER = LogManager.getLogger(MOD_NAME); public static final Logger LOGGER = LogManager.getLogger(NaturesAura.MOD_NAME);
public static final CreativeModeTab CREATIVE_TAB = new CreativeModeTab(MOD_ID) { public static final CreativeModeTab CREATIVE_TAB = new CreativeModeTab(NaturesAura.MOD_ID) {
@Override @Override
public ItemStack makeIcon() { public ItemStack makeIcon() {
return new ItemStack(ModItems.GOLD_LEAF); return new ItemStack(ModItems.GOLD_LEAF);
@ -44,7 +44,7 @@ public final class NaturesAura {
public static IProxy proxy = DistExecutor.unsafeRunForDist(() -> () -> new ClientProxy(), () -> () -> new ServerProxy()); public static IProxy proxy = DistExecutor.unsafeRunForDist(() -> () -> new ClientProxy(), () -> () -> new ServerProxy());
public NaturesAura() { public NaturesAura() {
instance = this; NaturesAura.instance = this;
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
var builder = new ForgeConfigSpec.Builder(); var builder = new ForgeConfigSpec.Builder();
@ -65,7 +65,7 @@ public final class NaturesAura {
MinecraftForge.EVENT_BUS.register(new CommonEvents()); MinecraftForge.EVENT_BUS.register(new CommonEvents());
proxy.preInit(event); NaturesAura.proxy.preInit(event);
} }
private void init(FMLCommonSetupEvent event) { private void init(FMLCommonSetupEvent event) {
@ -75,16 +75,16 @@ public final class NaturesAura {
ModRegistry.init(); ModRegistry.init();
DrainSpotEffects.init(); DrainSpotEffects.init();
proxy.init(event); NaturesAura.proxy.init(event);
} }
private void postInit(FMLCommonSetupEvent event) { private void postInit(FMLCommonSetupEvent event) {
proxy.postInit(event); NaturesAura.proxy.postInit(event);
LOGGER.info("-- Nature's Aura Fake Player Information --"); NaturesAura.LOGGER.info("-- Nature's Aura Fake Player Information --");
LOGGER.info("Name: [Minecraft]"); NaturesAura.LOGGER.info("Name: [Minecraft]");
LOGGER.info("UUID: 41C82C87-7AfB-4024-BA57-13D2C99CAE77"); NaturesAura.LOGGER.info("UUID: 41C82C87-7AfB-4024-BA57-13D2C99CAE77");
LOGGER.info(Strings.padStart("", 43, '-')); NaturesAura.LOGGER.info(Strings.padStart("", 43, '-'));
} }
} }

View file

@ -56,10 +56,10 @@ public final class NaturesAuraAPI {
* easily registered using {@link BasicAuraType#register()}. * 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(new ResourceLocation(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(new ResourceLocation(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(new ResourceLocation(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(new ResourceLocation(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 * A map of all {@link IDrainSpotEffect} suppliers which are effects that
* happen passively at every spot that Aura has been drained from in the * happen passively at every spot that Aura has been drained from in the
@ -150,7 +150,7 @@ public final class NaturesAuraAPI {
* @return The active {@link IInternalHooks} instance * @return The active {@link IInternalHooks} instance
*/ */
public static IInternalHooks instance() { public static IInternalHooks instance() {
return INSTANCE; return NaturesAuraAPI.INSTANCE;
} }
/** /**

View file

@ -24,7 +24,7 @@ public interface IDrainSpotEffect {
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
public enum ActiveType { enum ActiveType {
INACTIVE, INHIBITED, ACTIVE INACTIVE, INHIBITED, ACTIVE
} }
} }

View file

@ -15,8 +15,8 @@ public interface ILevelData extends ICapabilityProvider, INBTSerializable<Compou
static ILevelData getOverworldData(Level level) { static ILevelData getOverworldData(Level level) {
if (!level.isClientSide) if (!level.isClientSide)
return getLevelData(level.getServer().getLevel(Level.OVERWORLD)); return ILevelData.getLevelData(level.getServer().getLevel(Level.OVERWORLD));
return getLevelData(level); return ILevelData.getLevelData(level);
} }
IItemHandlerModifiable getEnderStorage(String name); IItemHandlerModifiable getEnderStorage(String name);

View file

@ -1,7 +1,6 @@
package de.ellpeck.naturesaura.api.multiblock; package de.ellpeck.naturesaura.api.multiblock;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.tags.Tag;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
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;

View file

@ -8,6 +8,7 @@ import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.color.item.ItemColor; import net.minecraft.client.color.item.ItemColor;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
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;
import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.EntityBlock;
@ -27,8 +28,8 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP
public BlockAncientLeaves() { public BlockAncientLeaves() {
super(Block.Properties.of(Material.LEAVES, MaterialColor.COLOR_PINK).strength(0.2F).randomTicks().noOcclusion().sound(SoundType.GRASS)); super(Block.Properties.of(Material.LEAVES, MaterialColor.COLOR_PINK).strength(0.2F).randomTicks().noOcclusion().sound(SoundType.GRASS));
ModRegistry.add(this); ModRegistry.ALL_ITEMS.add(this);
ModRegistry.add(new ModTileType<>(BlockEntityAncientLeaves::new, this)); ModRegistry.ALL_ITEMS.add(new ModTileType<BlockEntityAncientLeaves>(BlockEntityAncientLeaves::new, this));
} }
@Override @Override
@ -50,7 +51,7 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, RandomSource rand) {
super.animateTick(stateIn, levelIn, pos, rand); super.animateTick(stateIn, levelIn, pos, rand);
if (rand.nextFloat() >= 0.95F && !levelIn.getBlockState(pos.below()).isCollisionShapeFullBlock(levelIn, pos)) { if (rand.nextFloat() >= 0.95F && !levelIn.getBlockState(pos.below()).isCollisionShapeFullBlock(levelIn, pos)) {
var tile = levelIn.getBlockEntity(pos); var tile = levelIn.getBlockEntity(pos);
@ -69,7 +70,7 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP
} }
@Override @Override
public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) { public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, RandomSource random) {
super.randomTick(state, levelIn, pos, random); super.randomTick(state, levelIn, pos, random);
if (!levelIn.isClientSide) { if (!levelIn.isClientSide) {
var tile = levelIn.getBlockEntity(pos); var tile = levelIn.getBlockEntity(pos);

View file

@ -16,7 +16,7 @@ public class BlockAncientLog extends RotatedPillarBlock implements IModItem, ICu
public BlockAncientLog(String baseName) { public BlockAncientLog(String baseName) {
super(Properties.of(Material.WOOD, MaterialColor.COLOR_PURPLE).strength(2.0F).sound(SoundType.WOOD)); super(Properties.of(Material.WOOD, MaterialColor.COLOR_PURPLE).strength(2.0F).sound(SoundType.WOOD));
this.baseName = baseName; this.baseName = baseName;
ModRegistry.add(this); ModRegistry.ALL_ITEMS.add(this);
} }
@Override @Override

View file

@ -7,6 +7,7 @@ import de.ellpeck.naturesaura.reg.*;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
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.*; import net.minecraft.world.level.block.*;
@ -17,25 +18,24 @@ import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.ForgeEventFactory;
import java.util.Random;
import java.util.function.Supplier; import java.util.function.Supplier;
public class BlockAncientSapling extends BushBlock implements BonemealableBlock, IModItem, ICustomBlockState, ICustomItemModel, ICustomRenderType { public class BlockAncientSapling extends BushBlock implements BonemealableBlock, IModItem, ICustomBlockState, ICustomItemModel, ICustomRenderType {
protected static final VoxelShape SHAPE = box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D); protected static final VoxelShape SHAPE = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D);
public BlockAncientSapling() { public BlockAncientSapling() {
super(Properties.of(Material.GRASS).strength(0.0F).sound(SoundType.GRASS)); super(Properties.of(Material.GRASS).strength(0.0F).sound(SoundType.GRASS));
ModRegistry.add(this); ModRegistry.ALL_ITEMS.add(this);
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
return SHAPE; return BlockAncientSapling.SHAPE;
} }
@Override @Override
public void randomTick(BlockState state, ServerLevel level, BlockPos pos, Random random) { public void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
if (!level.isClientSide) { if (!level.isClientSide) {
super.randomTick(state, level, pos, random); super.randomTick(state, level, pos, random);
@ -60,12 +60,12 @@ public class BlockAncientSapling extends BushBlock implements BonemealableBlock,
} }
@Override @Override
public boolean isBonemealSuccess(Level level, Random rand, BlockPos pos, BlockState state) { public boolean isBonemealSuccess(Level level, RandomSource rand, BlockPos pos, BlockState state) {
return level.random.nextFloat() < 0.45F; return level.random.nextFloat() < 0.45F;
} }
@Override @Override
public void performBonemeal(ServerLevel level, Random 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 if (ForgeEventFactory.saplingGrowTree(level, rand, pos)) { } else if (ForgeEventFactory.saplingGrowTree(level, rand, pos)) {

View file

@ -7,6 +7,7 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
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.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.phys.AABB; import net.minecraft.world.phys.AABB;
@ -17,7 +18,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockAnimalContainer extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public class BlockAnimalContainer extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
private static final VoxelShape SHAPE = box(5, 0, 5, 11, 13, 11); private static final VoxelShape SHAPE = Block.box(5, 0, 5, 11, 13, 11);
public BlockAnimalContainer() { public BlockAnimalContainer() {
super("animal_container", BlockEntityAnimalContainer.class, Properties.copy(Blocks.STONE)); super("animal_container", BlockEntityAnimalContainer.class, Properties.copy(Blocks.STONE));
@ -30,7 +31,7 @@ public class BlockAnimalContainer extends BlockContainerImpl implements IVisuali
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
return SHAPE; return BlockAnimalContainer.SHAPE;
} }
@Override @Override

View file

@ -39,7 +39,7 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS
super(Properties.of(Material.PLANT).noCollission().strength(0).sound(SoundType.GRASS)); super(Properties.of(Material.PLANT).noCollission().strength(0).sound(SoundType.GRASS));
this.baseName = baseName; this.baseName = baseName;
this.allowedGround = allowedGround; this.allowedGround = allowedGround;
ModRegistry.add(this); ModRegistry.ALL_ITEMS.add(this);
} }
@Override @Override
@ -62,7 +62,7 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
var vec3d = state.getOffset(levelIn, pos); var vec3d = state.getOffset(levelIn, pos);
return SHAPE.move(vec3d.x, vec3d.y, vec3d.z); return BlockAuraBloom.SHAPE.move(vec3d.x, vec3d.y, vec3d.z);
} }
@Override @Override

View file

@ -13,6 +13,7 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; 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.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;
@ -32,7 +33,7 @@ import java.util.function.Supplier;
public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockState, ITESRProvider<BlockEntityAuraTimer>, ICustomRenderType { public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockState, ITESRProvider<BlockEntityAuraTimer>, ICustomRenderType {
private static final VoxelShape SHAPE = box(1, 0, 1, 15, 15, 15); private static final VoxelShape SHAPE = Block.box(1, 0, 1, 15, 15, 15);
public BlockAuraTimer() { public BlockAuraTimer() {
super("aura_timer", BlockEntityAuraTimer.class, Properties.copy(Blocks.SMOOTH_STONE)); super("aura_timer", BlockEntityAuraTimer.class, Properties.copy(Blocks.SMOOTH_STONE));
@ -46,7 +47,7 @@ public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockSt
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
return SHAPE; return BlockAuraTimer.SHAPE;
} }
@Override @Override
@ -75,7 +76,7 @@ public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockSt
} }
@Override @Override
public void tick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) { public void tick(BlockState state, ServerLevel levelIn, BlockPos pos, RandomSource random) {
super.tick(state, levelIn, pos, random); super.tick(state, levelIn, pos, random);
if (state.getValue(BlockStateProperties.POWERED)) if (state.getValue(BlockStateProperties.POWERED))
levelIn.setBlockAndUpdate(pos, state.setValue(BlockStateProperties.POWERED, false)); levelIn.setBlockAndUpdate(pos, state.setValue(BlockStateProperties.POWERED, false));

View file

@ -23,12 +23,12 @@ public class BlockAutoCrafter extends BlockContainerImpl implements ICustomBlock
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
super.createBlockStateDefinition(builder); super.createBlockStateDefinition(builder);
builder.add(FACING); builder.add(BlockAutoCrafter.FACING);
} }
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext context) { public BlockState getStateForPlacement(BlockPlaceContext context) {
return super.getStateForPlacement(context).setValue(FACING, context.getPlayer().getDirection()); return super.getStateForPlacement(context).setValue(BlockAutoCrafter.FACING, context.getPlayer().getDirection());
} }
@Override @Override

View file

@ -32,18 +32,18 @@ public class BlockBlastFurnaceBooster extends BlockContainerImpl implements ICus
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
return SHAPE; return BlockBlastFurnaceBooster.SHAPE;
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
super.createBlockStateDefinition(builder); super.createBlockStateDefinition(builder);
builder.add(FACING); builder.add(BlockBlastFurnaceBooster.FACING);
} }
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext context) { public BlockState getStateForPlacement(BlockPlaceContext context) {
return super.getStateForPlacement(context).setValue(FACING, context.getHorizontalDirection().getOpposite()); return super.getStateForPlacement(context).setValue(BlockBlastFurnaceBooster.FACING, context.getHorizontalDirection().getOpposite());
} }
@Override @Override

View file

@ -16,19 +16,19 @@ public class BlockCatalyst extends BlockImpl implements ICustomBlockState {
public BlockCatalyst(String baseName, Properties properties) { public BlockCatalyst(String baseName, Properties properties) {
super(baseName, properties); super(baseName, properties);
this.registerDefaultState(this.defaultBlockState().setValue(NETHER, false)); this.registerDefaultState(this.defaultBlockState().setValue(BlockCatalyst.NETHER, false));
} }
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext context) { public BlockState getStateForPlacement(BlockPlaceContext context) {
var nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER); var nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER);
return super.getStateForPlacement(context).setValue(NETHER, nether); return super.getStateForPlacement(context).setValue(BlockCatalyst.NETHER, nether);
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
super.createBlockStateDefinition(builder); super.createBlockStateDefinition(builder);
builder.add(NETHER); builder.add(BlockCatalyst.NETHER);
} }
@Override @Override

View file

@ -9,8 +9,10 @@ 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.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
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.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
@ -20,11 +22,9 @@ import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import java.util.Random;
public class BlockChunkLoader extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public class BlockChunkLoader extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
private static final VoxelShape SHAPE = box(4, 4, 4, 12, 12, 12); private static final VoxelShape SHAPE = Block.box(4, 4, 4, 12, 12, 12);
public BlockChunkLoader() { public BlockChunkLoader() {
super("chunk_loader", BlockEntityChunkLoader.class, Properties.of(Material.STONE).strength(3F).sound(SoundType.STONE)); super("chunk_loader", BlockEntityChunkLoader.class, Properties.of(Material.STONE).strength(3F).sound(SoundType.STONE));
@ -43,12 +43,12 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl
var range = ((BlockEntityChunkLoader) tile).range(); var range = ((BlockEntityChunkLoader) tile).range();
if (range > 0) { if (range > 0) {
return new AABB( return new AABB(
(pos.getX() - range) >> 4 << 4, pos.getX() - range >> 4 << 4,
0, 0,
(pos.getZ() - range) >> 4 << 4, pos.getZ() - range >> 4 << 4,
((pos.getX() + range) >> 4 << 4) + 16, (pos.getX() + range >> 4 << 4) + 16,
level.getHeight(), level.getHeight(),
((pos.getZ() + range) >> 4 << 4) + 16); (pos.getZ() + range >> 4 << 4) + 16);
} }
} }
return null; return null;
@ -56,7 +56,7 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, RandomSource rand) {
if (!ModConfig.instance.chunkLoader.get()) if (!ModConfig.instance.chunkLoader.get())
return; return;
var tile = levelIn.getBlockEntity(pos); var tile = levelIn.getBlockEntity(pos);
@ -78,7 +78,7 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
return SHAPE; return BlockChunkLoader.SHAPE;
} }
@Override @Override

View file

@ -9,6 +9,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.FluidTags; import net.minecraft.tags.FluidTags;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
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;
@ -48,8 +49,8 @@ public class BlockContainerImpl extends BaseEntityBlock implements IModItem {
this.tileClass = tileClass; this.tileClass = tileClass;
this.tileType = new ModTileType<>(this::createBlockEntity, this); this.tileType = new ModTileType<>(this::createBlockEntity, this);
ModRegistry.add(this); ModRegistry.ALL_ITEMS.add(this);
ModRegistry.add(this.tileType); ModRegistry.ALL_ITEMS.add(this.tileType);
if (this.hasWaterlogging()) if (this.hasWaterlogging())
this.registerDefaultState(this.stateDefinition.any().setValue(BlockStateProperties.WATERLOGGED, false)); this.registerDefaultState(this.stateDefinition.any().setValue(BlockStateProperties.WATERLOGGED, false));
@ -166,7 +167,7 @@ public class BlockContainerImpl extends BaseEntityBlock implements IModItem {
} }
@Override @Override
public void tick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) { public void tick(BlockState state, ServerLevel levelIn, BlockPos pos, RandomSource random) {
if (!levelIn.isClientSide) { if (!levelIn.isClientSide) {
var tile = levelIn.getBlockEntity(pos); var tile = levelIn.getBlockEntity(pos);
if (tile instanceof BlockEntityImpl impl) { if (tile instanceof BlockEntityImpl impl) {

View file

@ -6,6 +6,7 @@ import de.ellpeck.naturesaura.reg.ICustomRenderType;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
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;
@ -21,7 +22,7 @@ public class BlockDecayedLeaves extends BlockImpl implements ICustomBlockState,
} }
@Override @Override
public void tick(BlockState state, ServerLevel level, BlockPos pos, Random random) { public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
if (!level.isClientSide) { if (!level.isClientSide) {
level.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState()); level.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState());
} }

View file

@ -53,7 +53,7 @@ public class BlockDimensionRail extends BaseRailBlock implements IModItem, ICust
this.goalDim = goalDim; this.goalDim = goalDim;
this.canUseDims = canUseDims; this.canUseDims = canUseDims;
ModRegistry.add(this); ModRegistry.ALL_ITEMS.add(this);
} }
private boolean canUseHere(ResourceKey<Level> dimension) { private boolean canUseHere(ResourceKey<Level> dimension) {
@ -136,7 +136,7 @@ public class BlockDimensionRail extends BaseRailBlock implements IModItem, ICust
@Override @Override
public Property<RailShape> getShapeProperty() { public Property<RailShape> getShapeProperty() {
return SHAPE; return BlockDimensionRail.SHAPE;
} }
@Override @Override
@ -151,7 +151,7 @@ public class BlockDimensionRail extends BaseRailBlock implements IModItem, ICust
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(SHAPE, WATERLOGGED); builder.add(BlockDimensionRail.SHAPE, BaseRailBlock.WATERLOGGED);
} }
@Override @Override

View file

@ -15,10 +15,7 @@ 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.LevelReader; import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.BushBlock;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
@ -40,19 +37,19 @@ import java.util.function.Supplier;
public class BlockEndFlower extends BushBlock implements IModItem, ICustomBlockState, ICustomItemModel, ICustomRenderType, EntityBlock { public class BlockEndFlower extends BushBlock implements IModItem, ICustomBlockState, ICustomItemModel, ICustomRenderType, EntityBlock {
protected static final VoxelShape SHAPE = box(5.0D, 0.0D, 5.0D, 11.0D, 10.0D, 11.0D); protected static final VoxelShape SHAPE = Block.box(5.0D, 0.0D, 5.0D, 11.0D, 10.0D, 11.0D);
public BlockEndFlower() { public BlockEndFlower() {
super(Properties.of(Material.GRASS).noCollission().strength(0.5F).sound(SoundType.GRASS)); super(Properties.of(Material.GRASS).noCollission().strength(0.5F).sound(SoundType.GRASS));
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
ModRegistry.add(this); ModRegistry.ALL_ITEMS.add(this);
ModRegistry.add(new ModTileType<>(BlockEntityEndFlower::new, this)); ModRegistry.ALL_ITEMS.add(new ModTileType<BlockEntityEndFlower>(BlockEntityEndFlower::new, this));
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
var vec3d = state.getOffset(levelIn, pos); var vec3d = state.getOffset(levelIn, pos);
return SHAPE.move(vec3d.x, vec3d.y, vec3d.z); return BlockEndFlower.SHAPE.move(vec3d.x, vec3d.y, vec3d.z);
} }
@SubscribeEvent @SubscribeEvent

View file

@ -15,8 +15,8 @@ import net.minecraft.client.resources.language.I18n;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes; import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
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;
@ -38,7 +38,6 @@ import net.minecraftforge.network.NetworkHooks;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List; import java.util.List;
import java.util.Random;
public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider<BlockEntityEnderCrate>, ICustomBlockState { public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider<BlockEntityEnderCrate>, ICustomBlockState {
@ -56,11 +55,11 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public static void addEnderNameInfo(ItemStack stack, List<Component> tooltip) { public static void addEnderNameInfo(ItemStack stack, List<Component> tooltip) {
var name = getEnderName(stack); var name = BlockEnderCrate.getEnderName(stack);
if (name != null && !name.isEmpty()) { if (name != null && !name.isEmpty()) {
tooltip.add(new TextComponent(ChatFormatting.DARK_PURPLE + I18n.get("info." + NaturesAura.MOD_ID + ".ender_name", ChatFormatting.ITALIC + name + ChatFormatting.RESET))); tooltip.add(Component.literal(ChatFormatting.DARK_PURPLE + I18n.get("info." + NaturesAura.MOD_ID + ".ender_name", ChatFormatting.ITALIC + name + ChatFormatting.RESET)));
} else { } else {
tooltip.add(new TextComponent(ChatFormatting.DARK_PURPLE + I18n.get("info." + NaturesAura.MOD_ID + ".ender_name.missing"))); tooltip.add(Component.literal(ChatFormatting.DARK_PURPLE + I18n.get("info." + NaturesAura.MOD_ID + ".ender_name.missing")));
} }
} }
@ -102,12 +101,12 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void appendHoverText(ItemStack stack, @Nullable BlockGetter levelIn, List<Component> tooltip, TooltipFlag flagIn) { public void appendHoverText(ItemStack stack, @Nullable BlockGetter levelIn, List<Component> tooltip, TooltipFlag flagIn) {
addEnderNameInfo(stack, tooltip); BlockEnderCrate.addEnderNameInfo(stack, tooltip);
} }
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, RandomSource rand) {
for (var i = 0; i < 3; ++i) { for (var i = 0; i < 3; ++i) {
var j = rand.nextInt(2) * 2 - 1; var j = rand.nextInt(2) * 2 - 1;
var k = rand.nextInt(2) * 2 - 1; var k = rand.nextInt(2) * 2 - 1;

View file

@ -8,7 +8,8 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState;
import de.ellpeck.naturesaura.reg.ICustomRenderType; import de.ellpeck.naturesaura.reg.ICustomRenderType;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.network.chat.Component;
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;
@ -52,16 +53,16 @@ public class BlockFieldCreator extends BlockContainerImpl implements ICustomBloc
otherCreator.sendToClients(); otherCreator.sendToClients();
compound.remove(key); compound.remove(key);
player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".connected"), true); player.displayClientMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".connected"), true);
} else } else
player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".stored_pos_gone"), true); player.displayClientMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".stored_pos_gone"), true);
} else } else
player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".too_far"), true); player.displayClientMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".too_far"), true);
} else } else
player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".same_position"), true); player.displayClientMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".same_position"), true);
} else { } else {
compound.putLong(key, pos.asLong()); compound.putLong(key, pos.asLong());
player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".stored_pos"), true); player.displayClientMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".stored_pos"), true);
} }
} }
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
@ -71,7 +72,7 @@ public class BlockFieldCreator extends BlockContainerImpl implements ICustomBloc
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, RandomSource rand) {
var tile = levelIn.getBlockEntity(pos); var tile = levelIn.getBlockEntity(pos);
if (tile instanceof BlockEntityFieldCreator creator && creator.isCharged) { if (tile instanceof BlockEntityFieldCreator creator && creator.isCharged) {
var connected = creator.getConnectedPos(); var connected = creator.getConnectedPos();

View file

@ -5,6 +5,7 @@ import de.ellpeck.naturesaura.reg.*;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.FlowerPotBlock; import net.minecraft.world.level.block.FlowerPotBlock;
import net.minecraftforge.registries.ForgeRegistries;
import java.util.function.Supplier; import java.util.function.Supplier;
@ -12,19 +13,19 @@ public class BlockFlowerPot extends FlowerPotBlock implements ICustomBlockState,
public BlockFlowerPot(Supplier<FlowerPotBlock> emptyPot, Supplier<? extends Block> block, Properties props) { public BlockFlowerPot(Supplier<FlowerPotBlock> emptyPot, Supplier<? extends Block> block, Properties props) {
super(emptyPot, block, props); super(emptyPot, block, props);
ModRegistry.add(this); ModRegistry.ALL_ITEMS.add(this);
} }
@Override @Override
public void generateCustomBlockState(BlockStateGenerator generator) { public void generateCustomBlockState(BlockStateGenerator generator) {
generator.simpleBlock(this, generator.models() generator.simpleBlock(this, generator.models()
.withExistingParent(this.getBaseName(), "block/flower_pot_cross") .withExistingParent(this.getBaseName(), "block/flower_pot_cross")
.texture("plant", "block/" + this.getContent().getRegistryName().getPath())); .texture("plant", "block/" + ForgeRegistries.BLOCKS.getKey(this.getContent()).getPath()));
} }
@Override @Override
public String getBaseName() { public String getBaseName() {
return "potted_" + this.getContent().getRegistryName().getPath(); return "potted_" + ForgeRegistries.BLOCKS.getKey(this.getContent()).getPath();
} }
@Override @Override

View file

@ -6,6 +6,7 @@ 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.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
@ -21,19 +22,18 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Random;
public class BlockFurnaceHeater extends BlockContainerImpl implements ICustomBlockState { public class BlockFurnaceHeater extends BlockContainerImpl implements ICustomBlockState {
public static final DirectionProperty FACING = BlockStateProperties.FACING; public static final DirectionProperty FACING = BlockStateProperties.FACING;
private static final VoxelShape[] SHAPES = new VoxelShape[]{ private static final VoxelShape[] SHAPES = new VoxelShape[]{
box(2, 12, 2, 14, 16, 14), // Down Block.box(2, 12, 2, 14, 16, 14), // Down
box(2, 0, 2, 14, 4, 14), // Up Block.box(2, 0, 2, 14, 4, 14), // Up
box(2, 2, 12, 14, 14, 16), // North Block.box(2, 2, 12, 14, 14, 16), // North
box(2, 2, 0, 14, 14, 4), // South Block.box(2, 2, 0, 14, 14, 4), // South
box(12, 2, 2, 16, 14, 14), // West Block.box(12, 2, 2, 16, 14, 14), // West
box(0, 2, 2, 4, 14, 14) // East Block.box(0, 2, 2, 4, 14, 14) // East
}; };
public BlockFurnaceHeater() { public BlockFurnaceHeater() {
@ -47,10 +47,10 @@ public class BlockFurnaceHeater extends BlockContainerImpl implements ICustomBlo
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, RandomSource rand) {
var tile = levelIn.getBlockEntity(pos); var tile = levelIn.getBlockEntity(pos);
if (tile instanceof BlockEntityFurnaceHeater heater && heater.isActive) { if (tile instanceof BlockEntityFurnaceHeater heater && heater.isActive) {
var facing = stateIn.getValue(FACING); var facing = stateIn.getValue(BlockFurnaceHeater.FACING);
float x; float x;
float y; float y;
@ -64,9 +64,9 @@ public class BlockFurnaceHeater extends BlockContainerImpl implements ICustomBlo
y = 1F; y = 1F;
z = 0.35F + rand.nextFloat() * 0.3F; z = 0.35F + rand.nextFloat() * 0.3F;
} else { } else {
x = facing.getStepZ() != 0 ? (0.35F + rand.nextFloat() * 0.3F) : facing.getStepX() < 0 ? 1 : 0; x = facing.getStepZ() != 0 ? 0.35F + rand.nextFloat() * 0.3F : facing.getStepX() < 0 ? 1 : 0;
y = 0.35F + rand.nextFloat() * 0.3F; y = 0.35F + rand.nextFloat() * 0.3F;
z = facing.getStepX() != 0 ? (0.35F + rand.nextFloat() * 0.3F) : facing.getStepZ() < 0 ? 1 : 0; z = facing.getStepX() != 0 ? 0.35F + rand.nextFloat() * 0.3F : facing.getStepZ() < 0 ? 1 : 0;
} }
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
@ -80,19 +80,19 @@ public class BlockFurnaceHeater extends BlockContainerImpl implements ICustomBlo
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
return SHAPES[state.getValue(FACING).get3DDataValue()]; return BlockFurnaceHeater.SHAPES[state.getValue(BlockFurnaceHeater.FACING).get3DDataValue()];
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
super.createBlockStateDefinition(builder); super.createBlockStateDefinition(builder);
builder.add(FACING); builder.add(BlockFurnaceHeater.FACING);
} }
@Nullable @Nullable
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext context) { public BlockState getStateForPlacement(BlockPlaceContext context) {
return super.getStateForPlacement(context).setValue(FACING, context.getClickedFace()); return super.getStateForPlacement(context).setValue(BlockFurnaceHeater.FACING, context.getClickedFace());
} }
@Override @Override

View file

@ -35,19 +35,19 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
public static final EnumProperty<RedstoneSide> EAST = BlockStateProperties.EAST_REDSTONE; public static final EnumProperty<RedstoneSide> EAST = BlockStateProperties.EAST_REDSTONE;
public static final EnumProperty<RedstoneSide> SOUTH = BlockStateProperties.SOUTH_REDSTONE; public static final EnumProperty<RedstoneSide> SOUTH = BlockStateProperties.SOUTH_REDSTONE;
public static final EnumProperty<RedstoneSide> WEST = BlockStateProperties.WEST_REDSTONE; public static final EnumProperty<RedstoneSide> WEST = BlockStateProperties.WEST_REDSTONE;
protected static final VoxelShape[] SHAPES = new VoxelShape[]{box(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D), box(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), box(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D), box(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), box(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), box(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 16.0D), box(0.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), box(0.0D, 0.0D, 0.0D, 13.0D, 1.0D, 16.0D), box(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), box(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 16.0D), box(0.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), box(0.0D, 0.0D, 3.0D, 16.0D, 1.0D, 16.0D), box(3.0D, 0.0D, 0.0D, 16.0D, 1.0D, 13.0D), box(3.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D), box(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 13.0D), box(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D)}; protected static final VoxelShape[] SHAPES = new VoxelShape[]{Block.box(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D), Block.box(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), Block.box(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D), Block.box(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), Block.box(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), Block.box(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), Block.box(0.0D, 0.0D, 0.0D, 13.0D, 1.0D, 16.0D), Block.box(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), Block.box(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 16.0D), Block.box(0.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), Block.box(0.0D, 0.0D, 3.0D, 16.0D, 1.0D, 16.0D), Block.box(3.0D, 0.0D, 0.0D, 16.0D, 1.0D, 13.0D), Block.box(3.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 13.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D)};
public BlockGoldPowder() { public BlockGoldPowder() {
super("gold_powder", Properties.copy(Blocks.REDSTONE_WIRE)); super("gold_powder", Properties.copy(Blocks.REDSTONE_WIRE));
this.registerDefaultState(this.defaultBlockState().setValue(NORTH, RedstoneSide.NONE).setValue(EAST, RedstoneSide.NONE).setValue(SOUTH, RedstoneSide.NONE).setValue(WEST, RedstoneSide.NONE)); this.registerDefaultState(this.defaultBlockState().setValue(BlockGoldPowder.NORTH, RedstoneSide.NONE).setValue(BlockGoldPowder.EAST, RedstoneSide.NONE).setValue(BlockGoldPowder.SOUTH, RedstoneSide.NONE).setValue(BlockGoldPowder.WEST, RedstoneSide.NONE));
} }
private static int getShapeIndex(BlockState state) { private static int getShapeIndex(BlockState state) {
var i = 0; var i = 0;
var n = state.getValue(NORTH) != RedstoneSide.NONE; var n = state.getValue(BlockGoldPowder.NORTH) != RedstoneSide.NONE;
var e = state.getValue(EAST) != RedstoneSide.NONE; var e = state.getValue(BlockGoldPowder.EAST) != RedstoneSide.NONE;
var s = state.getValue(SOUTH) != RedstoneSide.NONE; var s = state.getValue(BlockGoldPowder.SOUTH) != RedstoneSide.NONE;
var w = state.getValue(WEST) != RedstoneSide.NONE; var w = state.getValue(BlockGoldPowder.WEST) != RedstoneSide.NONE;
if (n || s && !n && !e && !w) { if (n || s && !n && !e && !w) {
i |= 1 << Direction.NORTH.get2DDataValue(); i |= 1 << Direction.NORTH.get2DDataValue();
@ -66,7 +66,7 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(NORTH, EAST, SOUTH, WEST); builder.add(BlockGoldPowder.NORTH, BlockGoldPowder.EAST, BlockGoldPowder.SOUTH, BlockGoldPowder.WEST);
} }
@Override @Override
@ -76,14 +76,14 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
return SHAPES[getShapeIndex(state)]; return BlockGoldPowder.SHAPES[BlockGoldPowder.getShapeIndex(state)];
} }
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext context) { public BlockState getStateForPlacement(BlockPlaceContext context) {
BlockGetter iblockreader = context.getLevel(); BlockGetter iblockreader = context.getLevel();
var blockpos = context.getClickedPos(); var blockpos = context.getClickedPos();
return this.defaultBlockState().setValue(WEST, this.getSide(iblockreader, blockpos, Direction.WEST)).setValue(EAST, this.getSide(iblockreader, blockpos, Direction.EAST)).setValue(NORTH, this.getSide(iblockreader, blockpos, Direction.NORTH)).setValue(SOUTH, this.getSide(iblockreader, blockpos, Direction.SOUTH)); return this.defaultBlockState().setValue(BlockGoldPowder.WEST, this.getSide(iblockreader, blockpos, Direction.WEST)).setValue(BlockGoldPowder.EAST, this.getSide(iblockreader, blockpos, Direction.EAST)).setValue(BlockGoldPowder.NORTH, this.getSide(iblockreader, blockpos, Direction.NORTH)).setValue(BlockGoldPowder.SOUTH, this.getSide(iblockreader, blockpos, Direction.SOUTH));
} }
@Override @Override
@ -91,7 +91,7 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
if (facing == Direction.DOWN) { if (facing == Direction.DOWN) {
return stateIn; return stateIn;
} else { } else {
return facing == Direction.UP ? stateIn.setValue(WEST, this.getSide(levelIn, currentPos, Direction.WEST)).setValue(EAST, this.getSide(levelIn, currentPos, Direction.EAST)).setValue(NORTH, this.getSide(levelIn, currentPos, Direction.NORTH)).setValue(SOUTH, this.getSide(levelIn, currentPos, Direction.SOUTH)) : stateIn.setValue(RedStoneWireBlock.PROPERTY_BY_DIRECTION.get(facing), this.getSide(levelIn, currentPos, facing)); return facing == Direction.UP ? stateIn.setValue(BlockGoldPowder.WEST, this.getSide(levelIn, currentPos, Direction.WEST)).setValue(BlockGoldPowder.EAST, this.getSide(levelIn, currentPos, Direction.EAST)).setValue(BlockGoldPowder.NORTH, this.getSide(levelIn, currentPos, Direction.NORTH)).setValue(BlockGoldPowder.SOUTH, this.getSide(levelIn, currentPos, Direction.SOUTH)) : stateIn.setValue(RedStoneWireBlock.PROPERTY_BY_DIRECTION.get(facing), this.getSide(levelIn, currentPos, facing));
} }
} }
@ -180,7 +180,7 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
public void neighborChanged(BlockState state, Level levelIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { public void neighborChanged(BlockState state, Level levelIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
if (!levelIn.isClientSide) { if (!levelIn.isClientSide) {
if (!state.canSurvive(levelIn, pos)) { if (!state.canSurvive(levelIn, pos)) {
dropResources(state, levelIn, pos); Block.dropResources(state, levelIn, pos);
levelIn.removeBlock(pos, false); levelIn.removeBlock(pos, false);
} }
} }
@ -197,7 +197,7 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
if (blockstate.getBlock() != Blocks.OBSERVER) { if (blockstate.getBlock() != Blocks.OBSERVER) {
var blockpos = pool.relative(direction.getOpposite()); var blockpos = pool.relative(direction.getOpposite());
var blockstate1 = blockstate.updateShape(direction.getOpposite(), levelIn.getBlockState(blockpos), levelIn, pool, blockpos); var blockstate1 = blockstate.updateShape(direction.getOpposite(), levelIn.getBlockState(blockpos), levelIn, pool, blockpos);
updateOrDestroy(blockstate, blockstate1, levelIn, pool, flags); Block.updateOrDestroy(blockstate, blockstate1, levelIn, pool, flags);
} }
pool.set(pos).move(direction).move(Direction.UP); pool.set(pos).move(direction).move(Direction.UP);
@ -205,7 +205,7 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
if (blockstate3.getBlock() != Blocks.OBSERVER) { if (blockstate3.getBlock() != Blocks.OBSERVER) {
var blockpos1 = pool.relative(direction.getOpposite()); var blockpos1 = pool.relative(direction.getOpposite());
var blockstate2 = blockstate3.updateShape(direction.getOpposite(), levelIn.getBlockState(blockpos1), levelIn, pool, blockpos1); var blockstate2 = blockstate3.updateShape(direction.getOpposite(), levelIn.getBlockState(blockpos1), levelIn, pool, blockpos1);
updateOrDestroy(blockstate3, blockstate2, levelIn, pool, flags); Block.updateOrDestroy(blockstate3, blockstate2, levelIn, pool, flags);
} }
} }
} }

View file

@ -10,6 +10,7 @@ import net.minecraft.client.renderer.BiomeColors;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; 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.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.LeavesBlock; import net.minecraft.world.level.block.LeavesBlock;
@ -22,16 +23,14 @@ import net.minecraft.world.level.material.MaterialColor;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import java.util.Random;
public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorProvidingBlock, IColorProvidingItem, ICustomBlockState { public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorProvidingBlock, IColorProvidingItem, ICustomBlockState {
public static final int HIGHEST_STAGE = 3; public static final int HIGHEST_STAGE = 3;
public static final IntegerProperty STAGE = IntegerProperty.create("stage", 0, HIGHEST_STAGE); public static final IntegerProperty STAGE = IntegerProperty.create("stage", 0, BlockGoldenLeaves.HIGHEST_STAGE);
public BlockGoldenLeaves() { public BlockGoldenLeaves() {
super(Properties.of(Material.LEAVES, MaterialColor.GOLD).strength(0.2F).randomTicks().noOcclusion().sound(SoundType.GRASS)); super(Properties.of(Material.LEAVES, MaterialColor.GOLD).strength(0.2F).randomTicks().noOcclusion().sound(SoundType.GRASS));
ModRegistry.add(this); ModRegistry.ALL_ITEMS.add(this);
} }
public static boolean convert(Level level, BlockPos pos) { public static boolean convert(Level level, BlockPos pos) {
@ -39,8 +38,8 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr
if (state.getBlock() instanceof LeavesBlock && !(state.getBlock() instanceof BlockAncientLeaves || state.getBlock() instanceof BlockGoldenLeaves)) { if (state.getBlock() instanceof LeavesBlock && !(state.getBlock() instanceof BlockAncientLeaves || state.getBlock() instanceof BlockGoldenLeaves)) {
if (!level.isClientSide) { if (!level.isClientSide) {
level.setBlockAndUpdate(pos, ModBlocks.GOLDEN_LEAVES.defaultBlockState() level.setBlockAndUpdate(pos, ModBlocks.GOLDEN_LEAVES.defaultBlockState()
.setValue(DISTANCE, state.hasProperty(DISTANCE) ? state.getValue(DISTANCE) : 1) .setValue(LeavesBlock.DISTANCE, state.hasProperty(LeavesBlock.DISTANCE) ? state.getValue(LeavesBlock.DISTANCE) : 1)
.setValue(PERSISTENT, state.hasProperty(PERSISTENT) ? state.getValue(PERSISTENT) : false)); .setValue(LeavesBlock.PERSISTENT, state.hasProperty(LeavesBlock.PERSISTENT) ? state.getValue(LeavesBlock.PERSISTENT) : false));
} }
return true; return true;
} }
@ -54,8 +53,8 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, RandomSource rand) {
if (stateIn.getValue(STAGE) == HIGHEST_STAGE && rand.nextFloat() >= 0.75F) if (stateIn.getValue(BlockGoldenLeaves.STAGE) == BlockGoldenLeaves.HIGHEST_STAGE && rand.nextFloat() >= 0.75F)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
pos.getX() + rand.nextFloat(), pos.getX() + rand.nextFloat(),
pos.getY() + rand.nextFloat(), pos.getY() + rand.nextFloat(),
@ -67,7 +66,7 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
super.createBlockStateDefinition(builder); super.createBlockStateDefinition(builder);
builder.add(STAGE); builder.add(BlockGoldenLeaves.STAGE);
} }
@Override @Override
@ -77,7 +76,7 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr
var color = 0xF2FF00; var color = 0xF2FF00;
if (state != null && levelIn != null && pos != null) { if (state != null && levelIn != null && pos != null) {
var foliage = BiomeColors.getAverageFoliageColor(levelIn, pos); var foliage = BiomeColors.getAverageFoliageColor(levelIn, pos);
return Helper.blendColors(color, foliage, state.getValue(STAGE) / (float) HIGHEST_STAGE); return Helper.blendColors(color, foliage, state.getValue(BlockGoldenLeaves.STAGE) / (float) BlockGoldenLeaves.HIGHEST_STAGE);
} else { } else {
return color; return color;
} }
@ -91,18 +90,18 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr
} }
@Override @Override
public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) { public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, RandomSource random) {
super.randomTick(state, levelIn, pos, random); super.randomTick(state, levelIn, pos, random);
if (!levelIn.isClientSide) { if (!levelIn.isClientSide) {
int stage = state.getValue(STAGE); int stage = state.getValue(BlockGoldenLeaves.STAGE);
if (stage < HIGHEST_STAGE) { if (stage < BlockGoldenLeaves.HIGHEST_STAGE) {
levelIn.setBlockAndUpdate(pos, state.setValue(STAGE, stage + 1)); levelIn.setBlockAndUpdate(pos, state.setValue(BlockGoldenLeaves.STAGE, stage + 1));
} }
if (stage > 1) { if (stage > 1) {
var offset = pos.relative(Direction.getRandom(random)); var offset = pos.relative(Direction.getRandom(random));
if (levelIn.isLoaded(offset)) if (levelIn.isLoaded(offset))
convert(levelIn, offset); BlockGoldenLeaves.convert(levelIn, offset);
} }
} }
} }

View file

@ -35,20 +35,20 @@ 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 INPUT_SHAPE = 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 = 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(MIDDLE_SHAPE, 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(INPUT_MIDDLE_SHAPE, Hopper.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(COMBINED_SHAPE, 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(COMBINED_SHAPE, 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(COMBINED_SHAPE, 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(COMBINED_SHAPE, 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(COMBINED_SHAPE, 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 = Hopper.INSIDE; private static final VoxelShape DOWN_RAYTRACE_SHAPE = Hopper.INSIDE;
private static final VoxelShape EAST_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, 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(Hopper.INSIDE, 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(Hopper.INSIDE, 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(Hopper.INSIDE, 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(Material.METAL).strength(3.0F, 8.0F).sound(SoundType.METAL)); super("grated_chute", BlockEntityGratedChute.class, Properties.of(Material.METAL).strength(3.0F, 8.0F).sound(SoundType.METAL));
@ -61,24 +61,24 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
return switch (state.getValue(FACING)) { return switch (state.getValue(BlockGratedChute.FACING)) {
case DOWN -> DOWN_SHAPE; case DOWN -> BlockGratedChute.DOWN_SHAPE;
case NORTH -> NORTH_SHAPE; case NORTH -> BlockGratedChute.NORTH_SHAPE;
case SOUTH -> SOUTH_SHAPE; case SOUTH -> BlockGratedChute.SOUTH_SHAPE;
case WEST -> WEST_SHAPE; case WEST -> BlockGratedChute.WEST_SHAPE;
case EAST -> EAST_SHAPE; case EAST -> BlockGratedChute.EAST_SHAPE;
default -> COMBINED_SHAPE; default -> BlockGratedChute.COMBINED_SHAPE;
}; };
} }
@Override @Override
public VoxelShape getInteractionShape(BlockState state, BlockGetter levelIn, BlockPos pos) { public VoxelShape getInteractionShape(BlockState state, BlockGetter levelIn, BlockPos pos) {
return switch (state.getValue(FACING)) { return switch (state.getValue(BlockGratedChute.FACING)) {
case DOWN -> DOWN_RAYTRACE_SHAPE; case DOWN -> BlockGratedChute.DOWN_RAYTRACE_SHAPE;
case NORTH -> NORTH_RAYTRACE_SHAPE; case NORTH -> BlockGratedChute.NORTH_RAYTRACE_SHAPE;
case SOUTH -> SOUTH_RAYTRACE_SHAPE; case SOUTH -> BlockGratedChute.SOUTH_RAYTRACE_SHAPE;
case WEST -> WEST_RAYTRACE_SHAPE; case WEST -> BlockGratedChute.WEST_RAYTRACE_SHAPE;
case EAST -> EAST_RAYTRACE_SHAPE; case EAST -> BlockGratedChute.EAST_RAYTRACE_SHAPE;
default -> Hopper.INSIDE; default -> Hopper.INSIDE;
}; };
} }
@ -103,7 +103,7 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock
var newFacing = context.getClickedFace().getOpposite(); var newFacing = context.getClickedFace().getOpposite();
if (newFacing == Direction.UP) if (newFacing == Direction.UP)
newFacing = Direction.DOWN; newFacing = Direction.DOWN;
return super.getStateForPlacement(context).setValue(FACING, newFacing); return super.getStateForPlacement(context).setValue(BlockGratedChute.FACING, newFacing);
} }
@Override @Override
@ -132,7 +132,7 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
super.createBlockStateDefinition(builder); super.createBlockStateDefinition(builder);
builder.add(FACING); builder.add(BlockGratedChute.FACING);
} }
@Override @Override

View file

@ -11,7 +11,7 @@ public class BlockImpl extends Block implements IModItem {
public BlockImpl(String baseName, Block.Properties properties) { public BlockImpl(String baseName, Block.Properties properties) {
super(properties); super(properties);
this.baseName = baseName; this.baseName = baseName;
ModRegistry.add(this); ModRegistry.ALL_ITEMS.add(this);
} }
@Override @Override

View file

@ -7,9 +7,11 @@ import de.ellpeck.naturesaura.reg.ICustomRenderType;
import de.ellpeck.naturesaura.reg.INoItemBlock; import de.ellpeck.naturesaura.reg.INoItemBlock;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.item.context.BlockPlaceContext;
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.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.CollisionContext;
@ -22,7 +24,7 @@ import java.util.function.Supplier;
public class BlockLight extends BlockImpl implements ICustomBlockState, INoItemBlock, ICustomRenderType { public class BlockLight extends BlockImpl implements ICustomBlockState, INoItemBlock, ICustomRenderType {
private static final VoxelShape SHAPE = box(4, 4, 4, 12, 12, 12); private static final VoxelShape SHAPE = Block.box(4, 4, 4, 12, 12, 12);
public BlockLight() { public BlockLight() {
super("light", Properties.of(Material.WOOL).noCollission().lightLevel(s -> 15)); super("light", Properties.of(Material.WOOL).noCollission().lightLevel(s -> 15));
@ -30,7 +32,7 @@ public class BlockLight extends BlockImpl implements ICustomBlockState, INoItemB
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, RandomSource rand) {
for (var i = 0; i < 2; i++) for (var i = 0; i < 2; i++)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F,
@ -40,7 +42,7 @@ public class BlockLight extends BlockImpl implements ICustomBlockState, INoItemB
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
return SHAPE; return BlockLight.SHAPE;
} }
@Override @Override

View file

@ -36,7 +36,7 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide
public BlockNatureAltar() { public BlockNatureAltar() {
super("nature_altar", BlockEntityNatureAltar.class, Block.Properties.of(Material.STONE).strength(4F)); super("nature_altar", BlockEntityNatureAltar.class, Block.Properties.of(Material.STONE).strength(4F));
this.registerDefaultState(this.defaultBlockState().setValue(NETHER, false)); this.registerDefaultState(this.defaultBlockState().setValue(BlockNatureAltar.NETHER, false));
} }
@Override @Override
@ -46,7 +46,7 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
return SHAPE; return BlockNatureAltar.SHAPE;
} }
@Override @Override
@ -63,14 +63,14 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
super.createBlockStateDefinition(builder); super.createBlockStateDefinition(builder);
builder.add(NETHER); builder.add(BlockNatureAltar.NETHER);
} }
@Nullable @Nullable
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext context) { public BlockState getStateForPlacement(BlockPlaceContext context) {
var nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER); var nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER);
return super.getStateForPlacement(context).setValue(NETHER, nether); return super.getStateForPlacement(context).setValue(BlockNatureAltar.NETHER, nether);
} }
@Override @Override

View file

@ -5,6 +5,7 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; 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.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.Blocks; import net.minecraft.world.level.block.Blocks;
@ -20,7 +21,7 @@ public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, Bo
} }
@Override @Override
public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) { public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, RandomSource random) {
var up = pos.above(); var up = pos.above();
var upState = levelIn.getBlockState(up); var upState = levelIn.getBlockState(up);
if (upState.isFaceSturdy(levelIn, up, Direction.DOWN)) if (upState.isFaceSturdy(levelIn, up, Direction.DOWN))
@ -41,12 +42,12 @@ public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, Bo
} }
@Override @Override
public boolean isBonemealSuccess(Level levelIn, Random rand, BlockPos pos, BlockState state) { public boolean isBonemealSuccess(Level levelIn, RandomSource rand, BlockPos pos, BlockState state) {
return true; return true;
} }
@Override @Override
public void performBonemeal(ServerLevel level, Random rand, BlockPos pos, BlockState state) { public void performBonemeal(ServerLevel level, RandomSource rand, BlockPos pos, BlockState state) {
var blockpos = pos.above(); var blockpos = pos.above();
var blockstate = Blocks.GRASS.defaultBlockState(); var blockstate = Blocks.GRASS.defaultBlockState();

View file

@ -42,7 +42,7 @@ public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvi
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
return SHAPE; return BlockOfferingTable.SHAPE;
} }
@Override @Override

View file

@ -27,7 +27,7 @@ public class BlockPowderPlacer extends BlockContainerImpl implements ICustomBloc
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
return SHAPE; return BlockPowderPlacer.SHAPE;
} }
@Override @Override

View file

@ -84,7 +84,7 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
return SHAPE; return BlockSpawnLamp.SHAPE;
} }
@Override @Override

View file

@ -19,7 +19,7 @@ public class BlockStairsNA extends StairBlock implements IModItem, ICustomBlockS
super(modelState, properties.dynamicShape()); super(modelState, properties.dynamicShape());
this.baseName = baseName; this.baseName = baseName;
this.textureName = textureName; this.textureName = textureName;
ModRegistry.add(this); ModRegistry.ALL_ITEMS.add(this);
} }
@Override @Override

View file

@ -49,7 +49,7 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
return SHAPE; return BlockWoodStand.SHAPE;
} }
@SubscribeEvent @SubscribeEvent

View file

@ -16,7 +16,7 @@ public class Slab extends SlabBlock implements IModItem, ICustomBlockState {
super(properties); super(properties);
this.baseName = baseName; this.baseName = baseName;
this.textureName = textureName; this.textureName = textureName;
ModRegistry.add(this); ModRegistry.ALL_ITEMS.add(this);
} }
@Override @Override

View file

@ -24,7 +24,7 @@ public final class Multiblocks {
{" ", " WBW ", " WBW ", " WWCWCWW ", " BBW WBB ", " WWCWCWW ", " WBW ", " WBW ", " "}}; {" ", " WBW ", " WBW ", " WWCWCWW ", " BBW WBB ", " WWCWCWW ", " WBW ", " WBW ", " "}};
public static final IMultiblock ALTAR = NaturesAuraAPI.instance().createMultiblock( public static final IMultiblock ALTAR = NaturesAuraAPI.instance().createMultiblock(
new ResourceLocation(NaturesAura.MOD_ID, "altar"), new ResourceLocation(NaturesAura.MOD_ID, "altar"),
ALTAR_PATTERN, Multiblocks.ALTAR_PATTERN,
'C', Blocks.CHISELED_STONE_BRICKS, 'C', Blocks.CHISELED_STONE_BRICKS,
'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),
@ -33,7 +33,7 @@ public final class Multiblocks {
' ', Matcher.wildcard()); ' ', Matcher.wildcard());
public static final IMultiblock NETHER_ALTAR = NaturesAuraAPI.instance().createMultiblock( public static final IMultiblock NETHER_ALTAR = NaturesAuraAPI.instance().createMultiblock(
new ResourceLocation(NaturesAura.MOD_ID, "nether_altar"), new ResourceLocation(NaturesAura.MOD_ID, "nether_altar"),
ALTAR_PATTERN, Multiblocks.ALTAR_PATTERN,
'C', Blocks.RED_NETHER_BRICKS, 'C', Blocks.RED_NETHER_BRICKS,
'B', Matcher.tag(Blocks.NETHER_BRICKS, BlockTagProvider.NETHER_ALTAR_STONE), 'B', Matcher.tag(Blocks.NETHER_BRICKS, BlockTagProvider.NETHER_ALTAR_STONE),
'W', Matcher.tag(Blocks.CRIMSON_PLANKS, BlockTagProvider.NETHER_ALTAR_WOOD), 'W', Matcher.tag(Blocks.CRIMSON_PLANKS, BlockTagProvider.NETHER_ALTAR_WOOD),

View file

@ -84,7 +84,7 @@ public class BlockEntityAuraTimer extends BlockEntityImpl implements ITickableBl
var stack = this.itemHandler.getStackInSlot(0); var stack = this.itemHandler.getStackInSlot(0);
if (stack.isEmpty()) if (stack.isEmpty())
return 0; return 0;
var amount = TIMES.get(ItemAuraBottle.getType(stack)); var amount = BlockEntityAuraTimer.TIMES.get(ItemAuraBottle.getType(stack));
if (amount == null) if (amount == null)
return 0; return 0;
return amount * stack.getCount(); return amount * stack.getCount();

View file

@ -10,6 +10,7 @@ import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.CraftingContainer; import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.crafting.RecipeType;
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;
@ -17,6 +18,11 @@ import net.minecraft.world.phys.AABB;
public class BlockEntityAutoCrafter extends BlockEntityImpl implements ITickableBlockEntity { public class BlockEntityAutoCrafter extends BlockEntityImpl implements ITickableBlockEntity {
public final CraftingContainer crafting = new CraftingContainer(new AbstractContainerMenu(null, 0) { public final CraftingContainer crafting = new CraftingContainer(new AbstractContainerMenu(null, 0) {
@Override
public ItemStack quickMoveStack(Player p_38941_, int p_38942_) {
return ItemStack.EMPTY;
}
@Override @Override
public boolean stillValid(Player playerIn) { public boolean stillValid(Player playerIn) {
return false; return false;

View file

@ -51,8 +51,8 @@ public class BlockEntityChunkLoader extends BlockEntityImpl implements ITickable
if (!unload) { if (!unload) {
var range = this.range(); var range = this.range();
if (range > 0) { if (range > 0) {
for (var x = (this.worldPosition.getX() - range) >> 4; x <= (this.worldPosition.getX() + range) >> 4; x++) { for (var x = this.worldPosition.getX() - range >> 4; x <= this.worldPosition.getX() + range >> 4; x++) {
for (var z = (this.worldPosition.getZ() - range) >> 4; z <= (this.worldPosition.getZ() + range) >> 4; z++) { for (var z = this.worldPosition.getZ() - range >> 4; z <= this.worldPosition.getZ() + range >> 4; z++) {
var pos = new ChunkPos(x, z); var pos = new ChunkPos(x, z);
// Only force chunks that we're already forcing or that nobody else is forcing // Only force chunks that we're already forcing or that nobody else is forcing
if (this.forcedChunks.contains(pos) || !level.getForcedChunks().contains(pos.toLong())) if (this.forcedChunks.contains(pos) || !level.getForcedChunks().contains(pos.toLong()))

View file

@ -10,7 +10,6 @@ import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
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.network.chat.TranslatableComponent;
import net.minecraft.world.MenuProvider; import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
@ -140,7 +139,7 @@ public class BlockEntityEnderCrate extends BlockEntityImpl implements MenuProvid
@Override @Override
public Component getDisplayName() { public Component getDisplayName() {
return new TranslatableComponent("info." + NaturesAura.MOD_ID + ".ender_crate", ChatFormatting.ITALIC + this.name + ChatFormatting.RESET); return Component.translatable("info." + NaturesAura.MOD_ID + ".ender_crate", ChatFormatting.ITALIC + this.name + ChatFormatting.RESET);
} }
@Nullable @Nullable

View file

@ -106,7 +106,7 @@ public class BlockEntityFlowerGenerator extends BlockEntityImpl implements ITick
var block = state.getBlock(); var block = state.getBlock();
var tag = new CompoundTag(); var tag = new CompoundTag();
tag.putString("block", block.getRegistryName().toString()); tag.putString("block", ForgeRegistries.BLOCKS.getKey(block).toString());
tag.putInt("amount", entry.getValue().intValue()); tag.putInt("amount", entry.getValue().intValue());
list.add(tag); list.add(tag);
} }

View file

@ -33,7 +33,7 @@ public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickab
public static ContainerData getFurnaceData(AbstractFurnaceBlockEntity tile) { public static ContainerData getFurnaceData(AbstractFurnaceBlockEntity tile) {
try { try {
return (ContainerData) FURNACE_DATA_FIELD.get(tile); return (ContainerData) BlockEntityFurnaceHeater.FURNACE_DATA_FIELD.get(tile);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
NaturesAura.LOGGER.fatal("Couldn't reflect furnace field", e); NaturesAura.LOGGER.fatal("Couldn't reflect furnace field", e);
return null; return null;
@ -59,7 +59,7 @@ public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickab
var tilePos = this.worldPosition.relative(facing.getOpposite()); var tilePos = this.worldPosition.relative(facing.getOpposite());
var tile = this.level.getBlockEntity(tilePos); var tile = this.level.getBlockEntity(tilePos);
if (tile instanceof AbstractFurnaceBlockEntity furnace && this.isReady(furnace)) { if (tile instanceof AbstractFurnaceBlockEntity furnace && this.isReady(furnace)) {
var data = getFurnaceData(furnace); var data = BlockEntityFurnaceHeater.getFurnaceData(furnace);
var burnTime = data.get(0); var burnTime = data.get(0);
if (burnTime <= 0) if (burnTime <= 0)
this.level.setBlockAndUpdate(tilePos, this.level.getBlockState(tilePos).setValue(AbstractFurnaceBlock.LIT, true)); this.level.setBlockAndUpdate(tilePos, this.level.getBlockState(tilePos).setValue(AbstractFurnaceBlock.LIT, true));
@ -99,7 +99,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(getRecipeType(furnace), furnace, 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.getResultItem(); var output = recipe.getResultItem();

View file

@ -34,7 +34,7 @@ public class BlockEntityHopperUpgrade extends BlockEntityImpl implements ITickab
if (IAuraChunk.getAuraInArea(this.level, this.worldPosition, 25) < 100000) if (IAuraChunk.getAuraInArea(this.level, this.worldPosition, 25) < 100000)
return; return;
var tile = this.level.getBlockEntity(this.worldPosition.below()); var tile = this.level.getBlockEntity(this.worldPosition.below());
if (!isValidHopper(tile)) if (!BlockEntityHopperUpgrade.isValidHopper(tile))
return; return;
var handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).orElse(null); var handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).orElse(null);
if (handler == null) if (handler == null)

View file

@ -44,7 +44,7 @@ public class BlockEntitySlimeSplitGenerator extends BlockEntityImpl implements I
public void startGenerating(Slime slime) { public void startGenerating(Slime slime) {
var size = slime.getSize(); var size = slime.getSize();
this.generationTimer = size * 30; this.generationTimer = size * 30;
this.amountToRelease = (size * this.getGenerationAmount(slime)) / this.generationTimer; this.amountToRelease = size * this.getGenerationAmount(slime) / this.generationTimer;
this.color = this.getSlimeColor(slime); this.color = this.getSlimeColor(slime);
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles((float) slime.getX(), (float) slime.getY(), (float) slime.getZ(), PacketParticles.Type.SLIME_SPLIT_GEN_START, PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles((float) slime.getX(), (float) slime.getY(), (float) slime.getZ(), PacketParticles.Type.SLIME_SPLIT_GEN_START,

View file

@ -68,7 +68,7 @@ public class BlockEntityTimeChanger extends BlockEntityImpl implements ITickable
if (stack.isEmpty() || stack.getItem() != Items.CLOCK) if (stack.isEmpty() || stack.getItem() != Items.CLOCK)
continue; continue;
var dayGoal = Mth.floor((frame.getRotation() / 8F) * 24000F) + 18000; var dayGoal = Mth.floor(frame.getRotation() / 8F * 24000F) + 18000;
var current = this.level.getDayTime(); var current = this.level.getDayTime();
var toMove = (24000 - current % 24000 + dayGoal) % 24000; var toMove = (24000 - current % 24000 + dayGoal) % 24000;
this.goalTime = current + toMove; this.goalTime = current + toMove;

View file

@ -80,7 +80,7 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
this.level.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState()); this.level.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState());
return true; return true;
}); });
recurseTreeDestruction(this.level, this.ritualPos, this.ritualPos, true, false); BlockEntityWoodStand.recurseTreeDestruction(this.level, this.ritualPos, this.ritualPos, true, false);
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,
@ -141,7 +141,7 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
level.setBlockAndUpdate(offset, Blocks.AIR.defaultBlockState()); level.setBlockAndUpdate(offset, Blocks.AIR.defaultBlockState());
PacketHandler.sendToAllAround(level, pos, 32, new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), PacketParticles.Type.TR_DISAPPEAR)); PacketHandler.sendToAllAround(level, pos, 32, new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), PacketParticles.Type.TR_DISAPPEAR));
} }
recurseTreeDestruction(level, offset, start, includeLeaves, drop); BlockEntityWoodStand.recurseTreeDestruction(level, offset, start, includeLeaves, drop);
} }
} }
} }
@ -154,7 +154,7 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
} }
for (var i = 0; i < 2; i++) { for (var i = 0; i < 2; i++) {
var state = this.level.getBlockState(this.ritualPos.above(i)); var state = this.level.getBlockState(this.ritualPos.above(i));
if (!(state.is(BlockTags.LOGS))) if (!state.is(BlockTags.LOGS))
return false; return false;
} }
if (this.timer < this.recipe.time / 2) { if (this.timer < this.recipe.time / 2) {

View file

@ -43,7 +43,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(RES)), combinedLightIn, combinedOverlayIn, 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();
} }

View file

@ -47,7 +47,7 @@ public class RenderGeneratorLimitRemover implements BlockEntityRenderer<BlockEnt
stack.translate(-0.001F, yOff + 1 + 0.001F, 1 + 0.001F); stack.translate(-0.001F, yOff + 1 + 0.001F, 1 + 0.001F);
stack.mulPose(Vector3f.XP.rotationDegrees(180F)); stack.mulPose(Vector3f.XP.rotationDegrees(180F));
stack.scale(1.002F, 1.002F, 1.002F); stack.scale(1.002F, 1.002F, 1.002F);
this.model.renderToBuffer(stack, buffer.getBuffer(this.model.renderType(RES)), brightness, combinedOverlayIn, 1, 1, 1, alpha); this.model.renderToBuffer(stack, buffer.getBuffer(this.model.renderType(RenderGeneratorLimitRemover.RES)), brightness, combinedOverlayIn, 1, 1, 1, alpha);
stack.popPose(); stack.popPose();
} }

View file

@ -46,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(RES)), brightness, combinedOverlayIn, 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();
} }

View file

@ -76,6 +76,6 @@ public class AngerEffect implements IDrainSpotEffect {
@Override @Override
public ResourceLocation getName() { public ResourceLocation getName() {
return NAME; return AngerEffect.NAME;
} }
} }

View file

@ -55,7 +55,7 @@ public class AnimalEffect implements IDrainSpotEffect {
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (!this.bb.contains(player.getEyePosition())) if (!this.bb.contains(player.getEyePosition()))
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (!NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), NAME)) if (!NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), AnimalEffect.NAME))
return ActiveType.INHIBITED; return ActiveType.INHIBITED;
return ActiveType.ACTIVE; return ActiveType.ACTIVE;
} }
@ -80,7 +80,7 @@ public class AnimalEffect implements IDrainSpotEffect {
for (var item : items) { for (var item : items) {
if (!item.isAlive()) if (!item.isAlive())
continue; continue;
if (!NaturesAuraAPI.instance().isEffectPowderActive(level, item.blockPosition(), NAME)) if (!NaturesAuraAPI.instance().isEffectPowderActive(level, item.blockPosition(), AnimalEffect.NAME))
continue; continue;
var stack = item.getItem(); var stack = item.getItem();
@ -111,7 +111,7 @@ public class AnimalEffect implements IDrainSpotEffect {
var first = animals.get(level.random.nextInt(animals.size())); var first = animals.get(level.random.nextInt(animals.size()));
if (first.isBaby() || first.isInLove()) if (first.isBaby() || first.isInLove())
return; return;
if (!NaturesAuraAPI.instance().isEffectPowderActive(level, first.blockPosition(), NAME)) if (!NaturesAuraAPI.instance().isEffectPowderActive(level, first.blockPosition(), AnimalEffect.NAME))
return; return;
var secondOptional = animals.stream() var secondOptional = animals.stream()
@ -150,6 +150,6 @@ public class AnimalEffect implements IDrainSpotEffect {
@Override @Override
public ResourceLocation getName() { public ResourceLocation getName() {
return NAME; return AnimalEffect.NAME;
} }
} }

View file

@ -41,6 +41,6 @@ public class BalanceEffect implements IDrainSpotEffect {
@Override @Override
public ResourceLocation getName() { public ResourceLocation getName() {
return NAME; return BalanceEffect.NAME;
} }
} }

View file

@ -73,6 +73,6 @@ public class BreathlessEffect implements IDrainSpotEffect {
@Override @Override
public ResourceLocation getName() { public ResourceLocation getName() {
return NAME; return BreathlessEffect.NAME;
} }
} }

View file

@ -45,7 +45,7 @@ public class CacheRechargeEffect implements IDrainSpotEffect {
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (!this.bb.contains(player.getEyePosition())) if (!this.bb.contains(player.getEyePosition()))
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), NAME)) if (NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), CacheRechargeEffect.NAME))
return ActiveType.INHIBITED; return ActiveType.INHIBITED;
return ActiveType.ACTIVE; return ActiveType.ACTIVE;
} }
@ -61,7 +61,7 @@ public class CacheRechargeEffect implements IDrainSpotEffect {
return; return;
var players = level.getEntitiesOfClass(Player.class, this.bb); var players = level.getEntitiesOfClass(Player.class, this.bb);
for (var player : players) { for (var player : players) {
if (NaturesAuraAPI.instance().isEffectPowderActive(level, player.blockPosition(), NAME)) if (NaturesAuraAPI.instance().isEffectPowderActive(level, player.blockPosition(), CacheRechargeEffect.NAME))
continue; continue;
if (NaturesAuraAPI.instance().insertAuraIntoPlayer(player, this.amount, true)) { if (NaturesAuraAPI.instance().insertAuraIntoPlayer(player, this.amount, true)) {
NaturesAuraAPI.instance().insertAuraIntoPlayer(player, this.amount, false); NaturesAuraAPI.instance().insertAuraIntoPlayer(player, this.amount, false);
@ -77,6 +77,6 @@ public class CacheRechargeEffect implements IDrainSpotEffect {
@Override @Override
public ResourceLocation getName() { public ResourceLocation getName() {
return NAME; return CacheRechargeEffect.NAME;
} }
} }

View file

@ -77,6 +77,6 @@ public class ExplosionEffect implements IDrainSpotEffect {
@Override @Override
public ResourceLocation getName() { public ResourceLocation getName() {
return NAME; return ExplosionEffect.NAME;
} }
} }

View file

@ -91,6 +91,6 @@ public class GrassDieEffect implements IDrainSpotEffect {
@Override @Override
public ResourceLocation getName() { public ResourceLocation getName() {
return NAME; return GrassDieEffect.NAME;
} }
} }

View file

@ -100,6 +100,6 @@ public class NetherDecayEffect implements IDrainSpotEffect {
@Override @Override
public ResourceLocation getName() { public ResourceLocation getName() {
return NAME; return NetherDecayEffect.NAME;
} }
} }

View file

@ -49,7 +49,7 @@ public class NetherGrassEffect implements IDrainSpotEffect {
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (player.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist) if (player.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist)
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), NAME)) if (NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), NetherGrassEffect.NAME))
return ActiveType.INHIBITED; return ActiveType.INHIBITED;
return ActiveType.ACTIVE; return ActiveType.ACTIVE;
} }
@ -73,7 +73,7 @@ public class NetherGrassEffect implements IDrainSpotEffect {
for (var yOff = -5; yOff <= 5; yOff++) { for (var yOff = -5; yOff <= 5; yOff++) {
var goalPos = new BlockPos(x, y + yOff, z); var goalPos = new BlockPos(x, y + yOff, z);
if (goalPos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(goalPos)) { if (goalPos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(goalPos)) {
if (NaturesAuraAPI.instance().isEffectPowderActive(level, goalPos, NAME)) if (NaturesAuraAPI.instance().isEffectPowderActive(level, goalPos, NetherGrassEffect.NAME))
continue; continue;
var up = goalPos.above(); var up = goalPos.above();
if (level.getBlockState(up).isFaceSturdy(level, up, Direction.DOWN)) if (level.getBlockState(up).isFaceSturdy(level, up, Direction.DOWN))
@ -102,6 +102,6 @@ public class NetherGrassEffect implements IDrainSpotEffect {
@Override @Override
public ResourceLocation getName() { public ResourceLocation getName() {
return NAME; return NetherGrassEffect.NAME;
} }
} }

View file

@ -12,10 +12,8 @@ import net.minecraft.core.Direction;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.Tag;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.util.Tuple;
import net.minecraft.util.random.WeightedRandom; import net.minecraft.util.random.WeightedRandom;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
@ -30,9 +28,7 @@ import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.common.util.FakePlayerFactory;
import org.apache.commons.lang3.tuple.Pair;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -66,7 +62,7 @@ public class OreSpawnEffect implements IDrainSpotEffect {
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (player.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist) if (player.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist)
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (!NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), NAME)) if (!NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), OreSpawnEffect.NAME))
return ActiveType.INHIBITED; return ActiveType.INHIBITED;
return ActiveType.ACTIVE; return ActiveType.ACTIVE;
} }
@ -95,7 +91,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), 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++) {
@ -130,7 +126,7 @@ public class OreSpawnEffect implements IDrainSpotEffect {
var ray = new BlockHitResult(Vec3.atCenterOf(pos), Direction.UP, pos, false); var ray = new BlockHitResult(Vec3.atCenterOf(pos), Direction.UP, pos, false);
var context = new BlockPlaceContext(new UseOnContext(player, InteractionHand.MAIN_HAND, ray)); var context = new BlockPlaceContext(new UseOnContext(player, InteractionHand.MAIN_HAND, ray));
var stateToPlace = toPlace.getStateForPlacement(context); var stateToPlace = toPlace.getStateForPlacement(context);
if (SPAWN_EXCEPTIONS.contains(stateToPlace)) if (OreSpawnEffect.SPAWN_EXCEPTIONS.contains(stateToPlace))
continue; continue;
level.setBlockAndUpdate(orePos, stateToPlace); level.setBlockAndUpdate(orePos, stateToPlace);
@ -154,6 +150,6 @@ public class OreSpawnEffect implements IDrainSpotEffect {
@Override @Override
public ResourceLocation getName() { public ResourceLocation getName() {
return NAME; return OreSpawnEffect.NAME;
} }
} }

View file

@ -49,7 +49,7 @@ public class PlantBoostEffect implements IDrainSpotEffect {
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (player.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist) if (player.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist)
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), NAME)) if (NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), PlantBoostEffect.NAME))
return ActiveType.INHIBITED; return ActiveType.INHIBITED;
return ActiveType.ACTIVE; return ActiveType.ACTIVE;
} }
@ -68,7 +68,7 @@ public class PlantBoostEffect implements IDrainSpotEffect {
var z = Mth.floor(pos.getZ() + (2 * level.random.nextFloat() - 1) * this.dist); var z = Mth.floor(pos.getZ() + (2 * level.random.nextFloat() - 1) * this.dist);
var plantPos = new BlockPos(x, level.getHeight(Heightmap.Types.WORLD_SURFACE, x, z), z).below(); var plantPos = new BlockPos(x, level.getHeight(Heightmap.Types.WORLD_SURFACE, x, z), z).below();
if (plantPos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(plantPos)) { if (plantPos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(plantPos)) {
if (NaturesAuraAPI.instance().isEffectPowderActive(level, plantPos, NAME)) if (NaturesAuraAPI.instance().isEffectPowderActive(level, plantPos, PlantBoostEffect.NAME))
continue; continue;
var state = level.getBlockState(plantPos); var state = level.getBlockState(plantPos);
@ -99,6 +99,6 @@ public class PlantBoostEffect implements IDrainSpotEffect {
@Override @Override
public ResourceLocation getName() { public ResourceLocation getName() {
return NAME; return PlantBoostEffect.NAME;
} }
} }

View file

@ -55,6 +55,6 @@ public class ReplenishingEffect implements IDrainSpotEffect {
@Override @Override
public ResourceLocation getName() { public ResourceLocation getName() {
return NAME; return ReplenishingEffect.NAME;
} }
} }

View file

@ -61,6 +61,6 @@ public class SpreadEffect implements IDrainSpotEffect {
@Override @Override
public ResourceLocation getName() { public ResourceLocation getName() {
return NAME; return SpreadEffect.NAME;
} }
} }

View file

@ -6,7 +6,7 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands; import net.minecraft.commands.Commands;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.Component;
public final class CommandAura { public final class CommandAura {
@ -20,7 +20,7 @@ public final class CommandAura {
var spot = IAuraChunk.getLowestSpot(source.getLevel(), pos, 35, pos); var spot = IAuraChunk.getLowestSpot(source.getLevel(), pos, 35, pos);
amount -= IAuraChunk.getAuraChunk(source.getLevel(), spot).storeAura(spot, amount); amount -= IAuraChunk.getAuraChunk(source.getLevel(), spot).storeAura(spot, amount);
} }
source.sendSuccess(new TextComponent("Added aura to area"), true); source.sendSuccess(Component.literal("Added aura to area"), true);
return 0; return 0;
}))) })))
.then(Commands.literal("remove").then(Commands.argument("amount", IntegerArgumentType.integer(1)).executes(context -> { .then(Commands.literal("remove").then(Commands.argument("amount", IntegerArgumentType.integer(1)).executes(context -> {
@ -31,7 +31,7 @@ public final class CommandAura {
var spot = IAuraChunk.getHighestSpot(source.getLevel(), pos, 35, pos); var spot = IAuraChunk.getHighestSpot(source.getLevel(), pos, 35, pos);
amount -= IAuraChunk.getAuraChunk(source.getLevel(), spot).drainAura(spot, amount); amount -= IAuraChunk.getAuraChunk(source.getLevel(), spot).drainAura(spot, amount);
} }
source.sendSuccess(new TextComponent("Removed aura from area"), true); source.sendSuccess(Component.literal("Removed aura from area"), true);
return 0; return 0;
}))) })))
.then(Commands.literal("reset").executes(context -> { .then(Commands.literal("reset").executes(context -> {
@ -44,7 +44,7 @@ public final class CommandAura {
else else
chunk.storeAura(spot, -amount); chunk.storeAura(spot, -amount);
}); });
source.sendSuccess(new TextComponent("Reset aura in area"), true); source.sendSuccess(Component.literal("Reset aura in area"), true);
return 0; return 0;
}))); })));
} }

View file

@ -22,29 +22,29 @@ public final class Compat {
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) {
populateModules(ModList.get()::isLoaded); Compat.populateModules(ModList.get()::isLoaded);
MODULES.values().forEach(c -> c.setup(event)); Compat.MODULES.values().forEach(c -> c.setup(event));
} }
public static void setupClient() { public static void setupClient() {
MODULES.values().forEach(ICompat::setupClient); Compat.MODULES.values().forEach(ICompat::setupClient);
} }
public static boolean hasCompat(String mod) { public static boolean hasCompat(String mod) {
return MODULES.containsKey(mod); return Compat.MODULES.containsKey(mod);
} }
public static void addItemTags(ItemTagProvider provider) { public static void addItemTags(ItemTagProvider provider) {
// since other mods don't get loaded in runData, just populate all modules // since other mods don't get loaded in runData, just populate all modules
populateModules(s -> true); Compat.populateModules(s -> true);
MODULES.values().forEach(m -> m.addItemTags(provider)); Compat.MODULES.values().forEach(m -> m.addItemTags(provider));
} }
private static void populateModules(Predicate<String> isLoaded) { private static void populateModules(Predicate<String> isLoaded) {
for (var entry : MODULE_TYPES.entrySet()) { for (var entry : Compat.MODULE_TYPES.entrySet()) {
var id = entry.getKey(); var id = entry.getKey();
if (isLoaded.test(id)) { if (isLoaded.test(id)) {
MODULES.put(id, entry.getValue().get()); Compat.MODULES.put(id, entry.getValue().get());
NaturesAura.LOGGER.info("Loading compat module for mod " + id); NaturesAura.LOGGER.info("Loading compat module for mod " + id);
} }
} }

View file

@ -50,12 +50,12 @@ public class CuriosCompat implements ICompat {
} }
private void sendImc(InterModEnqueueEvent event) { private void sendImc(InterModEnqueueEvent event) {
TYPES.values().stream().distinct().forEach(t -> InterModComms.sendTo("curios", SlotTypeMessage.REGISTER_TYPE, () -> new SlotTypeMessage.Builder(t).build())); CuriosCompat.TYPES.values().stream().distinct().forEach(t -> InterModComms.sendTo("curios", SlotTypeMessage.REGISTER_TYPE, () -> new SlotTypeMessage.Builder(t).build()));
} }
private void onCapabilitiesAttach(AttachCapabilitiesEvent<ItemStack> event) { private void onCapabilitiesAttach(AttachCapabilitiesEvent<ItemStack> event) {
var stack = event.getObject(); var stack = event.getObject();
if (TYPES.containsKey(stack.getItem())) { if (CuriosCompat.TYPES.containsKey(stack.getItem())) {
event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "curios"), new ICapabilityProvider() { event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "curios"), new ICapabilityProvider() {
private final LazyOptional<ICurio> curio = LazyOptional.of(() -> new ICurio() { private final LazyOptional<ICurio> curio = LazyOptional.of(() -> new ICurio() {
@Override @Override
@ -92,7 +92,7 @@ public class CuriosCompat implements ICompat {
@Override @Override
public void addItemTags(ItemTagProvider provider) { public void addItemTags(ItemTagProvider provider) {
for (var entry : TYPES.entrySet()) { for (var entry : CuriosCompat.TYPES.entrySet()) {
var tag = ItemTags.create(new ResourceLocation("curios", entry.getValue())); var tag = ItemTags.create(new ResourceLocation("curios", entry.getValue()));
provider.tag(tag).add(entry.getKey()); provider.tag(tag).add(entry.getKey());
} }

View file

@ -1,17 +1,16 @@
package de.ellpeck.naturesaura.compat.jei; package de.ellpeck.naturesaura.compat.jei;
import com.google.common.collect.ImmutableList;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.blocks.ModBlocks;
import de.ellpeck.naturesaura.recipes.AltarRecipe; import de.ellpeck.naturesaura.recipes.AltarRecipe;
import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.RecipeType;
import mezz.jei.api.recipe.category.IRecipeCategory; import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
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.Ingredient; import net.minecraft.world.item.crafting.Ingredient;
@ -29,18 +28,13 @@ public class AltarCategory implements IRecipeCategory<AltarRecipe> {
} }
@Override @Override
public ResourceLocation getUid() { public RecipeType<AltarRecipe> getRecipeType() {
return JEINaturesAuraPlugin.ALTAR; return JEINaturesAuraPlugin.ALTAR;
} }
@Override
public Class<? extends AltarRecipe> getRecipeClass() {
return AltarRecipe.class;
}
@Override @Override
public Component getTitle() { public Component getTitle() {
return new TranslatableComponent("container." + JEINaturesAuraPlugin.ALTAR + ".name"); return Component.translatable("container." + JEINaturesAuraPlugin.ALTAR + ".name");
} }
@Override @Override
@ -54,29 +48,10 @@ public class AltarCategory implements IRecipeCategory<AltarRecipe> {
} }
@Override @Override
public void setIngredients(AltarRecipe altarRecipe, IIngredients iIngredients) { public void setRecipe(IRecipeLayoutBuilder builder, AltarRecipe recipe, IFocusGroup focuses) {
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder(); builder.addSlot(RecipeIngredientRole.INPUT, 0, 18).addItemStacks(Arrays.asList(recipe.input.getItems()));
builder.add(altarRecipe.input.getItems()); builder.addSlot(RecipeIngredientRole.OUTPUT, 80, 18).addItemStack(recipe.output);
if (altarRecipe.catalyst != Ingredient.EMPTY) builder.addSlot(RecipeIngredientRole.CATALYST, 26, 18).addItemStacks(recipe.catalyst == Ingredient.EMPTY ? Collections.singletonList(this.altar) : Arrays.asList(recipe.catalyst.getItems()));
builder.add(altarRecipe.catalyst.getItems()); builder.addSlot(RecipeIngredientRole.CATALYST, 51, 18).addItemStack(recipe.requiredType != null ? recipe.getDimensionBottle() : ItemStack.EMPTY);
if (altarRecipe.requiredType != null)
builder.add(altarRecipe.getDimensionBottle());
iIngredients.setInputs(VanillaTypes.ITEM, builder.build());
iIngredients.setOutput(VanillaTypes.ITEM, altarRecipe.output);
}
@Override
public void setRecipe(IRecipeLayout iRecipeLayout, AltarRecipe recipe, IIngredients iIngredients) {
var group = iRecipeLayout.getItemStacks();
group.init(0, true, 0, 18);
group.set(0, Arrays.asList(recipe.input.getItems()));
group.init(1, false, 80, 18);
group.set(1, recipe.output);
group.init(2, true, 26, 18);
group.set(2, recipe.catalyst == Ingredient.EMPTY ?
Collections.singletonList(this.altar) : Arrays.asList(recipe.catalyst.getItems()));
group.init(3, true, 51, 18);
if (recipe.requiredType != null)
group.set(3, recipe.getDimensionBottle());
} }
} }

View file

@ -1,22 +1,22 @@
package de.ellpeck.naturesaura.compat.jei; package de.ellpeck.naturesaura.compat.jei;
import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.platform.Lighting; import com.mojang.blaze3d.platform.Lighting;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f; import com.mojang.math.Vector3f;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe; import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe;
import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.RecipeType;
import mezz.jei.api.recipe.category.IRecipeCategory; import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
@ -81,18 +81,13 @@ public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecip
} }
@Override @Override
public ResourceLocation getUid() { public RecipeType<AnimalSpawnerRecipe> getRecipeType() {
return JEINaturesAuraPlugin.SPAWNER; return JEINaturesAuraPlugin.SPAWNER;
} }
@Override
public Class<? extends AnimalSpawnerRecipe> getRecipeClass() {
return AnimalSpawnerRecipe.class;
}
@Override @Override
public Component getTitle() { public Component getTitle() {
return new TranslatableComponent("container." + JEINaturesAuraPlugin.SPAWNER + ".name"); return Component.translatable("container." + JEINaturesAuraPlugin.SPAWNER + ".name");
} }
@Override @Override
@ -106,25 +101,14 @@ public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecip
} }
@Override @Override
public void setIngredients(AnimalSpawnerRecipe animalSpawnerRecipe, IIngredients iIngredients) { public void setRecipe(IRecipeLayoutBuilder builder, AnimalSpawnerRecipe recipe, IFocusGroup focuses) {
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder(); for (var i = 0; i < recipe.ingredients.length; i++)
for (var ing : animalSpawnerRecipe.ingredients) builder.addSlot(RecipeIngredientRole.INPUT, i * 18, 68).addItemStacks(Arrays.asList(recipe.ingredients[i].getItems()));
builder.add(ing.getItems()); builder.addInvisibleIngredients(RecipeIngredientRole.OUTPUT).addItemStack(new ItemStack(ForgeSpawnEggItem.fromEntityType(recipe.entity)));
iIngredients.setInputs(VanillaTypes.ITEM, builder.build());
iIngredients.setOutput(VanillaTypes.ITEM, new ItemStack(ForgeSpawnEggItem.fromEntityType(animalSpawnerRecipe.entity)));
} }
@Override @Override
public void setRecipe(IRecipeLayout iRecipeLayout, AnimalSpawnerRecipe recipe, IIngredients iIngredients) { public void draw(AnimalSpawnerRecipe recipe, IRecipeSlotsView recipeSlotsView, PoseStack matrixStack, double mouseX, double mouseY) {
var group = iRecipeLayout.getItemStacks();
for (var i = 0; i < recipe.ingredients.length; i++) {
group.init(i, true, i * 18, 68);
group.set(i, Arrays.asList(recipe.ingredients[i].getItems()));
}
}
@Override
public void draw(AnimalSpawnerRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) {
var minecraft = Minecraft.getInstance(); var minecraft = Minecraft.getInstance();
var entity = this.entityCache.get(recipe.entity); var entity = this.entityCache.get(recipe.entity);
if (entity == null) { if (entity == null) {
@ -134,7 +118,7 @@ public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecip
matrixStack.pushPose(); matrixStack.pushPose();
var size = Math.max(1F, Math.max(recipe.entity.getWidth(), recipe.entity.getHeight())); var size = Math.max(1F, Math.max(recipe.entity.getWidth(), recipe.entity.getHeight()));
renderEntity(matrixStack, 35, 55, 100F / size * 0.4F, 40, size * 0.5F, (LivingEntity) entity); AnimalSpawnerCategory.renderEntity(matrixStack, 35, 55, 100F / size * 0.4F, 40, size * 0.5F, (LivingEntity) entity);
matrixStack.popPose(); matrixStack.popPose();
var name = recipe.entity.getDescription().getString(); var name = recipe.entity.getDescription().getString();

View file

@ -6,10 +6,12 @@ import de.ellpeck.naturesaura.blocks.ModBlocks;
import de.ellpeck.naturesaura.items.ItemAuraBottle; import de.ellpeck.naturesaura.items.ItemAuraBottle;
import de.ellpeck.naturesaura.items.ItemEffectPowder; import de.ellpeck.naturesaura.items.ItemEffectPowder;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.recipes.ModRecipes; 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.ingredients.subtypes.IIngredientSubtypeInterpreter; import mezz.jei.api.ingredients.subtypes.IIngredientSubtypeInterpreter;
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;
import mezz.jei.api.registration.IRecipeRegistration; import mezz.jei.api.registration.IRecipeRegistration;
@ -21,10 +23,10 @@ import net.minecraft.world.item.ItemStack;
@JeiPlugin @JeiPlugin
public class JEINaturesAuraPlugin implements IModPlugin { public class JEINaturesAuraPlugin implements IModPlugin {
public static final ResourceLocation TREE_RITUAL = new ResourceLocation(NaturesAura.MOD_ID, "tree_ritual"); public static final RecipeType<TreeRitualRecipe> TREE_RITUAL = RecipeType.create(NaturesAura.MOD_ID, "tree_ritual", TreeRitualRecipe.class);
public static final ResourceLocation ALTAR = new ResourceLocation(NaturesAura.MOD_ID, "altar"); public static final RecipeType<AltarRecipe> ALTAR = RecipeType.create(NaturesAura.MOD_ID, "altar", AltarRecipe.class);
public static final ResourceLocation OFFERING = new ResourceLocation(NaturesAura.MOD_ID, "offering"); public static final RecipeType<OfferingRecipe> OFFERING = RecipeType.create(NaturesAura.MOD_ID, "offering", OfferingRecipe.class);
public static final ResourceLocation SPAWNER = new ResourceLocation(NaturesAura.MOD_ID, "animal_spawner"); public static final RecipeType<AnimalSpawnerRecipe> SPAWNER = RecipeType.create(NaturesAura.MOD_ID, "animal_spawner", AnimalSpawnerRecipe.class);
@Override @Override
public ResourceLocation getPluginUid() { public ResourceLocation getPluginUid() {
@ -44,8 +46,8 @@ public class JEINaturesAuraPlugin implements IModPlugin {
@Override @Override
public void registerItemSubtypes(ISubtypeRegistration registration) { public void registerItemSubtypes(ISubtypeRegistration registration) {
registration.registerSubtypeInterpreter(ModItems.EFFECT_POWDER, (stack, context) -> ItemEffectPowder.getEffect(stack).toString()); registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.EFFECT_POWDER, (stack, context) -> ItemEffectPowder.getEffect(stack).toString());
registration.registerSubtypeInterpreter(ModItems.AURA_BOTTLE, (stack, context) -> ItemAuraBottle.getType(stack).getName().toString()); registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.AURA_BOTTLE, (stack, context) -> ItemAuraBottle.getType(stack).getName().toString());
var auraInterpreter = (IIngredientSubtypeInterpreter<ItemStack>) (stack, context) -> { var auraInterpreter = (IIngredientSubtypeInterpreter<ItemStack>) (stack, context) -> {
var container = stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).orElse(null); var container = stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).orElse(null);
@ -53,25 +55,25 @@ public class JEINaturesAuraPlugin implements IModPlugin {
return String.valueOf(container.getStoredAura()); return String.valueOf(container.getStoredAura());
return IIngredientSubtypeInterpreter.NONE; return IIngredientSubtypeInterpreter.NONE;
}; };
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
public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) { public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
registration.addRecipeCatalyst(new ItemStack(ModBlocks.GOLD_POWDER), TREE_RITUAL); registration.addRecipeCatalyst(new ItemStack(ModBlocks.GOLD_POWDER), JEINaturesAuraPlugin.TREE_RITUAL);
registration.addRecipeCatalyst(new ItemStack(ModBlocks.WOOD_STAND), TREE_RITUAL); registration.addRecipeCatalyst(new ItemStack(ModBlocks.WOOD_STAND), JEINaturesAuraPlugin.TREE_RITUAL);
registration.addRecipeCatalyst(new ItemStack(ModBlocks.NATURE_ALTAR), ALTAR); registration.addRecipeCatalyst(new ItemStack(ModBlocks.NATURE_ALTAR), JEINaturesAuraPlugin.ALTAR);
registration.addRecipeCatalyst(new ItemStack(ModBlocks.OFFERING_TABLE), OFFERING); registration.addRecipeCatalyst(new ItemStack(ModBlocks.OFFERING_TABLE), JEINaturesAuraPlugin.OFFERING);
registration.addRecipeCatalyst(new ItemStack(ModBlocks.ANIMAL_SPAWNER), SPAWNER); registration.addRecipeCatalyst(new ItemStack(ModBlocks.ANIMAL_SPAWNER), JEINaturesAuraPlugin.SPAWNER);
} }
@Override @Override
public void registerRecipes(IRecipeRegistration registration) { public void registerRecipes(IRecipeRegistration registration) {
var manager = Minecraft.getInstance().level.getRecipeManager(); var manager = Minecraft.getInstance().level.getRecipeManager();
registration.addRecipes(manager.getAllRecipesFor(ModRecipes.TREE_RITUAL_TYPE), TREE_RITUAL); registration.addRecipes(JEINaturesAuraPlugin.TREE_RITUAL, manager.getAllRecipesFor(ModRecipes.TREE_RITUAL_TYPE));
registration.addRecipes(manager.getAllRecipesFor(ModRecipes.ALTAR_TYPE), ALTAR); registration.addRecipes(JEINaturesAuraPlugin.ALTAR, manager.getAllRecipesFor(ModRecipes.ALTAR_TYPE));
registration.addRecipes(manager.getAllRecipesFor(ModRecipes.OFFERING_TYPE), OFFERING); registration.addRecipes(JEINaturesAuraPlugin.OFFERING, manager.getAllRecipesFor(ModRecipes.OFFERING_TYPE));
registration.addRecipes(manager.getAllRecipesFor(ModRecipes.ANIMAL_SPAWNER_TYPE), SPAWNER); registration.addRecipes(JEINaturesAuraPlugin.SPAWNER, manager.getAllRecipesFor(ModRecipes.ANIMAL_SPAWNER_TYPE));
} }
} }

View file

@ -1,19 +1,16 @@
package de.ellpeck.naturesaura.compat.jei; package de.ellpeck.naturesaura.compat.jei;
import com.google.common.collect.ImmutableList;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.recipes.OfferingRecipe; import de.ellpeck.naturesaura.recipes.OfferingRecipe;
import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.RecipeType;
import mezz.jei.api.recipe.category.IRecipeCategory; import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import java.util.Arrays; import java.util.Arrays;
@ -26,18 +23,13 @@ public class OfferingCategory implements IRecipeCategory<OfferingRecipe> {
} }
@Override @Override
public ResourceLocation getUid() { public RecipeType<OfferingRecipe> getRecipeType() {
return JEINaturesAuraPlugin.OFFERING; return JEINaturesAuraPlugin.OFFERING;
} }
@Override
public Class<? extends OfferingRecipe> getRecipeClass() {
return OfferingRecipe.class;
}
@Override @Override
public Component getTitle() { public Component getTitle() {
return new TranslatableComponent("container." + JEINaturesAuraPlugin.OFFERING + ".name"); return Component.translatable("container." + JEINaturesAuraPlugin.OFFERING + ".name");
} }
@Override @Override
@ -51,21 +43,9 @@ public class OfferingCategory implements IRecipeCategory<OfferingRecipe> {
} }
@Override @Override
public void setIngredients(OfferingRecipe offeringRecipe, IIngredients iIngredients) { public void setRecipe(IRecipeLayoutBuilder builder, OfferingRecipe recipe, IFocusGroup focuses) {
iIngredients.setInputs(VanillaTypes.ITEM, ImmutableList.<ItemStack>builder() builder.addSlot(RecipeIngredientRole.INPUT, 0, 14).addItemStacks(Arrays.asList(recipe.input.getItems()));
.add(offeringRecipe.input.getItems()) builder.addSlot(RecipeIngredientRole.OUTPUT, 65, 14).addItemStack(recipe.output);
.add(offeringRecipe.startItem.getItems()).build()); builder.addSlot(RecipeIngredientRole.INPUT, 27, 0).addItemStacks(Arrays.asList(recipe.startItem.getItems()));
iIngredients.setOutput(VanillaTypes.ITEM, offeringRecipe.output);
}
@Override
public void setRecipe(IRecipeLayout recipeLayout, OfferingRecipe recipe, IIngredients ingredients) {
IGuiItemStackGroup group = recipeLayout.getItemStacks();
group.init(0, true, 0, 14);
group.set(0, Arrays.asList(recipe.input.getItems()));
group.init(1, false, 65, 14);
group.set(1, recipe.output);
group.init(2, true, 27, 0);
group.set(2, Arrays.asList(recipe.startItem.getItems()));
} }
} }

View file

@ -1,18 +1,16 @@
package de.ellpeck.naturesaura.compat.jei; package de.ellpeck.naturesaura.compat.jei;
import com.google.common.collect.ImmutableList;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.recipes.TreeRitualRecipe; import de.ellpeck.naturesaura.recipes.TreeRitualRecipe;
import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.RecipeType;
import mezz.jei.api.recipe.category.IRecipeCategory; import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import java.util.Arrays; import java.util.Arrays;
@ -25,18 +23,13 @@ public class TreeRitualCategory implements IRecipeCategory<TreeRitualRecipe> {
} }
@Override @Override
public ResourceLocation getUid() { public RecipeType<TreeRitualRecipe> getRecipeType() {
return JEINaturesAuraPlugin.TREE_RITUAL; return JEINaturesAuraPlugin.TREE_RITUAL;
} }
@Override
public Class<? extends TreeRitualRecipe> getRecipeClass() {
return TreeRitualRecipe.class;
}
@Override @Override
public Component getTitle() { public Component getTitle() {
return new TranslatableComponent("container." + JEINaturesAuraPlugin.TREE_RITUAL + ".name"); return Component.translatable("container." + JEINaturesAuraPlugin.TREE_RITUAL + ".name");
} }
@Override @Override
@ -50,29 +43,13 @@ public class TreeRitualCategory implements IRecipeCategory<TreeRitualRecipe> {
} }
@Override @Override
public void setIngredients(TreeRitualRecipe treeRitualRecipe, IIngredients iIngredients) { public void setRecipe(IRecipeLayoutBuilder builder, TreeRitualRecipe recipe, IFocusGroup focuses) {
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder(); builder.addSlot(RecipeIngredientRole.CATALYST, 34, 34).addItemStacks(Arrays.asList(recipe.saplingType.getItems()));
for (var ing : treeRitualRecipe.ingredients) builder.addSlot(RecipeIngredientRole.OUTPUT, 124, 34).addItemStack(recipe.result);
builder.add(ing.getItems());
builder.add(treeRitualRecipe.saplingType.getItems());
iIngredients.setInputs(VanillaTypes.ITEM, builder.build());
iIngredients.setOutput(VanillaTypes.ITEM, treeRitualRecipe.result);
}
@Override
public void setRecipe(IRecipeLayout iRecipeLayout, TreeRitualRecipe treeRitualRecipe, IIngredients iIngredients) {
var group = iRecipeLayout.getItemStacks();
group.init(0, true, 34, 34);
group.set(0, Arrays.asList(treeRitualRecipe.saplingType.getItems()));
group.init(1, true, 124, 34);
group.set(1, treeRitualRecipe.result);
var positions = new int[][]{{35, 1}, {35, 69}, {1, 35}, {69, 35}, {12, 12}, {58, 58}, {58, 12}, {12, 58}}; var positions = new int[][]{{35, 1}, {35, 69}, {1, 35}, {69, 35}, {12, 12}, {58, 58}, {58, 12}, {12, 58}};
for (var i = 0; i < treeRitualRecipe.ingredients.length; i++) { for (var i = 0; i < recipe.ingredients.length; i++)
group.init(i + 2, true, positions[i][0] - 1, positions[i][1] - 1); builder.addSlot(RecipeIngredientRole.INPUT, positions[i][0] - 1, positions[i][1] - 1).addItemStacks(Arrays.asList(recipe.ingredients[i].getItems()));
group.set(i + 2, Arrays.asList(treeRitualRecipe.ingredients[i].getItems()));
}
} }
} }

View file

@ -12,8 +12,8 @@ import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style; import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
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;
@ -51,7 +51,7 @@ public class PatchouliCompat implements ICompat {
state -> check.matches(null, null, null, null, state, (char) 0)); state -> check.matches(null, null, null, null, state, (char) 0));
} }
} }
MULTIBLOCKS.put(name, PatchouliAPI.get().makeMultiblock(pattern, rawMatchers)); PatchouliCompat.MULTIBLOCKS.put(name, PatchouliAPI.get().makeMultiblock(pattern, rawMatchers));
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -70,7 +70,7 @@ public class PatchouliCompat implements ICompat {
@Override @Override
public void setup(FMLCommonSetupEvent event) { public void setup(FMLCommonSetupEvent event) {
event.enqueueWork(() -> { event.enqueueWork(() -> {
for (var entry : MULTIBLOCKS.entrySet()) for (var entry : PatchouliCompat.MULTIBLOCKS.entrySet())
PatchouliAPI.get().registerMultiblock(entry.getKey(), entry.getValue()); PatchouliAPI.get().registerMultiblock(entry.getKey(), entry.getValue());
PatchouliAPI.get().setConfigFlag(NaturesAura.MOD_ID + ":rf_converter", ModConfig.instance.rfConverter.get()); PatchouliAPI.get().setConfigFlag(NaturesAura.MOD_ID + ":rf_converter", ModConfig.instance.rfConverter.get());
@ -93,7 +93,7 @@ public class PatchouliCompat implements ICompat {
public void onBookDraw(BookDrawScreenEvent event) { public void onBookDraw(BookDrawScreenEvent event) {
var book = event.getBook(); var book = event.getBook();
var gui = event.getScreen(); var gui = event.getScreen();
if (book == null || !book.equals(BOOK)) if (book == null || !book.equals(PatchouliCompat.BOOK))
return; return;
var now = LocalDateTime.now(); var now = LocalDateTime.now();
if (now.getMonth() == Month.MAY && now.getDayOfMonth() == 21) { if (now.getMonth() == Month.MAY && now.getDayOfMonth() == 21) {
@ -106,7 +106,7 @@ 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)
gui.renderComponentTooltip(event.getPoseStack(), gui.renderComponentTooltip(event.getPoseStack(),
Collections.singletonList(new TextComponent("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))),
event.getMouseX(), event.getMouseY(), gui.getMinecraft().font); event.getMouseX(), event.getMouseY(), gui.getMinecraft().font);
} 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;
@ -118,7 +118,7 @@ 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)
gui.renderComponentTooltip(event.getPoseStack(), gui.renderComponentTooltip(event.getPoseStack(),
Collections.singletonList(new TextComponent("\u00A76Happy \u00A74P\u00A76r\u00A7ei\u00A72d\u00A79e\u00A75!")), Collections.singletonList(Component.literal("\u00A76Happy \u00A74P\u00A76r\u00A7ei\u00A72d\u00A79e\u00A75!")),
event.getMouseX(), event.getMouseY(), gui.getMinecraft().font); event.getMouseX(), event.getMouseY(), gui.getMinecraft().font);
} }
@ -135,8 +135,8 @@ public class PatchouliCompat implements ICompat {
if (info.tier() == 1) { if (info.tier() == 1) {
Screen.blit(event.getPoseStack(), x, y, 496 - 16, 44, 16, 18, 512, 256); Screen.blit(event.getPoseStack(), x, y, 496 - 16, 44, 16, 18, 512, 256);
} else { } else {
var r = ((info.color() >> 16) & 255) / 255F; var r = (info.color() >> 16 & 255) / 255F;
var g = ((info.color() >> 8) & 255) / 255F; var g = (info.color() >> 8 & 255) / 255F;
var b = (info.color() & 255) / 255F; var b = (info.color() & 255) / 255F;
RenderSystem.setShaderColor(r, g, b, 1); RenderSystem.setShaderColor(r, g, b, 1);
Screen.blit(event.getPoseStack(), x, y, 496 - 32, 44, 16, 18, 512, 256); Screen.blit(event.getPoseStack(), x, y, 496 - 32, 44, 16, 18, 512, 256);
@ -144,7 +144,7 @@ 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)
gui.renderComponentTooltip(event.getPoseStack(), gui.renderComponentTooltip(event.getPoseStack(),
Collections.singletonList(new TextComponent("Thanks for your support, " + name + "!").setStyle(Style.EMPTY.applyFormat(ChatFormatting.YELLOW))), Collections.singletonList(Component.literal("Thanks for your support, " + name + "!").setStyle(Style.EMPTY.applyFormat(ChatFormatting.YELLOW))),
event.getMouseX(), event.getMouseY(), gui.getMinecraft().font); event.getMouseX(), event.getMouseY(), gui.getMinecraft().font);
} }

View file

@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.compat.patchouli;
import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe; import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.ForgeSpawnEggItem; import net.minecraftforge.common.ForgeSpawnEggItem;
import net.minecraftforge.registries.ForgeRegistries;
import vazkii.patchouli.api.IComponentProcessor; import vazkii.patchouli.api.IComponentProcessor;
import vazkii.patchouli.api.IVariable; import vazkii.patchouli.api.IVariable;
import vazkii.patchouli.api.IVariableProvider; import vazkii.patchouli.api.IVariableProvider;
@ -26,7 +27,7 @@ public class ProcessorAnimalSpawner implements IComponentProcessor {
} else { } else {
return switch (key) { return switch (key) {
case "name" -> IVariable.wrap(this.recipe.entity.getDescription().getString()); case "name" -> IVariable.wrap(this.recipe.entity.getDescription().getString());
case "entity" -> IVariable.wrap(this.recipe.entity.getRegistryName().toString()); case "entity" -> IVariable.wrap(ForgeRegistries.ENTITIES.getKey(this.recipe.entity).toString());
case "egg" -> IVariable.from(new ItemStack(ForgeSpawnEggItem.fromEntityType(this.recipe.entity))); case "egg" -> IVariable.from(new ItemStack(ForgeSpawnEggItem.fromEntityType(this.recipe.entity)));
default -> null; default -> null;
}; };

View file

@ -7,12 +7,11 @@ import de.ellpeck.naturesaura.blocks.BlockGoldenLeaves;
import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.blocks.ModBlocks;
import de.ellpeck.naturesaura.blocks.Slab; import de.ellpeck.naturesaura.blocks.Slab;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.reg.IModItem;
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.data.CachedOutput;
import net.minecraft.data.DataGenerator; import net.minecraft.data.DataGenerator;
import net.minecraft.data.DataProvider; import net.minecraft.data.DataProvider;
import net.minecraft.data.HashCache;
import net.minecraft.data.loot.BlockLoot; import net.minecraft.data.loot.BlockLoot;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Items; import net.minecraft.world.item.Items;
@ -31,6 +30,7 @@ import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePrope
import net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceCondition; import net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceCondition;
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue; import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator; import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator;
import net.minecraftforge.registries.ForgeRegistries;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.io.IOException; import java.io.IOException;
@ -72,13 +72,13 @@ public class BlockLootProvider implements DataProvider {
} }
@Override @Override
public void run(HashCache cache) throws IOException { public void run(CachedOutput cache) throws IOException {
for (var function : this.lootFunctions.entrySet()) { for (var function : this.lootFunctions.entrySet()) {
var block = function.getKey(); var block = function.getKey();
var func = function.getValue(); var func = function.getValue();
var table = func.apply(block).setParamSet(LootContextParamSets.BLOCK).build(); var table = func.apply(block).setParamSet(LootContextParamSets.BLOCK).build();
var path = getPath(this.generator.getOutputFolder(), block.getRegistryName()); var path = BlockLootProvider.getPath(this.generator.getOutputFolder(), ForgeRegistries.BLOCKS.getKey(block));
DataProvider.save(GSON, cache, LootTables.serialize(table), path); DataProvider.saveStable(cache, LootTables.serialize(table), path);
} }
} }
@ -92,31 +92,31 @@ public class BlockLootProvider implements DataProvider {
private static class LootTableHooks extends BlockLoot { private static class LootTableHooks extends BlockLoot {
public static LootTable.Builder genLeaves(Block block, Block drop) { public static LootTable.Builder genLeaves(Block block, Block drop) {
return createLeavesDrops(block, drop, 0.05F, 0.0625F, 0.083333336F, 0.1F); return BlockLoot.createLeavesDrops(block, drop, 0.05F, 0.0625F, 0.083333336F, 0.1F);
} }
public static LootTable.Builder genSlab(Block block) { public static LootTable.Builder genSlab(Block block) {
return createSlabItemTable(block); return BlockLoot.createSlabItemTable(block);
} }
public static LootTable.Builder genRegular(Block block) { public static LootTable.Builder genRegular(Block block) {
return createSingleItemTable(block); return BlockLoot.createSingleItemTable(block);
} }
public static LootTable.Builder genSilkOnly(Block block) { public static LootTable.Builder genSilkOnly(Block block) {
return createSilkTouchOnlyTable(block); return BlockLoot.createSilkTouchOnlyTable(block);
} }
public static LootTable.Builder genSilkOr(Block block, LootPoolEntryContainer.Builder<?> builder) { public static LootTable.Builder genSilkOr(Block block, LootPoolEntryContainer.Builder<?> builder) {
return createSilkTouchOrShearsDispatchTable(block, builder); return BlockLoot.createSilkTouchOrShearsDispatchTable(block, builder);
} }
public static LootTable.Builder genFlowerPot(Block block) { public static LootTable.Builder genFlowerPot(Block block) {
return createPotFlowerItemTable(((FlowerPotBlock) block).getContent()); return BlockLoot.createPotFlowerItemTable(((FlowerPotBlock) block).getContent());
} }
public static <T> T survivesExplosion(Block block, ConditionUserBuilder<T> then) { public static <T extends ConditionUserBuilder<T>> T survivesExplosion(Block block, ConditionUserBuilder<T> then) {
return applyExplosionCondition(block, then); return BlockLoot.applyExplosionCondition(block, then);
} }
} }
} }

View file

@ -34,10 +34,10 @@ public class BlockTagProvider extends BlockTagsProvider {
this.tag(BlockTags.SLABS).add(ModBlocks.ANCIENT_SLAB, ModBlocks.INFUSED_SLAB, ModBlocks.INFUSED_BRICK_SLAB); this.tag(BlockTags.SLABS).add(ModBlocks.ANCIENT_SLAB, ModBlocks.INFUSED_SLAB, ModBlocks.INFUSED_BRICK_SLAB);
this.tag(BlockTags.DIRT).add(ModBlocks.NETHER_GRASS); this.tag(BlockTags.DIRT).add(ModBlocks.NETHER_GRASS);
this.tag(BlockTags.SMALL_FLOWERS).add(ModBlocks.END_FLOWER, ModBlocks.AURA_BLOOM); this.tag(BlockTags.SMALL_FLOWERS).add(ModBlocks.END_FLOWER, ModBlocks.AURA_BLOOM);
this.tag(ALTAR_WOOD).addTag(BlockTags.PLANKS); this.tag(BlockTagProvider.ALTAR_WOOD).addTag(BlockTags.PLANKS);
this.tag(ALTAR_STONE).addTag(BlockTags.STONE_BRICKS); this.tag(BlockTagProvider.ALTAR_STONE).addTag(BlockTags.STONE_BRICKS);
this.tag(NETHER_ALTAR_WOOD).add(Blocks.CRIMSON_PLANKS, Blocks.WARPED_PLANKS); this.tag(BlockTagProvider.NETHER_ALTAR_WOOD).add(Blocks.CRIMSON_PLANKS, Blocks.WARPED_PLANKS);
this.tag(NETHER_ALTAR_STONE).add(Blocks.NETHER_BRICKS); this.tag(BlockTagProvider.NETHER_ALTAR_STONE).add(Blocks.NETHER_BRICKS);
} }
} }

View file

@ -3,14 +3,11 @@ package de.ellpeck.naturesaura.data;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.compat.Compat; import de.ellpeck.naturesaura.compat.Compat;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.items.tools.ItemPickaxe;
import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.data.DataGenerator; import net.minecraft.data.DataGenerator;
import net.minecraft.data.tags.BlockTagsProvider; import net.minecraft.data.tags.BlockTagsProvider;
import net.minecraft.data.tags.ItemTagsProvider; import net.minecraft.data.tags.ItemTagsProvider;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags; import net.minecraft.tags.ItemTags;
import net.minecraft.tags.Tag;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraftforge.common.Tags; import net.minecraftforge.common.Tags;

View file

@ -12,10 +12,10 @@ public final class ModData {
var generator = event.getGenerator(); var generator = event.getGenerator();
var ex = event.getExistingFileHelper(); var ex = event.getExistingFileHelper();
var blockTags = new BlockTagProvider(generator, ex); var blockTags = new BlockTagProvider(generator, ex);
generator.addProvider(blockTags); generator.addProvider(event.includeServer(), blockTags);
generator.addProvider(new ItemTagProvider(generator, blockTags, ex)); generator.addProvider(event.includeServer(), new ItemTagProvider(generator, blockTags, ex));
generator.addProvider(new BlockLootProvider(generator)); generator.addProvider(event.includeServer(), new BlockLootProvider(generator));
generator.addProvider(new BlockStateGenerator(generator, ex)); generator.addProvider(event.includeServer(), new BlockStateGenerator(generator, ex));
generator.addProvider(new ItemModelGenerator(generator, ex)); generator.addProvider(event.includeServer(), new ItemModelGenerator(generator, ex));
} }
} }

View file

@ -13,7 +13,7 @@ public class ModEnchantment extends Enchantment implements IModItem {
protected ModEnchantment(String name, Rarity rarityIn, EnchantmentCategory typeIn, EquipmentSlot[] slots) { protected ModEnchantment(String name, Rarity rarityIn, EnchantmentCategory typeIn, EquipmentSlot[] slots) {
super(rarityIn, typeIn, slots); super(rarityIn, typeIn, slots);
this.name = name; this.name = name;
ModRegistry.add(this); ModRegistry.ALL_ITEMS.add(this);
} }
@Override @Override

View file

@ -68,15 +68,15 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
@Override @Override
protected void defineSynchedData() { protected void defineSynchedData() {
this.entityData.define(INHIBITED_EFFECT, null); this.entityData.define(EntityEffectInhibitor.INHIBITED_EFFECT, null);
this.entityData.define(COLOR, 0); this.entityData.define(EntityEffectInhibitor.COLOR, 0);
this.entityData.define(AMOUNT, 0); this.entityData.define(EntityEffectInhibitor.AMOUNT, 0);
} }
@Override @Override
public void onSyncedDataUpdated(EntityDataAccessor<?> key) { public void onSyncedDataUpdated(EntityDataAccessor<?> key) {
super.onSyncedDataUpdated(key); super.onSyncedDataUpdated(key);
if (INHIBITED_EFFECT.equals(key) || AMOUNT.equals(key)) if (EntityEffectInhibitor.INHIBITED_EFFECT.equals(key) || EntityEffectInhibitor.AMOUNT.equals(key))
this.powderListDirty = true; this.powderListDirty = true;
} }
@ -161,30 +161,30 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
} }
public ResourceLocation getInhibitedEffect() { public ResourceLocation getInhibitedEffect() {
var effect = this.entityData.get(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 new ResourceLocation(effect); return new ResourceLocation(effect);
} }
public void setInhibitedEffect(ResourceLocation effect) { public void setInhibitedEffect(ResourceLocation effect) {
this.entityData.set(INHIBITED_EFFECT, effect != null ? effect.toString() : null); this.entityData.set(EntityEffectInhibitor.INHIBITED_EFFECT, effect != null ? effect.toString() : null);
} }
public int getColor() { public int getColor() {
return this.entityData.get(COLOR); return this.entityData.get(EntityEffectInhibitor.COLOR);
} }
public void setColor(int color) { public void setColor(int color) {
this.entityData.set(COLOR, color); this.entityData.set(EntityEffectInhibitor.COLOR, color);
} }
public int getAmount() { public int getAmount() {
return this.entityData.get(AMOUNT); return this.entityData.get(EntityEffectInhibitor.AMOUNT);
} }
public void setAmount(int amount) { public void setAmount(int amount) {
this.entityData.set(AMOUNT, amount); this.entityData.set(EntityEffectInhibitor.AMOUNT, amount);
} }
@Override @Override

View file

@ -12,17 +12,19 @@ import net.minecraft.nbt.Tag;
import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.Packet;
import net.minecraft.server.level.ServerLevel; 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.InteractionResult;
import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.vehicle.AbstractMinecart; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.vehicle.Minecart;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameRules; 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.phys.HitResult; import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.util.ITeleporter; import net.minecraftforge.common.util.ITeleporter;
import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.NetworkHooks;
@ -30,7 +32,7 @@ import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class EntityMoverMinecart extends AbstractMinecart { public class EntityMoverMinecart extends Minecart {
private final List<BlockPos> spotOffsets = new ArrayList<>(); private final List<BlockPos> spotOffsets = new ArrayList<>();
public boolean isActive; public boolean isActive;
@ -41,7 +43,11 @@ public class EntityMoverMinecart extends AbstractMinecart {
} }
public EntityMoverMinecart(EntityType<?> type, Level level, double x, double y, double z) { public EntityMoverMinecart(EntityType<?> type, Level level, double x, double y, double z) {
super(type, level, x, y, z); super(type, level);
this.setPos(x, y, z);
this.xo = x;
this.yo = y;
this.zo = z;
} }
@Override @Override
@ -180,4 +186,9 @@ public class EntityMoverMinecart extends AbstractMinecart {
public Packet<?> getAddEntityPacket() { public Packet<?> getAddEntityPacket() {
return NetworkHooks.getEntitySpawningPacket(this); return NetworkHooks.getEntitySpawningPacket(this);
} }
@Override
public InteractionResult interact(Player p_38483_, InteractionHand p_38484_) {
return InteractionResult.PASS;
}
} }

View file

@ -34,19 +34,19 @@ public class EntityStructureFinder extends EyeOfEnder {
@Override @Override
protected void defineSynchedData() { protected void defineSynchedData() {
super.defineSynchedData(); super.defineSynchedData();
this.entityData.define(COLOR, 0); this.entityData.define(EntityStructureFinder.COLOR, 0);
} }
@Override @Override
public void addAdditionalSaveData(CompoundTag compound) { public void addAdditionalSaveData(CompoundTag compound) {
super.addAdditionalSaveData(compound); super.addAdditionalSaveData(compound);
compound.putInt("color", this.entityData.get(COLOR)); compound.putInt("color", this.entityData.get(EntityStructureFinder.COLOR));
} }
@Override @Override
public void readAdditionalSaveData(CompoundTag compound) { public void readAdditionalSaveData(CompoundTag compound) {
super.readAdditionalSaveData(compound); super.readAdditionalSaveData(compound);
this.entityData.set(COLOR, compound.getInt("color")); this.entityData.set(EntityStructureFinder.COLOR, compound.getInt("color"));
} }
@Override @Override
@ -58,8 +58,8 @@ public class EntityStructureFinder extends EyeOfEnder {
var d3 = d1 - this.getZ(); var d3 = d1 - this.getZ();
var f = Math.sqrt(d2 * d2 + d3 * d3); var f = Math.sqrt(d2 * d2 + d3 * d3);
if (f > 12.0F) { if (f > 12.0F) {
this.targetX = this.getX() + d2 / (double) f * 12.0D; this.targetX = this.getX() + d2 / f * 12.0D;
this.targetZ = this.getZ() + d3 / (double) f * 12.0D; this.targetZ = this.getZ() + d3 / f * 12.0D;
this.targetY = this.getY() + 8.0D; this.targetY = this.getY() + 8.0D;
} else { } else {
this.targetX = d0; this.targetX = d0;
@ -113,7 +113,7 @@ public class EntityStructureFinder extends EyeOfEnder {
for (var i = 0; i < 4; ++i) for (var i = 0; i < 4; ++i)
this.level.addParticle(ParticleTypes.BUBBLE, d0 - vec3d.x * 0.25D, d1 - vec3d.y * 0.25D, d2 - vec3d.z * 0.25D, vec3d.x, vec3d.y, vec3d.z); this.level.addParticle(ParticleTypes.BUBBLE, d0 - vec3d.x * 0.25D, d1 - vec3d.y * 0.25D, d2 - vec3d.z * 0.25D, vec3d.x, vec3d.y, vec3d.z);
} else if (this.level.isClientSide) { } else if (this.level.isClientSide) {
NaturesAuraAPI.instance().spawnMagicParticle(d0 - vec3d.x * 0.25D + this.random.nextDouble() * 0.6D - 0.3D, d1 - vec3d.y * 0.25D - 0.5D, d2 - vec3d.z * 0.25D + this.random.nextDouble() * 0.6D - 0.3D, vec3d.x * 0.25F, vec3d.y * 0.25F, vec3d.z * 0.25F, this.entityData.get(COLOR), 1, 50, 0, false, true); NaturesAuraAPI.instance().spawnMagicParticle(d0 - vec3d.x * 0.25D + this.random.nextDouble() * 0.6D - 0.3D, d1 - vec3d.y * 0.25D - 0.5D, d2 - vec3d.z * 0.25D + this.random.nextDouble() * 0.6D - 0.3D, vec3d.x * 0.25F, vec3d.y * 0.25F, vec3d.z * 0.25F, this.entityData.get(EntityStructureFinder.COLOR), 1, 50, 0, false, true);
} }
if (!this.level.isClientSide) { if (!this.level.isClientSide) {

View file

@ -36,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(Vector3f.XP.rotationDegrees(180)); matrixStackIn.mulPose(Vector3f.XP.rotationDegrees(180));
this.model.renderToBuffer(matrixStackIn, bufferIn.getBuffer(this.model.renderType(RES)), packedLightIn, OverlayTexture.NO_OVERLAY, 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();
} }

View file

@ -88,16 +88,16 @@ public class ClientEvents {
@SubscribeEvent @SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent event) { public void onClientTick(TickEvent.ClientTickEvent event) {
if (event.phase != TickEvent.Phase.END) { if (event.phase != TickEvent.Phase.END) {
heldCache = ItemStack.EMPTY; ClientEvents.heldCache = ItemStack.EMPTY;
heldEye = ItemStack.EMPTY; ClientEvents.heldEye = ItemStack.EMPTY;
heldOcular = 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();
PENDING_AURA_CHUNKS.clear(); ClientEvents.PENDING_AURA_CHUNKS.clear();
} else { } else {
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) {
@ -144,14 +144,14 @@ public class ClientEvents {
inst.setParticleSpawnRange(32); inst.setParticleSpawnRange(32);
} }
heldCache = Helper.getEquippedItem(s -> s.getItem() instanceof ItemAuraCache, mc.player); ClientEvents.heldCache = Helper.getEquippedItem(s -> s.getItem() instanceof ItemAuraCache, mc.player);
heldEye = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE, mc.player); ClientEvents.heldEye = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE, mc.player);
heldOcular = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE_IMPROVED, mc.player); ClientEvents.heldOcular = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE_IMPROVED, mc.player);
if (!heldOcular.isEmpty() && mc.level.getGameTime() % 20 == 0) { if (!ClientEvents.heldOcular.isEmpty() && mc.level.getGameTime() % 20 == 0) {
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, SHOWING_EFFECTS)); chunk -> chunk.getActiveEffectIcons(mc.player, ClientEvents.SHOWING_EFFECTS));
} }
} }
} }
@ -176,7 +176,7 @@ public class ClientEvents {
RenderSystem.enableBlend(); RenderSystem.enableBlend();
// aura spot debug // aura spot debug
hoveringAuraSpot = null; ClientEvents.hoveringAuraSpot = null;
if (mc.options.renderDebug && mc.player.isCreative() && ModConfig.instance.debugLevel.get()) { if (mc.options.renderDebug && mc.player.isCreative() && ModConfig.instance.debugLevel.get()) {
var playerEye = mc.player.getEyePosition(event.getPartialTick()); var playerEye = mc.player.getEyePosition(event.getPartialTick());
var playerView = mc.player.getViewVector(event.getPartialTick()).normalize(); var playerView = mc.player.getViewVector(event.getPartialTick()).normalize();
@ -188,7 +188,7 @@ public class ClientEvents {
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) {
if (pos.equals(new BlockPos(playerEye.add(playerView.scale(d))))) { if (pos.equals(new BlockPos(playerEye.add(playerView.scale(d))))) {
hoveringAuraSpot = pos; ClientEvents.hoveringAuraSpot = pos;
break; break;
} }
} }
@ -240,12 +240,12 @@ public class ClientEvents {
@SubscribeEvent @SubscribeEvent
public void onOverlayRender(RenderGameOverlayEvent.Post event) { public void onOverlayRender(RenderGameOverlayEvent.Post event) {
var mc = Minecraft.getInstance(); var mc = Minecraft.getInstance();
var stack = event.getMatrixStack(); var stack = event.getPoseStack();
if (event.getType() == RenderGameOverlayEvent.ElementType.ALL) { if (event.getType() == RenderGameOverlayEvent.ElementType.ALL) {
var res = event.getWindow(); var res = event.getWindow();
if (mc.player != null) { if (mc.player != null) {
if (!heldCache.isEmpty()) { if (!ClientEvents.heldCache.isEmpty()) {
var container = heldCache.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER, null).orElse(null); var container = ClientEvents.heldCache.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER, null).orElse(null);
var width = Mth.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80); var width = Mth.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80);
int conf = ModConfig.instance.cacheBarLocation.get(); int conf = ModConfig.instance.cacheBarLocation.get();
@ -256,7 +256,7 @@ public class ClientEvents {
var color = container.getAuraColor(); var color = container.getAuraColor();
RenderSystem.setShaderColor((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 1); RenderSystem.setShaderColor((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 1);
RenderSystem.setShaderTexture(0, OVERLAYS); RenderSystem.setShaderTexture(0, ClientEvents.OVERLAYS);
if (width < 80) if (width < 80)
Screen.blit(stack, x + width, y, width, 0, 80 - width, 6, 256, 256); Screen.blit(stack, x + width, y, width, 0, 80 - width, 6, 256, 256);
if (width > 0) if (width > 0)
@ -265,7 +265,7 @@ public class ClientEvents {
var scale = 0.75F; var scale = 0.75F;
stack.pushPose(); stack.pushPose();
stack.scale(scale, scale, scale); stack.scale(scale, scale, scale);
var s = heldCache.getHoverName().getString(); var s = ClientEvents.heldCache.getHoverName().getString();
mc.font.drawShadow(stack, s, conf == 1 ? x / scale : (x + 80) / scale - mc.font.width(s), (y - 7) / scale, color); mc.font.drawShadow(stack, s, conf == 1 ? x / scale : (x + 80) / scale - mc.font.width(s), (y - 7) / scale, color);
stack.popPose(); stack.popPose();
@ -273,9 +273,9 @@ public class ClientEvents {
stack.pushPose(); stack.pushPose();
} }
if (!heldEye.isEmpty() || !heldOcular.isEmpty()) { if (!ClientEvents.heldEye.isEmpty() || !ClientEvents.heldOcular.isEmpty()) {
stack.pushPose(); stack.pushPose();
RenderSystem.setShaderTexture(0, OVERLAYS); RenderSystem.setShaderTexture(0, ClientEvents.OVERLAYS);
int conf = ModConfig.instance.auraBarLocation.get(); int conf = ModConfig.instance.auraBarLocation.get();
if (!mc.options.renderDebug && (conf != 2 || !(mc.screen instanceof ChatScreen))) { if (!mc.options.renderDebug && (conf != 2 || !(mc.screen instanceof ChatScreen))) {
@ -288,19 +288,19 @@ public class ClientEvents {
var textScale = 0.75F; var textScale = 0.75F;
var startX = conf % 2 == 0 ? 3 : res.getGuiScaledWidth() - 3 - 6; var startX = conf % 2 == 0 ? 3 : res.getGuiScaledWidth() - 3 - 6;
var startY = conf < 2 ? 10 : (!heldOcular.isEmpty() && (totalPercentage > 1F || totalPercentage < 0) ? -26 : 0) + res.getGuiScaledHeight() - 60; var startY = conf < 2 ? 10 : (!ClientEvents.heldOcular.isEmpty() && (totalPercentage > 1F || totalPercentage < 0) ? -26 : 0) + res.getGuiScaledHeight() - 60;
float plusOffX = conf % 2 == 0 ? 7 : -1 - 6; float plusOffX = conf % 2 == 0 ? 7 : -1 - 6;
var textX = conf % 2 == 0 ? 3 : res.getGuiScaledWidth() - 3 - mc.font.width(text) * textScale; var textX = conf % 2 == 0 ? 3 : res.getGuiScaledWidth() - 3 - mc.font.width(text) * textScale;
float textY = conf < 2 ? 3 : res.getGuiScaledHeight() - 3 - 6; float textY = conf < 2 ? 3 : res.getGuiScaledHeight() - 3 - 6;
var tHeight = Mth.ceil(Mth.clamp(totalPercentage, 0F, 1F) * 50); var tHeight = Mth.ceil(Mth.clamp(totalPercentage, 0F, 1F) * 50);
var y = !heldOcular.isEmpty() && totalPercentage > 1F ? startY + 26 : startY; var y = !ClientEvents.heldOcular.isEmpty() && totalPercentage > 1F ? startY + 26 : startY;
if (tHeight < 50) if (tHeight < 50)
Screen.blit(stack, startX, y, 6, 12, 6, 50 - tHeight, 256, 256); Screen.blit(stack, startX, y, 6, 12, 6, 50 - tHeight, 256, 256);
if (tHeight > 0) if (tHeight > 0)
Screen.blit(stack, startX, y + 50 - tHeight, 0, 12 + 50 - tHeight, 6, tHeight, 256, 256); Screen.blit(stack, startX, y + 50 - tHeight, 0, 12 + 50 - tHeight, 6, tHeight, 256, 256);
if (!heldOcular.isEmpty()) { if (!ClientEvents.heldOcular.isEmpty()) {
var topHeight = Mth.ceil(Mth.clamp((totalPercentage - 1F) * 2F, 0F, 1F) * 25); var topHeight = Mth.ceil(Mth.clamp((totalPercentage - 1F) * 2F, 0F, 1F) * 25);
if (topHeight > 0) { if (topHeight > 0) {
if (topHeight < 25) if (topHeight < 25)
@ -315,30 +315,30 @@ public class ClientEvents {
} }
} }
if (totalPercentage > (heldOcular.isEmpty() ? 1F : 1.5F)) if (totalPercentage > (ClientEvents.heldOcular.isEmpty() ? 1F : 1.5F))
mc.font.drawShadow(stack, "+", startX + plusOffX, startY - 0.5F, color); mc.font.drawShadow(stack, "+", startX + plusOffX, startY - 0.5F, color);
if (totalPercentage < (heldOcular.isEmpty() ? 0F : -0.5F)) if (totalPercentage < (ClientEvents.heldOcular.isEmpty() ? 0F : -0.5F))
mc.font.drawShadow(stack, "-", startX + plusOffX, startY - 0.5F + (heldOcular.isEmpty() ? 44 : 70), color); mc.font.drawShadow(stack, "-", startX + plusOffX, startY - 0.5F + (ClientEvents.heldOcular.isEmpty() ? 44 : 70), color);
stack.pushPose(); stack.pushPose();
stack.scale(textScale, textScale, textScale); stack.scale(textScale, textScale, textScale);
mc.font.drawShadow(stack, text, textX / textScale, textY / textScale, color); mc.font.drawShadow(stack, text, textX / textScale, textY / textScale, color);
stack.popPose(); stack.popPose();
if (!heldOcular.isEmpty()) { if (!ClientEvents.heldOcular.isEmpty()) {
var scale = 0.75F; var scale = 0.75F;
stack.pushPose(); stack.pushPose();
stack.scale(scale, scale, scale); stack.scale(scale, scale, scale);
var stackX = conf % 2 == 0 ? 10 : res.getGuiScaledWidth() - 22; var stackX = conf % 2 == 0 ? 10 : res.getGuiScaledWidth() - 22;
var stackY = conf < 2 ? 15 : res.getGuiScaledHeight() - 55; var stackY = conf < 2 ? 15 : res.getGuiScaledHeight() - 55;
for (var effect : SHOWING_EFFECTS.values()) { for (var effect : ClientEvents.SHOWING_EFFECTS.values()) {
var theX = (int) (stackX / scale); var theX = (int) (stackX / scale);
var theY = (int) (stackY / scale); var theY = (int) (stackY / scale);
var itemStack = effect.getA(); var itemStack = effect.getA();
Helper.renderItemInGui(itemStack, theX, theY, 1F); Helper.renderItemInGui(itemStack, theX, theY, 1F);
if (effect.getB()) { if (effect.getB()) {
RenderSystem.disableDepthTest(); RenderSystem.disableDepthTest();
RenderSystem.setShaderTexture(0, OVERLAYS); RenderSystem.setShaderTexture(0, ClientEvents.OVERLAYS);
Screen.blit(stack, theX, theY, 240, 0, 16, 16, 256, 256); Screen.blit(stack, theX, theY, 240, 0, 16, 16, 256, 256);
RenderSystem.enableDepthTest(); RenderSystem.enableDepthTest();
} }
@ -387,15 +387,15 @@ public class ClientEvents {
Helper.renderItemInGui(itemStack, x + 2, y - 18, 1F); Helper.renderItemInGui(itemStack, x + 2, y - 18, 1F);
} }
Helper.renderItemInGui(ITEM_FRAME, x - 24, y - 24, 1F); Helper.renderItemInGui(ClientEvents.ITEM_FRAME, x - 24, y - 24, 1F);
RenderSystem.setShaderTexture(0, OVERLAYS); RenderSystem.setShaderTexture(0, ClientEvents.OVERLAYS);
var u = chute.isBlacklist ? 240 : 224; var u = chute.isBlacklist ? 240 : 224;
RenderSystem.disableDepthTest(); RenderSystem.disableDepthTest();
Screen.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256); Screen.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256);
RenderSystem.enableDepthTest(); RenderSystem.enableDepthTest();
} else if (tile instanceof BlockEntityItemDistributor distributor) { } else if (tile instanceof BlockEntityItemDistributor distributor) {
Helper.renderItemInGui(DISPENSER, x - 24, y - 24, 1F); Helper.renderItemInGui(ClientEvents.DISPENSER, x - 24, y - 24, 1F);
RenderSystem.setShaderTexture(0, OVERLAYS); RenderSystem.setShaderTexture(0, ClientEvents.OVERLAYS);
var u = !distributor.isRandomMode ? 240 : 224; var u = !distributor.isRandomMode ? 240 : 224;
RenderSystem.disableDepthTest(); RenderSystem.disableDepthTest();
Screen.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256); Screen.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256);
@ -415,9 +415,9 @@ public class ClientEvents {
stack.popPose(); stack.popPose();
} }
if (hoveringAuraSpot != null) { if (ClientEvents.hoveringAuraSpot != null) {
var format = NumberFormat.getInstance(); var format = NumberFormat.getInstance();
var amount = IAuraChunk.getAuraChunk(mc.level, hoveringAuraSpot).getDrainSpot(hoveringAuraSpot); var amount = IAuraChunk.getAuraChunk(mc.level, ClientEvents.hoveringAuraSpot).getDrainSpot(ClientEvents.hoveringAuraSpot);
var color = amount > 0 ? ChatFormatting.GREEN : ChatFormatting.RED; var color = amount > 0 ? ChatFormatting.GREEN : ChatFormatting.RED;
mc.font.drawShadow(stack, color + format.format(amount), res.getGuiScaledWidth() / 2F + 5, res.getGuiScaledHeight() / 2F - 11, 0xFFFFFF); mc.font.drawShadow(stack, color + format.format(amount), res.getGuiScaledWidth() / 2F + 5, res.getGuiScaledHeight() / 2F - 11, 0xFFFFFF);
} }
@ -440,7 +440,7 @@ public class ClientEvents {
var y = res.getGuiScaledHeight() / 2 + yOffset; var y = res.getGuiScaledHeight() / 2 + yOffset;
var width = Mth.ceil(stored / (float) max * 80); var width = Mth.ceil(stored / (float) max * 80);
RenderSystem.setShaderTexture(0, OVERLAYS); RenderSystem.setShaderTexture(0, ClientEvents.OVERLAYS);
if (width < 80) if (width < 80)
Screen.blit(stack, x + width, y, width, 0, 80 - width, 6, 256, 256); Screen.blit(stack, x + width, y, width, 0, 80 - width, 6, 256, 256);
if (width > 0) if (width > 0)

View file

@ -3,7 +3,6 @@ package de.ellpeck.naturesaura.events;
import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap; import com.google.common.collect.ListMultimap;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
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;
@ -11,7 +10,6 @@ import de.ellpeck.naturesaura.api.misc.ILevelData;
import de.ellpeck.naturesaura.chunk.AuraChunk; import de.ellpeck.naturesaura.chunk.AuraChunk;
import de.ellpeck.naturesaura.chunk.AuraChunkProvider; import de.ellpeck.naturesaura.chunk.AuraChunkProvider;
import de.ellpeck.naturesaura.commands.CommandAura; import de.ellpeck.naturesaura.commands.CommandAura;
import de.ellpeck.naturesaura.gen.ModFeatures;
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 net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@ -26,24 +24,23 @@ import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.server.ServerStartingEvent; import net.minecraftforge.event.server.ServerStartingEvent;
import net.minecraftforge.event.world.BiomeLoadingEvent;
import net.minecraftforge.event.world.ChunkEvent; import net.minecraftforge.event.world.ChunkEvent;
import net.minecraftforge.event.world.ChunkWatchEvent; import net.minecraftforge.event.world.ChunkWatchEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.util.ObfuscationReflectionHelper; import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
import net.minecraftforge.registries.ForgeRegistries;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.UUID; import java.util.UUID;
import static net.minecraft.world.level.levelgen.GenerationStep.Decoration;
public class CommonEvents { public class CommonEvents {
private static final Method GET_LOADED_CHUNKS_METHOD = ObfuscationReflectionHelper.findMethod(ChunkMap.class, "m_140416_"); private static final Method GET_LOADED_CHUNKS_METHOD = ObfuscationReflectionHelper.findMethod(ChunkMap.class, "m_140416_");
private static final ListMultimap<UUID, ChunkPos> PENDING_AURA_CHUNKS = ArrayListMultimap.create(); private static final ListMultimap<UUID, ChunkPos> PENDING_AURA_CHUNKS = ArrayListMultimap.create();
@SubscribeEvent // TODO apparently this changed a ton to some weird biome modifier thing
/*@SubscribeEvent
public void onBiomeLoad(BiomeLoadingEvent event) { public void onBiomeLoad(BiomeLoadingEvent event) {
if (ModConfig.instance.auraBlooms.get()) { if (ModConfig.instance.auraBlooms.get()) {
event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Placed.AURA_BLOOM); event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Placed.AURA_BLOOM);
@ -56,7 +53,7 @@ public class CommonEvents {
case MUSHROOM -> event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Placed.AURA_MUSHROOM); case MUSHROOM -> event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Placed.AURA_MUSHROOM);
} }
} }
} }*/
@SubscribeEvent @SubscribeEvent
public void onChunkCapsAttach(AttachCapabilitiesEvent<LevelChunk> event) { public void onChunkCapsAttach(AttachCapabilitiesEvent<LevelChunk> event) {
@ -87,7 +84,7 @@ public class CommonEvents {
if (player.level.isClientSide) if (player.level.isClientSide)
return; return;
var held = event.getItemStack(); var held = event.getItemStack();
if (!held.isEmpty() && held.getItem().getRegistryName().getPath().contains("chisel")) { if (!held.isEmpty() && ForgeRegistries.ITEMS.getKey(held.getItem()).getPath().contains("chisel")) {
var state = player.level.getBlockState(event.getPos()); var state = player.level.getBlockState(event.getPos());
if (NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.containsKey(state)) { if (NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.containsKey(state)) {
var data = (LevelData) ILevelData.getLevelData(player.level); var data = (LevelData) ILevelData.getLevelData(player.level);
@ -104,7 +101,7 @@ public class CommonEvents {
event.world.getProfiler().push(NaturesAura.MOD_ID + ":onLevelTick"); event.world.getProfiler().push(NaturesAura.MOD_ID + ":onLevelTick");
try { try {
var manager = ((ServerChunkCache) event.world.getChunkSource()).chunkMap; var manager = ((ServerChunkCache) event.world.getChunkSource()).chunkMap;
var chunks = (Iterable<ChunkHolder>) 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();
if (chunk == null) if (chunk == null)
@ -125,7 +122,7 @@ public class CommonEvents {
public void onPlayerTick(TickEvent.PlayerTickEvent event) { public void onPlayerTick(TickEvent.PlayerTickEvent event) {
if (!event.player.level.isClientSide && event.phase == TickEvent.Phase.END) { if (!event.player.level.isClientSide && event.phase == TickEvent.Phase.END) {
if (event.player.level.getGameTime() % 10 == 0) { if (event.player.level.getGameTime() % 10 == 0) {
var pending = PENDING_AURA_CHUNKS.get(event.player.getUUID()); var pending = CommonEvents.PENDING_AURA_CHUNKS.get(event.player.getUUID());
pending.removeIf(p -> this.handleChunkWatchDeferred(event.player, p)); pending.removeIf(p -> this.handleChunkWatchDeferred(event.player, p));
} }
@ -142,7 +139,7 @@ public class CommonEvents {
@SubscribeEvent @SubscribeEvent
public void onChunkWatch(ChunkWatchEvent.Watch event) { public void onChunkWatch(ChunkWatchEvent.Watch event) {
PENDING_AURA_CHUNKS.put(event.getPlayer().getUUID(), event.getPos()); CommonEvents.PENDING_AURA_CHUNKS.put(event.getPlayer().getUUID(), event.getPos());
} }
private boolean handleChunkWatchDeferred(Player player, ChunkPos pos) { private boolean handleChunkWatchDeferred(Player player, ChunkPos pos) {

View file

@ -4,6 +4,7 @@ import com.mojang.serialization.Codec;
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.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.RotatedPillarBlock; import net.minecraft.world.level.block.RotatedPillarBlock;
@ -15,8 +16,6 @@ import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfigur
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import java.util.Random;
import static net.minecraft.core.Direction.Axis; import static net.minecraft.core.Direction.Axis;
public class LevelGenAncientTree extends Feature<NoneFeatureConfiguration> { public class LevelGenAncientTree extends Feature<NoneFeatureConfiguration> {
@ -100,7 +99,7 @@ public class LevelGenAncientTree extends Feature<NoneFeatureConfiguration> {
} }
} }
private void makeLeaves(WorldGenLevel level, BlockPos pos, BlockState state, int radius, Random rand) { private void makeLeaves(WorldGenLevel level, BlockPos pos, BlockState state, int radius, RandomSource rand) {
for (var x = -radius; x <= radius; x++) { for (var x = -radius; x <= radius; x++) {
for (var y = -radius; y <= radius; y++) { for (var y = -radius; y <= radius; y++) {
for (var z = -radius; z <= radius; z++) { for (var z = -radius; z <= radius; z++) {

View file

@ -3,7 +3,6 @@ package de.ellpeck.naturesaura.gen;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
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;

View file

@ -36,7 +36,7 @@ public class GuiEnderCrate extends AbstractContainerScreen<ContainerEnderCrate>
@Override @Override
protected void renderBg(PoseStack matrixStack, float partialTicks, int mouseX, int mouseY) { protected void renderBg(PoseStack matrixStack, float partialTicks, int mouseX, int mouseY) {
RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, CHEST_GUI_TEXTURE); RenderSystem.setShaderTexture(0, GuiEnderCrate.CHEST_GUI_TEXTURE);
var i = (this.width - this.imageWidth) / 2; var i = (this.width - this.imageWidth) / 2;
var j = (this.height - this.imageHeight) / 2; var j = (this.height - this.imageHeight) / 2;
this.blit(matrixStack, i, j, 0, 0, this.imageWidth, 3 * 18 + 17); this.blit(matrixStack, i, j, 0, 0, this.imageWidth, 3 * 18 + 17);

View file

@ -10,7 +10,6 @@ import net.minecraft.client.color.item.ItemColor;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.core.dispenser.DefaultDispenseItemBehavior; import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
@ -43,7 +42,7 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu
var dispense = stack.split(1); var dispense = stack.split(1);
if (offsetState.isAir()) { if (offsetState.isAir()) {
if (IAuraChunk.getAuraInArea(level, offset, 30) >= 100000) { if (IAuraChunk.getAuraInArea(level, offset, 30) >= 100000) {
dispense = setType(new ItemStack(ItemAuraBottle.this), IAuraType.forLevel(level)); dispense = ItemAuraBottle.setType(new ItemStack(ItemAuraBottle.this), IAuraType.forLevel(level));
var spot = IAuraChunk.getHighestSpot(level, offset, 30, offset); var spot = IAuraChunk.getHighestSpot(level, offset, 30, offset);
IAuraChunk.getAuraChunk(level, spot).drainAura(spot, 20000); IAuraChunk.getAuraChunk(level, spot).drainAura(spot, 20000);
@ -71,10 +70,10 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu
@Override @Override
public void fillItemCategory(CreativeModeTab tab, NonNullList<ItemStack> items) { public void fillItemCategory(CreativeModeTab tab, NonNullList<ItemStack> items) {
if (this.allowdedIn(tab)) { if (this.allowedIn(tab)) {
for (var type : NaturesAuraAPI.AURA_TYPES.values()) { for (var type : NaturesAuraAPI.AURA_TYPES.values()) {
var stack = new ItemStack(this); var stack = new ItemStack(this);
setType(stack, type); ItemAuraBottle.setType(stack, type);
items.add(stack); items.add(stack);
} }
} }
@ -82,13 +81,13 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu
@Override @Override
public Component getName(ItemStack stack) { public Component getName(ItemStack stack) {
return new TranslatableComponent(stack.getDescriptionId() + "." + getType(stack).getName()); return Component.translatable(stack.getDescriptionId() + "." + ItemAuraBottle.getType(stack).getName());
} }
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public ItemColor getItemColor() { public ItemColor getItemColor() {
return (stack, tintIndex) -> tintIndex > 0 ? getType(stack).getColor() : 0xFFFFFF; return (stack, tintIndex) -> tintIndex > 0 ? ItemAuraBottle.getType(stack).getColor() : 0xFFFFFF;
} }
@Override @Override
@ -106,7 +105,7 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu
if (held.isEmpty() || held.getItem() != ModItems.BOTTLE_TWO_THE_REBOTTLING) if (held.isEmpty() || held.getItem() != ModItems.BOTTLE_TWO_THE_REBOTTLING)
return; return;
var player = event.getPlayer(); var player = event.getPlayer();
HitResult ray = getPlayerPOVHitResult(player.level, player, ClipContext.Fluid.NONE); HitResult ray = Item.getPlayerPOVHitResult(player.level, player, ClipContext.Fluid.NONE);
if (ray.getType() == HitResult.Type.BLOCK) if (ray.getType() == HitResult.Type.BLOCK)
return; return;
var pos = player.blockPosition(); var pos = player.blockPosition();
@ -116,7 +115,7 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu
if (!player.level.isClientSide) { if (!player.level.isClientSide) {
held.shrink(1); held.shrink(1);
player.getInventory().add(setType(new ItemStack(ItemAuraBottle.this), IAuraType.forLevel(player.level))); player.getInventory().add(ItemAuraBottle.setType(new ItemStack(ItemAuraBottle.this), IAuraType.forLevel(player.level)));
var spot = IAuraChunk.getHighestSpot(player.level, pos, 30, pos); var spot = IAuraChunk.getHighestSpot(player.level, pos, 30, pos);
IAuraChunk.getAuraChunk(player.level, spot).drainAura(spot, 20000); IAuraChunk.getAuraChunk(player.level, spot).drainAura(spot, 20000);

View file

@ -66,7 +66,7 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem {
@Override @Override
public void fillItemCategory(CreativeModeTab tab, NonNullList<ItemStack> items) { public void fillItemCategory(CreativeModeTab tab, NonNullList<ItemStack> items) {
if (this.allowdedIn(tab)) { if (this.allowedIn(tab)) {
items.add(new ItemStack(this)); items.add(new ItemStack(this));
var stack = new ItemStack(this); var stack = new ItemStack(this);
@ -86,7 +86,7 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem {
public int getBarWidth(ItemStack stack) { public int getBarWidth(ItemStack stack) {
if (stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).isPresent()) { if (stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).isPresent()) {
var container = stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).orElse(null); var container = stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).orElse(null);
return Math.round((container.getStoredAura() / (float) container.getMaxAura()) * 13); return Math.round(container.getStoredAura() / (float) container.getMaxAura() * 13);
} }
return 0; return 0;
} }

View file

@ -5,10 +5,7 @@ import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.Style; import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ElytraItem; import net.minecraft.world.item.ElytraItem;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
@ -17,8 +14,6 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import java.util.List;
public class ItemBreakPrevention extends ItemImpl { public class ItemBreakPrevention extends ItemImpl {
public ItemBreakPrevention() { public ItemBreakPrevention() {
@ -63,14 +58,14 @@ public class ItemBreakPrevention extends ItemImpl {
if (!stack.hasTag() || !stack.getTag().getBoolean(NaturesAura.MOD_ID + ":break_prevention")) if (!stack.hasTag() || !stack.getTag().getBoolean(NaturesAura.MOD_ID + ":break_prevention"))
return; return;
var tooltip = event.getToolTip(); var tooltip = event.getToolTip();
tooltip.add(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".break_prevention").setStyle(Style.EMPTY.applyFormat(ChatFormatting.GRAY))); tooltip.add(Component.translatable("info." + NaturesAura.MOD_ID + ".break_prevention").setStyle(Style.EMPTY.applyFormat(ChatFormatting.GRAY)));
if (ElytraItem.isFlyEnabled(stack)) if (ElytraItem.isFlyEnabled(stack))
return; return;
if (tooltip.size() < 1) if (tooltip.size() < 1)
return; return;
var head = tooltip.get(0); var head = tooltip.get(0);
if (head instanceof MutableComponent) if (head instanceof MutableComponent)
((MutableComponent) head).append(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".broken").setStyle(Style.EMPTY.applyFormat(ChatFormatting.GRAY))); ((MutableComponent) head).append(Component.translatable("info." + NaturesAura.MOD_ID + ".broken").setStyle(Style.EMPTY.applyFormat(ChatFormatting.GRAY)));
} }
} }
} }

View file

@ -37,13 +37,13 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, I
return false; return false;
var color = DyeColor.byId(blocks.indexOf(block)); var color = DyeColor.byId(blocks.indexOf(block));
if (firstColor == null || color == firstColor) { if (firstColor == null || color == firstColor) {
var stored = getStoredColor(stack); var stored = ItemColorChanger.getStoredColor(stack);
if (player.isCrouching()) { if (player.isCrouching()) {
if (stored != color) { if (stored != color) {
level.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, level.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
SoundEvents.BUCKET_FILL, SoundSource.PLAYERS, 0.65F, 1F); SoundEvents.BUCKET_FILL, SoundSource.PLAYERS, 0.65F, 1F);
if (!level.isClientSide) if (!level.isClientSide)
storeColor(stack, color); ItemColorChanger.storeColor(stack, color);
return true; return true;
} }
} else { } else {
@ -56,9 +56,9 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, I
if (!level.isClientSide) { if (!level.isClientSide) {
level.setBlockAndUpdate(pos, blocks.get(stored.getId()).defaultBlockState()); level.setBlockAndUpdate(pos, blocks.get(stored.getId()).defaultBlockState());
if (isFillMode(stack)) { if (ItemColorChanger.isFillMode(stack)) {
for (var off : Direction.values()) { for (var off : Direction.values()) {
changeOrCopyColor(player, stack, level, pos.relative(off), color); ItemColorChanger.changeOrCopyColor(player, stack, level, pos.relative(off), color);
} }
} }
} }
@ -98,7 +98,7 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, I
@Override @Override
public InteractionResult useOn(UseOnContext context) { public InteractionResult useOn(UseOnContext context) {
var stack = context.getPlayer().getItemInHand(context.getHand()); var stack = context.getPlayer().getItemInHand(context.getHand());
if (changeOrCopyColor(context.getPlayer(), stack, context.getLevel(), context.getClickedPos(), null)) { if (ItemColorChanger.changeOrCopyColor(context.getPlayer(), stack, context.getLevel(), context.getClickedPos(), null)) {
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} else { } else {
return InteractionResult.PASS; return InteractionResult.PASS;
@ -108,10 +108,10 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, I
@Override @Override
public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, InteractionHand handIn) { public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, InteractionHand handIn) {
var stack = playerIn.getItemInHand(handIn); var stack = playerIn.getItemInHand(handIn);
if (playerIn.isCrouching() && getStoredColor(stack) != null) { if (playerIn.isCrouching() && ItemColorChanger.getStoredColor(stack) != null) {
levelIn.playSound(playerIn, playerIn.getX(), playerIn.getY(), playerIn.getZ(), SoundEvents.BUCKET_FILL_LAVA, SoundSource.PLAYERS, 0.65F, 1F); levelIn.playSound(playerIn, playerIn.getX(), playerIn.getY(), playerIn.getZ(), SoundEvents.BUCKET_FILL_LAVA, SoundSource.PLAYERS, 0.65F, 1F);
if (!levelIn.isClientSide) { if (!levelIn.isClientSide) {
setFillMode(stack, !isFillMode(stack)); ItemColorChanger.setFillMode(stack, !ItemColorChanger.isFillMode(stack));
} }
return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack); return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack);
} else { } else {
@ -124,7 +124,7 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, I
public ItemColor getItemColor() { public ItemColor getItemColor() {
return (stack, tintIndex) -> { return (stack, tintIndex) -> {
if (tintIndex > 0) { if (tintIndex > 0) {
var color = getStoredColor(stack); var color = ItemColorChanger.getStoredColor(stack);
if (color != null) { if (color != null) {
return color.getFireworkColor(); return color.getFireworkColor();
} }

View file

@ -6,14 +6,11 @@ import de.ellpeck.naturesaura.reg.IColorProvidingItem;
import net.minecraft.client.color.item.ItemColor; import net.minecraft.client.color.item.ItemColor;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@ -51,10 +48,10 @@ public class ItemEffectPowder extends ItemImpl implements IColorProvidingItem {
@Override @Override
public void fillItemCategory(CreativeModeTab tab, NonNullList<ItemStack> items) { public void fillItemCategory(CreativeModeTab tab, NonNullList<ItemStack> items) {
if (this.allowdedIn(tab)) { if (this.allowedIn(tab)) {
for (var effect : NaturesAuraAPI.EFFECT_POWDERS.keySet()) { for (var effect : NaturesAuraAPI.EFFECT_POWDERS.keySet()) {
var stack = new ItemStack(this); var stack = new ItemStack(this);
setEffect(stack, effect); ItemEffectPowder.setEffect(stack, effect);
items.add(stack); items.add(stack);
} }
} }
@ -62,12 +59,12 @@ public class ItemEffectPowder extends ItemImpl implements IColorProvidingItem {
@Override @Override
public Component getName(ItemStack stack) { public Component getName(ItemStack stack) {
return new TranslatableComponent(this.getDescriptionId(stack) + "." + getEffect(stack)); return Component.translatable(this.getDescriptionId(stack) + "." + ItemEffectPowder.getEffect(stack));
} }
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public ItemColor getItemColor() { public ItemColor getItemColor() {
return (stack, tintIndex) -> NaturesAuraAPI.EFFECT_POWDERS.getOrDefault(getEffect(stack), 0xFFFFFF); return (stack, tintIndex) -> NaturesAuraAPI.EFFECT_POWDERS.getOrDefault(ItemEffectPowder.getEffect(stack), 0xFFFFFF);
} }
} }

View file

@ -9,7 +9,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.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
@ -46,7 +45,7 @@ public class ItemEnderAccess extends ItemImpl {
NetworkHooks.openGui((ServerPlayer) playerIn, new MenuProvider() { NetworkHooks.openGui((ServerPlayer) playerIn, new MenuProvider() {
@Override @Override
public Component getDisplayName() { public Component getDisplayName() {
return new TranslatableComponent("info." + NaturesAura.MOD_ID + ".ender_access", ChatFormatting.ITALIC + name + ChatFormatting.RESET); return Component.translatable("info." + NaturesAura.MOD_ID + ".ender_access", ChatFormatting.ITALIC + name + ChatFormatting.RESET);
} }
@Nullable @Nullable

View file

@ -16,7 +16,7 @@ public class ItemImpl extends Item implements IModItem {
public ItemImpl(String baseName, Item.Properties properties) { public ItemImpl(String baseName, Item.Properties properties) {
super(properties.tab(NaturesAura.CREATIVE_TAB)); super(properties.tab(NaturesAura.CREATIVE_TAB));
this.baseName = baseName; this.baseName = baseName;
ModRegistry.add(this); ModRegistry.ALL_ITEMS.add(this);
} }
@Override @Override

View file

@ -28,8 +28,8 @@ public class ItemMultiblockMaker extends ItemImpl {
public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, InteractionHand handIn) { public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, InteractionHand handIn) {
var stack = playerIn.getItemInHand(handIn); var stack = playerIn.getItemInHand(handIn);
if (!levelIn.isClientSide && playerIn.isCreative()) { if (!levelIn.isClientSide && playerIn.isCreative()) {
var curr = getMultiblockId(stack); var curr = ItemMultiblockMaker.getMultiblockId(stack);
var next = (curr + 1) % multiblocks().size(); var next = (curr + 1) % ItemMultiblockMaker.multiblocks().size();
stack.getOrCreateTag().putInt("multiblock", next); stack.getOrCreateTag().putInt("multiblock", next);
} }
return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack); return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack);
@ -39,7 +39,7 @@ public class ItemMultiblockMaker extends ItemImpl {
public InteractionResult useOn(UseOnContext context) { public InteractionResult useOn(UseOnContext context) {
var player = context.getPlayer(); var player = context.getPlayer();
if (player.isCreative()) { if (player.isCreative()) {
var multi = getMultiblock(player.getItemInHand(context.getHand())); var multi = ItemMultiblockMaker.getMultiblock(player.getItemInHand(context.getHand()));
if (multi == null) if (multi == null)
return InteractionResult.PASS; return InteractionResult.PASS;
@ -57,19 +57,19 @@ public class ItemMultiblockMaker extends ItemImpl {
@Override @Override
public Component getName(ItemStack stack) { public Component getName(ItemStack stack) {
var name = (MutableComponent) super.getName(stack); var name = (MutableComponent) super.getName(stack);
var multi = getMultiblock(stack); var multi = ItemMultiblockMaker.getMultiblock(stack);
return multi == null ? name : name.append(" (" + multi.getName() + ")"); return multi == null ? name : name.append(" (" + multi.getName() + ")");
} }
private static List<IMultiblock> multiblocks() { private static List<IMultiblock> multiblocks() {
if (multiblocks == null) { if (ItemMultiblockMaker.multiblocks == null) {
// some weird mixins call getName way too early, before multiblocks are initialized // some weird mixins call getName way too early, before multiblocks are initialized
if (NaturesAuraAPI.MULTIBLOCKS.isEmpty()) if (NaturesAuraAPI.MULTIBLOCKS.isEmpty())
return null; return null;
multiblocks = new ArrayList<>(); ItemMultiblockMaker.multiblocks = new ArrayList<>();
multiblocks.addAll(NaturesAuraAPI.MULTIBLOCKS.values()); ItemMultiblockMaker.multiblocks.addAll(NaturesAuraAPI.MULTIBLOCKS.values());
} }
return multiblocks; return ItemMultiblockMaker.multiblocks;
} }
private static int getMultiblockId(ItemStack stack) { private static int getMultiblockId(ItemStack stack) {
@ -79,10 +79,10 @@ public class ItemMultiblockMaker extends ItemImpl {
} }
private static IMultiblock getMultiblock(ItemStack stack) { private static IMultiblock getMultiblock(ItemStack stack) {
var multiblocks = multiblocks(); var multiblocks = ItemMultiblockMaker.multiblocks();
if (multiblocks == null) if (multiblocks == null)
return null; return null;
var id = getMultiblockId(stack); var id = ItemMultiblockMaker.getMultiblockId(stack);
if (id < 0 || id >= multiblocks.size()) if (id < 0 || id >= multiblocks.size())
return null; return null;
return multiblocks.get(id); return multiblocks.get(id);

View file

@ -9,7 +9,7 @@ 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;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.registries.ForgeRegistries;
public class ItemNetheriteFinder extends ItemImpl { public class ItemNetheriteFinder extends ItemImpl {
@ -35,7 +35,7 @@ public class ItemNetheriteFinder extends ItemImpl {
for (var z = -range; z <= range; z++) { for (var z = -range; z <= range; z++) {
var offset = new BlockPos(pos.getX() + x, y, pos.getZ() + z); var offset = new BlockPos(pos.getX() + x, y, pos.getZ() + z);
var state = levelIn.getBlockState(offset); var state = levelIn.getBlockState(offset);
if (state.getBlock() == Blocks.ANCIENT_DEBRIS || state.getBlock().getRegistryName().toString().contains("netherite")) { if (state.getBlock() == Blocks.ANCIENT_DEBRIS || ForgeRegistries.BLOCKS.getKey(state.getBlock()).toString().contains("netherite")) {
inst.spawnMagicParticle( inst.spawnMagicParticle(
offset.getX() + 0.5F, offset.getY() + 0.5F, offset.getZ() + 0.5F, offset.getX() + 0.5F, offset.getY() + 0.5F, offset.getZ() + 0.5F,
0F, 0F, 0F, 0xab4d38, 6F, 20 * 60, 0F, false, true); 0F, 0F, 0F, 0xab4d38, 6F, 20 * 60, 0F, false, true);

View file

@ -5,17 +5,14 @@ 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.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes; import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.TamableAnimal; import net.minecraft.world.entity.TamableAnimal;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent;
@ -24,9 +21,6 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import java.util.Optional;
import java.util.UUID;
public class ItemPetReviver extends ItemImpl { public class ItemPetReviver extends ItemImpl {
public ItemPetReviver() { public ItemPetReviver() {
@ -105,7 +99,7 @@ public class ItemPetReviver extends ItemImpl {
var spawnedPet = tameable; var spawnedPet = tameable;
if (tameable.level != spawnLevel) { if (tameable.level != spawnLevel) {
((ServerLevel) tameable.level).removeEntity(tameable, true); tameable.remove(Entity.RemovalReason.DISCARDED);
spawnedPet = (TamableAnimal) tameable.getType().create(spawnLevel); spawnedPet = (TamableAnimal) tameable.getType().create(spawnLevel);
} }
// respawn (a copy of) the pet // respawn (a copy of) the pet
@ -132,7 +126,7 @@ public class ItemPetReviver extends ItemImpl {
PacketHandler.sendToAllAround(spawnedPet.level, spawnedPet.blockPosition(), 32, new PacketParticles((float) spawnedPet.getX(), (float) spawnedPet.getEyeY(), (float) spawnedPet.getZ(), PacketParticles.Type.PET_REVIVER, 0x4dba2f)); PacketHandler.sendToAllAround(spawnedPet.level, spawnedPet.blockPosition(), 32, new PacketParticles((float) spawnedPet.getX(), (float) spawnedPet.getEyeY(), (float) spawnedPet.getZ(), PacketParticles.Type.PET_REVIVER, 0x4dba2f));
if (owner instanceof Player) if (owner instanceof Player)
owner.sendMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".pet_reviver", spawnedPet.getDisplayName()).withStyle(ChatFormatting.ITALIC, ChatFormatting.GRAY), UUID.randomUUID()); owner.sendSystemMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".pet_reviver", spawnedPet.getDisplayName()).withStyle(ChatFormatting.ITALIC, ChatFormatting.GRAY));
event.setCanceled(true); event.setCanceled(true);
} }
} }

View file

@ -5,7 +5,7 @@ import com.google.common.collect.ListMultimap;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.render.IVisualizable; import de.ellpeck.naturesaura.api.render.IVisualizable;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
@ -15,8 +15,6 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.item.context.UseOnContext;
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.state.BlockState;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
@ -33,21 +31,21 @@ public class ItemRangeVisualizer extends ItemImpl {
} }
public static void clear() { public static void clear() {
if (!VISUALIZED_BLOCKS.isEmpty()) if (!ItemRangeVisualizer.VISUALIZED_BLOCKS.isEmpty())
VISUALIZED_BLOCKS.clear(); ItemRangeVisualizer.VISUALIZED_BLOCKS.clear();
if (!VISUALIZED_ENTITIES.isEmpty()) if (!ItemRangeVisualizer.VISUALIZED_ENTITIES.isEmpty())
VISUALIZED_ENTITIES.clear(); ItemRangeVisualizer.VISUALIZED_ENTITIES.clear();
if (!VISUALIZED_RAILS.isEmpty()) if (!ItemRangeVisualizer.VISUALIZED_RAILS.isEmpty())
VISUALIZED_RAILS.clear(); ItemRangeVisualizer.VISUALIZED_RAILS.clear();
} }
public static <T> void visualize(Player player, ListMultimap<ResourceLocation, T> map, ResourceLocation dim, T value) { public static <T> void visualize(Player player, ListMultimap<ResourceLocation, T> map, ResourceLocation dim, T value) {
if (map.containsEntry(dim, value)) { if (map.containsEntry(dim, value)) {
map.remove(dim, value); map.remove(dim, value);
player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".range_visualizer.end"), true); player.displayClientMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".range_visualizer.end"), true);
} else { } else {
map.put(dim, value); map.put(dim, value);
player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".range_visualizer.start"), true); player.displayClientMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".range_visualizer.start"), true);
} }
} }
@ -55,8 +53,8 @@ public class ItemRangeVisualizer extends ItemImpl {
public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, InteractionHand handIn) { public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, InteractionHand handIn) {
var stack = playerIn.getItemInHand(handIn); var stack = playerIn.getItemInHand(handIn);
if (playerIn.isCrouching()) { if (playerIn.isCrouching()) {
clear(); ItemRangeVisualizer.clear();
playerIn.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".range_visualizer.end_all"), true); playerIn.displayClientMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".range_visualizer.end_all"), true);
return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack); return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack);
} }
return new InteractionResultHolder<>(InteractionResult.PASS, stack); return new InteractionResultHolder<>(InteractionResult.PASS, stack);
@ -70,7 +68,7 @@ public class ItemRangeVisualizer extends ItemImpl {
var block = state.getBlock(); var block = state.getBlock();
if (block instanceof IVisualizable) { if (block instanceof IVisualizable) {
if (level.isClientSide) if (level.isClientSide)
visualize(context.getPlayer(), VISUALIZED_BLOCKS, level.dimension().location(), pos); ItemRangeVisualizer.visualize(context.getPlayer(), ItemRangeVisualizer.VISUALIZED_BLOCKS, level.dimension().location(), pos);
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }
return InteractionResult.PASS; return InteractionResult.PASS;
@ -87,7 +85,7 @@ public class ItemRangeVisualizer extends ItemImpl {
if (entity instanceof IVisualizable) { if (entity instanceof IVisualizable) {
if (entity.level.isClientSide) { if (entity.level.isClientSide) {
var dim = entity.level.dimension().location(); var dim = entity.level.dimension().location();
visualize(event.getPlayer(), VISUALIZED_ENTITIES, dim, entity); ItemRangeVisualizer.visualize(event.getPlayer(), ItemRangeVisualizer.VISUALIZED_ENTITIES, dim, entity);
} }
event.getPlayer().swing(event.getHand()); event.getPlayer().swing(event.getHand());
event.setCancellationResult(InteractionResult.SUCCESS); event.setCancellationResult(InteractionResult.SUCCESS);

Some files were not shown because too many files have changed in this diff Show more