IT C O M P I L E S

This commit is contained in:
Ell 2021-12-15 16:24:53 +01:00
parent 584514944b
commit 24cf4ae186
101 changed files with 1534 additions and 1555 deletions

View file

@ -23,6 +23,7 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.Property; import net.minecraft.world.level.block.state.properties.Property;
@ -51,7 +52,7 @@ import java.util.function.Predicate;
public final class Helper { public final class Helper {
public static boolean getBlockEntitiesInArea(Level 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 = getLoadedChunk(level, x, z);
@ -89,7 +90,7 @@ public final class Helper {
return frames; return frames;
} }
public static LevelChunk getLoadedChunk(Level level, int x, int z) { public static LevelChunk getLoadedChunk(LevelAccessor level, int x, int z) {
// DO NOT EDIT PLEASE FOR THE LOVE OF GOD // DO NOT EDIT PLEASE FOR THE LOVE OF GOD
// This is very finicky and easily causes the game to hang for some reason // This is very finicky and easily causes the game to hang for some reason
var provider = level.getChunkSource(); var provider = level.getChunkSource();

View file

@ -2,10 +2,6 @@ package de.ellpeck.naturesaura;
import com.google.common.base.Strings; import com.google.common.base.Strings;
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.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
import de.ellpeck.naturesaura.api.misc.ILevelData;
import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.chunk.effect.DrainSpotEffects; import de.ellpeck.naturesaura.chunk.effect.DrainSpotEffects;
import de.ellpeck.naturesaura.compat.Compat; import de.ellpeck.naturesaura.compat.Compat;
@ -61,11 +57,6 @@ public final class NaturesAura {
} }
private void preInit(FMLCommonSetupEvent event) { private void preInit(FMLCommonSetupEvent event) {
Helper.registerCap(IAuraContainer.class);
Helper.registerCap(IAuraRecharge.class);
Helper.registerCap(IAuraChunk.class);
Helper.registerCap(ILevelData.class);
Compat.setup(event); Compat.setup(event);
PacketHandler.init(); PacketHandler.init();
new Multiblocks(); new Multiblocks();

View file

@ -51,7 +51,7 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali
LivingEntity entity = event.getEntityLiving(); LivingEntity entity = event.getEntityLiving();
if (entity.level.isClientSide || !(entity instanceof Animal) || entity instanceof Mob || entity instanceof Npc) if (entity.level.isClientSide || !(entity instanceof Animal) || entity instanceof Mob || entity instanceof Npc)
return; return;
BlockPos pos = entity.getOnPos(); BlockPos pos = entity.blockPosition();
Helper.getBlockEntitiesInArea(entity.level, pos, 5, tile -> { Helper.getBlockEntitiesInArea(entity.level, pos, 5, tile -> {
if (!(tile instanceof BlockEntityAnimalGenerator gen)) if (!(tile instanceof BlockEntityAnimalGenerator gen))
return false; return false;

View file

@ -84,6 +84,6 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS
@org.jetbrains.annotations.Nullable @org.jetbrains.annotations.Nullable
@Override @Override
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new BlockEntityAuraBloom(); return new BlockEntityAuraBloom(pos, state);
} }
} }

View file

@ -9,11 +9,10 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState;
import de.ellpeck.naturesaura.reg.ICustomRenderType; import de.ellpeck.naturesaura.reg.ICustomRenderType;
import de.ellpeck.naturesaura.reg.ITESRProvider; import de.ellpeck.naturesaura.reg.ITESRProvider;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; 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.Tuple;
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;
@ -21,7 +20,6 @@ import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.BlockStateProperties;
@ -51,11 +49,6 @@ public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockSt
return SHAPE; return SHAPE;
} }
@Override
public Tuple<BlockEntityType<? extends BlockEntityAuraTimer>, Supplier<BlockEntityRendererProvider<BlockEntityAuraTimer>>> getTESR() {
return new Tuple<>(ModTileEntities.AURA_TIMER, () -> RenderAuraTimer::new);
}
@Override @Override
public Supplier<RenderType> getRenderType() { public Supplier<RenderType> getRenderType() {
return RenderType::cutout; return RenderType::cutout;
@ -88,4 +81,8 @@ public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockSt
levelIn.setBlockAndUpdate(pos, state.setValue(BlockStateProperties.POWERED, false)); levelIn.setBlockAndUpdate(pos, state.setValue(BlockStateProperties.POWERED, false));
} }
@Override
public void registerTESR() {
BlockEntityRenderers.register(ModTileEntities.AURA_TIMER, RenderAuraTimer::new);
}
} }

View file

@ -10,15 +10,13 @@ import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import de.ellpeck.naturesaura.reg.ITESRProvider; import de.ellpeck.naturesaura.reg.ITESRProvider;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.resources.language.I18n; 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.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.Tuple;
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;
@ -29,7 +27,6 @@ import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
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.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
@ -43,8 +40,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; import java.util.Random;
import java.util.function.Function;
import java.util.function.Supplier;
public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider<BlockEntityEnderCrate>, ICustomBlockState { public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider<BlockEntityEnderCrate>, ICustomBlockState {
@ -127,11 +122,6 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
} }
} }
@Override
public Tuple<BlockEntityType<BlockEntityEnderCrate>, Supplier<Function<? super BlockEntityRenderDispatcher, ? extends BlockEntityRenderer<? super BlockEntityEnderCrate>>>> getTESR() {
return new Tuple<>(ModTileEntities.ENDER_CRATE, () -> RenderEnderCrate::new);
}
@Override @Override
public void generateCustomBlockState(BlockStateGenerator generator) { public void generateCustomBlockState(BlockStateGenerator generator) {
generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(), generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(),
@ -139,4 +129,9 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
generator.modLoc("block/" + this.getBaseName() + "_bottom"), generator.modLoc("block/" + this.getBaseName() + "_bottom"),
generator.modLoc("block/" + this.getBaseName() + "_top"))); generator.modLoc("block/" + this.getBaseName() + "_top")));
} }
@Override
public void registerTESR() {
BlockEntityRenderers.register(ModTileEntities.ENDER_CRATE, RenderEnderCrate::new);
}
} }

View file

@ -6,25 +6,16 @@ import de.ellpeck.naturesaura.blocks.tiles.render.RenderGeneratorLimitRemover;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import de.ellpeck.naturesaura.reg.ITESRProvider; import de.ellpeck.naturesaura.reg.ITESRProvider;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraft.util.Tuple;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import java.util.function.Supplier;
public class BlockGeneratorLimitRemover extends BlockContainerImpl implements ITESRProvider<BlockEntityGeneratorLimitRemover>, ICustomBlockState { public class BlockGeneratorLimitRemover extends BlockContainerImpl implements ITESRProvider<BlockEntityGeneratorLimitRemover>, ICustomBlockState {
public BlockGeneratorLimitRemover() { public BlockGeneratorLimitRemover() {
super("generator_limit_remover", BlockEntityGeneratorLimitRemover::new, Properties.of(Material.STONE).strength(2F).sound(SoundType.STONE)); super("generator_limit_remover", BlockEntityGeneratorLimitRemover::new, Properties.of(Material.STONE).strength(2F).sound(SoundType.STONE));
} }
@Override
public Tuple<BlockEntityType<? extends BlockEntityGeneratorLimitRemover>, Supplier<BlockEntityRendererProvider<BlockEntityGeneratorLimitRemover>>> getTESR() {
return new Tuple<>(ModTileEntities.GENERATOR_LIMIT_REMOVER, () -> RenderGeneratorLimitRemover::new);
}
@Override @Override
public void generateCustomBlockState(BlockStateGenerator generator) { public void generateCustomBlockState(BlockStateGenerator generator) {
generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(), generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(),
@ -32,4 +23,9 @@ public class BlockGeneratorLimitRemover extends BlockContainerImpl implements IT
generator.modLoc("block/" + this.getBaseName() + "_top"), generator.modLoc("block/" + this.getBaseName() + "_top"),
generator.modLoc("block/" + this.getBaseName() + "_top"))); generator.modLoc("block/" + this.getBaseName() + "_top")));
} }
@Override
public void registerTESR() {
BlockEntityRenderers.register(ModTileEntities.GENERATOR_LIMIT_REMOVER, RenderGeneratorLimitRemover::new);
}
} }

View file

@ -3,25 +3,25 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityItemDistributor; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityItemDistributor;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.BlockState; import net.minecraft.core.BlockPos;
import net.minecraft.block.Blocks; import net.minecraft.world.InteractionHand;
import net.minecraft.entity.player.Player; import net.minecraft.world.InteractionResult;
import net.minecraft.tileentity.BlockEntity; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.InteractionResult; import net.minecraft.world.level.Level;
import net.minecraft.util.Hand; import net.minecraft.world.level.block.Blocks;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.level.Level; import net.minecraft.world.phys.BlockHitResult;
public class BlockItemDistributor extends BlockContainerImpl implements ICustomBlockState { public class BlockItemDistributor extends BlockContainerImpl implements ICustomBlockState {
public BlockItemDistributor() { public BlockItemDistributor() {
super("item_distributor", BlockEntityItemDistributor::new, Properties.from(Blocks.STONE_BRICKS)); super("item_distributor", BlockEntityItemDistributor::new, Properties.copy(Blocks.STONE_BRICKS));
} }
@Override @Override
public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult hit) { public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
if (!player.isSneaking()) if (!player.isCrouching())
return InteractionResult.FAIL; return InteractionResult.FAIL;
BlockEntity tile = levelIn.getBlockEntity(pos); BlockEntity tile = levelIn.getBlockEntity(pos);
if (!(tile instanceof BlockEntityItemDistributor)) if (!(tile instanceof BlockEntityItemDistributor))

View file

@ -5,15 +5,15 @@ import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import de.ellpeck.naturesaura.reg.ICustomRenderType; import de.ellpeck.naturesaura.reg.ICustomRenderType;
import de.ellpeck.naturesaura.reg.INoItemBlock; import de.ellpeck.naturesaura.reg.INoItemBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.item.BlockItemUseContext; import net.minecraft.core.BlockPos;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.world.level.BlockGetter;
import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.level.Level;
import net.minecraft.level.BlockGetter; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.level.Level; import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.shapes.CollisionContext;
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;
@ -22,10 +22,10 @@ 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 = makeCuboidShape(4, 4, 4, 12, 12, 12); private static final VoxelShape SHAPE = box(4, 4, 4, 12, 12, 12);
public BlockLight() { public BlockLight() {
super("light", Properties.create(Material.WOOL).doesNotBlockMovement().setLightLevel(s -> 15)); super("light", Properties.of(Material.WOOL).noCollission().lightLevel(s -> 15));
} }
@Override @Override
@ -39,12 +39,12 @@ public class BlockLight extends BlockImpl implements ICustomBlockState, INoItemB
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
return SHAPE; return SHAPE;
} }
@Override @Override
public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) { public boolean canBeReplaced(BlockState state, BlockPlaceContext useContext) {
return true; return true;
} }
@ -56,6 +56,6 @@ public class BlockLight extends BlockImpl implements ICustomBlockState, INoItemB
@Override @Override
public Supplier<RenderType> getRenderType() { public Supplier<RenderType> getRenderType() {
return RenderType::getCutoutMipped; return RenderType::cutoutMipped;
} }
} }

View file

@ -2,23 +2,24 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.render.IVisualizable; import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityMossGenerator; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityMossGenerator;
import net.minecraft.block.SoundType; import net.minecraft.core.BlockPos;
import net.minecraft.block.material.Material; import net.minecraft.world.level.Level;
import net.minecraft.util.math.AABB; import net.minecraft.world.level.block.SoundType;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.material.Material;
import net.minecraft.level.Level; import net.minecraft.world.phys.AABB;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockMossGenerator extends BlockContainerImpl implements IVisualizable { public class BlockMossGenerator extends BlockContainerImpl implements IVisualizable {
public BlockMossGenerator() { public BlockMossGenerator() {
super("moss_generator", BlockEntityMossGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE)); super("moss_generator", BlockEntityMossGenerator::new, Properties.of(Material.STONE).strength(2.5F).sound(SoundType.STONE));
} }
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public AABB getVisualizationBounds(Level level, BlockPos pos) { public AABB getVisualizationBounds(Level level, BlockPos pos) {
return new AABB(pos).grow(2); return new AABB(pos).inflate(2);
} }
@Override @Override

View file

@ -9,32 +9,25 @@ import de.ellpeck.naturesaura.blocks.tiles.render.RenderNatureAltar;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import de.ellpeck.naturesaura.reg.ITESRProvider; import de.ellpeck.naturesaura.reg.ITESRProvider;
import net.minecraft.block.Block; import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer;
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.entity.player.Player; import net.minecraft.world.InteractionHand;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.BlockEntityType;
import net.minecraft.util.Hand;
import net.minecraft.util.Tuple;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
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.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.common.ToolType;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.function.Function;
import java.util.function.Supplier;
public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvider<BlockEntityNatureAltar>, ICustomBlockState { public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvider<BlockEntityNatureAltar>, ICustomBlockState {
@ -42,8 +35,8 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide
public static final BooleanProperty NETHER = BooleanProperty.create("nether"); public static final BooleanProperty NETHER = BooleanProperty.create("nether");
public BlockNatureAltar() { public BlockNatureAltar() {
super("nature_altar", BlockEntityNatureAltar::new, Block.Properties.create(Material.ROCK).hardnessAndResistance(4F).harvestLevel(1).harvestTool(ToolType.PICKAXE)); super("nature_altar", BlockEntityNatureAltar::new, Block.Properties.of(Material.STONE).strength(4F));
this.setDefaultState(this.getDefaultState().with(NETHER, false)); this.registerDefaultState(this.defaultBlockState().setValue(NETHER, false));
} }
@Override @Override
@ -58,30 +51,30 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide
@Override @Override
public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult hit) { public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
return Helper.putStackOnTile(player, handIn, pos, 0, true); return Helper.putStackOnTile(player, handIn, pos, 0, true);
} }
@Override
public Tuple<BlockEntityType<BlockEntityNatureAltar>, Supplier<Function<? super BlockEntityRenderDispatcher, ? extends BlockEntityRenderer<? super BlockEntityNatureAltar>>>> getTESR() {
return new Tuple<>(ModTileEntities.NATURE_ALTAR, () -> RenderNatureAltar::new);
}
@Override @Override
public void generateCustomBlockState(BlockStateGenerator generator) { public void generateCustomBlockState(BlockStateGenerator generator) {
// noop // noop
} }
@Override @Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder); super.createBlockStateDefinition(builder);
builder.add(NETHER); builder.add(NETHER);
} }
@Nullable @Nullable
@Override @Override
public BlockState getStateForPlacement(BlockItemUseContext context) { public BlockState getStateForPlacement(BlockPlaceContext context) {
boolean nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER); boolean nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER);
return super.getStateForPlacement(context).with(NETHER, nether); return super.getStateForPlacement(context).setValue(NETHER, nether);
}
@Override
public void registerTESR() {
BlockEntityRenderers.register(ModTileEntities.NATURE_ALTAR, RenderNatureAltar::new);
} }
} }

View file

@ -2,29 +2,29 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.BlockState; import net.minecraft.core.BlockPos;
import net.minecraft.block.Blocks; import net.minecraft.core.Direction;
import net.minecraft.block.IGrowable; import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Direction; import net.minecraft.world.level.BlockGetter;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.Level;
import net.minecraft.level.BlockGetter; import net.minecraft.world.level.block.Blocks;
import net.minecraft.level.Level; import net.minecraft.world.level.block.BonemealableBlock;
import net.minecraft.level.server.ServerLevel; import net.minecraft.world.level.block.state.BlockState;
import java.util.Random; import java.util.Random;
public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, IGrowable { public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, BonemealableBlock {
public BlockNetherGrass() { public BlockNetherGrass() {
super("nether_grass", Properties.from(Blocks.NETHERRACK).tickRandomly()); super("nether_grass", Properties.copy(Blocks.NETHERRACK).randomTicks());
} }
@Override @Override
public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) { public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) {
BlockPos up = pos.up(); BlockPos up = pos.above();
BlockState upState = levelIn.getBlockState(up); BlockState upState = levelIn.getBlockState(up);
if (upState.isSolidSide(levelIn, up, Direction.DOWN)) if (upState.isFaceSturdy(levelIn, up, Direction.DOWN))
levelIn.setBlockState(pos, Blocks.NETHERRACK.getDefaultState()); levelIn.setBlockAndUpdate(pos, Blocks.NETHERRACK.defaultBlockState());
} }
@Override @Override
@ -36,19 +36,19 @@ public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, IG
} }
@Override @Override
public boolean canGrow(BlockGetter levelIn, BlockPos pos, BlockState state, boolean isClient) { public boolean isValidBonemealTarget(BlockGetter levelIn, BlockPos pos, BlockState state, boolean isClient) {
return levelIn.getBlockState(pos.up()).isAir(levelIn, pos.up()); return levelIn.getBlockState(pos.above()).isAir();
} }
@Override @Override
public boolean canUseBonemeal(Level levelIn, Random rand, BlockPos pos, BlockState state) { public boolean isBonemealSuccess(Level levelIn, Random rand, BlockPos pos, BlockState state) {
return true; return true;
} }
@Override @Override
public void grow(ServerLevel level, Random rand, BlockPos pos, BlockState state) { public void performBonemeal(ServerLevel level, Random rand, BlockPos pos, BlockState state) {
BlockPos blockpos = pos.up(); BlockPos blockpos = pos.above();
BlockState blockstate = Blocks.GRASS.getDefaultState(); BlockState blockstate = Blocks.GRASS.defaultBlockState();
for (int i = 0; i < 128; ++i) { for (int i = 0; i < 128; ++i) {
BlockPos blockpos1 = blockpos; BlockPos blockpos1 = blockpos;
@ -58,21 +58,21 @@ public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, IG
if (j >= i / 16) { if (j >= i / 16) {
BlockState blockstate2 = level.getBlockState(blockpos1); BlockState blockstate2 = level.getBlockState(blockpos1);
if (blockstate2.getBlock() == blockstate.getBlock() && rand.nextInt(10) == 0) { if (blockstate2.getBlock() == blockstate.getBlock() && rand.nextInt(10) == 0) {
((IGrowable) blockstate.getBlock()).grow(level, rand, blockpos1, blockstate2); ((BonemealableBlock) blockstate.getBlock()).performBonemeal(level, rand, blockpos1, blockstate2);
} }
if (!blockstate2.isAir()) { if (!blockstate2.isAir()) {
break; break;
} }
if (blockstate.isValidPosition(level, blockpos1)) { if (blockstate.canSurvive(level, blockpos1)) {
level.setBlockState(blockpos1, blockstate, 3); level.setBlock(blockpos1, blockstate, 3);
} }
break; break;
} }
blockpos1 = blockpos1.add(rand.nextInt(3) - 1, (rand.nextInt(3) - 1) * rand.nextInt(3) / 2, rand.nextInt(3) - 1); blockpos1 = blockpos1.offset(rand.nextInt(3) - 1, (rand.nextInt(3) - 1) * rand.nextInt(3) / 2, rand.nextInt(3) - 1);
if (level.getBlockState(blockpos1.down()).getBlock() != this || level.getBlockState(blockpos1).hasOpaqueCollisionShape(level, blockpos1)) { if (level.getBlockState(blockpos1.below()).getBlock() != this || level.getBlockState(blockpos1).isCollisionShapeFullBlock(level, blockpos1)) {
break; break;
} }

View file

@ -7,17 +7,16 @@ import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityOakGenerator; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityOakGenerator;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.SaplingBlock; import net.minecraft.core.BlockPos;
import net.minecraft.block.SoundType; import net.minecraft.world.level.Level;
import net.minecraft.block.material.Material; import net.minecraft.world.level.block.SaplingBlock;
import net.minecraft.util.math.AABB; import net.minecraft.world.level.block.SoundType;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.material.Material;
import net.minecraft.level.ILevel; import net.minecraft.world.phys.AABB;
import net.minecraft.level.Level;
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;
import net.minecraftforge.event.level.SaplingGrowTreeEvent; import net.minecraftforge.event.world.SaplingGrowTreeEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import java.util.Random; import java.util.Random;
@ -25,16 +24,16 @@ import java.util.Random;
public class BlockOakGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public class BlockOakGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockOakGenerator() { public BlockOakGenerator() {
super("oak_generator", BlockEntityOakGenerator::new, Properties.create(Material.WOOD).hardnessAndResistance(2F).sound(SoundType.WOOD)); super("oak_generator", BlockEntityOakGenerator::new, Properties.of(Material.WOOD).strength(2F).sound(SoundType.WOOD));
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }
@SubscribeEvent @SubscribeEvent
public void onTreeGrow(SaplingGrowTreeEvent event) { public void onTreeGrow(SaplingGrowTreeEvent event) {
ILevel level = event.getLevel(); var level = event.getWorld();
BlockPos pos = event.getPos(); BlockPos pos = event.getPos();
if (level instanceof Level && !level.isClientSide() && IAuraType.forLevel(level).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD) if (level instanceof Level && !level.isClientSide() && IAuraType.forLevel((Level) level).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD)
&& level.getBlockState(pos).getBlock() instanceof SaplingBlock) { && level.getBlockState(pos).getBlock() instanceof SaplingBlock) {
Helper.getBlockEntitiesInArea(level, pos, 10, tile -> { Helper.getBlockEntitiesInArea(level, pos, 10, tile -> {
if (!(tile instanceof BlockEntityOakGenerator)) if (!(tile instanceof BlockEntityOakGenerator))
@ -60,7 +59,7 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public AABB getVisualizationBounds(Level level, BlockPos pos) { public AABB getVisualizationBounds(Level level, BlockPos pos) {
return new AABB(pos).grow(10); return new AABB(pos).inflate(10);
} }
@Override @Override

View file

@ -1,39 +1,33 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityOfferingTable; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityOfferingTable;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderOfferingTable; import de.ellpeck.naturesaura.blocks.tiles.render.RenderOfferingTable;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import de.ellpeck.naturesaura.reg.ITESRProvider; import de.ellpeck.naturesaura.reg.ITESRProvider;
import net.minecraft.block.BlockState; import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraft.block.SoundType; import net.minecraft.core.BlockPos;
import net.minecraft.block.material.Material; import net.minecraft.world.InteractionHand;
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer; import net.minecraft.world.InteractionResult;
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher; import net.minecraft.world.entity.player.Player;
import net.minecraft.entity.player.Player; import net.minecraft.world.level.BlockGetter;
import net.minecraft.tileentity.BlockEntityType; import net.minecraft.world.level.Level;
import net.minecraft.util.InteractionResult; import net.minecraft.world.level.block.SoundType;
import net.minecraft.util.Hand; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.util.Tuple; import net.minecraft.world.level.material.Material;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.util.math.shapes.Shapes;
import net.minecraft.level.BlockGetter;
import net.minecraft.level.Level;
import java.util.function.Function;
import java.util.function.Supplier;
public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvider<BlockEntityOfferingTable>, ICustomBlockState { public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvider<BlockEntityOfferingTable>, ICustomBlockState {
private static final VoxelShape SHAPE = Shapes.create(2 / 16F, 0F, 2 / 16F, 14 / 16F, 1F, 14 / 16F); private static final VoxelShape SHAPE = Shapes.create(2 / 16F, 0F, 2 / 16F, 14 / 16F, 1F, 14 / 16F);
public BlockOfferingTable() { public BlockOfferingTable() {
super("offering_table", BlockEntityOfferingTable::new, Properties.create(Material.WOOD).hardnessAndResistance(2F).sound(SoundType.WOOD)); super("offering_table", BlockEntityOfferingTable::new, Properties.of(Material.WOOD).strength(2F).sound(SoundType.WOOD));
} }
@Override @Override
@ -42,22 +36,22 @@ public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvi
} }
@Override @Override
public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult hit) { public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
return Helper.putStackOnTile(player, handIn, pos, 0, true); return Helper.putStackOnTile(player, handIn, pos, 0, true);
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
return SHAPE; return SHAPE;
} }
@Override
public Tuple<BlockEntityType<BlockEntityOfferingTable>, Supplier<Function<? super BlockEntityRendererDispatcher, ? extends BlockEntityRenderer<? super BlockEntityOfferingTable>>>> getTESR() {
return new Tuple<>(ModTileEntities.OFFERING_TABLE, () -> RenderOfferingTable::new);
}
@Override @Override
public void generateCustomBlockState(BlockStateGenerator generator) { public void generateCustomBlockState(BlockStateGenerator generator) {
generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName()))); generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName())));
} }
@Override
public void registerTESR() {
BlockEntityRenderers.register(ModTileEntities.OFFERING_TABLE, RenderOfferingTable::new);
}
} }

View file

@ -7,14 +7,14 @@ import de.ellpeck.naturesaura.data.BlockStateGenerator;
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 de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.SoundType; import net.minecraft.core.BlockPos;
import net.minecraft.block.material.Material; import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player;
import net.minecraft.entity.player.Player; import net.minecraft.world.level.Level;
import net.minecraft.tileentity.BlockEntity; import net.minecraft.world.level.block.SoundType;
import net.minecraft.util.math.AABB; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.material.Material;
import net.minecraft.level.Level; import net.minecraft.world.phys.AABB;
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;
@ -22,8 +22,9 @@ import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
public class BlockPickupStopper extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public class BlockPickupStopper extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockPickupStopper() { public BlockPickupStopper() {
super("pickup_stopper", BlockEntityPickupStopper::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE)); super("pickup_stopper", BlockEntityPickupStopper::new, Properties.of(Material.STONE).strength(2F).sound(SoundType.STONE));
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }
@ -31,25 +32,24 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza
@SubscribeEvent @SubscribeEvent
public void onPickup(EntityItemPickupEvent event) { public void onPickup(EntityItemPickupEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (player != null && !player.isSneaking()) { if (player != null && !player.isCrouching()) {
ItemEntity item = event.getItem(); ItemEntity item = event.getItem();
BlockPos pos = item.getPosition(); BlockPos pos = item.blockPosition();
Helper.getBlockEntitiesInArea(item.level, pos, 8, tile -> { Helper.getBlockEntitiesInArea(item.level, pos, 8, tile -> {
if (!(tile instanceof BlockEntityPickupStopper)) if (!(tile instanceof BlockEntityPickupStopper stopper))
return false; return false;
BlockEntityPickupStopper stopper = (BlockEntityPickupStopper) tile;
float radius = stopper.getRadius(); float radius = stopper.getRadius();
if (radius <= 0F) if (radius <= 0F)
return false; return false;
BlockPos stopperPos = stopper.getPos(); BlockPos stopperPos = stopper.getBlockPos();
if (!new AABB(stopperPos).grow(radius).intersects(item.getBoundingBox())) if (!new AABB(stopperPos).inflate(radius).intersects(item.getBoundingBox()))
return false; return false;
event.setCanceled(true); event.setCanceled(true);
if (item.level.getGameTime() % 3 == 0) if (item.level.getGameTime() % 3 == 0)
PacketHandler.sendToAllAround(item.level, pos, 32, PacketHandler.sendToAllAround(item.level, pos, 32,
new PacketParticles((float) item.getPosX(), (float) item.getPosY(), (float) item.getPosZ(), PacketParticles.Type.PICKUP_STOPPER)); new PacketParticles((float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.PICKUP_STOPPER));
return true; return true;
}); });
} }
@ -62,7 +62,7 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza
if (tile instanceof BlockEntityPickupStopper) { if (tile instanceof BlockEntityPickupStopper) {
double radius = ((BlockEntityPickupStopper) tile).getRadius(); double radius = ((BlockEntityPickupStopper) tile).getRadius();
if (radius > 0) if (radius > 0)
return new AABB(pos).grow(radius); return new AABB(pos).inflate(radius);
} }
return null; return null;
} }

View file

@ -4,24 +4,24 @@ import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityPlacer; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityPlacer;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.SoundType; import net.minecraft.core.BlockPos;
import net.minecraft.block.material.Material; import net.minecraft.world.level.Level;
import net.minecraft.util.math.AABB; import net.minecraft.world.level.block.SoundType;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.material.Material;
import net.minecraft.level.Level; import net.minecraft.world.phys.AABB;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockPlacer extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public class BlockPlacer extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockPlacer() { public BlockPlacer() {
super("placer", BlockEntityPlacer::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE)); super("placer", BlockEntityPlacer::new, Properties.of(Material.STONE).strength(2.5F).sound(SoundType.STONE));
} }
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public AABB getVisualizationBounds(Level level, BlockPos pos) { public AABB getVisualizationBounds(Level level, BlockPos pos) {
return new AABB(pos).grow(5); return new AABB(pos).inflate(5);
} }
@Override @Override

View file

@ -3,12 +3,12 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityPotionGenerator; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityPotionGenerator;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.material.Material; import net.minecraft.world.level.material.Material;
import net.minecraftforge.common.ToolType;
public class BlockPotionGenerator extends BlockContainerImpl implements ICustomBlockState { public class BlockPotionGenerator extends BlockContainerImpl implements ICustomBlockState {
public BlockPotionGenerator() { public BlockPotionGenerator() {
super("potion_generator", BlockEntityPotionGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(5F).harvestTool(ToolType.PICKAXE).harvestLevel(1)); super("potion_generator", BlockEntityPotionGenerator::new, Properties.of(Material.STONE).strength(5F));
} }
@Override @Override

View file

@ -3,21 +3,21 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityPowderPlacer; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityPowderPlacer;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.BlockState; import net.minecraft.core.BlockPos;
import net.minecraft.block.SoundType; import net.minecraft.world.level.BlockGetter;
import net.minecraft.block.material.Material; import net.minecraft.world.level.block.SoundType;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.world.level.material.Material;
import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.util.math.shapes.Shapes; import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.level.BlockGetter; import net.minecraft.world.phys.shapes.VoxelShape;
public class BlockPowderPlacer extends BlockContainerImpl implements ICustomBlockState { public class BlockPowderPlacer extends BlockContainerImpl implements ICustomBlockState {
private static final VoxelShape SHAPE = Shapes.create(0F, 0F, 0F, 1F, 4 / 16F, 1F); private static final VoxelShape SHAPE = Shapes.create(0F, 0F, 0F, 1F, 4 / 16F, 1F);
public BlockPowderPlacer() { public BlockPowderPlacer() {
super("powder_placer", BlockEntityPowderPlacer::new, Properties.create(Material.ROCK).hardnessAndResistance(2, 5F).sound(SoundType.STONE)); super("powder_placer", BlockEntityPowderPlacer::new, Properties.of(Material.STONE).strength(2, 5F).sound(SoundType.STONE));
} }
@Override @Override
@ -26,7 +26,7 @@ public class BlockPowderPlacer extends BlockContainerImpl implements ICustomBloc
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
return SHAPE; return SHAPE;
} }

View file

@ -1,69 +1,62 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityProjectileGenerator; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityProjectileGenerator;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderProjectileGenerator; import de.ellpeck.naturesaura.blocks.tiles.render.RenderProjectileGenerator;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
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 de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import de.ellpeck.naturesaura.reg.ITESRProvider; import de.ellpeck.naturesaura.reg.ITESRProvider;
import net.minecraft.block.DispenserBlock; import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraft.block.SoundType; import net.minecraft.core.BlockPos;
import net.minecraft.block.material.Material; import net.minecraft.core.Position;
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer; import net.minecraft.core.dispenser.AbstractProjectileDispenseBehavior;
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher; import net.minecraft.sounds.SoundEvents;
import net.minecraft.dispenser.IPosition; import net.minecraft.sounds.SoundSource;
import net.minecraft.dispenser.ProjectileDispenseBehavior; import net.minecraft.world.entity.Entity;
import net.minecraft.entity.Entity; import net.minecraft.world.entity.EntityType;
import net.minecraft.entity.EntityType; import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.entity.item.EnderPearlEntity; import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.entity.projectile.AbstractArrowEntity; import net.minecraft.world.entity.projectile.ThrownEnderpearl;
import net.minecraft.entity.projectile.ProjectileEntity; import net.minecraft.world.entity.projectile.ThrownTrident;
import net.minecraft.entity.projectile.TridentEntity; import net.minecraft.world.item.ItemStack;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.Items;
import net.minecraft.item.Items; import net.minecraft.world.level.Level;
import net.minecraft.tileentity.BlockEntity; import net.minecraft.world.level.block.DispenserBlock;
import net.minecraft.tileentity.BlockEntityType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.util.SoundCategory; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.util.SoundEvents; import net.minecraft.world.level.material.Material;
import net.minecraft.util.Tuple; import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.phys.HitResult;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.level.Level;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.ProjectileImpactEvent; import net.minecraftforge.event.entity.ProjectileImpactEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
import java.util.function.Function;
import java.util.function.Supplier;
public class BlockProjectileGenerator extends BlockContainerImpl implements ITESRProvider<BlockEntityProjectileGenerator>, ICustomBlockState { public class BlockProjectileGenerator extends BlockContainerImpl implements ITESRProvider<BlockEntityProjectileGenerator>, ICustomBlockState {
public BlockProjectileGenerator() { public BlockProjectileGenerator() {
super("projectile_generator", BlockEntityProjectileGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE)); super("projectile_generator", BlockEntityProjectileGenerator::new, Properties.of(Material.STONE).strength(2.5F).sound(SoundType.STONE));
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
DispenserBlock.registerDispenseBehavior(Items.ENDER_PEARL, new ProjectileDispenseBehavior() { DispenserBlock.registerBehavior(Items.ENDER_PEARL, new AbstractProjectileDispenseBehavior() {
@Override @Override
protected ProjectileEntity getProjectileEntity(Level levelIn, IPosition position, ItemStack stackIn) { protected Projectile getProjectile(Level levelIn, Position position, ItemStack stackIn) {
EnderPearlEntity ret = new EnderPearlEntity(EntityType.ENDER_PEARL, levelIn); ThrownEnderpearl ret = new ThrownEnderpearl(EntityType.ENDER_PEARL, levelIn);
ret.setPosition(position.getX(), position.getY(), position.getZ()); ret.setPos(position.x(), position.y(), position.z());
return ret; return ret;
} }
}); });
DispenserBlock.registerDispenseBehavior(Items.TRIDENT, new ProjectileDispenseBehavior() { DispenserBlock.registerBehavior(Items.TRIDENT, new AbstractProjectileDispenseBehavior() {
@Override @Override
protected ProjectileEntity getProjectileEntity(Level levelIn, IPosition position, ItemStack stackIn) { protected Projectile getProjectile(Level levelIn, Position position, ItemStack stackIn) {
TridentEntity ret = new TridentEntity(EntityType.TRIDENT, levelIn); ThrownTrident ret = new ThrownTrident(EntityType.TRIDENT, levelIn);
ret.setPosition(position.getX(), position.getY(), position.getZ()); ret.setPos(position.x(), position.y(), position.z());
// set thrownStack ObfuscationReflectionHelper.setPrivateValue(ThrownTrident.class, ret, stackIn.copy(), "tridentItem");
ObfuscationReflectionHelper.setPrivateValue(TridentEntity.class, ret, stackIn.copy(), "field_203054_h"); ret.pickup = AbstractArrow.Pickup.ALLOWED;
ret.pickupStatus = AbstractArrowEntity.PickupStatus.ALLOWED;
return ret; return ret;
} }
}); });
@ -74,18 +67,16 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (entity.level.isClientSide) if (entity.level.isClientSide)
return; return;
RayTraceResult ray = event.getRayTraceResult(); HitResult ray = event.getRayTraceResult();
if (!(ray instanceof BlockRayTraceResult)) if (!(ray instanceof BlockHitResult blockRay))
return; return;
BlockRayTraceResult blockRay = (BlockRayTraceResult) ray; BlockPos pos = blockRay.getBlockPos();
BlockPos pos = blockRay.getPos();
if (pos == null) if (pos == null)
return; return;
BlockEntity tile = entity.level.getBlockEntity(pos); BlockEntity tile = entity.level.getBlockEntity(pos);
if (!(tile instanceof BlockEntityProjectileGenerator)) if (!(tile instanceof BlockEntityProjectileGenerator generator))
return; return;
BlockEntityProjectileGenerator generator = (BlockEntityProjectileGenerator) tile; if (generator.nextSide != blockRay.getDirection())
if (generator.nextSide != blockRay.getFace())
return; return;
Integer amount = NaturesAuraAPI.PROJECTILE_GENERATIONS.get(entity.getType()); Integer amount = NaturesAuraAPI.PROJECTILE_GENERATIONS.get(entity.getType());
if (amount == null || amount <= 0) if (amount == null || amount <= 0)
@ -95,21 +86,16 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
generator.generateAura(amount); generator.generateAura(amount);
PacketHandler.sendToAllAround(entity.level, pos, 32, PacketHandler.sendToAllAround(entity.level, pos, 32,
new PacketParticles((float) entity.getPosX(), (float) entity.getPosY(), (float) entity.getPosZ(), PacketParticles.Type.PROJECTILE_GEN, pos.getX(), pos.getY(), pos.getZ())); new PacketParticles((float) entity.getX(), (float) entity.getY(), (float) entity.getZ(), PacketParticles.Type.PROJECTILE_GEN, pos.getX(), pos.getY(), pos.getZ()));
entity.level.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_ENDER_EYE_LAUNCH, SoundCategory.BLOCKS, 0.8F, 1F); entity.level.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENDER_EYE_LAUNCH, SoundSource.BLOCKS, 0.8F, 1F);
generator.nextSide = generator.nextSide.rotateY(); generator.nextSide = generator.nextSide.getClockWise();
generator.sendToClients(); generator.sendToClients();
entity.remove(); entity.kill();
event.setCanceled(true); event.setCanceled(true);
} }
@Override
public Tuple<BlockEntityType<BlockEntityProjectileGenerator>, Supplier<Function<? super BlockEntityRendererDispatcher, ? extends BlockEntityRenderer<? super BlockEntityProjectileGenerator>>>> getTESR() {
return new Tuple<>(ModTileEntities.PROJECTILE_GENERATOR, () -> RenderProjectileGenerator::new);
}
@Override @Override
public void generateCustomBlockState(BlockStateGenerator generator) { public void generateCustomBlockState(BlockStateGenerator generator) {
generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(), generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(),
@ -117,4 +103,9 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
generator.modLoc("block/" + this.getBaseName() + "_top"), generator.modLoc("block/" + this.getBaseName() + "_top"),
generator.modLoc("block/" + this.getBaseName() + "_top"))); generator.modLoc("block/" + this.getBaseName() + "_top")));
} }
@Override
public void registerTESR() {
BlockEntityRenderers.register(ModTileEntities.PROJECTILE_GENERATOR, RenderProjectileGenerator::new);
}
} }

View file

@ -3,17 +3,17 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityRFConverter; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityRFConverter;
import net.minecraft.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.world.level.material.Material;
public class BlockRFConverter extends BlockContainerImpl { public class BlockRFConverter extends BlockContainerImpl {
public BlockRFConverter() { public BlockRFConverter() {
super("rf_converter", BlockEntityRFConverter::new, Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(3)); super("rf_converter", BlockEntityRFConverter::new, Properties.of(Material.STONE).sound(SoundType.STONE).strength(3));
} }
@Override @Override
public String getTranslationKey() { public String getDescriptionId() {
return ModConfig.instance.rfConverter.get() ? super.getTranslationKey() : "block." + NaturesAura.MOD_ID + "." + this.getBaseName() + ".disabled"; return ModConfig.instance.rfConverter.get() ? super.getDescriptionId() : "block." + NaturesAura.MOD_ID + "." + this.getBaseName() + ".disabled";
} }
} }

View file

@ -5,12 +5,12 @@ import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntitySlimeSplitGenerator; import de.ellpeck.naturesaura.blocks.tiles.BlockEntitySlimeSplitGenerator;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.Blocks; import net.minecraft.core.BlockPos;
import net.minecraft.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.entity.monster.SlimeEntity; import net.minecraft.world.entity.monster.Slime;
import net.minecraft.util.math.AABB; import net.minecraft.world.level.Level;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.block.Blocks;
import net.minecraft.level.Level; import net.minecraft.world.phys.AABB;
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;
@ -18,8 +18,9 @@ import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
public class BlockSlimeSplitGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public class BlockSlimeSplitGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockSlimeSplitGenerator() { public BlockSlimeSplitGenerator() {
super("slime_split_generator", BlockEntitySlimeSplitGenerator::new, Properties.from(Blocks.SLIME_BLOCK).hardnessAndResistance(2)); super("slime_split_generator", BlockEntitySlimeSplitGenerator::new, Properties.copy(Blocks.SLIME_BLOCK).strength(2));
MinecraftForge.EVENT_BUS.register(new Events()); MinecraftForge.EVENT_BUS.register(new Events());
} }
@ -34,7 +35,7 @@ public class BlockSlimeSplitGenerator extends BlockContainerImpl implements IVis
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public AABB getVisualizationBounds(Level level, BlockPos pos) { public AABB getVisualizationBounds(Level level, BlockPos pos) {
return new AABB(pos).grow(8); return new AABB(pos).inflate(8);
} }
@Override @Override
@ -48,16 +49,14 @@ public class BlockSlimeSplitGenerator extends BlockContainerImpl implements IVis
@SubscribeEvent @SubscribeEvent
public void onLivingDeath(LivingDeathEvent event) { public void onLivingDeath(LivingDeathEvent event) {
LivingEntity entity = event.getEntityLiving(); LivingEntity entity = event.getEntityLiving();
if (!(entity instanceof SlimeEntity) || entity.level.isClientSide) if (!(entity instanceof Slime slime) || entity.level.isClientSide)
return; return;
SlimeEntity slime = (SlimeEntity) entity; int size = slime.getSize();
int size = slime.getSlimeSize();
if (size <= 1) if (size <= 1)
return; return;
Helper.getBlockEntitiesInArea(entity.level, entity.getPosition(), 8, tile -> { Helper.getBlockEntitiesInArea(entity.level, entity.blockPosition(), 8, tile -> {
if (!(tile instanceof BlockEntitySlimeSplitGenerator)) if (!(tile instanceof BlockEntitySlimeSplitGenerator gen))
return false; return false;
BlockEntitySlimeSplitGenerator gen = (BlockEntitySlimeSplitGenerator) tile;
if (gen.isBusy()) if (gen.isBusy())
return false; return false;
gen.startGenerating(slime); gen.startGenerating(slime);

View file

@ -4,17 +4,18 @@ import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntitySnowCreator; import de.ellpeck.naturesaura.blocks.tiles.BlockEntitySnowCreator;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.Blocks; import net.minecraft.core.BlockPos;
import net.minecraft.tileentity.BlockEntity; import net.minecraft.world.level.Level;
import net.minecraft.util.math.AABB; import net.minecraft.world.level.block.Blocks;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.level.Level; import net.minecraft.world.phys.AABB;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockSnowCreator extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public class BlockSnowCreator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockSnowCreator() { public BlockSnowCreator() {
super("snow_creator", BlockEntitySnowCreator::new, Properties.from(Blocks.STONE_BRICKS)); super("snow_creator", BlockEntitySnowCreator::new, Properties.copy(Blocks.STONE_BRICKS));
} }
@Override @Override
@ -24,7 +25,7 @@ public class BlockSnowCreator extends BlockContainerImpl implements IVisualizabl
if (tile instanceof BlockEntitySnowCreator) { if (tile instanceof BlockEntitySnowCreator) {
int radius = ((BlockEntitySnowCreator) tile).getRange(); int radius = ((BlockEntitySnowCreator) tile).getRange();
if (radius > 0) if (radius > 0)
return new AABB(pos).grow(radius); return new AABB(pos).inflate(radius);
} }
return null; return null;
} }

View file

@ -10,22 +10,22 @@ import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles; import de.ellpeck.naturesaura.packet.PacketParticles;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import de.ellpeck.naturesaura.reg.ICustomRenderType; import de.ellpeck.naturesaura.reg.ICustomRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.entity.MobEntity; import net.minecraft.core.BlockPos;
import net.minecraft.tileentity.BlockEntity; import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.math.AABB; import net.minecraft.world.entity.Mob;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.BlockGetter;
import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.world.level.Level;
import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.level.LevelAccessor;
import net.minecraft.util.math.shapes.Shapes; import net.minecraft.world.level.block.SoundType;
import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.level.BlockGetter; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.level.ILevel; import net.minecraft.world.level.material.Material;
import net.minecraft.level.Level; import net.minecraft.world.phys.AABB;
import net.minecraft.level.server.ServerLevel; import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
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 net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
@ -40,7 +40,7 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
private static final VoxelShape SHAPE = Shapes.create(4 / 16F, 0F, 4 / 16F, 12 / 16F, 13 / 16F, 12 / 16F); private static final VoxelShape SHAPE = Shapes.create(4 / 16F, 0F, 4 / 16F, 12 / 16F, 13 / 16F, 12 / 16F);
public BlockSpawnLamp() { public BlockSpawnLamp() {
super("spawn_lamp", BlockEntitySpawnLamp::new, Properties.create(Material.IRON).hardnessAndResistance(3F).setLightLevel(s -> 15).sound(SoundType.METAL)); super("spawn_lamp", BlockEntitySpawnLamp::new, Properties.of(Material.METAL).strength(3F).lightLevel(s -> 15).sound(SoundType.METAL));
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }
@ -53,7 +53,7 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
public void onSpawn(LivingSpawnEvent.CheckSpawn event) { public void onSpawn(LivingSpawnEvent.CheckSpawn event) {
if (event.getSpawner() != null) if (event.getSpawner() != null)
return; return;
ILevel level = event.getLevel(); LevelAccessor level = event.getWorld();
BlockPos pos = new BlockPos(event.getX(), event.getY(), event.getZ()); BlockPos pos = new BlockPos(event.getX(), event.getY(), event.getZ());
if (!(level instanceof Level)) if (!(level instanceof Level))
return; return;
@ -66,14 +66,14 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
if (range <= 0) if (range <= 0)
continue; continue;
BlockPos lampPos = lamp.getPos(); BlockPos lampPos = lamp.getBlockPos();
if (!new AABB(lampPos).grow(range).contains(new Vector3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5))) if (!new AABB(lampPos).inflate(range).contains(new Vec3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5)))
continue; continue;
MobEntity entity = (MobEntity) event.getEntityLiving(); Mob entity = (Mob) event.getEntityLiving();
if (entity.canSpawn(level, event.getSpawnReason()) && entity.isNotColliding(level)) { if (entity.checkSpawnRules(level, event.getSpawnReason()) && entity.checkSpawnObstruction(level)) {
BlockPos spot = IAuraChunk.getHighestSpot(level, lampPos, 32, lampPos); BlockPos spot = IAuraChunk.getHighestSpot((Level) level, lampPos, 32, lampPos);
IAuraChunk.getAuraChunk(level, spot).drainAura(spot, 200); IAuraChunk.getAuraChunk((Level) level, spot).drainAura(spot, 200);
PacketHandler.sendToAllAround((ServerLevel) level, lampPos, 32, PacketHandler.sendToAllAround((ServerLevel) level, lampPos, 32,
new PacketParticles(lampPos.getX(), lampPos.getY(), lampPos.getZ(), PacketParticles.Type.SPAWN_LAMP)); new PacketParticles(lampPos.getX(), lampPos.getY(), lampPos.getZ(), PacketParticles.Type.SPAWN_LAMP));
@ -85,7 +85,7 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
return SHAPE; return SHAPE;
} }
@ -96,7 +96,7 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
if (tile instanceof BlockEntitySpawnLamp) { if (tile instanceof BlockEntitySpawnLamp) {
int radius = ((BlockEntitySpawnLamp) tile).getRadius(); int radius = ((BlockEntitySpawnLamp) tile).getRadius();
if (radius > 0) if (radius > 0)
return new AABB(pos).grow(radius); return new AABB(pos).inflate(radius);
} }
return null; return null;
} }
@ -114,6 +114,6 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
@Override @Override
public Supplier<RenderType> getRenderType() { public Supplier<RenderType> getRenderType() {
return RenderType::getCutoutMipped; return RenderType::cutoutMipped;
} }
} }

View file

@ -6,46 +6,49 @@ import de.ellpeck.naturesaura.reg.IColorProvidingBlock;
import de.ellpeck.naturesaura.reg.IColorProvidingItem; import de.ellpeck.naturesaura.reg.IColorProvidingItem;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import de.ellpeck.naturesaura.reg.ICustomRenderType; import de.ellpeck.naturesaura.reg.ICustomRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.IBucketPickupHandler;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.client.renderer.BiomeColors;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.core.BlockPos;
import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.sounds.SoundEvent;
import net.minecraft.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.fluid.Fluid; import net.minecraft.world.item.ItemStack;
import net.minecraft.fluid.Fluids; import net.minecraft.world.item.Items;
import net.minecraft.item.ItemStack; import net.minecraft.world.level.LevelAccessor;
import net.minecraft.tileentity.BlockEntity; import net.minecraft.world.level.block.Blocks;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.block.BucketPickup;
import net.minecraft.level.ILevel; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.level.biome.BiomeColors; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluids;
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.Optional;
import java.util.function.Supplier; import java.util.function.Supplier;
public class BlockSpring extends BlockContainerImpl implements ICustomBlockState, IColorProvidingBlock, IColorProvidingItem, IBucketPickupHandler, ICustomRenderType { public class BlockSpring extends BlockContainerImpl implements ICustomBlockState, IColorProvidingBlock, IColorProvidingItem, BucketPickup, ICustomRenderType {
public BlockSpring() { public BlockSpring() {
super("spring", BlockEntitySpring::new, Properties.from(Blocks.STONE_BRICKS)); super("spring", BlockEntitySpring::new, Properties.copy(Blocks.STONE_BRICKS));
} }
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public IBlockColor getBlockColor() { public BlockColor getBlockColor() {
return (state, level, pos, i) -> BiomeColors.getWaterColor(level, pos); return (state, level, pos, i) -> BiomeColors.getAverageWaterColor(level, pos);
} }
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@SuppressWarnings("Convert2Lambda") @SuppressWarnings("Convert2Lambda")
public IItemColor getItemColor() { public ItemColor getItemColor() {
return new IItemColor() { return new ItemColor() {
@Override @Override
public int getColor(ItemStack stack, int i) { public int getColor(ItemStack stack, int i) {
Player player = Minecraft.getInstance().player; Player player = Minecraft.getInstance().player;
return BiomeColors.getWaterColor(player.level, player.getPosition()); return BiomeColors.getAverageWaterColor(player.level, player.blockPosition());
} }
}; };
} }
@ -55,16 +58,21 @@ public class BlockSpring extends BlockContainerImpl implements ICustomBlockState
generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName()))); generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName())));
} }
@Override
public Fluid pickupFluid(ILevel levelIn, BlockPos pos, BlockState state) {
BlockEntity tile = levelIn.getBlockEntity(pos);
if (tile instanceof BlockEntitySpring)
((BlockEntitySpring) tile).consumeAura(2500);
return Fluids.WATER;
}
@Override @Override
public Supplier<RenderType> getRenderType() { public Supplier<RenderType> getRenderType() {
return RenderType::getTranslucent; return RenderType::translucent;
}
@Override
public ItemStack pickupBlock(LevelAccessor levelIn, BlockPos pos, BlockState state) {
BlockEntity tile = levelIn.getBlockEntity(pos);
if (tile instanceof BlockEntitySpring)
((BlockEntitySpring) tile).consumeAura(2500);
return new ItemStack(Items.WATER_BUCKET); }
@Override
public Optional<SoundEvent> getPickupSound() {
return Fluids.WATER.getPickupSound();
} }
} }

View file

@ -3,12 +3,13 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityTimeChanger; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityTimeChanger;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.world.level.material.Material;
public class BlockTimeChanger extends BlockContainerImpl implements ICustomBlockState { public class BlockTimeChanger extends BlockContainerImpl implements ICustomBlockState {
public BlockTimeChanger() { public BlockTimeChanger() {
super("time_changer", BlockEntityTimeChanger::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE)); super("time_changer", BlockEntityTimeChanger::new, Properties.of(Material.STONE).strength(2.5F).sound(SoundType.STONE));
} }
@Override @Override

View file

@ -3,11 +3,12 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityWeatherChanger; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityWeatherChanger;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.Blocks; import net.minecraft.world.level.block.Blocks;
public class BlockWeatherChanger extends BlockContainerImpl implements ICustomBlockState { public class BlockWeatherChanger extends BlockContainerImpl implements ICustomBlockState {
public BlockWeatherChanger() { public BlockWeatherChanger() {
super("weather_changer", BlockEntityWeatherChanger::new, Properties.from(Blocks.STONE_BRICKS)); super("weather_changer", BlockEntityWeatherChanger::new, Properties.copy(Blocks.STONE_BRICKS));
} }
@Override @Override

View file

@ -10,9 +10,8 @@ import de.ellpeck.naturesaura.recipes.ModRecipes;
import de.ellpeck.naturesaura.recipes.TreeRitualRecipe; import de.ellpeck.naturesaura.recipes.TreeRitualRecipe;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import de.ellpeck.naturesaura.reg.ITESRProvider; import de.ellpeck.naturesaura.reg.ITESRProvider;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.util.Tuple;
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;
@ -23,7 +22,6 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.SoundType; 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.BlockEntityType;
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.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
@ -38,7 +36,6 @@ import org.apache.commons.lang3.mutable.MutableObject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.function.Supplier;
public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<BlockEntityWoodStand>, ICustomBlockState { public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<BlockEntityWoodStand>, ICustomBlockState {
@ -111,14 +108,13 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<
return Helper.putStackOnTile(player, handIn, pos, 0, true); return Helper.putStackOnTile(player, handIn, pos, 0, true);
} }
@Override
public Tuple<BlockEntityType<? extends BlockEntityWoodStand>, Supplier<BlockEntityRendererProvider<BlockEntityWoodStand>>> getTESR() {
return new Tuple<>(ModTileEntities.WOOD_STAND, () -> RenderWoodStand::new);
}
@Override @Override
public void generateCustomBlockState(BlockStateGenerator generator) { public void generateCustomBlockState(BlockStateGenerator generator) {
generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName()))); generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName())));
} }
@Override
public void registerTESR() {
BlockEntityRenderers.register(ModTileEntities.WOOD_STAND, RenderWoodStand::new);
}
} }

View file

@ -96,7 +96,7 @@ public class Multiblock implements IMultiblock {
Matcher matcher = matchers.get(this.rawPattern[x][y][z]); Matcher matcher = matchers.get(this.rawPattern[x][y][z]);
if (matcher == null) if (matcher == null)
throw new IllegalStateException(); throw new IllegalStateException();
if (matcher.getCheck() != null) if (matcher.check() != null)
this.matchers.put(new BlockPos(x, y, z), matcher); this.matchers.put(new BlockPos(x, y, z), matcher);
} }
@ -109,7 +109,7 @@ public class Multiblock implements IMultiblock {
BlockPos start = this.getStart(center); BlockPos start = this.getStart(center);
return this.forEach(center, (char) 0, (pos, matcher) -> { return this.forEach(center, (char) 0, (pos, matcher) -> {
BlockPos offset = pos.subtract(start); BlockPos offset = pos.subtract(start);
return matcher.getCheck().matches(level, start, offset, pos, level.getBlockState(pos), this.getChar(offset)); return matcher.check().matches(level, start, offset, pos, level.getBlockState(pos), this.getChar(offset));
}); });
} }

View file

@ -25,8 +25,6 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.ItemStackHandler;
import java.util.Random;
public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickableBlockEntity { public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickableBlockEntity {
private final BasicAuraContainer container = new BasicAuraContainer(null, 500000) { private final BasicAuraContainer container = new BasicAuraContainer(null, 500000) {
@ -49,7 +47,7 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
@Override @Override
protected boolean canExtract(ItemStack stack, int slot, int amount) { protected boolean canExtract(ItemStack stack, int slot, int amount) {
IAuraContainer cap = stack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null); var cap = stack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
if (cap != null) if (cap != null)
return cap.storeAura(1, true) <= 0; return cap.storeAura(1, true) <= 0;
else else
@ -72,14 +70,14 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
@Override @Override
public void tick() { public void tick() {
Random rand = this.level.random; var rand = this.level.random;
if (this.level.getGameTime() % 40 == 0) { if (this.level.getGameTime() % 40 == 0) {
int index = 0; var index = 0;
for (int x = -2; x <= 2; x += 4) { for (var x = -2; x <= 2; x += 4) {
for (int z = -2; z <= 2; z += 4) { for (var z = -2; z <= 2; z += 4) {
BlockPos offset = this.worldPosition.offset(x, 1, z); var offset = this.worldPosition.offset(x, 1, z);
BlockState state = this.level.getBlockState(offset); var state = this.level.getBlockState(offset);
this.catalysts[index] = state.getBlock().getCloneItemStack(this.level, offset, state); this.catalysts[index] = state.getBlock().getCloneItemStack(this.level, offset, state);
index++; index++;
} }
@ -88,7 +86,7 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
if (!this.level.isClientSide) { if (!this.level.isClientSide) {
if (this.level.getGameTime() % 40 == 0 || this.firstTick) { if (this.level.getGameTime() % 40 == 0 || this.firstTick) {
StructureState newState = this.getNewState(); var newState = this.getNewState();
if (newState != this.structureState) { if (newState != this.structureState) {
this.structureState = newState; this.structureState = newState;
this.sendToClients(); this.sendToClients();
@ -97,13 +95,13 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
} }
if (this.structureState != StructureState.INVALID) { if (this.structureState != StructureState.INVALID) {
int space = this.container.storeAura(300, true); var space = this.container.storeAura(300, true);
IAuraType expectedType = this.structureState == StructureState.NETHER ? NaturesAuraAPI.TYPE_NETHER : NaturesAuraAPI.TYPE_OVERWORLD; IAuraType expectedType = this.structureState == StructureState.NETHER ? NaturesAuraAPI.TYPE_NETHER : NaturesAuraAPI.TYPE_OVERWORLD;
if (space > 0 && IAuraType.forLevel(this.level).isSimilar(expectedType)) { if (space > 0 && IAuraType.forLevel(this.level).isSimilar(expectedType)) {
int toStore = Math.min(IAuraChunk.getAuraInArea(this.level, this.worldPosition, 20), space); var toStore = Math.min(IAuraChunk.getAuraInArea(this.level, this.worldPosition, 20), space);
if (toStore > 0) { if (toStore > 0) {
BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 20, this.worldPosition); var spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 20, this.worldPosition);
IAuraChunk chunk = IAuraChunk.getAuraChunk(this.level, spot); var chunk = IAuraChunk.getAuraChunk(this.level, spot);
chunk.drainAura(spot, toStore); chunk.drainAura(spot, toStore);
this.container.storeAura(toStore, false); this.container.storeAura(toStore, false);
@ -114,17 +112,17 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
this.worldPosition.getY() + rand.nextFloat() * 10F, this.worldPosition.getY() + rand.nextFloat() * 10F,
this.worldPosition.getZ() + (float) rand.nextGaussian() * 10F, this.worldPosition.getZ() + (float) rand.nextGaussian() * 10F,
this.worldPosition.getX() + 0.5F, this.worldPosition.getY() + 0.5F, this.worldPosition.getZ() + 0.5F, this.worldPosition.getX() + 0.5F, this.worldPosition.getY() + 0.5F, this.worldPosition.getZ() + 0.5F,
rand.nextFloat() * 0.1F + 0.1F, this.container.getAuraColor(), rand.nextFloat() * 1F + 1F rand.nextFloat() * 0.1F + 0.1F, this.container.getAuraColor(), rand.nextFloat() + 1F
)); ));
} }
} }
ItemStack stack = this.items.getStackInSlot(0); var stack = this.items.getStackInSlot(0);
IAuraContainer container = stack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null); var container = stack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
if (!stack.isEmpty() && container != null) { if (!stack.isEmpty() && container != null) {
int theoreticalDrain = this.container.drainAura(1000, true); var theoreticalDrain = this.container.drainAura(1000, true);
if (theoreticalDrain > 0) { if (theoreticalDrain > 0) {
int stored = container.storeAura(theoreticalDrain, false); var stored = container.storeAura(theoreticalDrain, false);
if (stored > 0) { if (stored > 0) {
this.container.drainAura(stored, false); this.container.drainAura(stored, false);
@ -142,7 +140,7 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
this.currentRecipe = null; this.currentRecipe = null;
this.timer = 0; this.timer = 0;
} else { } else {
int req = Mth.ceil(this.currentRecipe.aura / (double) this.currentRecipe.time); var req = Mth.ceil(this.currentRecipe.aura / (double) this.currentRecipe.time);
if (this.container.getStoredAura() >= req) { if (this.container.getStoredAura() >= req) {
this.container.drainAura(req, false); this.container.drainAura(req, false);
@ -170,7 +168,7 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
} else { } else {
if (this.structureState != StructureState.INVALID) { if (this.structureState != StructureState.INVALID) {
if (rand.nextFloat() >= 0.7F) { if (rand.nextFloat() >= 0.7F) {
int fourths = this.container.getMaxAura() / 4; var fourths = this.container.getMaxAura() / 4;
if (this.container.getStoredAura() > 0) { if (this.container.getStoredAura() > 0) {
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
this.worldPosition.getX() - 4F + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() + rand.nextFloat(), this.worldPosition.getX() - 4F + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() + rand.nextFloat(),
@ -200,12 +198,12 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
} }
private AltarRecipe getRecipeForInput(ItemStack input) { private AltarRecipe getRecipeForInput(ItemStack input) {
IAuraType type = IAuraType.forLevel(this.level); var type = IAuraType.forLevel(this.level);
for (AltarRecipe recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.ALTAR_TYPE, null, null)) { for (var recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.ALTAR_TYPE, null, null)) {
if (recipe.input.test(input) && (recipe.requiredType == null || type.isSimilar(recipe.requiredType))) { if (recipe.input.test(input) && (recipe.requiredType == null || type.isSimilar(recipe.requiredType))) {
if (recipe.catalyst == Ingredient.EMPTY) if (recipe.catalyst == Ingredient.EMPTY)
return recipe; return recipe;
for (ItemStack stack : this.catalysts) for (var stack : this.catalysts)
if (recipe.catalyst.test(stack)) if (recipe.catalyst.test(stack))
return recipe; return recipe;
} }

View file

@ -7,12 +7,17 @@ import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEnderCrate;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public class RenderEnderCrate implements BlockEntityRenderer<BlockEntityEnderCrate> { public class RenderEnderCrate implements BlockEntityRenderer<BlockEntityEnderCrate> {
public RenderEnderCrate(BlockEntityRendererProvider.Context context) {
}
@Override @Override
public void render(BlockEntityEnderCrate tileEntityIn, float partialTicks, PoseStack matrixStackIn, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) { public void render(BlockEntityEnderCrate tileEntityIn, float partialTicks, PoseStack matrixStackIn, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) {
Matrix4f matrix4f = matrixStackIn.last().pose(); Matrix4f matrix4f = matrixStackIn.last().pose();

View file

@ -7,10 +7,15 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
public class RenderNatureAltar implements BlockEntityRenderer<BlockEntityNatureAltar> { public class RenderNatureAltar implements BlockEntityRenderer<BlockEntityNatureAltar> {
public RenderNatureAltar(BlockEntityRendererProvider.Context context) {
}
@Override @Override
public void render(BlockEntityNatureAltar tileEntityIn, float partialTicks, PoseStack matrixStackIn, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) { public void render(BlockEntityNatureAltar tileEntityIn, float partialTicks, PoseStack matrixStackIn, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) {
ItemStack stack = tileEntityIn.items.getStackInSlot(0); ItemStack stack = tileEntityIn.items.getStackInSlot(0);

View file

@ -7,6 +7,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
@ -18,6 +19,10 @@ public class RenderOfferingTable implements BlockEntityRenderer<BlockEntityOffer
private final Random rand = new Random(); private final Random rand = new Random();
public RenderOfferingTable(BlockEntityRendererProvider.Context context) {
}
@Override @Override
public void render(BlockEntityOfferingTable tileEntityOfferingTable, float v, PoseStack matrixStack, MultiBufferSource iRenderTypeBuffer, int combinedLightIn, int combinedOverlayIn) { public void render(BlockEntityOfferingTable tileEntityOfferingTable, float v, PoseStack matrixStack, MultiBufferSource iRenderTypeBuffer, int combinedLightIn, int combinedOverlayIn) {
ItemStack stack = tileEntityOfferingTable.items.getStackInSlot(0); ItemStack stack = tileEntityOfferingTable.items.getStackInSlot(0);

View file

@ -6,6 +6,7 @@ import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityProjectileGenerator; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityProjectileGenerator;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@ -17,6 +18,10 @@ public class RenderProjectileGenerator implements BlockEntityRenderer<BlockEntit
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/projectile_generator_overlay.png"); private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/projectile_generator_overlay.png");
//private final ModelOverlay model = new ModelOverlay(); //private final ModelOverlay model = new ModelOverlay();
public RenderProjectileGenerator(BlockEntityRendererProvider.Context context) {
}
@Override @Override
public void render(BlockEntityProjectileGenerator te, float partialTicks, PoseStack stack, MultiBufferSource buffer, int combinedLightIn, int combinedOverlayIn) { public void render(BlockEntityProjectileGenerator te, float partialTicks, PoseStack stack, MultiBufferSource buffer, int combinedLightIn, int combinedOverlayIn) {
stack.pushPose(); stack.pushPose();

View file

@ -3,9 +3,9 @@ package de.ellpeck.naturesaura.chunk;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Direction; import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.level.chunk.Chunk;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.INBTSerializable; import net.minecraftforge.common.util.INBTSerializable;
@ -16,11 +16,11 @@ import javax.annotation.Nullable;
public class AuraChunkProvider implements ICapabilityProvider, INBTSerializable<CompoundTag> { public class AuraChunkProvider implements ICapabilityProvider, INBTSerializable<CompoundTag> {
private final Chunk chunk; private final LevelChunk chunk;
private final LazyOptional<IAuraChunk> lazyChunk = LazyOptional.of(this::getAuraChunk); private final LazyOptional<IAuraChunk> lazyChunk = LazyOptional.of(this::getAuraChunk);
private IAuraChunk auraChunk; private IAuraChunk auraChunk;
public AuraChunkProvider(Chunk chunk) { public AuraChunkProvider(LevelChunk chunk) {
this.chunk = chunk; this.chunk = chunk;
} }

View file

@ -5,16 +5,16 @@ import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import net.minecraft.entity.IAngerable; import net.minecraft.core.BlockPos;
import net.minecraft.entity.LivingEntity; import net.minecraft.resources.ResourceLocation;
import net.minecraft.entity.player.Player; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.item.ItemStack; import net.minecraft.world.entity.NeutralMob;
import net.minecraft.item.Items; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.math.AABB; import net.minecraft.world.item.Items;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.Level;
import net.minecraft.level.Level; import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.level.chunk.Chunk; import net.minecraft.world.phys.AABB;
import java.util.List; import java.util.List;
@ -33,43 +33,44 @@ public class AngerEffect implements IDrainSpotEffect {
int dist = Math.min(Math.abs(aura) / 50000, 75); int dist = Math.min(Math.abs(aura) / 50000, 75);
if (dist < 10) if (dist < 10)
return false; return false;
this.bb = new AABB(pos).grow(dist); this.bb = new AABB(pos).inflate(dist);
return true; return true;
} }
@Override @Override
public ActiveType isActiveHere(Player player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public ActiveType isActiveHere(Player player, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (!this.calcValues(player.level, pos, spot)) if (!this.calcValues(player.level, pos, spot))
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (!this.bb.contains(player.getPositionVec())) if (!this.bb.contains(player.getEyePosition()))
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
return ActiveType.ACTIVE; return ActiveType.ACTIVE;
} }
@Override @Override
public ItemStack getDisplayIcon() { public ItemStack getDisplayIcon() {
return new ItemStack(Items.FIRE_CHARGE); return new ItemStack(Items.FIRE_CHARGE);
} }
@Override @Override
public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (level.getGameTime() % 100 != 0) if (level.getGameTime() % 100 != 0)
return; return;
if (!this.calcValues(level, pos, spot)) if (!this.calcValues(level, pos, spot))
return; return;
List<LivingEntity> entities = level.getEntitiesWithinAABB(LivingEntity.class, this.bb); List<LivingEntity> entities = level.getEntitiesOfClass(LivingEntity.class, this.bb);
for (LivingEntity entity : entities) { for (LivingEntity entity : entities) {
if (!(entity instanceof IAngerable)) if (!(entity instanceof NeutralMob))
continue; continue;
Player player = level.getClosestPlayer(entity, 25); Player player = level.getNearestPlayer(entity, 25);
if (player == null) if (player == null)
continue; continue;
((IAngerable) entity).setAttackTarget(player); ((NeutralMob) entity).setTarget(player);
} }
} }
@Override @Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) { public boolean appliesHere(LevelChunk chunk, IAuraChunk auraChunk, IAuraType type) {
return ModConfig.instance.angerEffect.get(); return ModConfig.instance.angerEffect.get();
} }

View file

@ -6,22 +6,21 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import net.minecraft.entity.EntityType; import net.minecraft.core.BlockPos;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.resources.ResourceLocation;
import net.minecraft.entity.passive.ChickenEntity; import net.minecraft.util.Mth;
import net.minecraft.entity.player.Player; import net.minecraft.world.entity.EntityType;
import net.minecraft.item.EggItem; import net.minecraft.world.entity.animal.Animal;
import net.minecraft.item.ItemStack; import net.minecraft.world.entity.animal.Chicken;
import net.minecraft.item.Items; import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.particles.ParticleTypes; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.item.EggItem;
import net.minecraft.util.math.AABB; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.item.Items;
import net.minecraft.util.math.Mth; import net.minecraft.world.level.Level;
import net.minecraft.level.Level; import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.level.chunk.Chunk; import net.minecraft.world.phys.AABB;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import java.util.Comparator; import java.util.Comparator;
@ -46,17 +45,17 @@ public class AnimalEffect implements IDrainSpotEffect {
if (this.chance <= 0) if (this.chance <= 0)
return false; return false;
int dist = Mth.clamp(Math.abs(aura) / 150000, 5, 35); int dist = Mth.clamp(Math.abs(aura) / 150000, 5, 35);
this.bb = new AABB(pos).grow(dist); this.bb = new AABB(pos).inflate(dist);
return true; return true;
} }
@Override @Override
public ActiveType isActiveHere(Player player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public ActiveType isActiveHere(Player player, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (!this.calcValues(player.level, pos, spot)) if (!this.calcValues(player.level, pos, spot))
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (!this.bb.contains(player.getPositionVec())) if (!this.bb.contains(player.getEyePosition()))
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (!NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.getPosition(), NAME)) if (!NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), NAME))
return ActiveType.INHIBITED; return ActiveType.INHIBITED;
return ActiveType.ACTIVE; return ActiveType.ACTIVE;
} }
@ -67,87 +66,85 @@ public class AnimalEffect implements IDrainSpotEffect {
} }
@Override @Override
public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (level.getGameTime() % 200 != 0) if (level.getGameTime() % 200 != 0)
return; return;
if (!this.calcValues(level, pos, spot)) if (!this.calcValues(level, pos, spot))
return; return;
List<AnimalEntity> animals = level.getEntitiesWithinAABB(AnimalEntity.class, this.bb); List<Animal> animals = level.getEntitiesOfClass(Animal.class, this.bb);
if (animals.size() >= ModConfig.instance.maxAnimalsAroundPowder.get()) if (animals.size() >= ModConfig.instance.maxAnimalsAroundPowder.get())
return; return;
List<ItemEntity> items = level.getEntitiesWithinAABB(ItemEntity.class, this.bb); List<ItemEntity> items = level.getEntitiesOfClass(ItemEntity.class, this.bb);
for (ItemEntity item : items) { for (ItemEntity item : items) {
if (!item.isAlive()) if (!item.isAlive())
continue; continue;
if (!NaturesAuraAPI.instance().isEffectPowderActive(level, item.getPosition(), NAME)) if (!NaturesAuraAPI.instance().isEffectPowderActive(level, item.blockPosition(), NAME))
continue; continue;
ItemStack stack = item.getItem(); ItemStack stack = item.getItem();
if (!(stack.getItem() instanceof EggItem)) if (!(stack.getItem() instanceof EggItem))
continue; continue;
// The getAge() method is client-side only for absolutely no reason but I want it so I don't care if (item.getAge() < item.lifespan / 2)
int age = ObfuscationReflectionHelper.getPrivateValue(ItemEntity.class, item, "field_70292_b");
if (age < item.lifespan / 2)
continue; continue;
if (stack.getCount() <= 1) if (stack.getCount() <= 1)
item.remove(); item.kill();
else { else {
stack.shrink(1); stack.shrink(1);
item.setItem(stack); item.setItem(stack);
} }
ChickenEntity chicken = new ChickenEntity(EntityType.CHICKEN, level); Chicken chicken = new Chicken(EntityType.CHICKEN, level);
chicken.setGrowingAge(-24000); chicken.setAge(-24000);
chicken.setPosition(item.getPosX(), item.getPosY(), item.getPosZ()); chicken.setPos(item.getX(), item.getY(), item.getZ());
level.addEntity(chicken); level.addFreshEntity(chicken);
BlockPos closestSpot = IAuraChunk.getHighestSpot(level, item.getPosition(), 35, pos); BlockPos closestSpot = IAuraChunk.getHighestSpot(level, item.blockPosition(), 35, pos);
IAuraChunk.getAuraChunk(level, closestSpot).drainAura(closestSpot, 2000); IAuraChunk.getAuraChunk(level, closestSpot).drainAura(closestSpot, 2000);
} }
if (level.rand.nextInt(20) <= this.chance) { if (level.random.nextInt(20) <= this.chance) {
if (animals.size() < 2) if (animals.size() < 2)
return; return;
AnimalEntity first = animals.get(level.rand.nextInt(animals.size())); Animal first = animals.get(level.random.nextInt(animals.size()));
if (first.isChild() || first.isInLove()) if (first.isBaby() || first.isInLove())
return; return;
if (!NaturesAuraAPI.instance().isEffectPowderActive(level, first.getPosition(), NAME)) if (!NaturesAuraAPI.instance().isEffectPowderActive(level, first.blockPosition(), NAME))
return; return;
Optional<AnimalEntity> secondOptional = animals.stream() Optional<Animal> secondOptional = animals.stream()
.filter(e -> e != first && !e.isInLove() && !e.isChild()) .filter(e -> e != first && !e.isInLove() && !e.isBaby())
.min(Comparator.comparingDouble(e -> e.getDistanceSq(first))); .min(Comparator.comparingDouble(e -> e.distanceToSqr(first)));
if (!secondOptional.isPresent()) if (secondOptional.isEmpty())
return; return;
AnimalEntity second = secondOptional.get(); Animal second = secondOptional.get();
if (second.getDistanceSq(first) > 5 * 5) if (second.distanceToSqr(first) > 5 * 5)
return; return;
this.setInLove(first); this.setInLove(first);
this.setInLove(second); this.setInLove(second);
BlockPos closestSpot = IAuraChunk.getHighestSpot(level, first.getPosition(), 35, pos); BlockPos closestSpot = IAuraChunk.getHighestSpot(level, first.blockPosition(), 35, pos);
IAuraChunk.getAuraChunk(level, closestSpot).drainAura(closestSpot, 3500); IAuraChunk.getAuraChunk(level, closestSpot).drainAura(closestSpot, 3500);
} }
} }
private void setInLove(AnimalEntity animal) { private void setInLove(Animal animal) {
animal.setInLove(null); animal.setInLove(null);
for (int j = 0; j < 7; j++) for (int j = 0; j < 7; j++)
animal.level.addParticle(ParticleTypes.HEART, animal.level.addParticle(ParticleTypes.HEART,
animal.getPosX() + (double) (animal.level.rand.nextFloat() * animal.getWidth() * 2.0F) - animal.getWidth(), animal.getX() + (double) (animal.level.random.nextFloat() * animal.getBbWidth() * 2.0F) - animal.getBbWidth(),
animal.getPosY() + 0.5D + (double) (animal.level.rand.nextFloat() * animal.getHeight()), animal.getY() + 0.5D + (double) (animal.level.random.nextFloat() * animal.getBbHeight()),
animal.getPosZ() + (double) (animal.level.rand.nextFloat() * animal.getWidth() * 2.0F) - animal.getWidth(), animal.getZ() + (double) (animal.level.random.nextFloat() * animal.getBbWidth() * 2.0F) - animal.getBbWidth(),
animal.level.rand.nextGaussian() * 0.02D, animal.level.random.nextGaussian() * 0.02D,
animal.level.rand.nextGaussian() * 0.02D, animal.level.random.nextGaussian() * 0.02D,
animal.level.rand.nextGaussian() * 0.02D); animal.level.random.nextGaussian() * 0.02D);
} }
@Override @Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) { public boolean appliesHere(LevelChunk chunk, IAuraChunk auraChunk, IAuraType type) {
return ModConfig.instance.animalEffect.get(); return ModConfig.instance.animalEffect.get();
} }

View file

@ -4,10 +4,10 @@ import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import net.minecraft.util.ResourceLocation; import net.minecraft.core.BlockPos;
import net.minecraft.util.math.BlockPos; import net.minecraft.resources.ResourceLocation;
import net.minecraft.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.level.chunk.Chunk; import net.minecraft.world.level.chunk.LevelChunk;
import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.mutable.MutableInt;
public class BalanceEffect implements IDrainSpotEffect { public class BalanceEffect implements IDrainSpotEffect {
@ -15,7 +15,7 @@ public class BalanceEffect implements IDrainSpotEffect {
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "balance"); public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "balance");
@Override @Override
public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (spot < 100000) if (spot < 100000)
return; return;
if (level.getGameTime() % 200 != 0) if (level.getGameTime() % 200 != 0)
@ -35,7 +35,7 @@ public class BalanceEffect implements IDrainSpotEffect {
} }
@Override @Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) { public boolean appliesHere(LevelChunk chunk, IAuraChunk auraChunk, IAuraType type) {
return true; return true;
} }

View file

@ -6,17 +6,17 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.potion.ModPotions; import de.ellpeck.naturesaura.potion.ModPotions;
import net.minecraft.block.Blocks; import net.minecraft.core.BlockPos;
import net.minecraft.entity.LivingEntity; import net.minecraft.resources.ResourceLocation;
import net.minecraft.entity.player.Player; import net.minecraft.util.Mth;
import net.minecraft.item.ItemStack; import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.potion.EffectInstance; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.math.AABB; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.Level;
import net.minecraft.util.math.Mth; import net.minecraft.world.level.block.Blocks;
import net.minecraft.level.Level; import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.level.chunk.Chunk; import net.minecraft.world.phys.AABB;
import java.util.List; import java.util.List;
@ -37,15 +37,15 @@ public class BreathlessEffect implements IDrainSpotEffect {
if (dist < 10) if (dist < 10)
return false; return false;
this.amp = Math.min(Mth.floor(Math.abs(aura) / 2500000F), 3); this.amp = Math.min(Mth.floor(Math.abs(aura) / 2500000F), 3);
this.bb = new AABB(pos).grow(dist); this.bb = new AABB(pos).inflate(dist);
return true; return true;
} }
@Override @Override
public ActiveType isActiveHere(Player player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public ActiveType isActiveHere(Player player, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (!this.calcValues(player.level, pos, spot)) if (!this.calcValues(player.level, pos, spot))
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (!this.bb.contains(player.getPositionVec())) if (!this.bb.contains(player.getEyePosition()))
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
return ActiveType.ACTIVE; return ActiveType.ACTIVE;
} }
@ -56,18 +56,18 @@ public class BreathlessEffect implements IDrainSpotEffect {
} }
@Override @Override
public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (level.getGameTime() % 100 != 0) if (level.getGameTime() % 100 != 0)
return; return;
if (!this.calcValues(level, pos, spot)) if (!this.calcValues(level, pos, spot))
return; return;
List<LivingEntity> entities = level.getEntitiesWithinAABB(LivingEntity.class, this.bb); List<LivingEntity> entities = level.getEntitiesOfClass(LivingEntity.class, this.bb);
for (LivingEntity entity : entities) for (LivingEntity entity : entities)
entity.addPotionEffect(new EffectInstance(ModPotions.BREATHLESS, 300, this.amp)); entity.addEffect(new MobEffectInstance(ModPotions.BREATHLESS, 300, this.amp));
} }
@Override @Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) { public boolean appliesHere(LevelChunk chunk, IAuraChunk auraChunk, IAuraType type) {
return ModConfig.instance.breathlessEffect.get(); return ModConfig.instance.breathlessEffect.get();
} }

View file

@ -7,14 +7,14 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import net.minecraft.entity.player.Player; import net.minecraft.core.BlockPos;
import net.minecraft.item.ItemStack; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.Mth;
import net.minecraft.util.math.AABB; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.math.Mth; import net.minecraft.world.level.Level;
import net.minecraft.level.Level; import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.level.chunk.Chunk; import net.minecraft.world.phys.AABB;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import java.util.List; import java.util.List;
@ -34,18 +34,18 @@ public class CacheRechargeEffect implements IDrainSpotEffect {
if (aura < 1500000) if (aura < 1500000)
return false; return false;
int dist = Mth.clamp(aura / 3500, 3, 15); int dist = Mth.clamp(aura / 3500, 3, 15);
this.bb = new AABB(pos).grow(dist); this.bb = new AABB(pos).inflate(dist);
this.amount = Mth.ceil(aura / 250F / auraAndSpots.getRight()); this.amount = Mth.ceil(aura / 250F / auraAndSpots.getRight());
return true; return true;
} }
@Override @Override
public ActiveType isActiveHere(Player player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public ActiveType isActiveHere(Player player, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (!this.calcValues(player.level, pos, spot)) if (!this.calcValues(player.level, pos, spot))
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (!this.bb.contains(player.getPositionVec())) if (!this.bb.contains(player.getEyePosition()))
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.getPosition(), NAME)) if (NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), NAME))
return ActiveType.INHIBITED; return ActiveType.INHIBITED;
return ActiveType.ACTIVE; return ActiveType.ACTIVE;
} }
@ -56,12 +56,12 @@ public class CacheRechargeEffect implements IDrainSpotEffect {
} }
@Override @Override
public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (!this.calcValues(level, pos, spot)) if (!this.calcValues(level, pos, spot))
return; return;
List<Player> players = level.getEntitiesWithinAABB(Player.class, this.bb); List<Player> players = level.getEntitiesOfClass(Player.class, this.bb);
for (Player player : players) { for (Player player : players) {
if (NaturesAuraAPI.instance().isEffectPowderActive(level, player.getPosition(), NAME)) if (NaturesAuraAPI.instance().isEffectPowderActive(level, player.blockPosition(), 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);
@ -71,7 +71,7 @@ public class CacheRechargeEffect implements IDrainSpotEffect {
} }
@Override @Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) { public boolean appliesHere(LevelChunk chunk, IAuraChunk auraChunk, IAuraType type) {
return ModConfig.instance.cacheRechargeEffect.get(); return ModConfig.instance.cacheRechargeEffect.get();
} }

View file

@ -5,16 +5,16 @@ import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import net.minecraft.block.Blocks; import net.minecraft.core.BlockPos;
import net.minecraft.entity.player.Player; import net.minecraft.resources.ResourceLocation;
import net.minecraft.item.ItemStack; import net.minecraft.util.Mth;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.math.Mth; import net.minecraft.world.level.Explosion;
import net.minecraft.level.Explosion; import net.minecraft.world.level.Level;
import net.minecraft.level.Level; import net.minecraft.world.level.block.Blocks;
import net.minecraft.level.chunk.Chunk; import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.level.gen.Heightmap; import net.minecraft.world.level.levelgen.Heightmap;
public class ExplosionEffect implements IDrainSpotEffect { public class ExplosionEffect implements IDrainSpotEffect {
@ -30,7 +30,7 @@ public class ExplosionEffect implements IDrainSpotEffect {
if (aura > -5000000) if (aura > -5000000)
return false; return false;
int chance = 140 - Math.abs(aura) / 200000; int chance = 140 - Math.abs(aura) / 200000;
if (chance > 1 && level.rand.nextInt(chance) != 0) if (chance > 1 && level.random.nextInt(chance) != 0)
return false; return false;
this.strength = Math.min(Math.abs(aura) / 5000000F, 5F); this.strength = Math.min(Math.abs(aura) / 5000000F, 5F);
if (this.strength <= 0) if (this.strength <= 0)
@ -40,10 +40,10 @@ public class ExplosionEffect implements IDrainSpotEffect {
} }
@Override @Override
public ActiveType isActiveHere(Player player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public ActiveType isActiveHere(Player player, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (!this.calcValues(player.level, pos, spot)) if (!this.calcValues(player.level, pos, spot))
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (player.getDistanceSq(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;
return ActiveType.ACTIVE; return ActiveType.ACTIVE;
} }
@ -54,24 +54,24 @@ public class ExplosionEffect implements IDrainSpotEffect {
} }
@Override @Override
public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (level.getGameTime() % 40 != 0) if (level.getGameTime() % 40 != 0)
return; return;
if (!this.calcValues(level, pos, spot)) if (!this.calcValues(level, pos, spot))
return; return;
int x = Mth.floor(pos.getX() + level.rand.nextGaussian() * this.dist); int x = Mth.floor(pos.getX() + level.random.nextGaussian() * this.dist);
int z = Mth.floor(pos.getZ() + level.rand.nextGaussian() * this.dist); int z = Mth.floor(pos.getZ() + level.random.nextGaussian() * this.dist);
BlockPos chosenPos = new BlockPos(x, level.getHeight(Heightmap.Type.WORLD_SURFACE, x, z), z); BlockPos chosenPos = new BlockPos(x, level.getHeight(Heightmap.Types.WORLD_SURFACE, x, z), z);
if (chosenPos.distanceSq(pos) <= this.dist * this.dist && level.isBlockLoaded(chosenPos)) { if (chosenPos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(chosenPos)) {
level.createExplosion(null, level.explode(null,
chosenPos.getX() + 0.5, chosenPos.getY() + 0.5, chosenPos.getZ() + 0.5, chosenPos.getX() + 0.5, chosenPos.getY() + 0.5, chosenPos.getZ() + 0.5,
this.strength, false, Explosion.Mode.DESTROY); this.strength, false, Explosion.BlockInteraction.DESTROY);
} }
} }
@Override @Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) { public boolean appliesHere(LevelChunk chunk, IAuraChunk auraChunk, IAuraType type) {
return ModConfig.instance.explosionEffect.get(); return ModConfig.instance.explosionEffect.get();
} }

View file

@ -7,14 +7,15 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.blocks.ModBlocks;
import net.minecraft.block.*; import net.minecraft.core.BlockPos;
import net.minecraft.entity.player.Player; import net.minecraft.resources.ResourceLocation;
import net.minecraft.item.ItemStack; import net.minecraft.util.Mth;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.math.Mth; import net.minecraft.world.level.Level;
import net.minecraft.level.Level; import net.minecraft.world.level.block.*;
import net.minecraft.level.chunk.Chunk; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
public class GrassDieEffect implements IDrainSpotEffect { public class GrassDieEffect implements IDrainSpotEffect {
@ -40,10 +41,10 @@ public class GrassDieEffect implements IDrainSpotEffect {
} }
@Override @Override
public ActiveType isActiveHere(Player player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public ActiveType isActiveHere(Player player, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (!this.calcValues(player.level, pos, spot)) if (!this.calcValues(player.level, pos, spot))
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (player.getDistanceSq(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;
return ActiveType.ACTIVE; return ActiveType.ACTIVE;
} }
@ -54,37 +55,37 @@ public class GrassDieEffect implements IDrainSpotEffect {
} }
@Override @Override
public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (!this.calcValues(level, pos, spot)) if (!this.calcValues(level, pos, spot))
return; return;
for (int i = this.amount / 2 + level.rand.nextInt(this.amount / 2); i >= 0; i--) { for (int i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) {
BlockPos grassPos = new BlockPos( BlockPos grassPos = new BlockPos(
pos.getX() + level.rand.nextGaussian() * this.dist, pos.getX() + level.random.nextGaussian() * this.dist,
pos.getY() + level.rand.nextGaussian() * this.dist, pos.getY() + level.random.nextGaussian() * this.dist,
pos.getZ() + level.rand.nextGaussian() * this.dist pos.getZ() + level.random.nextGaussian() * this.dist
); );
if (grassPos.distanceSq(pos) <= this.dist * this.dist && level.isBlockLoaded(grassPos)) { if (grassPos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(grassPos)) {
BlockState state = level.getBlockState(grassPos); BlockState state = level.getBlockState(grassPos);
Block block = state.getBlock(); Block block = state.getBlock();
BlockState newState = null; BlockState newState = null;
if (block instanceof LeavesBlock) { if (block instanceof LeavesBlock) {
newState = ModBlocks.DECAYED_LEAVES.getDefaultState(); newState = ModBlocks.DECAYED_LEAVES.defaultBlockState();
} else if (block instanceof GrassBlock) { } else if (block instanceof GrassBlock) {
newState = Blocks.COARSE_DIRT.getDefaultState(); newState = Blocks.COARSE_DIRT.defaultBlockState();
} else if (block instanceof BushBlock) { } else if (block instanceof BushBlock) {
newState = Blocks.AIR.getDefaultState(); newState = Blocks.AIR.defaultBlockState();
} else if (block == ModBlocks.NETHER_GRASS) { } else if (block == ModBlocks.NETHER_GRASS) {
newState = Blocks.NETHERRACK.getDefaultState(); newState = Blocks.NETHERRACK.defaultBlockState();
} }
if (newState != null) if (newState != null)
level.setBlockState(grassPos, newState); level.setBlockAndUpdate(grassPos, newState);
} }
} }
} }
@Override @Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) { public boolean appliesHere(LevelChunk chunk, IAuraChunk auraChunk, IAuraType type) {
return ModConfig.instance.grassDieEffect.get() && (type.isSimilar(NaturesAuraAPI.TYPE_OVERWORLD) || type.isSimilar(NaturesAuraAPI.TYPE_NETHER)); return ModConfig.instance.grassDieEffect.get() && (type.isSimilar(NaturesAuraAPI.TYPE_OVERWORLD) || type.isSimilar(NaturesAuraAPI.TYPE_NETHER));
} }

View file

@ -6,20 +6,20 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import net.minecraft.block.AbstractFireBlock; import net.minecraft.core.BlockPos;
import net.minecraft.block.Block; import net.minecraft.core.Direction;
import net.minecraft.block.BlockState; import net.minecraft.resources.ResourceLocation;
import net.minecraft.block.Blocks;
import net.minecraft.entity.player.Player;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
import net.minecraft.util.Direction; import net.minecraft.util.Mth;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.math.Mth; import net.minecraft.world.item.Items;
import net.minecraft.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.level.chunk.Chunk; import net.minecraft.world.level.block.BaseFireBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
public class NetherDecayEffect implements IDrainSpotEffect { public class NetherDecayEffect implements IDrainSpotEffect {
@ -44,10 +44,10 @@ public class NetherDecayEffect implements IDrainSpotEffect {
} }
@Override @Override
public ActiveType isActiveHere(Player player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public ActiveType isActiveHere(Player player, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (!this.calcValues(player.level, pos, spot)) if (!this.calcValues(player.level, pos, spot))
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (player.getDistanceSq(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;
return ActiveType.ACTIVE; return ActiveType.ACTIVE;
} }
@ -58,15 +58,15 @@ public class NetherDecayEffect implements IDrainSpotEffect {
} }
@Override @Override
public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (!this.calcValues(level, pos, spot)) if (!this.calcValues(level, pos, spot))
return; return;
for (int i = this.amount / 2 + level.rand.nextInt(this.amount / 2); i >= 0; i--) { for (int i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) {
BlockPos offset = new BlockPos( BlockPos offset = new BlockPos(
pos.getX() + level.rand.nextGaussian() * this.dist, pos.getX() + level.random.nextGaussian() * this.dist,
pos.getY() + level.rand.nextGaussian() * this.dist, pos.getY() + level.random.nextGaussian() * this.dist,
pos.getZ() + level.rand.nextGaussian() * this.dist); pos.getZ() + level.random.nextGaussian() * this.dist);
if (offset.distanceSq(pos) > this.dist * this.dist || !level.isBlockLoaded(offset)) if (offset.distSqr(pos) > this.dist * this.dist || !level.isLoaded(offset))
continue; continue;
// degrade blocks // degrade blocks
@ -74,27 +74,27 @@ public class NetherDecayEffect implements IDrainSpotEffect {
BlockState state = level.getBlockState(offset); BlockState state = level.getBlockState(offset);
if (state.getBlock() == Blocks.GLOWSTONE) { if (state.getBlock() == Blocks.GLOWSTONE) {
degraded = Blocks.NETHERRACK; degraded = Blocks.NETHERRACK;
} else if (state.getBlock().isIn(BlockTags.NYLIUM) || state.getBlock() == Blocks.NETHERRACK) { } else if (state.is(BlockTags.NYLIUM) || state.getBlock() == Blocks.NETHERRACK) {
degraded = Blocks.SOUL_SOIL; degraded = Blocks.SOUL_SOIL;
} else if (state.getBlock() == Blocks.SOUL_SOIL) { } else if (state.getBlock() == Blocks.SOUL_SOIL) {
degraded = Blocks.SOUL_SAND; degraded = Blocks.SOUL_SAND;
} }
if (degraded != null) { if (degraded != null) {
level.playEvent(2001, offset, Block.getStateId(state)); level.levelEvent(2001, offset, Block.getId(state));
level.setBlockState(offset, degraded.getDefaultState()); level.setBlockAndUpdate(offset, degraded.defaultBlockState());
} }
// ignite blocks // ignite blocks
if (AbstractFireBlock.canLightBlock(level, offset, Direction.NORTH)) { if (BaseFireBlock.canBePlacedAt(level, offset, Direction.NORTH)) {
BlockState fire = AbstractFireBlock.getFireForPlacement(level, offset); BlockState fire = BaseFireBlock.getState(level, offset);
level.setBlockState(offset, fire); level.setBlockAndUpdate(offset, fire);
level.playEvent(1009, offset, 0); level.levelEvent(1009, offset, 0);
} }
} }
} }
@Override @Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) { public boolean appliesHere(LevelChunk chunk, IAuraChunk auraChunk, IAuraType type) {
return ModConfig.instance.netherDecayEffect.get() && type.isSimilar(NaturesAuraAPI.TYPE_NETHER); return ModConfig.instance.netherDecayEffect.get() && type.isSimilar(NaturesAuraAPI.TYPE_NETHER);
} }

View file

@ -9,16 +9,16 @@ import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.blocks.ModBlocks;
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.block.Block; import net.minecraft.core.BlockPos;
import net.minecraft.block.BlockState; import net.minecraft.core.Direction;
import net.minecraft.entity.player.Player; import net.minecraft.resources.ResourceLocation;
import net.minecraft.item.ItemStack; import net.minecraft.util.Mth;
import net.minecraft.util.Direction; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.Level;
import net.minecraft.util.math.Mth; import net.minecraft.world.level.block.Block;
import net.minecraft.level.Level; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.level.chunk.Chunk; import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraftforge.common.Tags; import net.minecraftforge.common.Tags;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
@ -44,12 +44,12 @@ public class NetherGrassEffect implements IDrainSpotEffect {
} }
@Override @Override
public ActiveType isActiveHere(Player player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public ActiveType isActiveHere(Player player, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (!this.calcValues(player.level, pos, spot)) if (!this.calcValues(player.level, pos, spot))
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (player.getDistanceSq(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.getPosition(), NAME)) if (NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), NAME))
return ActiveType.INHIBITED; return ActiveType.INHIBITED;
return ActiveType.ACTIVE; return ActiveType.ACTIVE;
} }
@ -60,29 +60,29 @@ public class NetherGrassEffect implements IDrainSpotEffect {
} }
@Override @Override
public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (level.getGameTime() % 40 != 0) if (level.getGameTime() % 40 != 0)
return; return;
if (!this.calcValues(level, pos, spot)) if (!this.calcValues(level, pos, spot))
return; return;
for (int i = this.amount / 2 + level.rand.nextInt(this.amount / 2); i >= 0; i--) { for (int i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) {
int x = Mth.floor(pos.getX() + level.rand.nextGaussian() * this.dist); int x = Mth.floor(pos.getX() + level.random.nextGaussian() * this.dist);
int y = Mth.floor(pos.getY() + level.rand.nextGaussian() * this.dist); int y = Mth.floor(pos.getY() + level.random.nextGaussian() * this.dist);
int z = Mth.floor(pos.getZ() + level.rand.nextGaussian() * this.dist); int z = Mth.floor(pos.getZ() + level.random.nextGaussian() * this.dist);
for (int yOff = -5; yOff <= 5; yOff++) { for (int yOff = -5; yOff <= 5; yOff++) {
BlockPos goalPos = new BlockPos(x, y + yOff, z); BlockPos goalPos = new BlockPos(x, y + yOff, z);
if (goalPos.distanceSq(pos) <= this.dist * this.dist && level.isBlockLoaded(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, NAME))
continue; continue;
BlockPos up = goalPos.up(); BlockPos up = goalPos.above();
if (level.getBlockState(up).isSolidSide(level, up, Direction.DOWN)) if (level.getBlockState(up).isFaceSturdy(level, up, Direction.DOWN))
continue; continue;
BlockState state = level.getBlockState(goalPos); BlockState state = level.getBlockState(goalPos);
Block block = state.getBlock(); Block block = state.getBlock();
if (Tags.Blocks.NETHERRACK.contains(block)) { if (Tags.Blocks.NETHERRACK.contains(block)) {
level.setBlockState(goalPos, ModBlocks.NETHER_GRASS.getDefaultState()); level.setBlockAndUpdate(goalPos, ModBlocks.NETHER_GRASS.defaultBlockState());
BlockPos closestSpot = IAuraChunk.getHighestSpot(level, goalPos, 25, pos); BlockPos closestSpot = IAuraChunk.getHighestSpot(level, goalPos, 25, pos);
IAuraChunk.getAuraChunk(level, closestSpot).drainAura(closestSpot, 500); IAuraChunk.getAuraChunk(level, closestSpot).drainAura(closestSpot, 500);
@ -97,7 +97,7 @@ public class NetherGrassEffect implements IDrainSpotEffect {
} }
@Override @Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) { public boolean appliesHere(LevelChunk chunk, IAuraChunk auraChunk, IAuraType type) {
return ModConfig.instance.netherGrassEffect.get() && type.isSimilar(NaturesAuraAPI.TYPE_NETHER); return ModConfig.instance.netherGrassEffect.get() && type.isSimilar(NaturesAuraAPI.TYPE_NETHER);
} }

View file

@ -65,7 +65,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.getOnPos(), NAME)) if (!NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), NAME))
return ActiveType.INHIBITED; return ActiveType.INHIBITED;
return ActiveType.ACTIVE; return ActiveType.ACTIVE;
} }

View file

@ -8,17 +8,18 @@ import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles; import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.*; import net.minecraft.core.BlockPos;
import net.minecraft.entity.player.Player; import net.minecraft.resources.ResourceLocation;
import net.minecraft.item.ItemStack; import net.minecraft.server.level.ServerLevel;
import net.minecraft.item.Items; import net.minecraft.util.Mth;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.math.Mth; import net.minecraft.world.item.Items;
import net.minecraft.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.level.chunk.Chunk; import net.minecraft.world.level.block.*;
import net.minecraft.level.gen.Heightmap; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.level.server.ServerLevel; import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.levelgen.Heightmap;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
public class PlantBoostEffect implements IDrainSpotEffect { public class PlantBoostEffect implements IDrainSpotEffect {
@ -43,12 +44,12 @@ public class PlantBoostEffect implements IDrainSpotEffect {
} }
@Override @Override
public ActiveType isActiveHere(Player player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public ActiveType isActiveHere(Player player, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (!this.calcValues(player.level, pos, spot)) if (!this.calcValues(player.level, pos, spot))
return ActiveType.INACTIVE; return ActiveType.INACTIVE;
if (player.getDistanceSq(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.getPosition(), NAME)) if (NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), NAME))
return ActiveType.INHIBITED; return ActiveType.INHIBITED;
return ActiveType.ACTIVE; return ActiveType.ACTIVE;
} }
@ -59,24 +60,23 @@ public class PlantBoostEffect implements IDrainSpotEffect {
} }
@Override @Override
public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (!this.calcValues(level, pos, spot)) if (!this.calcValues(level, pos, spot))
return; return;
for (int i = this.amount / 2 + level.rand.nextInt(this.amount / 2); i >= 0; i--) { for (int i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) {
int x = Mth.floor(pos.getX() + (2 * level.rand.nextFloat() - 1) * this.dist); int x = Mth.floor(pos.getX() + (2 * level.random.nextFloat() - 1) * this.dist);
int z = Mth.floor(pos.getZ() + (2 * level.rand.nextFloat() - 1) * this.dist); int z = Mth.floor(pos.getZ() + (2 * level.random.nextFloat() - 1) * this.dist);
BlockPos plantPos = new BlockPos(x, level.getHeight(Heightmap.Type.WORLD_SURFACE, x, z), z).down(); BlockPos plantPos = new BlockPos(x, level.getHeight(Heightmap.Types.WORLD_SURFACE, x, z), z).below();
if (plantPos.distanceSq(pos) <= this.dist * this.dist && level.isBlockLoaded(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, NAME))
continue; continue;
BlockState state = level.getBlockState(plantPos); BlockState state = level.getBlockState(plantPos);
Block block = state.getBlock(); Block block = state.getBlock();
if (block instanceof IGrowable && !(block instanceof DoublePlantBlock) && !(block instanceof TallGrassBlock) && block != Blocks.GRASS_BLOCK) { if (block instanceof BonemealableBlock growable && !(block instanceof DoublePlantBlock) && !(block instanceof TallGrassBlock) && block != Blocks.GRASS_BLOCK) {
IGrowable growable = (IGrowable) block; if (growable.isValidBonemealTarget(level, plantPos, state, false)) {
if (growable.canGrow(level, plantPos, state, false)) {
try { try {
growable.grow((ServerLevel) level, level.rand, plantPos, state); growable.performBonemeal((ServerLevel) level, level.random, plantPos, state);
} catch (Exception e) { } catch (Exception e) {
// a lot of stuff throws here (double plants where generation only caused half of it to exist, bamboo at level height...) // a lot of stuff throws here (double plants where generation only caused half of it to exist, bamboo at level height...)
// so just catch all, bleh // so just catch all, bleh
@ -93,7 +93,7 @@ public class PlantBoostEffect implements IDrainSpotEffect {
} }
@Override @Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) { public boolean appliesHere(LevelChunk chunk, IAuraChunk auraChunk, IAuraType type) {
return ModConfig.instance.plantBoostEffect.get() && type.isSimilar(NaturesAuraAPI.TYPE_OVERWORLD); return ModConfig.instance.plantBoostEffect.get() && type.isSimilar(NaturesAuraAPI.TYPE_OVERWORLD);
} }

View file

@ -8,10 +8,10 @@ import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.chunk.ISpotDrainable; import de.ellpeck.naturesaura.api.aura.chunk.ISpotDrainable;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import net.minecraft.util.ResourceLocation; import net.minecraft.core.BlockPos;
import net.minecraft.util.math.BlockPos; import net.minecraft.resources.ResourceLocation;
import net.minecraft.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.level.chunk.Chunk; import net.minecraft.world.level.chunk.LevelChunk;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -21,7 +21,7 @@ public class ReplenishingEffect implements IDrainSpotEffect {
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "replenishing"); public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "replenishing");
@Override @Override
public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (spot < 0) { if (spot < 0) {
List<ISpotDrainable> tiles = new ArrayList<>(); List<ISpotDrainable> tiles = new ArrayList<>();
Helper.getBlockEntitiesInArea(level, pos, 25, tile -> { Helper.getBlockEntitiesInArea(level, pos, 25, tile -> {
@ -32,8 +32,8 @@ public class ReplenishingEffect implements IDrainSpotEffect {
}); });
if (!tiles.isEmpty()) { if (!tiles.isEmpty()) {
IAuraType type = IAuraType.forLevel(level); IAuraType type = IAuraType.forLevel(level);
for (int i = level.rand.nextInt(6); i >= 0; i--) { for (int i = level.random.nextInt(6); i >= 0; i--) {
ISpotDrainable tile = tiles.get(level.rand.nextInt(tiles.size())); ISpotDrainable tile = tiles.get(level.random.nextInt(tiles.size()));
if (!tile.isAcceptableType(type)) if (!tile.isAcceptableType(type))
continue; continue;
int drained = tile.drainAuraPassively(-spot, false); int drained = tile.drainAuraPassively(-spot, false);
@ -50,7 +50,7 @@ public class ReplenishingEffect implements IDrainSpotEffect {
} }
@Override @Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) { public boolean appliesHere(LevelChunk chunk, IAuraChunk auraChunk, IAuraType type) {
return true; return true;
} }

View file

@ -4,19 +4,19 @@ import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import net.minecraft.util.Direction; import net.minecraft.core.BlockPos;
import net.minecraft.util.ResourceLocation; import net.minecraft.core.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.math.Mth; import net.minecraft.util.Mth;
import net.minecraft.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.level.chunk.Chunk; import net.minecraft.world.level.chunk.LevelChunk;
public class SpreadEffect implements IDrainSpotEffect { public class SpreadEffect implements IDrainSpotEffect {
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "spread"); public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "spread");
@Override @Override
public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (Math.abs(spot) < 500000 || Math.abs(IAuraChunk.getAuraInArea(level, pos, 25)) < 2000000) if (Math.abs(spot) < 500000 || Math.abs(IAuraChunk.getAuraInArea(level, pos, 25)) < 2000000)
return; return;
boolean drain = spot > 0; boolean drain = spot > 0;
@ -26,8 +26,8 @@ public class SpreadEffect implements IDrainSpotEffect {
BlockPos bestOffset = null; BlockPos bestOffset = null;
int bestAmount = drain ? Integer.MAX_VALUE : Integer.MIN_VALUE; int bestAmount = drain ? Integer.MAX_VALUE : Integer.MIN_VALUE;
for (Direction facing : Direction.values()) { for (Direction facing : Direction.values()) {
BlockPos offset = pos.offset(facing, 15); BlockPos offset = pos.relative(facing, 15);
if (level.isBlockLoaded(offset) && offset.getY() >= 0 && offset.getY() <= level.getHeight()) { if (level.isLoaded(offset) && offset.getY() >= 0 && offset.getY() <= level.getHeight()) {
int amount = IAuraChunk.getAuraInArea(level, offset, 14); int amount = IAuraChunk.getAuraInArea(level, offset, 14);
if (drain ? amount < bestAmount : amount > bestAmount) { if (drain ? amount < bestAmount : amount > bestAmount) {
bestAmount = amount; bestAmount = amount;
@ -55,7 +55,7 @@ public class SpreadEffect implements IDrainSpotEffect {
} }
@Override @Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) { public boolean appliesHere(LevelChunk chunk, IAuraChunk auraChunk, IAuraType type) {
return true; return true;
} }

View file

@ -3,40 +3,40 @@ package de.ellpeck.naturesaura.commands;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.arguments.IntegerArgumentType;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import net.minecraft.command.CommandSource; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.command.Commands; import net.minecraft.commands.Commands;
import net.minecraft.util.math.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.util.text.StringTextComponent; import net.minecraft.network.chat.TextComponent;
public final class CommandAura { public final class CommandAura {
public static void register(CommandDispatcher<CommandSource> dispatcher) { public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
dispatcher.register(Commands.literal("naaura").requires(s -> s.hasPermissionLevel(2)) dispatcher.register(Commands.literal("naaura").requires(s -> s.hasPermission(2))
.then(Commands.literal("add").then(Commands.argument("amount", IntegerArgumentType.integer(1)).executes(context -> { .then(Commands.literal("add").then(Commands.argument("amount", IntegerArgumentType.integer(1)).executes(context -> {
int amount = IntegerArgumentType.getInteger(context, "amount"); int amount = IntegerArgumentType.getInteger(context, "amount");
CommandSource source = context.getSource(); CommandSourceStack source = context.getSource();
BlockPos pos = new BlockPos(source.getPos()); BlockPos pos = new BlockPos(source.getPosition());
while (amount > 0) { while (amount > 0) {
BlockPos spot = IAuraChunk.getLowestSpot(source.getLevel(), pos, 35, pos); BlockPos 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.sendFeedback(new StringTextComponent("Added aura to area"), true); source.sendSuccess(new TextComponent("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 -> {
int amount = IntegerArgumentType.getInteger(context, "amount"); int amount = IntegerArgumentType.getInteger(context, "amount");
CommandSource source = context.getSource(); CommandSourceStack source = context.getSource();
BlockPos pos = new BlockPos(source.getPos()); BlockPos pos = new BlockPos(source.getPosition());
while (amount > 0) { while (amount > 0) {
BlockPos spot = IAuraChunk.getHighestSpot(source.getLevel(), pos, 35, pos); BlockPos 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.sendFeedback(new StringTextComponent("Removed aura from area"), true); source.sendSuccess(new TextComponent("Removed aura from area"), true);
return 0; return 0;
}))) })))
.then(Commands.literal("reset").executes(context -> { .then(Commands.literal("reset").executes(context -> {
CommandSource source = context.getSource(); CommandSourceStack source = context.getSource();
BlockPos pos = new BlockPos(source.getPos()); BlockPos pos = new BlockPos(source.getPosition());
IAuraChunk.getSpotsInArea(source.getLevel(), pos, 35, (spot, amount) -> { IAuraChunk.getSpotsInArea(source.getLevel(), pos, 35, (spot, amount) -> {
IAuraChunk chunk = IAuraChunk.getAuraChunk(source.getLevel(), spot); IAuraChunk chunk = IAuraChunk.getAuraChunk(source.getLevel(), spot);
if (amount > 0) if (amount > 0)
@ -44,7 +44,7 @@ public final class CommandAura {
else else
chunk.storeAura(spot, -amount); chunk.storeAura(spot, -amount);
}); });
source.sendFeedback(new StringTextComponent("Reset aura in area"), true); source.sendSuccess(new TextComponent("Reset aura in area"), true);
return 0; return 0;
}))); })));
} }

View file

@ -2,7 +2,6 @@ package de.ellpeck.naturesaura.compat;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.compat.enchantibility.EnchantibilityCompat;
import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat; import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat;
import de.ellpeck.naturesaura.data.ItemTagProvider; import de.ellpeck.naturesaura.data.ItemTagProvider;
import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.ModList;
@ -17,8 +16,8 @@ public final class Compat {
private static final Map<String, Supplier<ICompat>> MODULE_TYPES = ImmutableMap.<String, Supplier<ICompat>>builder() private static final Map<String, Supplier<ICompat>> MODULE_TYPES = ImmutableMap.<String, Supplier<ICompat>>builder()
.put("patchouli", PatchouliCompat::new) .put("patchouli", PatchouliCompat::new)
.put("curios", CuriosCompat::new) /* .put("curios", CuriosCompat::new)
.put("enchantability", EnchantibilityCompat::new) .put("enchantability", EnchantibilityCompat::new)*/
.build(); .build();
private static final Map<String, ICompat> MODULES = new HashMap<>(); private static final Map<String, ICompat> MODULES = new HashMap<>();

View file

@ -1,3 +1,5 @@
// TODO Curios
/*
package de.ellpeck.naturesaura.compat; package de.ellpeck.naturesaura.compat;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
@ -96,3 +98,4 @@ public class CuriosCompat implements ICompat {
} }
} }
} }
*/

View file

@ -1,3 +1,5 @@
// TODO Enchantability
/*
package de.ellpeck.naturesaura.compat.enchantibility; package de.ellpeck.naturesaura.compat.enchantibility;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
@ -34,3 +36,4 @@ public class EnchantibilityAuraMending extends AbstractEnchantEffect {
return RES; return RES;
} }
} }
*/

View file

@ -1,3 +1,5 @@
// TODO Enchantability
/*
package de.ellpeck.naturesaura.compat.enchantibility; package de.ellpeck.naturesaura.compat.enchantibility;
import de.ellpeck.naturesaura.compat.ICompat; import de.ellpeck.naturesaura.compat.ICompat;
@ -30,3 +32,4 @@ public class EnchantibilityCompat implements ICompat {
} }
} }
*/

View file

@ -1,3 +1,4 @@
/*
package de.ellpeck.naturesaura.compat.jei; package de.ellpeck.naturesaura.compat.jei;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -80,3 +81,4 @@ public class AltarCategory implements IRecipeCategory<AltarRecipe> {
group.set(3, recipe.getDimensionBottle()); group.set(3, recipe.getDimensionBottle());
} }
} }
*/

View file

@ -1,3 +1,4 @@
/*
package de.ellpeck.naturesaura.compat.jei; package de.ellpeck.naturesaura.compat.jei;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -140,3 +141,4 @@ public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecip
} }
} }
*/

View file

@ -1,3 +1,4 @@
/*
package de.ellpeck.naturesaura.compat.jei; package de.ellpeck.naturesaura.compat.jei;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
@ -78,3 +79,4 @@ public class JEINaturesAuraPlugin implements IModPlugin {
registration.addRecipes(manager.getRecipes(ModRecipes.ANIMAL_SPAWNER_TYPE, null, null), SPAWNER); registration.addRecipes(manager.getRecipes(ModRecipes.ANIMAL_SPAWNER_TYPE, null, null), SPAWNER);
} }
} }
*/

View file

@ -1,3 +1,4 @@
/*
package de.ellpeck.naturesaura.compat.jei; package de.ellpeck.naturesaura.compat.jei;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -68,3 +69,4 @@ public class OfferingCategory implements IRecipeCategory<OfferingRecipe> {
group.set(2, Arrays.asList(recipe.startItem.getMatchingStacks())); group.set(2, Arrays.asList(recipe.startItem.getMatchingStacks()));
} }
} }
*/

View file

@ -1,3 +1,4 @@
/*
package de.ellpeck.naturesaura.compat.jei; package de.ellpeck.naturesaura.compat.jei;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -77,3 +78,4 @@ public class TreeRitualCategory implements IRecipeCategory<TreeRitualRecipe> {
} }
} }
} }
*/

View file

@ -1,3 +1,4 @@
/*
package de.ellpeck.naturesaura.compat.patchouli; package de.ellpeck.naturesaura.compat.patchouli;
import de.ellpeck.naturesaura.recipes.AltarRecipe; import de.ellpeck.naturesaura.recipes.AltarRecipe;
@ -46,3 +47,4 @@ public class ProcessorAltar implements IComponentProcessor {
return group.isEmpty() || group.equals(this.recipe.catalyst == Ingredient.EMPTY ? "altar" : "catalyst"); return group.isEmpty() || group.equals(this.recipe.catalyst == Ingredient.EMPTY ? "altar" : "catalyst");
} }
} }
*/

View file

@ -1,3 +1,4 @@
/*
package de.ellpeck.naturesaura.compat.patchouli; package de.ellpeck.naturesaura.compat.patchouli;
import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe; import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe;
@ -46,3 +47,4 @@ public class ProcessorAnimalSpawner implements IComponentProcessor {
return !"seekrit".equals(group); return !"seekrit".equals(group);
} }
} }
*/

View file

@ -1,3 +1,4 @@
/*
package de.ellpeck.naturesaura.compat.patchouli; package de.ellpeck.naturesaura.compat.patchouli;
import de.ellpeck.naturesaura.recipes.OfferingRecipe; import de.ellpeck.naturesaura.recipes.OfferingRecipe;
@ -32,3 +33,4 @@ public class ProcessorOffering implements IComponentProcessor {
} }
} }
} }
*/

View file

@ -1,3 +1,4 @@
/*
package de.ellpeck.naturesaura.compat.patchouli; package de.ellpeck.naturesaura.compat.patchouli;
import de.ellpeck.naturesaura.recipes.TreeRitualRecipe; import de.ellpeck.naturesaura.recipes.TreeRitualRecipe;
@ -38,3 +39,4 @@ public class ProcessorTreeRitual implements IComponentProcessor {
} }
} }
} }
*/

View file

@ -9,20 +9,28 @@ 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.IModItem;
import de.ellpeck.naturesaura.reg.ModRegistry; import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.advancements.criterion.StatePropertiesPredicate; import net.minecraft.advancements.critereon.StatePropertiesPredicate;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.FlowerPotBlock;
import net.minecraft.data.DataGenerator; import net.minecraft.data.DataGenerator;
import net.minecraft.data.DirectoryCache; import net.minecraft.data.DataProvider;
import net.minecraft.data.IDataProvider; import net.minecraft.data.HashCache;
import net.minecraft.data.loot.BlockLootTables; import net.minecraft.data.loot.BlockLoot;
import net.minecraft.item.Items; import net.minecraft.resources.ResourceLocation;
import net.minecraft.loot.*; import net.minecraft.world.item.Items;
import net.minecraft.loot.conditions.BlockStateProperty; import net.minecraft.world.level.block.Block;
import net.minecraft.loot.conditions.RandomChance; import net.minecraft.world.level.block.Blocks;
import net.minecraft.loot.functions.SetCount; import net.minecraft.world.level.block.FlowerPotBlock;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.level.storage.loot.LootPool;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.LootTables;
import net.minecraft.world.level.storage.loot.entries.LootItem;
import net.minecraft.world.level.storage.loot.entries.LootPoolEntryContainer;
import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import net.minecraft.world.level.storage.loot.predicates.ConditionUserBuilder;
import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition;
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.UniformGenerator;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.io.IOException; import java.io.IOException;
@ -31,7 +39,8 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
public class BlockLootProvider implements IDataProvider { public class BlockLootProvider implements DataProvider {
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
private final DataGenerator generator; private final DataGenerator generator;
private final Map<Block, Function<Block, LootTable.Builder>> lootFunctions = new HashMap<>(); private final Map<Block, Function<Block, LootTable.Builder>> lootFunctions = new HashMap<>();
@ -40,9 +49,8 @@ public class BlockLootProvider implements IDataProvider {
this.generator = generator; this.generator = generator;
for (IModItem item : ModRegistry.ALL_ITEMS) { for (IModItem item : ModRegistry.ALL_ITEMS) {
if (!(item instanceof Block)) if (!(item instanceof Block block))
continue; continue;
Block block = (Block) item;
if (block instanceof Slab) { if (block instanceof Slab) {
this.lootFunctions.put(block, LootTableHooks::genSlab); this.lootFunctions.put(block, LootTableHooks::genSlab);
} else if (block instanceof BlockFlowerPot) { } else if (block instanceof BlockFlowerPot) {
@ -54,9 +62,9 @@ public class BlockLootProvider implements IDataProvider {
this.lootFunctions.put(ModBlocks.ANCIENT_LEAVES, LootTableHooks::genSilkOnly); this.lootFunctions.put(ModBlocks.ANCIENT_LEAVES, LootTableHooks::genSilkOnly);
this.lootFunctions.put(ModBlocks.DECAYED_LEAVES, LootTableHooks::genSilkOnly); this.lootFunctions.put(ModBlocks.DECAYED_LEAVES, LootTableHooks::genSilkOnly);
this.lootFunctions.put(ModBlocks.GOLDEN_LEAVES, b -> LootTable.builder().addLootPool(LootPool.builder().rolls(ConstantRange.of(1)).addEntry(LootTableHooks.survivesExplosion(b, ItemLootEntry.builder(ModItems.GOLD_LEAF)).acceptCondition(BlockStateProperty.builder(b).fromProperties(StatePropertiesPredicate.Builder.newBuilder().withIntProp(BlockGoldenLeaves.STAGE, BlockGoldenLeaves.HIGHEST_STAGE)))).acceptCondition(RandomChance.builder(0.75F)))); this.lootFunctions.put(ModBlocks.GOLDEN_LEAVES, b -> LootTable.lootTable().withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1)).add(LootTableHooks.survivesExplosion(b, LootItem.lootTableItem(ModItems.GOLD_LEAF)).when(LootItemBlockStatePropertyCondition.hasBlockStateProperties(b).setProperties(StatePropertiesPredicate.Builder.properties().hasProperty(BlockGoldenLeaves.STAGE, BlockGoldenLeaves.HIGHEST_STAGE)))).when(LootItemRandomChanceCondition.randomChance(0.75F))));
this.lootFunctions.put(ModBlocks.NETHER_WART_MUSHROOM, b -> LootTableHooks.genSilkOr(b, ItemLootEntry.builder(Items.NETHER_WART).acceptFunction(SetCount.builder(RandomValueRange.of(1, 2))))); this.lootFunctions.put(ModBlocks.NETHER_WART_MUSHROOM, b -> LootTableHooks.genSilkOr(b, LootItem.lootTableItem(Items.NETHER_WART).apply(SetItemCountFunction.setCount(UniformGenerator.between(1, 2)))));
this.lootFunctions.put(ModBlocks.NETHER_GRASS, b -> LootTableHooks.genSilkOr(b, ItemLootEntry.builder(Blocks.NETHERRACK))); this.lootFunctions.put(ModBlocks.NETHER_GRASS, b -> LootTableHooks.genSilkOr(b, LootItem.lootTableItem(Blocks.NETHERRACK)));
} }
private static Path getPath(Path root, ResourceLocation res) { private static Path getPath(Path root, ResourceLocation res) {
@ -64,13 +72,13 @@ public class BlockLootProvider implements IDataProvider {
} }
@Override @Override
public void act(DirectoryCache cache) throws IOException { public void run(HashCache cache) throws IOException {
for (Map.Entry<Block, Function<Block, LootTable.Builder>> function : this.lootFunctions.entrySet()) { for (Map.Entry<Block, Function<Block, LootTable.Builder>> function : this.lootFunctions.entrySet()) {
Block block = function.getKey(); Block block = function.getKey();
Function<Block, LootTable.Builder> func = function.getValue(); Function<Block, LootTable.Builder> func = function.getValue();
LootTable table = func.apply(block).setParameterSet(LootParameterSets.BLOCK).build(); LootTable table = func.apply(block).setParamSet(LootContextParamSets.BLOCK).build();
Path path = getPath(this.generator.getOutputFolder(), block.getRegistryName()); Path path = getPath(this.generator.getOutputFolder(), block.getRegistryName());
IDataProvider.save(GSON, cache, LootTableManager.toJson(table), path); DataProvider.save(GSON, cache, LootTables.serialize(table), path);
} }
} }
@ -81,33 +89,34 @@ public class BlockLootProvider implements IDataProvider {
} }
// What a mess // What a mess
private static class LootTableHooks extends BlockLootTables { 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 droppingWithChancesAndSticks(block, drop, 0.05F, 0.0625F, 0.083333336F, 0.1F); return 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 droppingSlab(block); return createSlabItemTable(block);
} }
public static LootTable.Builder genRegular(Block block) { public static LootTable.Builder genRegular(Block block) {
return dropping(block); return createSingleItemTable(block);
} }
public static LootTable.Builder genSilkOnly(Block block) { public static LootTable.Builder genSilkOnly(Block block) {
return onlyWithSilkTouch(block); return createSilkTouchOnlyTable(block);
} }
public static LootTable.Builder genSilkOr(Block block, LootEntry.Builder<?> builder) { public static LootTable.Builder genSilkOr(Block block, LootPoolEntryContainer.Builder<?> builder) {
return droppingWithSilkTouch(block, builder); return createSilkTouchOrShearsDispatchTable(block, builder);
} }
public static LootTable.Builder genFlowerPot(Block block) { public static LootTable.Builder genFlowerPot(Block block) {
return droppingAndFlowerPot(((FlowerPotBlock) block).getFlower()); return createPotFlowerItemTable(((FlowerPotBlock) block).getContent());
} }
public static <T> T survivesExplosion(Block block, ILootConditionConsumer<T> then) { public static <T> T survivesExplosion(Block block, ConditionUserBuilder<T> then) {
return withSurvivesExplosion(block, then); return applyExplosionCondition(block, then);
} }
} }
} }

View file

@ -2,12 +2,12 @@ package de.ellpeck.naturesaura.data;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.blocks.ModBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.data.BlockTagsProvider;
import net.minecraft.data.DataGenerator; import net.minecraft.data.DataGenerator;
import net.minecraft.data.tags.BlockTagsProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.common.Tags; import net.minecraftforge.common.Tags;
public class BlockTagProvider extends BlockTagsProvider { public class BlockTagProvider extends BlockTagsProvider {
@ -19,15 +19,15 @@ public class BlockTagProvider extends BlockTagsProvider {
} }
@Override @Override
protected void registerTags() { protected void addTags() {
this.getOrCreateBuilder(BlockTags.LOGS).add(ModBlocks.ANCIENT_LOG, ModBlocks.ANCIENT_BARK); this.tag(BlockTags.LOGS).add(ModBlocks.ANCIENT_LOG, ModBlocks.ANCIENT_BARK);
this.getOrCreateBuilder(BlockTags.PLANKS).add(ModBlocks.ANCIENT_PLANKS); this.tag(BlockTags.PLANKS).add(ModBlocks.ANCIENT_PLANKS);
this.getOrCreateBuilder(BlockTags.STAIRS).add(ModBlocks.ANCIENT_STAIRS, ModBlocks.INFUSED_BRICK_STAIRS, ModBlocks.INFUSED_STAIRS); this.tag(BlockTags.STAIRS).add(ModBlocks.ANCIENT_STAIRS, ModBlocks.INFUSED_BRICK_STAIRS, ModBlocks.INFUSED_STAIRS);
this.getOrCreateBuilder(BlockTags.LEAVES).add(ModBlocks.GOLDEN_LEAVES, ModBlocks.ANCIENT_LEAVES, ModBlocks.DECAYED_LEAVES); this.tag(BlockTags.LEAVES).add(ModBlocks.GOLDEN_LEAVES, ModBlocks.ANCIENT_LEAVES, ModBlocks.DECAYED_LEAVES);
this.getOrCreateBuilder(BlockTags.RAILS).add(ModBlocks.DIMENSION_RAIL_END, ModBlocks.DIMENSION_RAIL_NETHER, ModBlocks.DIMENSION_RAIL_OVERWORLD); this.tag(BlockTags.RAILS).add(ModBlocks.DIMENSION_RAIL_END, ModBlocks.DIMENSION_RAIL_NETHER, ModBlocks.DIMENSION_RAIL_OVERWORLD);
this.getOrCreateBuilder(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.getOrCreateBuilder(Tags.Blocks.DIRT).add(ModBlocks.NETHER_GRASS); this.tag(Tags.Blocks.DIRT).add(ModBlocks.NETHER_GRASS);
this.getOrCreateBuilder(BlockTags.SMALL_FLOWERS).add(ModBlocks.END_FLOWER, ModBlocks.AURA_BLOOM); this.tag(BlockTags.SMALL_FLOWERS).add(ModBlocks.END_FLOWER, ModBlocks.AURA_BLOOM);
this.getOrCreateBuilder(NETHER_ALTAR_WOOD).add(Blocks.CRIMSON_PLANKS, Blocks.WARPED_PLANKS); this.tag(NETHER_ALTAR_WOOD).add(Blocks.CRIMSON_PLANKS, Blocks.WARPED_PLANKS);
} }
} }

View file

@ -4,21 +4,21 @@ 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 net.minecraft.data.DataGenerator; import net.minecraft.data.DataGenerator;
import net.minecraft.data.ItemTagsProvider; import net.minecraft.data.tags.BlockTagsProvider;
import net.minecraft.item.Item; import net.minecraft.data.tags.ItemTagsProvider;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ITag;
import net.minecraft.tags.ItemTags; import net.minecraft.tags.ItemTags;
import net.minecraftforge.common.Tags; import net.minecraftforge.common.Tags;
import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.common.data.ExistingFileHelper;
public class ItemTagProvider extends ItemTagsProvider { public class ItemTagProvider extends ItemTagsProvider {
public ItemTagProvider(DataGenerator generatorIn, BlockTagProvider blockTagProvider, ExistingFileHelper helper) {
public ItemTagProvider(DataGenerator generatorIn, BlockTagsProvider blockTagProvider, ExistingFileHelper helper) {
super(generatorIn, blockTagProvider, NaturesAura.MOD_ID, helper); super(generatorIn, blockTagProvider, NaturesAura.MOD_ID, helper);
} }
@Override @Override
protected void registerTags() { protected void addTags() {
this.copy(BlockTags.LOGS, ItemTags.LOGS); this.copy(BlockTags.LOGS, ItemTags.LOGS);
this.copy(BlockTags.PLANKS, ItemTags.PLANKS); this.copy(BlockTags.PLANKS, ItemTags.PLANKS);
this.copy(BlockTags.STAIRS, ItemTags.STAIRS); this.copy(BlockTags.STAIRS, ItemTags.STAIRS);
@ -26,13 +26,9 @@ public class ItemTagProvider extends ItemTagsProvider {
this.copy(BlockTags.RAILS, ItemTags.RAILS); this.copy(BlockTags.RAILS, ItemTags.RAILS);
this.copy(BlockTags.SLABS, ItemTags.SLABS); this.copy(BlockTags.SLABS, ItemTags.SLABS);
this.getOrCreateBuilder(Tags.Items.RODS_WOODEN).add(ModItems.ANCIENT_STICK); this.tag(Tags.Items.RODS_WOODEN).add(ModItems.ANCIENT_STICK);
Compat.addItemTags(this); Compat.addItemTags(this);
} }
@Override
public Builder<Item> getOrCreateBuilder(ITag.INamedTag<Item> tag) {
return super.getOrCreateBuilder(tag);
}
} }

View file

@ -4,7 +4,7 @@ import net.minecraft.data.DataGenerator;
import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; import net.minecraftforge.forge.event.lifecycle.GatherDataEvent;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public final class ModData { public final class ModData {

View file

@ -1,6 +1,6 @@
package de.ellpeck.naturesaura.enchant; package de.ellpeck.naturesaura.enchant;
import net.minecraft.enchantment.Enchantment; import net.minecraft.world.item.enchantment.Enchantment;
@SuppressWarnings("FieldNamingConvention") @SuppressWarnings("FieldNamingConvention")
public final class ModEnchantments { public final class ModEnchantments {

View file

@ -49,7 +49,7 @@ public class EntityMoverMinecart extends AbstractMinecart {
super.moveMinecartOnRail(railPos); super.moveMinecartOnRail(railPos);
if (!this.isActive) if (!this.isActive)
return; return;
BlockPos pos = this.getOnPos(); BlockPos pos = this.blockPosition();
if (!this.spotOffsets.isEmpty() && this.level.getGameTime() % 10 == 0) if (!this.spotOffsets.isEmpty() && this.level.getGameTime() % 10 == 0)
PacketHandler.sendToAllAround(this.level, pos, 32, new PacketParticles( PacketHandler.sendToAllAround(this.level, pos, 32, new PacketParticles(
@ -85,7 +85,7 @@ public class EntityMoverMinecart extends AbstractMinecart {
if (this.isActive != receivingPower) { if (this.isActive != receivingPower) {
this.isActive = receivingPower; this.isActive = receivingPower;
BlockPos pos = this.getOnPos(); BlockPos pos = this.blockPosition();
if (!this.isActive) { if (!this.isActive) {
this.moveAura(this.level, this.lastPosition, this.level, pos); this.moveAura(this.level, this.lastPosition, this.level, pos);
this.spotOffsets.clear(); this.spotOffsets.clear();
@ -138,7 +138,7 @@ public class EntityMoverMinecart extends AbstractMinecart {
public Entity changeDimension(ServerLevel destination, ITeleporter teleporter) { public Entity changeDimension(ServerLevel destination, ITeleporter teleporter) {
Entity entity = super.changeDimension(destination, teleporter); Entity entity = super.changeDimension(destination, teleporter);
if (entity instanceof EntityMoverMinecart) { if (entity instanceof EntityMoverMinecart) {
BlockPos pos = entity.getOnPos(); BlockPos pos = entity.blockPosition();
this.moveAura(this.level, this.lastPosition, entity.level, pos); this.moveAura(this.level, this.lastPosition, entity.level, pos);
((EntityMoverMinecart) entity).lastPosition = pos; ((EntityMoverMinecart) entity).lastPosition = pos;
} }

View file

@ -125,7 +125,7 @@ public class EntityStructureFinder extends EyeOfEnder {
if (this.shatterOrDrop) { if (this.shatterOrDrop) {
this.level.addFreshEntity(new ItemEntity(this.level, this.getX(), this.getY(), this.getZ(), this.getItem())); this.level.addFreshEntity(new ItemEntity(this.level, this.getX(), this.getY(), this.getZ(), this.getItem()));
} else { } else {
PacketHandler.sendToAllAround(this.level, this.getOnPos(), 32, new PacketParticles((float) this.getX(), (float) this.getY(), (float) this.getZ(), PacketParticles.Type.STRUCTURE_FINDER, this.getId())); PacketHandler.sendToAllAround(this.level, this.blockPosition(), 32, new PacketParticles((float) this.getX(), (float) this.getY(), (float) this.getZ(), PacketParticles.Type.STRUCTURE_FINDER, this.getId()));
} }
} }
} else { } else {

View file

@ -1,55 +1,35 @@
package de.ellpeck.naturesaura.events; package de.ellpeck.naturesaura.events;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.*;
import de.ellpeck.naturesaura.items.ItemAuraCache; import de.ellpeck.naturesaura.items.ItemAuraCache;
import de.ellpeck.naturesaura.items.ItemRangeVisualizer; import de.ellpeck.naturesaura.items.ItemRangeVisualizer;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.packet.PacketAuraChunk; import de.ellpeck.naturesaura.packet.PacketAuraChunk;
import net.minecraft.block.*; import net.minecraft.ChatFormatting;
import net.minecraft.client.MainWindow;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.AbstractGui; import net.minecraft.client.renderer.BiomeColors;
import net.minecraft.client.gui.screen.ChatScreen; import net.minecraft.core.BlockPos;
import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.resources.ResourceLocation;
import net.minecraft.client.resources.I18n; import net.minecraft.util.Mth;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Tuple; import net.minecraft.util.Tuple;
import net.minecraft.util.math.AABB; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.item.Items;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.level.block.*;
import net.minecraft.util.math.Mth; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.level.Level;
import net.minecraft.level.biome.BiomeColors;
import net.minecraft.level.gen.Heightmap;
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.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import net.minecraftforge.client.event.RenderLevelLastEvent; import net.minecraftforge.client.event.RenderLevelLastEvent;
import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.IPlantable;
import net.minecraftforge.energy.EnergyStorage;
import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.mutable.MutableInt;
import org.lwjgl.opengl.GL11;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.ArrayList; import java.util.ArrayList;
@ -73,19 +53,19 @@ public class ClientEvents {
@SubscribeEvent @SubscribeEvent
public void onDebugRender(RenderGameOverlayEvent.Text event) { public void onDebugRender(RenderGameOverlayEvent.Text event) {
Minecraft mc = Minecraft.getInstance(); Minecraft mc = Minecraft.getInstance();
if (mc.gameSettings.showDebugInfo && ModConfig.instance.debugText.get()) { if (mc.options.renderDebug && ModConfig.instance.debugText.get()) {
String prefix = TextFormatting.GREEN + "[" + NaturesAura.MOD_NAME + "]" + TextFormatting.RESET + " "; String prefix = ChatFormatting.GREEN + "[" + NaturesAura.MOD_NAME + "]" + ChatFormatting.RESET + " ";
List<String> left = event.getLeft(); List<String> left = event.getLeft();
if (mc.player.isCreative()) { if (mc.player.isCreative()) {
left.add(""); left.add("");
MutableInt amount = new MutableInt(IAuraChunk.DEFAULT_AURA); MutableInt amount = new MutableInt(IAuraChunk.DEFAULT_AURA);
MutableInt spots = new MutableInt(); MutableInt spots = new MutableInt();
MutableInt chunks = new MutableInt(); MutableInt chunks = new MutableInt();
IAuraChunk.getSpotsInArea(mc.level, mc.player.getPosition(), 35, (blockPos, drainSpot) -> { IAuraChunk.getSpotsInArea(mc.level, mc.player.blockPosition(), 35, (blockPos, drainSpot) -> {
spots.increment(); spots.increment();
amount.add(drainSpot); amount.add(drainSpot);
}); });
Helper.getAuraChunksWithSpotsInArea(mc.level, mc.player.getPosition(), 35, c -> chunks.increment()); Helper.getAuraChunksWithSpotsInArea(mc.level, mc.player.blockPosition(), 35, c -> chunks.increment());
NumberFormat format = NumberFormat.getInstance(); NumberFormat format = NumberFormat.getInstance();
left.add(prefix + "A: " + format.format(amount.intValue()) + " (S: " + spots.intValue() + ", C: " + chunks.intValue() + ")"); left.add(prefix + "A: " + format.format(amount.intValue()) + " (S: " + spots.intValue() + ", C: " + chunks.intValue() + ")");
left.add(prefix + "AT: " + IAuraType.forLevel(mc.level).getName()); left.add(prefix + "AT: " + IAuraType.forLevel(mc.level).getName());
@ -107,30 +87,30 @@ public class ClientEvents {
} else { } else {
PENDING_AURA_CHUNKS.removeIf(next -> next.tryHandle(mc.level)); PENDING_AURA_CHUNKS.removeIf(next -> next.tryHandle(mc.level));
if (!mc.isGamePaused()) { if (!mc.isPaused()) {
if (mc.level.getGameTime() % 20 == 0) { if (mc.level.getGameTime() % 20 == 0) {
int amount = Mth.floor(190 * ModConfig.instance.excessParticleAmount.get()); int amount = Mth.floor(190 * ModConfig.instance.excessParticleAmount.get());
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
int x = Mth.floor(mc.player.getPosX()) + mc.level.rand.nextInt(64) - 32; int x = Mth.floor(mc.player.getX()) + mc.level.random.nextInt(64) - 32;
int z = Mth.floor(mc.player.getPosZ()) + mc.level.rand.nextInt(64) - 32; int z = Mth.floor(mc.player.getZ()) + mc.level.random.nextInt(64) - 32;
BlockPos pos = new BlockPos(x, mc.level.getHeight(Heightmap.Type.WORLD_SURFACE, x, z) - 1, z); BlockPos pos = new BlockPos(x, mc.level.getHeight(Heightmap.Types.WORLD_SURFACE, x, z) - 1, z);
BlockState state = mc.level.getBlockState(pos); BlockState state = mc.level.getBlockState(pos);
Block block = state.getBlock(); Block block = state.getBlock();
if (block instanceof IGrowable || block instanceof IPlantable || block instanceof LeavesBlock || block instanceof MyceliumBlock) { if (block instanceof BonemealableBlock || block instanceof IPlantable || block instanceof LeavesBlock || block instanceof MyceliumBlock) {
int excess = IAuraChunk.triangulateAuraInArea(mc.level, pos, 45) - IAuraChunk.DEFAULT_AURA; int excess = IAuraChunk.triangulateAuraInArea(mc.level, pos, 45) - IAuraChunk.DEFAULT_AURA;
if (excess > 0) { if (excess > 0) {
int chance = Math.max(10, 50 - excess / 25000); int chance = Math.max(10, 50 - excess / 25000);
if (mc.level.rand.nextInt(chance) <= 0) if (mc.level.random.nextInt(chance) <= 0)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
pos.getX() + mc.level.rand.nextFloat(), pos.getX() + mc.level.random.nextFloat(),
pos.getY() + 0.5F, pos.getY() + 0.5F,
pos.getZ() + mc.level.rand.nextFloat(), pos.getZ() + mc.level.random.nextFloat(),
mc.level.rand.nextGaussian() * 0.01F, mc.level.random.nextGaussian() * 0.01F,
mc.level.rand.nextFloat() * 0.025F, mc.level.random.nextFloat() * 0.025F,
mc.level.rand.nextGaussian() * 0.01F, mc.level.random.nextGaussian() * 0.01F,
block instanceof MyceliumBlock ? 0x875ca1 : BiomeColors.getGrassColor(mc.level, pos), block instanceof MyceliumBlock ? 0x875ca1 : BiomeColors.getAverageGrassColor(mc.level, pos),
Math.min(2F, 1F + mc.level.rand.nextFloat() * (excess / 30000F)), Math.min(2F, 1F + mc.level.random.nextFloat() * (excess / 30000F)),
Math.min(300, 100 + mc.level.rand.nextInt(excess / 3000 + 1)), Math.min(300, 100 + mc.level.random.nextInt(excess / 3000 + 1)),
0F, false, true); 0F, false, true);
} }
} }
@ -141,12 +121,12 @@ public class ClientEvents {
NaturesAuraAPI.IInternalHooks inst = NaturesAuraAPI.instance(); NaturesAuraAPI.IInternalHooks inst = NaturesAuraAPI.instance();
inst.setParticleSpawnRange(512); inst.setParticleSpawnRange(512);
inst.setParticleDepth(false); inst.setParticleDepth(false);
for (BlockPos pos : ItemRangeVisualizer.VISUALIZED_RAILS.get(mc.level.func_234923_W_().func_240901_a_())) { for (BlockPos pos : ItemRangeVisualizer.VISUALIZED_RAILS.get(mc.level.dimension().location())) {
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
pos.getX() + mc.level.rand.nextFloat(), pos.getX() + mc.level.random.nextFloat(),
pos.getY() + mc.level.rand.nextFloat(), pos.getY() + mc.level.random.nextFloat(),
pos.getZ() + mc.level.rand.nextFloat(), pos.getZ() + mc.level.random.nextFloat(),
0F, 0F, 0F, 0xe0faff, mc.level.rand.nextFloat() * 5 + 1, 100, 0F, false, true); 0F, 0F, 0F, 0xe0faff, mc.level.random.nextFloat() * 5 + 1, 100, 0F, false, true);
} }
inst.setParticleDepth(true); inst.setParticleDepth(true);
inst.setParticleSpawnRange(32); inst.setParticleSpawnRange(32);
@ -158,7 +138,7 @@ public class ClientEvents {
if (!heldOcular.isEmpty() && mc.level.getGameTime() % 20 == 0) { if (!heldOcular.isEmpty() && mc.level.getGameTime() % 20 == 0) {
SHOWING_EFFECTS.clear(); SHOWING_EFFECTS.clear();
Helper.getAuraChunksWithSpotsInArea(mc.level, mc.player.getPosition(), 100, Helper.getAuraChunksWithSpotsInArea(mc.level, mc.player.blockPosition(), 100,
chunk -> chunk.getActiveEffectIcons(mc.player, SHOWING_EFFECTS)); chunk -> chunk.getActiveEffectIcons(mc.player, SHOWING_EFFECTS));
} }
} }
@ -168,7 +148,8 @@ public class ClientEvents {
@SubscribeEvent @SubscribeEvent
public void onLevelRender(RenderLevelLastEvent event) { public void onLevelRender(RenderLevelLastEvent event) {
Minecraft mc = Minecraft.getInstance(); // TODO GL-based in-world rendering
/* Minecraft mc = Minecraft.getInstance();
RenderSystem.pushMatrix(); RenderSystem.pushMatrix();
RenderSystem.multMatrix(event.getMatrixStack().getLast().getMatrix()); RenderSystem.multMatrix(event.getMatrixStack().getLast().getMatrix());
@ -239,10 +220,10 @@ public class ClientEvents {
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
GL11.glPopMatrix(); GL11.glPopMatrix();*/
} }
private void renderVisualize(IVisualizable visualize, Level /* private void renderVisualize(IVisualizable visualize, Level
level, BlockPos pos) { level, BlockPos pos) {
AABB box = visualize.getVisualizationBounds(level, pos); AABB box = visualize.getVisualizationBounds(level, pos);
if (box == null) if (box == null)
@ -251,22 +232,23 @@ public class ClientEvents {
int color = visualize.getVisualizationColor(level, pos); int color = visualize.getVisualizationColor(level, pos);
RenderSystem.color4f((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 0.5F); RenderSystem.color4f((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 0.5F);
Helper.renderWeirdBox(box.minX, box.minY, box.minZ, box.maxX - box.minX, box.maxY - box.minY, box.maxZ - box.minZ); Helper.renderWeirdBox(box.minX, box.minY, box.minZ, box.maxX - box.minX, box.maxY - box.minY, box.maxZ - box.minZ);
} }*/
@SubscribeEvent @SubscribeEvent
public void onOverlayRender(RenderGameOverlayEvent.Post event) { public void onOverlayRender(RenderGameOverlayEvent.Post event) {
Minecraft mc = Minecraft.getInstance(); // TODO raw rendering bleh, should be easy enough to convert to PoseStack stuff
MatrixStack stack = event.getMatrixStack(); /*Minecraft mc = Minecraft.getInstance();
PoseStack stack = event.getMatrixStack();
if (event.getType() == ElementType.ALL) { if (event.getType() == ElementType.ALL) {
MainWindow res = event.getWindow(); var res = event.getWindow();
if (mc.player != null) { if (mc.player != null) {
if (!heldCache.isEmpty()) { if (!heldCache.isEmpty()) {
IAuraContainer container = heldCache.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null); IAuraContainer container = heldCache.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
int width = Mth.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80); int width = Mth.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80);
int conf = ModConfig.instance.cacheBarLocation.get(); int conf = ModConfig.instance.cacheBarLocation.get();
int x = res.getScaledWidth() / 2 + (conf == 0 ? -173 - (mc.player.getHeldItemOffhand().isEmpty() ? 0 : 29) : 93); int x = res.getGuiScaledWidth() / 2 + (conf == 0 ? -173 - (mc.player.getOffhandItem().isEmpty() ? 0 : 29) : 93);
int y = res.getScaledHeight() - 8; int y = res.getScreenHeight() - 8;
RenderSystem.pushMatrix(); RenderSystem.pushMatrix();
@ -431,7 +413,7 @@ public class ClientEvents {
RenderSystem.popMatrix(); RenderSystem.popMatrix();
} }
} }
} }*/
} }
private String createTimeString(int totalTicks) { private String createTimeString(int totalTicks) {
@ -442,7 +424,7 @@ public class ClientEvents {
return String.format("%02d:%02d:%02d.%02d", hours, minutes, seconds, ticks); return String.format("%02d:%02d:%02d.%02d", hours, minutes, seconds, ticks);
} }
private void drawContainerInfo(MatrixStack stack, int stored, int max, int color, Minecraft mc, MainWindow res, int yOffset, String name, String textBelow) { /* private void drawContainerInfo(PoseStack stack, int stored, int max, int color, Minecraft mc, MainWindow res, int yOffset, String name, String textBelow) {
RenderSystem.color3f((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F); RenderSystem.color3f((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F);
int x = res.getScaledWidth() / 2 - 40; int x = res.getScaledWidth() / 2 - 40;
@ -459,5 +441,5 @@ public class ClientEvents {
if (textBelow != null) if (textBelow != null)
mc.fontRenderer.drawStringWithShadow(stack, textBelow, x + 40 - mc.fontRenderer.getStringWidth(textBelow) / 2F, y + 7, color); mc.fontRenderer.drawStringWithShadow(stack, textBelow, x + 40 - mc.fontRenderer.getStringWidth(textBelow) / 2F, y + 7, color);
} }*/
} }

View file

@ -14,60 +14,58 @@ import de.ellpeck.naturesaura.commands.CommandAura;
import de.ellpeck.naturesaura.gen.ModFeatures; 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.block.BlockState; import net.minecraft.resources.ResourceLocation;
import net.minecraft.entity.player.Player; import net.minecraft.server.level.ChunkHolder;
import net.minecraft.item.ItemStack; import net.minecraft.server.level.ChunkMap;
import net.minecraft.util.ResourceLocation; import net.minecraft.server.level.ServerChunkCache;
import net.minecraft.util.math.ChunkPos; import net.minecraft.world.entity.player.Player;
import net.minecraft.level.Level; import net.minecraft.world.item.ItemStack;
import net.minecraft.level.chunk.Chunk; import net.minecraft.world.level.ChunkPos;
import net.minecraft.level.chunk.IChunk; import net.minecraft.world.level.Level;
import net.minecraft.level.gen.GenerationStage.Decoration; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.level.server.ChunkHolder; import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.level.server.ChunkManager; import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.level.server.ServerChunkProvider;
import net.minecraftforge.event.AttachCapabilitiesEvent; 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.level.BiomeLoadingEvent; import net.minecraftforge.event.server.ServerStartingEvent;
import net.minecraftforge.event.level.ChunkEvent; import net.minecraftforge.event.world.BiomeLoadingEvent;
import net.minecraftforge.event.level.ChunkWatchEvent; import net.minecraftforge.event.world.ChunkEvent;
import net.minecraftforge.event.world.ChunkWatchEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.List; import java.util.List;
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(ChunkManager.class, "func_223491_f"); private static final Method GET_LOADED_CHUNKS_METHOD = ObfuscationReflectionHelper.findMethod(ChunkMap.class, "getChunks");
private static final ListMultimap<UUID, ChunkPos> PENDING_AURA_CHUNKS = ArrayListMultimap.create(); private static final ListMultimap<UUID, ChunkPos> PENDING_AURA_CHUNKS = ArrayListMultimap.create();
@SubscribeEvent @SubscribeEvent
public void onBiomeLoad(BiomeLoadingEvent event) { public void onBiomeLoad(BiomeLoadingEvent event) {
if (ModConfig.instance.auraBlooms.get()) { if (ModConfig.instance.auraBlooms.get()) {
event.getGeneration().func_242513_a(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.AURA_BLOOM); // TODO features might have to be registered *AGAIN* now because .placed() is another thing again oh my God
event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.AURA_BLOOM.placed());
switch (event.getCategory()) { switch (event.getCategory()) {
case DESERT: case DESERT -> event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.AURA_CACTUS.placed());
event.getGeneration().func_242513_a(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.AURA_CACTUS); case NETHER -> {
break; event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.CRIMSON_AURA_MUSHROOM.placed());
case NETHER: event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.WARPED_AURA_MUSHROOM.placed());
event.getGeneration().func_242513_a(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.CRIMSON_AURA_MUSHROOM); }
event.getGeneration().func_242513_a(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.WARPED_AURA_MUSHROOM); case MUSHROOM -> event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.AURA_MUSHROOM.placed());
break;
case MUSHROOM:
event.getGeneration().func_242513_a(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.AURA_MUSHROOM);
break;
} }
} }
} }
@SubscribeEvent @SubscribeEvent
public void onChunkCapsAttach(AttachCapabilitiesEvent<Chunk> event) { public void onChunkCapsAttach(AttachCapabilitiesEvent<LevelChunk> event) {
Chunk chunk = event.getObject(); LevelChunk chunk = event.getObject();
event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "aura"), new AuraChunkProvider(chunk)); event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "aura"), new AuraChunkProvider(chunk));
} }
@ -78,13 +76,12 @@ public class CommonEvents {
@SubscribeEvent @SubscribeEvent
public void onChunkUnload(ChunkEvent.Unload event) { public void onChunkUnload(ChunkEvent.Unload event) {
IChunk iChunk = event.getChunk(); ChunkAccess iChunk = event.getChunk();
if (iChunk instanceof Chunk) { if (iChunk instanceof LevelChunk chunk) {
Chunk chunk = (Chunk) iChunk;
IAuraChunk auraChunk = chunk.getCapability(NaturesAuraAPI.capAuraChunk).orElse(null); IAuraChunk auraChunk = chunk.getCapability(NaturesAuraAPI.capAuraChunk).orElse(null);
if (auraChunk instanceof AuraChunk) { if (auraChunk instanceof AuraChunk) {
LevelData data = (LevelData) ILevelData.getLevelData(chunk.getLevel()); LevelData data = (LevelData) ILevelData.getLevelData(chunk.getLevel());
data.auraChunksWithSpots.remove(chunk.getPos().asLong()); data.auraChunksWithSpots.remove(chunk.getPos().toLong());
} }
} }
} }
@ -105,15 +102,16 @@ public class CommonEvents {
} }
@SubscribeEvent @SubscribeEvent
public void onLevelTick(TickEvent.LevelTickEvent event) { @SuppressWarnings("unchecked")
if (!event.level.isClientSide && event.phase == TickEvent.Phase.END) { public void onLevelTick(TickEvent.WorldTickEvent event) {
if (event.level.getGameTime() % 20 == 0) { if (!event.world.isClientSide && event.phase == TickEvent.Phase.END) {
event.level.getProfiler().startSection(NaturesAura.MOD_ID + ":onLevelTick"); if (event.world.getGameTime() % 20 == 0) {
event.world.getProfiler().push(NaturesAura.MOD_ID + ":onLevelTick");
try { try {
ChunkManager manager = ((ServerChunkProvider) event.level.getChunkProvider()).chunkManager; ChunkMap manager = ((ServerChunkCache) event.world.getChunkSource()).chunkMap;
Iterable<ChunkHolder> chunks = (Iterable<ChunkHolder>) GET_LOADED_CHUNKS_METHOD.invoke(manager); Iterable<ChunkHolder> chunks = (Iterable<ChunkHolder>) GET_LOADED_CHUNKS_METHOD.invoke(manager);
for (ChunkHolder holder : chunks) { for (ChunkHolder holder : chunks) {
Chunk chunk = holder.getChunkIfComplete(); LevelChunk chunk = holder.getTickingChunk();
if (chunk == null) if (chunk == null)
continue; continue;
AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null); AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null);
@ -123,7 +121,7 @@ public class CommonEvents {
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
NaturesAura.LOGGER.fatal(e); NaturesAura.LOGGER.fatal(e);
} }
event.level.getProfiler().endSection(); event.world.getProfiler().pop();
} }
} }
} }
@ -132,14 +130,14 @@ 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) {
List<ChunkPos> pending = PENDING_AURA_CHUNKS.get(event.player.getUniqueID()); List<ChunkPos> pending = PENDING_AURA_CHUNKS.get(event.player.getUUID());
pending.removeIf(p -> this.handleChunkWatchDeferred(event.player, p)); pending.removeIf(p -> this.handleChunkWatchDeferred(event.player, p));
} }
if (event.player.level.getGameTime() % 200 != 0) if (event.player.level.getGameTime() % 200 != 0)
return; return;
int aura = IAuraChunk.triangulateAuraInArea(event.player.level, event.player.getPosition(), 25); int aura = IAuraChunk.triangulateAuraInArea(event.player.level, event.player.blockPosition(), 25);
if (aura <= 0) if (aura <= 0)
Helper.addAdvancement(event.player, new ResourceLocation(NaturesAura.MOD_ID, "negative_imbalance"), "triggered_in_code"); Helper.addAdvancement(event.player, new ResourceLocation(NaturesAura.MOD_ID, "negative_imbalance"), "triggered_in_code");
else if (aura >= 1500000) else if (aura >= 1500000)
@ -149,11 +147,11 @@ public class CommonEvents {
@SubscribeEvent @SubscribeEvent
public void onChunkWatch(ChunkWatchEvent.Watch event) { public void onChunkWatch(ChunkWatchEvent.Watch event) {
PENDING_AURA_CHUNKS.put(event.getPlayer().getUniqueID(), event.getPos()); PENDING_AURA_CHUNKS.put(event.getPlayer().getUUID(), event.getPos());
} }
private boolean handleChunkWatchDeferred(Player player, ChunkPos pos) { private boolean handleChunkWatchDeferred(Player player, ChunkPos pos) {
Chunk chunk = Helper.getLoadedChunk(player.level, pos.x, pos.z); LevelChunk chunk = Helper.getLoadedChunk(player.level, pos.x, pos.z);
if (chunk == null) if (chunk == null)
return false; return false;
AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null); AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null);
@ -164,7 +162,7 @@ public class CommonEvents {
} }
@SubscribeEvent @SubscribeEvent
public void onServerStarting(FMLServerStartingEvent event) { public void onServerStarting(ServerStartingEvent event) {
CommandAura.register(event.getServer().getCommandManager().getDispatcher()); CommandAura.register(event.getServer().getCommands().getDispatcher());
} }
} }

View file

@ -1,6 +1,7 @@
package de.ellpeck.naturesaura.items; package de.ellpeck.naturesaura.items;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
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;
@ -9,20 +10,19 @@ import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
import de.ellpeck.naturesaura.api.render.ITrinketItem; import de.ellpeck.naturesaura.api.render.ITrinketItem;
import de.ellpeck.naturesaura.enchant.ModEnchantments; import de.ellpeck.naturesaura.enchant.ModEnchantments;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.core.Direction;
import net.minecraft.entity.Entity; import net.minecraft.core.NonNullList;
import net.minecraft.entity.player.Player;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Direction; import net.minecraft.world.entity.Entity;
import net.minecraft.util.NonNullList; import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.util.math.vector.Vector3f; import net.minecraft.world.entity.player.Player;
import net.minecraft.level.Level; import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.level.Level;
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.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
@ -37,29 +37,28 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem {
private final int capacity; private final int capacity;
public ItemAuraCache(String name, int capacity) { public ItemAuraCache(String name, int capacity) {
super(name, new Properties().maxStackSize(1)); super(name, new Properties().stacksTo(1));
this.capacity = capacity; this.capacity = capacity;
} }
@Override @Override
public void inventoryTick(ItemStack stackIn, Level levelIn, Entity entityIn, int itemSlot, boolean isSelected) { public void inventoryTick(ItemStack stackIn, Level levelIn, Entity entityIn, int itemSlot, boolean isSelected) {
if (!levelIn.isClientSide && entityIn instanceof Player) { if (!levelIn.isClientSide && entityIn instanceof Player player) {
Player player = (Player) entityIn; if (player.isCrouching() && stackIn.getCapability(NaturesAuraAPI.capAuraContainer).isPresent()) {
if (player.isSneaking() && stackIn.getCapability(NaturesAuraAPI.capAuraContainer).isPresent()) {
IAuraContainer container = stackIn.getCapability(NaturesAuraAPI.capAuraContainer).orElse(null); IAuraContainer container = stackIn.getCapability(NaturesAuraAPI.capAuraContainer).orElse(null);
if (container.getStoredAura() <= 0) { if (container.getStoredAura() <= 0) {
return; return;
} }
for (int i = 0; i < player.inventory.getSizeInventory(); i++) { for (int i = 0; i < player.getInventory().getContainerSize(); i++) {
ItemStack stack = player.inventory.getStackInSlot(i); ItemStack stack = player.getInventory().getItem(i);
IAuraRecharge recharge = stack.getCapability(NaturesAuraAPI.capAuraRecharge).orElse(null); IAuraRecharge recharge = stack.getCapability(NaturesAuraAPI.capAuraRecharge).orElse(null);
if (recharge != null) { if (recharge != null) {
if (recharge.rechargeFromContainer(container, itemSlot, i, player.inventory.currentItem == i)) if (recharge.rechargeFromContainer(container, itemSlot, i, player.getInventory().selected == i))
break; break;
} else if (EnchantmentHelper.getEnchantmentLevel(ModEnchantments.AURA_MENDING, stack) > 0) { } else if (EnchantmentHelper.getItemEnchantmentLevel(ModEnchantments.AURA_MENDING, stack) > 0) {
int mainSize = player.inventory.mainInventory.size(); int mainSize = player.getInventory().items.size();
boolean isArmor = i >= mainSize && i < mainSize + player.inventory.armorInventory.size(); boolean isArmor = i >= mainSize && i < mainSize + player.getInventory().armor.size();
if ((isArmor || player.inventory.currentItem == i) && Helper.rechargeAuraItem(stack, container, 1000)) if ((isArmor || player.getInventory().selected == i) && Helper.rechargeAuraItem(stack, container, 1000))
break; break;
} }
} }
@ -68,8 +67,8 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem {
} }
@Override @Override
public void fillItemGroup(ItemGroup tab, NonNullList<ItemStack> items) { public void fillItemCategory(CreativeModeTab tab, NonNullList<ItemStack> items) {
if (this.isInGroup(tab)) { if (this.allowdedIn(tab)) {
items.add(new ItemStack(this)); items.add(new ItemStack(this));
ItemStack stack = new ItemStack(this); ItemStack stack = new ItemStack(this);
@ -81,15 +80,15 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem {
} }
@Override @Override
public boolean showDurabilityBar(ItemStack stack) { public boolean isBarVisible(ItemStack stack) {
return true; return true;
} }
@Override @Override
public double getDurabilityForDisplay(ItemStack stack) { public int getBarColor(ItemStack stack) {
if (stack.getCapability(NaturesAuraAPI.capAuraContainer).isPresent()) { if (stack.getCapability(NaturesAuraAPI.capAuraContainer).isPresent()) {
IAuraContainer container = stack.getCapability(NaturesAuraAPI.capAuraContainer).orElse(null); IAuraContainer container = stack.getCapability(NaturesAuraAPI.capAuraContainer).orElse(null);
return 1 - container.getStoredAura() / (double) container.getMaxAura(); return (int) (1 - container.getStoredAura() / (double) container.getMaxAura());
} }
return 0; return 0;
} }
@ -114,14 +113,14 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem {
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void render(ItemStack stack, Player player, RenderType type, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight, boolean isHolding) { public void render(ItemStack stack, Player player, RenderType type, PoseStack matrices, MultiBufferSource buffer, int packedLight, boolean isHolding) {
if (type == RenderType.BODY && !isHolding) { if (type == RenderType.BODY && !isHolding) {
boolean chest = !player.inventory.armorInventory.get(EquipmentSlotType.CHEST.getIndex()).isEmpty(); boolean chest = !player.getInventory().armor.get(EquipmentSlot.CHEST.getIndex()).isEmpty();
boolean legs = !player.inventory.armorInventory.get(EquipmentSlotType.LEGS.getIndex()).isEmpty(); boolean legs = !player.getInventory().armor.get(EquipmentSlot.LEGS.getIndex()).isEmpty();
matrices.translate(-0.15F, 0.65F, chest ? -0.195F : legs ? -0.165F : -0.1475F); matrices.translate(-0.15F, 0.65F, chest ? -0.195F : legs ? -0.165F : -0.1475F);
matrices.scale(0.5F, 0.5F, 0.5F); matrices.scale(0.5F, 0.5F, 0.5F);
matrices.rotate(Vector3f.XP.rotationDegrees(180F)); matrices.mulPose(Vector3f.XP.rotationDegrees(180F));
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.GROUND, packedLight, OverlayTexture.NO_OVERLAY, matrices, buffer); Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemTransforms.TransformType.GROUND, packedLight, OverlayTexture.NO_OVERLAY, matrices, buffer, 0);
} }
} }
} }

View file

@ -1,34 +1,35 @@
package de.ellpeck.naturesaura.items; package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import net.minecraft.entity.LivingEntity; import net.minecraft.core.BlockPos;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.item.ItemStack; import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.BabyEntitySpawnEvent; import net.minecraftforge.event.entity.living.BabyEntitySpawnEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
public class ItemBirthSpirit extends ItemGlowing { public class ItemBirthSpirit extends ItemGlowing {
public ItemBirthSpirit() { public ItemBirthSpirit() {
super("birth_spirit"); super("birth_spirit");
MinecraftForge.EVENT_BUS.register(new EventHandler()); MinecraftForge.EVENT_BUS.register(new EventHandler());
} }
private static class EventHandler { private static class EventHandler {
@SubscribeEvent @SubscribeEvent
public void onBabyBorn(BabyEntitySpawnEvent event) { public void onBabyBorn(BabyEntitySpawnEvent event) {
LivingEntity parent = event.getParentA(); LivingEntity parent = event.getParentA();
if (!parent.level.isClientSide && event.getCausedByPlayer() != null) { if (!parent.level.isClientSide && event.getCausedByPlayer() != null) {
BlockPos pos = parent.getPosition(); BlockPos pos = parent.blockPosition();
int aura = IAuraChunk.getAuraInArea(parent.level, pos, 30); int aura = IAuraChunk.getAuraInArea(parent.level, pos, 30);
if (aura < 1200000) if (aura < 1200000)
return; return;
int amount = parent.level.rand.nextInt(3) + 1; int amount = parent.level.random.nextInt(3) + 1;
ItemEntity item = new ItemEntity(parent.level, parent.getPosX(), parent.getPosY(), parent.getPosZ(), ItemEntity item = new ItemEntity(parent.level, parent.getX(), parent.getY(), parent.getZ(), new ItemStack(ModItems.BIRTH_SPIRIT, amount));
new ItemStack(ModItems.BIRTH_SPIRIT, amount)); parent.level.addFreshEntity(item);
parent.level.addEntity(item);
BlockPos spot = IAuraChunk.getHighestSpot(parent.level, pos, 30, pos); BlockPos spot = IAuraChunk.getHighestSpot(parent.level, pos, 30, pos);
IAuraChunk.getAuraChunk(parent.level, spot).drainAura(spot, 800 * amount); IAuraChunk.getAuraChunk(parent.level, spot).drainAura(spot, 800 * amount);

View file

@ -1,10 +1,14 @@
package de.ellpeck.naturesaura.items; package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import net.minecraft.entity.player.Player; import net.minecraft.ChatFormatting;
import net.minecraft.item.ElytraItem; import net.minecraft.network.chat.Component;
import net.minecraft.item.ItemStack; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.util.text.*; 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.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;
@ -16,16 +20,18 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
import java.util.List; import java.util.List;
public class ItemBreakPrevention extends ItemImpl { public class ItemBreakPrevention extends ItemImpl {
public ItemBreakPrevention() { public ItemBreakPrevention() {
super("break_prevention"); super("break_prevention");
MinecraftForge.EVENT_BUS.register(new Events()); MinecraftForge.EVENT_BUS.register(new Events());
} }
public static class Events { public static class Events {
@SubscribeEvent @SubscribeEvent
public void onAnvilUpdate(AnvilUpdateEvent event) { public void onAnvilUpdate(AnvilUpdateEvent event) {
ItemStack stack = event.getLeft(); ItemStack stack = event.getLeft();
if (stack.getToolTypes().isEmpty() || !stack.isDamageable()) if (!stack.isDamageableItem())
return; return;
ItemStack second = event.getRight(); ItemStack second = event.getRight();
if (second.getItem() != ModItems.BREAK_PREVENTION) if (second.getItem() != ModItems.BREAK_PREVENTION)
@ -42,10 +48,10 @@ public class ItemBreakPrevention extends ItemImpl {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (player == null) if (player == null)
return; return;
ItemStack stack = player.getHeldItemMainhand(); ItemStack stack = player.getMainHandItem();
if (!stack.hasTag() || !stack.getTag().getBoolean(NaturesAura.MOD_ID + ":break_prevention")) if (!stack.hasTag() || !stack.getTag().getBoolean(NaturesAura.MOD_ID + ":break_prevention"))
return; return;
if (ElytraItem.isUsable(stack)) if (ElytraItem.isFlyEnabled(stack))
return; return;
event.setNewSpeed(0); event.setNewSpeed(0);
} }
@ -56,15 +62,15 @@ public class ItemBreakPrevention extends ItemImpl {
ItemStack stack = event.getItemStack(); ItemStack stack = event.getItemStack();
if (!stack.hasTag() || !stack.getTag().getBoolean(NaturesAura.MOD_ID + ":break_prevention")) if (!stack.hasTag() || !stack.getTag().getBoolean(NaturesAura.MOD_ID + ":break_prevention"))
return; return;
List<ITextComponent> tooltip = event.getToolTip(); List<Component> tooltip = event.getToolTip();
tooltip.add(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".break_prevention").setStyle(Style.EMPTY.setFormatting(TextFormatting.GRAY))); tooltip.add(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".break_prevention").setStyle(Style.EMPTY.applyFormat(ChatFormatting.GRAY)));
if (ElytraItem.isUsable(stack)) if (ElytraItem.isFlyEnabled(stack))
return; return;
if (tooltip.size() < 1) if (tooltip.size() < 1)
return; return;
ITextComponent head = tooltip.get(0); Component head = tooltip.get(0);
if (head instanceof TextComponent) if (head instanceof MutableComponent)
((TextComponent) head).append(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".broken").setStyle(Style.EMPTY.setFormatting(TextFormatting.GRAY))); ((MutableComponent) head).append(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".broken").setStyle(Style.EMPTY.applyFormat(ChatFormatting.GRAY)));
} }
} }
} }

View file

@ -1,53 +1,54 @@
package de.ellpeck.naturesaura.items; package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import net.minecraft.block.BlockState; import net.minecraft.core.BlockPos;
import net.minecraft.entity.EntitySpawnPlacementRegistry; import net.minecraft.world.InteractionHand;
import net.minecraft.entity.player.Player; import net.minecraft.world.InteractionResult;
import net.minecraft.item.ItemStack; import net.minecraft.world.InteractionResultHolder;
import net.minecraft.util.ActionResult; import net.minecraft.world.entity.SpawnPlacements;
import net.minecraft.util.InteractionResult; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.Hand; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.Level;
import net.minecraft.level.LightType; import net.minecraft.world.level.LightLayer;
import net.minecraft.level.Level; import net.minecraft.world.level.block.state.BlockState;
public class ItemCaveFinder extends ItemImpl { public class ItemCaveFinder extends ItemImpl {
public ItemCaveFinder() { public ItemCaveFinder() {
super("cave_finder", new Properties().maxStackSize(1)); super("cave_finder", new Properties().stacksTo(1));
} }
@Override @Override
public ActionResult<ItemStack> onItemRightClick(Level levelIn, Player playerIn, Hand handIn) { public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, InteractionHand handIn) {
ItemStack stack = playerIn.getHeldItem(handIn); ItemStack stack = playerIn.getItemInHand(handIn);
NaturesAuraAPI.IInternalHooks inst = NaturesAuraAPI.instance(); NaturesAuraAPI.IInternalHooks inst = NaturesAuraAPI.instance();
if (!inst.extractAuraFromPlayer(playerIn, 20000, levelIn.isClientSide)) if (!inst.extractAuraFromPlayer(playerIn, 20000, levelIn.isClientSide))
return new ActionResult<>(InteractionResult.FAIL, stack); return new InteractionResultHolder<>(InteractionResult.FAIL, stack);
if (levelIn.isClientSide) { if (levelIn.isClientSide) {
inst.setParticleDepth(false); inst.setParticleDepth(false);
inst.setParticleSpawnRange(64); inst.setParticleSpawnRange(64);
inst.setParticleCulling(false); inst.setParticleCulling(false);
BlockPos pos = playerIn.getPosition(); BlockPos pos = playerIn.blockPosition();
int range = 30; int range = 30;
for (int x = -range; x <= range; x++) for (int x = -range; x <= range; x++)
for (int y = -range; y <= range; y++) for (int y = -range; y <= range; y++)
for (int z = -range; z <= range; z++) { for (int z = -range; z <= range; z++) {
BlockPos offset = pos.add(x, y, z); BlockPos offset = pos.offset(x, y, z);
BlockState state = levelIn.getBlockState(offset); BlockState state = levelIn.getBlockState(offset);
try { try {
if (!state.getBlock().canCreatureSpawn(state, levelIn, offset, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, null)) if (!state.getBlock().isValidSpawn(state, levelIn, offset, SpawnPlacements.Type.ON_GROUND, null))
continue; continue;
} catch (Exception e) { } catch (Exception e) {
continue; continue;
} }
BlockPos offUp = offset.up(); BlockPos offUp = offset.above();
BlockState stateUp = levelIn.getBlockState(offUp); BlockState stateUp = levelIn.getBlockState(offUp);
if (stateUp.isNormalCube(levelIn, offUp) || stateUp.getMaterial().isLiquid()) if (stateUp.isCollisionShapeFullBlock(levelIn, offUp) || stateUp.getMaterial().isLiquid())
continue; continue;
int sky = levelIn.getLightFor(LightType.SKY, offUp); int sky = levelIn.getBrightness(LightLayer.SKY, offUp);
int block = levelIn.getLightFor(LightType.BLOCK, offUp); int block = levelIn.getBrightness(LightLayer.BLOCK, offUp);
if (sky > 7 || block > 7) if (sky > 7 || block > 7)
continue; continue;
@ -59,9 +60,9 @@ public class ItemCaveFinder extends ItemImpl {
inst.setParticleSpawnRange(32); inst.setParticleSpawnRange(32);
inst.setParticleCulling(true); inst.setParticleCulling(true);
playerIn.swingArm(handIn); playerIn.swing(handIn);
} }
playerIn.getCooldownTracker().setCooldown(this, 20 * 30); playerIn.getCooldowns().addCooldown(this, 20 * 30);
return new ActionResult<>(InteractionResult.SUCCESS, stack); return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack);
} }
} }

View file

@ -5,14 +5,20 @@ import de.ellpeck.naturesaura.data.ItemModelGenerator;
import de.ellpeck.naturesaura.misc.ColoredBlockHelper; import de.ellpeck.naturesaura.misc.ColoredBlockHelper;
import de.ellpeck.naturesaura.reg.IColorProvidingItem; import de.ellpeck.naturesaura.reg.IColorProvidingItem;
import de.ellpeck.naturesaura.reg.ICustomItemModel; import de.ellpeck.naturesaura.reg.ICustomItemModel;
import net.minecraft.block.Block; import net.minecraft.client.color.item.ItemColor;
import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.core.BlockPos;
import net.minecraft.entity.player.Player; import net.minecraft.core.Direction;
import net.minecraft.item.ItemUseContext; import net.minecraft.sounds.SoundEvents;
import net.minecraft.level.Level; import net.minecraft.sounds.SoundSource;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@ -21,7 +27,7 @@ import java.util.List;
public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, ICustomItemModel { public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, ICustomItemModel {
public ItemColorChanger() { public ItemColorChanger() {
super("color_changer", new Properties().maxStackSize(1)); super("color_changer", new Properties().stacksTo(1));
} }
private static boolean changeOrCopyColor(Player player, ItemStack stack, Level level, BlockPos pos, DyeColor firstColor) { private static boolean changeOrCopyColor(Player player, ItemStack stack, Level level, BlockPos pos, DyeColor firstColor) {
@ -32,10 +38,10 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, I
DyeColor color = DyeColor.byId(blocks.indexOf(block)); DyeColor color = DyeColor.byId(blocks.indexOf(block));
if (firstColor == null || color == firstColor) { if (firstColor == null || color == firstColor) {
DyeColor stored = getStoredColor(stack); DyeColor stored = getStoredColor(stack);
if (player.isSneaking()) { 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.ITEM_BUCKET_FILL, SoundCategory.PLAYERS, 0.65F, 1F); SoundEvents.BUCKET_FILL, SoundSource.PLAYERS, 0.65F, 1F);
if (!level.isClientSide) if (!level.isClientSide)
storeColor(stack, color); storeColor(stack, color);
return true; return true;
@ -45,14 +51,14 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, I
if (NaturesAuraAPI.instance().extractAuraFromPlayer(player, 1000, level.isClientSide)) { if (NaturesAuraAPI.instance().extractAuraFromPlayer(player, 1000, level.isClientSide)) {
if (firstColor == null) { if (firstColor == null) {
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.ITEM_BUCKET_EMPTY, SoundCategory.PLAYERS, 0.65F, 1F); SoundEvents.BUCKET_EMPTY, SoundSource.PLAYERS, 0.65F, 1F);
} }
if (!level.isClientSide) { if (!level.isClientSide) {
level.setBlockState(pos, blocks.get(stored.getId()).getDefaultState()); level.setBlockAndUpdate(pos, blocks.get(stored.getId()).defaultBlockState());
if (isFillMode(stack)) { if (isFillMode(stack)) {
for (Direction off : Direction.values()) { for (Direction off : Direction.values()) {
changeOrCopyColor(player, stack, level, pos.offset(off), color); changeOrCopyColor(player, stack, level, pos.relative(off), color);
} }
} }
} }
@ -90,9 +96,9 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, I
} }
@Override @Override
public InteractionResult onItemUse(ItemUseContext context) { public InteractionResult useOn(UseOnContext context) {
ItemStack stack = context.getPlayer().getHeldItem(context.getHand()); ItemStack stack = context.getPlayer().getItemInHand(context.getHand());
if (changeOrCopyColor(context.getPlayer(), stack, context.getLevel(), context.getPos(), null)) { if (changeOrCopyColor(context.getPlayer(), stack, context.getLevel(), context.getClickedPos(), null)) {
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} else { } else {
return InteractionResult.PASS; return InteractionResult.PASS;
@ -100,27 +106,27 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, I
} }
@Override @Override
public ActionResult<ItemStack> onItemRightClick(Level levelIn, Player playerIn, Hand handIn) { public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, InteractionHand handIn) {
ItemStack stack = playerIn.getHeldItem(handIn); ItemStack stack = playerIn.getItemInHand(handIn);
if (playerIn.isSneaking() && getStoredColor(stack) != null) { if (playerIn.isCrouching() && getStoredColor(stack) != null) {
levelIn.playSound(playerIn, playerIn.getPosX(), playerIn.getPosY(), playerIn.getPosZ(), SoundEvents.ITEM_BUCKET_FILL_LAVA, SoundCategory.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)); setFillMode(stack, !isFillMode(stack));
} }
return new ActionResult<>(InteractionResult.SUCCESS, stack); return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack);
} else { } else {
return new ActionResult<>(InteractionResult.PASS, stack); return new InteractionResultHolder<>(InteractionResult.PASS, stack);
} }
} }
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public IItemColor getItemColor() { public ItemColor getItemColor() {
return (stack, tintIndex) -> { return (stack, tintIndex) -> {
if (tintIndex > 0) { if (tintIndex > 0) {
DyeColor color = getStoredColor(stack); DyeColor color = getStoredColor(stack);
if (color != null) { if (color != null) {
return color.getColorValue(); return color.getFireworkColor();
} }
} }
return 0xFFFFFF; return 0xFFFFFF;

View file

@ -3,19 +3,20 @@ package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.packet.PacketClient; import de.ellpeck.naturesaura.packet.PacketClient;
import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketHandler;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.Player;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.potion.EffectInstance; import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.potion.Effects; import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
public class ItemDeathRing extends ItemImpl { public class ItemDeathRing extends ItemImpl {
public ItemDeathRing() { public ItemDeathRing() {
super("death_ring", new Properties().maxStackSize(1)); super("death_ring", new Properties().stacksTo(1));
MinecraftForge.EVENT_BUS.register(new Events()); MinecraftForge.EVENT_BUS.register(new Events());
} }
@ -28,12 +29,12 @@ public class ItemDeathRing extends ItemImpl {
ItemStack equipped = Helper.getEquippedItem(s -> s.getItem() == ModItems.DEATH_RING, (Player) entity); ItemStack equipped = Helper.getEquippedItem(s -> s.getItem() == ModItems.DEATH_RING, (Player) entity);
if (!equipped.isEmpty()) { if (!equipped.isEmpty()) {
entity.setHealth(entity.getMaxHealth() / 2); entity.setHealth(entity.getMaxHealth() / 2);
entity.clearActivePotions(); entity.removeAllEffects();
entity.addPotionEffect(new EffectInstance(Effects.REGENERATION, 500, 1)); entity.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 500, 1));
CompoundTag data = new CompoundTag(); CompoundTag data = new CompoundTag();
data.putInt("id", entity.getEntityId()); data.putInt("id", entity.getId());
PacketHandler.sendToAllAround(entity.level, entity.getPosition(), 32, new PacketClient(1, data)); PacketHandler.sendToAllAround(entity.level, entity.blockPosition(), 32, new PacketClient(1, data));
equipped.shrink(1); equipped.shrink(1);
event.setCanceled(true); event.setCanceled(true);

View file

@ -7,63 +7,64 @@ import de.ellpeck.naturesaura.api.misc.ILevelData;
import de.ellpeck.naturesaura.blocks.BlockEnderCrate; import de.ellpeck.naturesaura.blocks.BlockEnderCrate;
import de.ellpeck.naturesaura.gui.ContainerEnderCrate; import de.ellpeck.naturesaura.gui.ContainerEnderCrate;
import de.ellpeck.naturesaura.gui.ModContainers; import de.ellpeck.naturesaura.gui.ModContainers;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.ChatFormatting;
import net.minecraft.entity.player.Player; import net.minecraft.network.chat.Component;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.entity.player.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.inventory.container.Container; import net.minecraft.world.InteractionHand;
import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.world.InteractionResult;
import net.minecraft.item.ItemStack; import net.minecraft.world.InteractionResultHolder;
import net.minecraft.util.ActionResult; import net.minecraft.world.MenuProvider;
import net.minecraft.util.InteractionResult; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.util.Hand; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.text.ITextComponent; import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.util.text.TextFormatting; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.item.TooltipFlag;
import net.minecraft.level.Level; import net.minecraft.world.level.Level;
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.fml.network.NetworkHooks;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.network.NetworkHooks;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List; import java.util.List;
public class ItemEnderAccess extends ItemImpl { public class ItemEnderAccess extends ItemImpl {
public ItemEnderAccess() { public ItemEnderAccess() {
super("ender_access"); super("ender_access");
} }
@Override @Override
public ActionResult<ItemStack> onItemRightClick(Level levelIn, Player playerIn, Hand handIn) { public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, InteractionHand handIn) {
if (handIn != Hand.MAIN_HAND) if (handIn != InteractionHand.MAIN_HAND)
return new ActionResult<>(InteractionResult.PASS, playerIn.getHeldItem(handIn)); return new InteractionResultHolder<>(InteractionResult.PASS, playerIn.getItemInHand(handIn));
ItemStack stack = playerIn.getHeldItemMainhand(); ItemStack stack = playerIn.getMainHandItem();
String name = BlockEnderCrate.getEnderName(stack); String name = BlockEnderCrate.getEnderName(stack);
if (!Strings.isNullOrEmpty(name)) { if (!Strings.isNullOrEmpty(name)) {
if (!levelIn.isClientSide && NaturesAuraAPI.instance().extractAuraFromPlayer(playerIn, 10000, false)) { if (!levelIn.isClientSide && NaturesAuraAPI.instance().extractAuraFromPlayer(playerIn, 10000, false)) {
NetworkHooks.openGui((ServerPlayer) playerIn, new INamedContainerProvider() { NetworkHooks.openGui((ServerPlayer) playerIn, new MenuProvider() {
@Override @Override
public ITextComponent getDisplayName() { public Component getDisplayName() {
return new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".ender_access", TextFormatting.ITALIC + name + TextFormatting.RESET); return new TranslatableComponent("info." + NaturesAura.MOD_ID + ".ender_access", ChatFormatting.ITALIC + name + ChatFormatting.RESET);
} }
@Nullable @Nullable
@Override @Override
public Container createMenu(int windowId, PlayerInventory inv, Player player) { public AbstractContainerMenu createMenu(int windowId, Inventory inv, Player player) {
IItemHandler handler = ILevelData.getOverworldData(inv.player.level).getEnderStorage(name); IItemHandler handler = ILevelData.getOverworldData(inv.player.level).getEnderStorage(name);
return new ContainerEnderCrate(ModContainers.ENDER_ACCESS, windowId, player, handler); return new ContainerEnderCrate(ModContainers.ENDER_ACCESS, windowId, player, handler);
} }
}, buffer -> buffer.writeString(name)); }, buffer -> buffer.writeUtf(name));
} }
return new ActionResult<>(InteractionResult.SUCCESS, stack); return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack);
} }
return new ActionResult<>(InteractionResult.FAIL, stack); return new InteractionResultHolder<>(InteractionResult.FAIL, stack);
} }
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack stack, @Nullable Level levelIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) { public void appendHoverText(ItemStack stack, @Nullable Level levelIn, List<Component> tooltip, TooltipFlag flagIn) {
BlockEnderCrate.addEnderNameInfo(stack, tooltip); BlockEnderCrate.addEnderNameInfo(stack, tooltip);
} }
} }

View file

@ -1,33 +1,33 @@
package de.ellpeck.naturesaura.items; package de.ellpeck.naturesaura.items;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import de.ellpeck.naturesaura.api.render.ITrinketItem; import de.ellpeck.naturesaura.api.render.ITrinketItem;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.entity.player.Player; import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.world.entity.player.Player;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.math.vector.Vector3f;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
public class ItemEye extends ItemImpl implements ITrinketItem { public class ItemEye extends ItemImpl implements ITrinketItem {
public ItemEye(String name) { public ItemEye(String name) {
super(name, new Properties().maxStackSize(1)); super(name, new Properties().stacksTo(1));
} }
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void render(ItemStack stack, Player player, RenderType type, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight, boolean isHolding) { public void render(ItemStack stack, Player player, RenderType type, PoseStack matrices, MultiBufferSource buffer, int packedLight, boolean isHolding) {
if (type == RenderType.BODY && !isHolding) { if (type == RenderType.BODY && !isHolding) {
boolean armor = !player.inventory.armorInventory.get(EquipmentSlotType.CHEST.getIndex()).isEmpty(); boolean armor = !player.getInventory().armor.get(EquipmentSlot.CHEST.getIndex()).isEmpty();
matrices.translate(0.1F, 0.225F, armor ? -0.195F : -0.1475F); matrices.translate(0.1F, 0.225F, armor ? -0.195F : -0.1475F);
matrices.scale(0.3F, 0.3F, 0.3F); matrices.scale(0.3F, 0.3F, 0.3F);
matrices.rotate(Vector3f.XP.rotationDegrees(180)); matrices.mulPose(Vector3f.XP.rotationDegrees(180));
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.GROUND, packedLight, OverlayTexture.NO_OVERLAY, matrices, buffer); Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemTransforms.TransformType.GROUND, packedLight, OverlayTexture.NO_OVERLAY, matrices, buffer, 0);
} }
} }
} }

View file

@ -1,17 +1,15 @@
package de.ellpeck.naturesaura.items; package de.ellpeck.naturesaura.items;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class ItemGlowing extends ItemImpl { public class ItemGlowing extends ItemImpl {
public ItemGlowing(String baseName) { public ItemGlowing(String baseName) {
super(baseName); super(baseName);
} }
@Override @Override
@OnlyIn(Dist.CLIENT) public boolean isFoil(ItemStack stack) {
public boolean hasEffect(ItemStack stack) {
return true; return true;
} }
} }

View file

@ -2,10 +2,10 @@ package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.blocks.BlockGoldenLeaves; import de.ellpeck.naturesaura.blocks.BlockGoldenLeaves;
import de.ellpeck.naturesaura.reg.IColorProvidingItem; import de.ellpeck.naturesaura.reg.IColorProvidingItem;
import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.client.color.item.ItemColor;
import net.minecraft.item.ItemStack; import net.minecraft.world.InteractionResult;
import net.minecraft.item.ItemUseContext; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.InteractionResult; import net.minecraft.world.item.context.UseOnContext;
public class ItemGoldFiber extends ItemImpl implements IColorProvidingItem { public class ItemGoldFiber extends ItemImpl implements IColorProvidingItem {
@ -14,14 +14,14 @@ public class ItemGoldFiber extends ItemImpl implements IColorProvidingItem {
} }
@Override @Override
public IItemColor getItemColor() { public ItemColor getItemColor() {
return (stack, tintIndex) -> 0xF2FF00; return (stack, tintIndex) -> 0xF2FF00;
} }
@Override @Override
public InteractionResult onItemUse(ItemUseContext context) { public InteractionResult useOn(UseOnContext context) {
ItemStack stack = context.getPlayer().getHeldItem(context.getHand()); ItemStack stack = context.getPlayer().getItemInHand(context.getHand());
if (BlockGoldenLeaves.convert(context.getLevel(), context.getPos())) { if (BlockGoldenLeaves.convert(context.getLevel(), context.getClickedPos())) {
if (!context.getLevel().isClientSide) { if (!context.getLevel().isClientSide) {
stack.shrink(1); stack.shrink(1);
} }

View file

@ -3,26 +3,27 @@ package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.entities.EntityLightProjectile; import de.ellpeck.naturesaura.entities.EntityLightProjectile;
import de.ellpeck.naturesaura.entities.ModEntities; import de.ellpeck.naturesaura.entities.ModEntities;
import net.minecraft.entity.player.Player; import net.minecraft.world.InteractionHand;
import net.minecraft.item.ItemStack; import net.minecraft.world.InteractionResult;
import net.minecraft.util.ActionResult; import net.minecraft.world.InteractionResultHolder;
import net.minecraft.util.InteractionResult; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.Hand; import net.minecraft.world.item.ItemStack;
import net.minecraft.level.Level; import net.minecraft.world.level.Level;
public class ItemLightStaff extends ItemImpl { public class ItemLightStaff extends ItemImpl {
public ItemLightStaff() { public ItemLightStaff() {
super("light_staff"); super("light_staff");
} }
@Override @Override
public ActionResult<ItemStack> onItemRightClick(Level levelIn, Player playerIn, Hand handIn) { public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, InteractionHand handIn) {
ItemStack stack = playerIn.getHeldItem(handIn); ItemStack stack = playerIn.getItemInHand(handIn);
if (!levelIn.isClientSide && NaturesAuraAPI.instance().extractAuraFromPlayer(playerIn, 1000, false)) { if (!levelIn.isClientSide && NaturesAuraAPI.instance().extractAuraFromPlayer(playerIn, 1000, false)) {
EntityLightProjectile projectile = new EntityLightProjectile(ModEntities.LIGHT_PROJECTILE, playerIn, levelIn); EntityLightProjectile projectile = new EntityLightProjectile(ModEntities.LIGHT_PROJECTILE, playerIn, levelIn);
projectile.func_234612_a_(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0, 1.5F, 0); projectile.shootFromRotation(playerIn, playerIn.getXRot(), playerIn.getYRot(), 0, 1.5F, 0);
levelIn.addEntity(projectile); levelIn.addFreshEntity(projectile);
} }
return new ActionResult<>(InteractionResult.SUCCESS, stack); return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack);
} }
} }

View file

@ -2,48 +2,49 @@ package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import net.minecraft.entity.Entity; import net.minecraft.core.BlockPos;
import net.minecraft.entity.LivingEntity; import net.minecraft.world.InteractionHand;
import net.minecraft.entity.player.Player; import net.minecraft.world.InteractionResult;
import net.minecraft.item.ItemStack; import net.minecraft.world.InteractionResultHolder;
import net.minecraft.tileentity.MobSpawnerBlockEntity; import net.minecraft.world.entity.Entity;
import net.minecraft.util.ActionResult; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.util.InteractionResult; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.Hand; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.math.AABB; import net.minecraft.world.level.Level;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
import net.minecraft.level.Level; import net.minecraft.world.phys.AABB;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
public class ItemLootFinder extends ItemImpl { public class ItemLootFinder extends ItemImpl {
public ItemLootFinder() { public ItemLootFinder() {
super("loot_finder"); super("loot_finder");
} }
@Override @Override
public ActionResult<ItemStack> onItemRightClick(Level levelIn, Player playerIn, Hand handIn) { public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, InteractionHand handIn) {
ItemStack stack = playerIn.getHeldItem(handIn); ItemStack stack = playerIn.getItemInHand(handIn);
NaturesAuraAPI.IInternalHooks inst = NaturesAuraAPI.instance(); NaturesAuraAPI.IInternalHooks inst = NaturesAuraAPI.instance();
if (!inst.extractAuraFromPlayer(playerIn, 100000, false)) if (!inst.extractAuraFromPlayer(playerIn, 100000, false))
return new ActionResult<>(InteractionResult.FAIL, stack); return new InteractionResultHolder<>(InteractionResult.FAIL, stack);
if (levelIn.isClientSide) { if (levelIn.isClientSide) {
inst.setParticleDepth(false); inst.setParticleDepth(false);
inst.setParticleSpawnRange(64); inst.setParticleSpawnRange(64);
inst.setParticleCulling(false); inst.setParticleCulling(false);
BlockPos pos = playerIn.getPosition(); BlockPos pos = playerIn.blockPosition();
Helper.getBlockEntitiesInArea(levelIn, pos, 64, tile -> { Helper.getBlockEntitiesInArea(levelIn, pos, 64, tile -> {
if (tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).isPresent() || tile instanceof MobSpawnerBlockEntity) { if (tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).isPresent() || tile instanceof SpawnerBlockEntity) {
inst.spawnMagicParticle( inst.spawnMagicParticle(
tile.getPos().getX() + 0.5F, tile.getPos().getY() + 0.5F, tile.getPos().getZ() + 0.5F, tile.getBlockPos().getX() + 0.5F, tile.getBlockPos().getY() + 0.5F, tile.getBlockPos().getZ() + 0.5F,
0F, 0F, 0F, 0xf5f10a, 6F, 20 * 60, 0F, false, true); 0F, 0F, 0F, 0xf5f10a, 6F, 20 * 60, 0F, false, true);
} }
return false; return false;
}); });
for (Entity entity : levelIn.getEntitiesWithinAABB(Entity.class, new AABB(pos).grow(64))) { for (Entity entity : levelIn.getEntitiesOfClass(Entity.class, new AABB(pos).inflate(64))) {
if (!(entity instanceof LivingEntity) && entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).isPresent()) { if (!(entity instanceof LivingEntity) && entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).isPresent()) {
inst.spawnMagicParticle( inst.spawnMagicParticle(
entity.getPosX(), entity.getPosYEye(), entity.getPosZ(), entity.getX(), entity.getEyeY(), entity.getZ(),
0F, 0F, 0F, 0xf5f10a, 6F, 20 * 60, 0F, false, true); 0F, 0F, 0F, 0xf5f10a, 6F, 20 * 60, 0F, false, true);
} }
} }
@ -52,9 +53,9 @@ public class ItemLootFinder extends ItemImpl {
inst.setParticleSpawnRange(32); inst.setParticleSpawnRange(32);
inst.setParticleCulling(true); inst.setParticleCulling(true);
playerIn.swingArm(handIn); playerIn.swing(handIn);
} }
playerIn.getCooldownTracker().setCooldown(this, 20 * 60); playerIn.getCooldowns().addCooldown(this, 20 * 60);
return new ActionResult<>(InteractionResult.SUCCESS, stack); return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack);
} }
} }

View file

@ -2,32 +2,32 @@ package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.entities.EntityMoverMinecart; import de.ellpeck.naturesaura.entities.EntityMoverMinecart;
import de.ellpeck.naturesaura.entities.ModEntities; import de.ellpeck.naturesaura.entities.ModEntities;
import net.minecraft.block.AbstractRailBlock; import net.minecraft.core.BlockPos;
import net.minecraft.entity.item.minecart.AbstractMinecartEntity; import net.minecraft.world.InteractionResult;
import net.minecraft.item.ItemUseContext; import net.minecraft.world.entity.vehicle.AbstractMinecart;
import net.minecraft.util.InteractionResult; import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.Level;
import net.minecraft.level.Level; import net.minecraft.world.level.block.BaseRailBlock;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public class ItemMoverMinecart extends ItemImpl { public class ItemMoverMinecart extends ItemImpl {
public ItemMoverMinecart() { public ItemMoverMinecart() {
super("mover_cart", new Properties().maxStackSize(1)); super("mover_cart", new Properties().stacksTo(1));
} }
@Nonnull @Nonnull
@Override @Override
public InteractionResult onItemUse(ItemUseContext context) { public InteractionResult useOn(UseOnContext context) {
Level level = context.getLevel(); Level level = context.getLevel();
BlockPos pos = context.getPos(); BlockPos pos = context.getClickedPos();
if (AbstractRailBlock.isRail(level.getBlockState(pos))) { if (BaseRailBlock.isRail(level.getBlockState(pos))) {
if (!level.isClientSide) { if (!level.isClientSide) {
AbstractMinecartEntity cart = new EntityMoverMinecart(ModEntities.MOVER_CART, level, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); AbstractMinecart cart = new EntityMoverMinecart(ModEntities.MOVER_CART, level, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
level.addEntity(cart); level.addFreshEntity(cart);
} }
context.getPlayer().getHeldItem(context.getHand()).shrink(1); context.getPlayer().getItemInHand(context.getHand()).shrink(1);
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }
return InteractionResult.PASS; return InteractionResult.PASS;

View file

@ -2,15 +2,15 @@ package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.multiblock.IMultiblock; import de.ellpeck.naturesaura.api.multiblock.IMultiblock;
import net.minecraft.entity.player.Player; import net.minecraft.network.chat.Component;
import net.minecraft.item.ItemStack; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.item.ItemUseContext; import net.minecraft.world.InteractionHand;
import net.minecraft.util.ActionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.util.InteractionResult; import net.minecraft.world.InteractionResultHolder;
import net.minecraft.util.Hand; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.text.ITextComponent; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.text.TextComponent; import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.level.Level; import net.minecraft.world.level.Level;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -38,21 +38,21 @@ public class ItemMultiblockMaker extends ItemImpl {
} }
@Override @Override
public ActionResult<ItemStack> onItemRightClick(Level levelIn, Player playerIn, Hand handIn) { public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, InteractionHand handIn) {
ItemStack stack = playerIn.getHeldItem(handIn); ItemStack stack = playerIn.getItemInHand(handIn);
if (!levelIn.isClientSide && playerIn.isCreative()) { if (!levelIn.isClientSide && playerIn.isCreative()) {
int curr = getMultiblock(stack); int curr = getMultiblock(stack);
int next = (curr + 1) % multiblocks().size(); int next = (curr + 1) % multiblocks().size();
stack.getOrCreateTag().putInt("multiblock", next); stack.getOrCreateTag().putInt("multiblock", next);
} }
return new ActionResult<>(InteractionResult.SUCCESS, stack); return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack);
} }
@Override @Override
public InteractionResult onItemUse(ItemUseContext context) { public InteractionResult useOn(UseOnContext context) {
Player player = context.getPlayer(); Player player = context.getPlayer();
if (player.isCreative()) { if (player.isCreative()) {
int id = getMultiblock(player.getHeldItem(context.getHand())); int id = getMultiblock(player.getItemInHand(context.getHand()));
if (id < 0) if (id < 0)
return InteractionResult.PASS; return InteractionResult.PASS;
IMultiblock multi = multiblocks().get(id); IMultiblock multi = multiblocks().get(id);
@ -60,8 +60,8 @@ public class ItemMultiblockMaker extends ItemImpl {
return InteractionResult.PASS; return InteractionResult.PASS;
if (!context.getLevel().isClientSide) if (!context.getLevel().isClientSide)
multi.forEach(context.getPos().up(), (char) 0, (blockPos, matcher) -> { multi.forEach(context.getClickedPos().above(), (char) 0, (blockPos, matcher) -> {
context.getLevel().setBlockState(blockPos, matcher.getDefaultState()); context.getLevel().setBlockAndUpdate(blockPos, matcher.defaultState());
return true; return true;
}); });
@ -71,12 +71,13 @@ public class ItemMultiblockMaker extends ItemImpl {
} }
@Override @Override
public ITextComponent getDisplayName(ItemStack stack) { public Component getName(ItemStack stack) {
TextComponent name = (TextComponent) super.getDisplayName(stack); MutableComponent name = (MutableComponent) super.getName(stack);
int id = getMultiblock(stack); int id = getMultiblock(stack);
if (id < 0) if (id < 0)
return name; return name;
IMultiblock multi = multiblocks().get(id); IMultiblock multi = multiblocks().get(id);
return multi == null ? name : name.appendString(" (" + multi.getName() + ")"); return multi == null ? name : name.append(" (" + multi.getName() + ")");
} }
} }

View file

@ -1,33 +1,34 @@
package de.ellpeck.naturesaura.items; package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import net.minecraft.block.BlockState; import net.minecraft.core.BlockPos;
import net.minecraft.block.Blocks; import net.minecraft.world.InteractionHand;
import net.minecraft.entity.player.Player; import net.minecraft.world.InteractionResult;
import net.minecraft.item.ItemStack; import net.minecraft.world.InteractionResultHolder;
import net.minecraft.util.ActionResult; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.InteractionResult; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.Hand; import net.minecraft.world.level.Level;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.block.Blocks;
import net.minecraft.level.Level; import net.minecraft.world.level.block.state.BlockState;
public class ItemNetheriteFinder extends ItemImpl { public class ItemNetheriteFinder extends ItemImpl {
public ItemNetheriteFinder() { public ItemNetheriteFinder() {
super("netherite_finder", new Properties().maxStackSize(1)); super("netherite_finder", new Properties().stacksTo(1));
} }
@Override @Override
public ActionResult<ItemStack> onItemRightClick(Level levelIn, Player playerIn, Hand handIn) { public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, InteractionHand handIn) {
ItemStack stack = playerIn.getHeldItem(handIn); ItemStack stack = playerIn.getItemInHand(handIn);
NaturesAuraAPI.IInternalHooks inst = NaturesAuraAPI.instance(); NaturesAuraAPI.IInternalHooks inst = NaturesAuraAPI.instance();
if (!inst.extractAuraFromPlayer(playerIn, 200000, false)) if (!inst.extractAuraFromPlayer(playerIn, 200000, false))
return new ActionResult<>(InteractionResult.FAIL, stack); return new InteractionResultHolder<>(InteractionResult.FAIL, stack);
if (levelIn.isClientSide) { if (levelIn.isClientSide) {
inst.setParticleDepth(false); inst.setParticleDepth(false);
inst.setParticleSpawnRange(64); inst.setParticleSpawnRange(64);
inst.setParticleCulling(false); inst.setParticleCulling(false);
BlockPos pos = playerIn.getPosition(); BlockPos pos = playerIn.blockPosition();
int range = 12; int range = 12;
for (int x = -range; x <= range; x++) { for (int x = -range; x <= range; x++) {
for (int y = 0; y <= 128; y++) { for (int y = 0; y <= 128; y++) {
@ -46,9 +47,9 @@ public class ItemNetheriteFinder extends ItemImpl {
inst.setParticleDepth(true); inst.setParticleDepth(true);
inst.setParticleSpawnRange(32); inst.setParticleSpawnRange(32);
inst.setParticleCulling(true); inst.setParticleCulling(true);
playerIn.swingArm(handIn); playerIn.swing(handIn);
} }
playerIn.getCooldownTracker().setCooldown(this, 20 * 60); playerIn.getCooldowns().addCooldown(this, 20 * 60);
return new ActionResult<>(InteractionResult.SUCCESS, stack); return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack);
} }
} }

View file

@ -4,19 +4,19 @@ import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; 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.entity.Entity; import net.minecraft.ChatFormatting;
import net.minecraft.entity.LivingEntity; import net.minecraft.core.BlockPos;
import net.minecraft.entity.passive.TameableEntity; import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.entity.player.Player; import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.entity.player.ServerPlayer; import net.minecraft.server.level.ServerLevel;
import net.minecraft.item.ItemStack; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.particles.ParticleTypes; import net.minecraft.world.InteractionResult;
import net.minecraft.util.InteractionResult; import net.minecraft.world.entity.Entity;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.entity.TamableAnimal;
import net.minecraft.util.text.TextFormatting; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.item.ItemStack;
import net.minecraft.level.server.ServerLevel; 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;
import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.living.LivingEvent;
@ -28,6 +28,7 @@ import java.util.Optional;
import java.util.UUID; import java.util.UUID;
public class ItemPetReviver extends ItemImpl { public class ItemPetReviver extends ItemImpl {
public ItemPetReviver() { public ItemPetReviver() {
super("pet_reviver"); super("pet_reviver");
MinecraftForge.EVENT_BUS.register(new Events()); MinecraftForge.EVENT_BUS.register(new Events());
@ -38,32 +39,31 @@ public class ItemPetReviver extends ItemImpl {
@SubscribeEvent @SubscribeEvent
public void onEntityTick(LivingEvent.LivingUpdateEvent event) { public void onEntityTick(LivingEvent.LivingUpdateEvent event) {
LivingEntity entity = event.getEntityLiving(); LivingEntity entity = event.getEntityLiving();
if (entity.level.isClientSide || entity.level.getGameTime() % 20 != 0 || !(entity instanceof TameableEntity)) if (entity.level.isClientSide || entity.level.getGameTime() % 20 != 0 || !(entity instanceof TamableAnimal tameable))
return; return;
TameableEntity tameable = (TameableEntity) entity; if (!tameable.isTame() || !tameable.getPersistentData().getBoolean(NaturesAura.MOD_ID + ":pet_reviver"))
if (!tameable.isTamed() || !tameable.getPersistentData().getBoolean(NaturesAura.MOD_ID + ":pet_reviver"))
return; return;
LivingEntity owner = tameable.getOwner(); LivingEntity owner = tameable.getOwner();
if (owner == null || owner.getDistanceSq(tameable) > 5 * 5) if (owner == null || owner.distanceToSqr(tameable) > 5 * 5)
return; return;
if (entity.level.rand.nextFloat() >= 0.65F) { if (entity.level.random.nextFloat() >= 0.65F) {
((ServerLevel) entity.level).spawnParticle(ParticleTypes.HEART, ((ServerLevel) entity.level).sendParticles(ParticleTypes.HEART,
entity.getPosX() + entity.level.rand.nextGaussian() * 0.25F, entity.getX() + entity.level.random.nextGaussian() * 0.25F,
entity.getPosYEye() + entity.level.rand.nextGaussian() * 0.25F, entity.getEyeY() + entity.level.random.nextGaussian() * 0.25F,
entity.getPosZ() + entity.level.rand.nextGaussian() * 0.25F, entity.getZ() + entity.level.random.nextGaussian() * 0.25F,
entity.level.rand.nextInt(2) + 1, 0, 0, 0, 0); entity.level.random.nextInt(2) + 1, 0, 0, 0, 0);
} }
} }
// we need to use the event since the item doesn't receive the interaction for tamed pets.. // we need to use the event since the item doesn't receive the interaction for tamed pets...
@SubscribeEvent @SubscribeEvent
public void onEntityInteract(PlayerInteractEvent.EntityInteractSpecific event) { public void onEntityInteract(PlayerInteractEvent.EntityInteractSpecific event) {
Entity target = event.getTarget(); Entity target = event.getTarget();
if (!(target instanceof TameableEntity) || !((TameableEntity) target).isTamed()) if (!(target instanceof TamableAnimal) || !((TamableAnimal) target).isTame())
return; return;
if (target.getPersistentData().getBoolean(NaturesAura.MOD_ID + ":pet_reviver")) if (target.getPersistentData().getBoolean(NaturesAura.MOD_ID + ":pet_reviver"))
return; return;
ItemStack stack = event.getPlayer().getHeldItem(event.getHand()); ItemStack stack = event.getPlayer().getItemInHand(event.getHand());
if (stack.getItem() != ModItems.PET_REVIVER) if (stack.getItem() != ModItems.PET_REVIVER)
return; return;
target.getPersistentData().putBoolean(NaturesAura.MOD_ID + ":pet_reviver", true); target.getPersistentData().putBoolean(NaturesAura.MOD_ID + ":pet_reviver", true);
@ -77,26 +77,23 @@ public class ItemPetReviver extends ItemImpl {
@SubscribeEvent(priority = EventPriority.LOWEST) @SubscribeEvent(priority = EventPriority.LOWEST)
public void onLivingDeath(LivingDeathEvent event) { public void onLivingDeath(LivingDeathEvent event) {
LivingEntity entity = event.getEntityLiving(); LivingEntity entity = event.getEntityLiving();
if (entity.level.isClientSide || !(entity instanceof TameableEntity)) if (entity.level.isClientSide || !(entity instanceof TamableAnimal tameable))
return; return;
TameableEntity tameable = (TameableEntity) entity; if (!tameable.isTame() || !tameable.getPersistentData().getBoolean(NaturesAura.MOD_ID + ":pet_reviver"))
if (!tameable.isTamed() || !tameable.getPersistentData().getBoolean(NaturesAura.MOD_ID + ":pet_reviver"))
return; return;
// get the overworld, and the overworld's spawn point, by default // get the overworld, and the overworld's spawn point, by default
ServerLevel spawnLevel = tameable.level.getServer().func_241755_D_(); ServerLevel spawnLevel = tameable.level.getServer().overworld();
Vector3d spawn = Vector3d.copyCenteredHorizontally(spawnLevel.func_241135_u_()); Vec3 spawn = Vec3.atBottomCenterOf(spawnLevel.getSharedSpawnPos());
// check if the owner is online, and respawn at the bed if they are // check if the owner is online, and respawn at the bed if they are
LivingEntity owner = tameable.getOwner(); LivingEntity owner = tameable.getOwner();
if (owner instanceof ServerPlayer) { if (owner instanceof ServerPlayer player) {
ServerPlayer player = (ServerPlayer) owner; BlockPos pos = player.getRespawnPosition();
// I'm not really sure what this means, but I got it from PlayerList.func_232644_a_ haha
BlockPos pos = player.func_241140_K_();
if (pos != null) { if (pos != null) {
float f = player.func_242109_L(); float f = player.getRespawnAngle();
boolean b = player.func_241142_M_(); boolean b = player.isRespawnForced();
Optional<Vector3d> bed = Player.func_242374_a((ServerLevel) player.level, pos, f, b, false); Optional<Vec3> bed = Player.findRespawnPositionAndUseSpawnBlock((ServerLevel) player.level, pos, f, b, false);
if (bed.isPresent()) { if (bed.isPresent()) {
spawnLevel = (ServerLevel) player.level; spawnLevel = (ServerLevel) player.level;
spawn = bed.get(); spawn = bed.get();
@ -104,38 +101,38 @@ public class ItemPetReviver extends ItemImpl {
} }
} }
PacketHandler.sendToAllAround(tameable.level, tameable.getPosition(), 32, new PacketParticles((float) tameable.getPosX(), (float) tameable.getPosYEye(), (float) tameable.getPosZ(), PacketParticles.Type.PET_REVIVER, 0xc2461d)); PacketHandler.sendToAllAround(tameable.level, tameable.blockPosition(), 32, new PacketParticles((float) tameable.getX(), (float) tameable.getEyeY(), (float) tameable.getZ(), PacketParticles.Type.PET_REVIVER, 0xc2461d));
TameableEntity spawnedPet = tameable; TamableAnimal spawnedPet = tameable;
if (tameable.level != spawnLevel) { if (tameable.level != spawnLevel) {
((ServerLevel) tameable.level).removeEntity(tameable, true); ((ServerLevel) tameable.level).removeEntity(tameable, true);
spawnedPet = (TameableEntity) tameable.getType().create(spawnLevel); spawnedPet = (TamableAnimal) tameable.getType().create(spawnLevel);
} }
// respawn (a copy of) the pet // respawn (a copy of) the pet
spawnedPet.copyDataFromOld(tameable); spawnedPet.restoreFrom(tameable);
spawnedPet.setMotion(0, 0, 0); spawnedPet.setDeltaMovement(0, 0, 0);
spawnedPet.setLocationAndAngles(spawn.x, spawn.y, spawn.z, tameable.rotationYaw, tameable.rotationPitch); spawnedPet.moveTo(spawn.x, spawn.y, spawn.z, tameable.getYRot(), tameable.getXRot());
while (!spawnLevel.hasNoCollisions(spawnedPet)) while (!spawnLevel.noCollision(spawnedPet))
spawnedPet.setPosition(spawnedPet.getPosX(), spawnedPet.getPosY() + 1, spawnedPet.getPosZ()); spawnedPet.setPos(spawnedPet.getX(), spawnedPet.getY() + 1, spawnedPet.getZ());
spawnedPet.setHealth(spawnedPet.getMaxHealth()); spawnedPet.setHealth(spawnedPet.getMaxHealth());
spawnedPet.getNavigator().clearPath(); spawnedPet.getNavigation().stop();
// sit down (on the server side!) // sit down (on the server side!)
spawnedPet.func_233687_w_(true); spawnedPet.setInSittingPose(true);
spawnedPet.setJumping(false); spawnedPet.setJumping(false);
spawnedPet.setAttackTarget(null); spawnedPet.setTarget(null);
if (tameable.level != spawnLevel) { if (tameable.level != spawnLevel) {
spawnLevel.addEntity(spawnedPet); spawnLevel.addFreshEntity(spawnedPet);
tameable.remove(false); tameable.remove(Entity.RemovalReason.DISCARDED);
} }
// drain aura // drain aura
BlockPos auraPos = IAuraChunk.getHighestSpot(spawnLevel, spawnedPet.getPosition(), 35, spawnedPet.getPosition()); BlockPos auraPos = IAuraChunk.getHighestSpot(spawnLevel, spawnedPet.blockPosition(), 35, spawnedPet.blockPosition());
IAuraChunk.getAuraChunk(spawnLevel, auraPos).drainAura(auraPos, 200000); IAuraChunk.getAuraChunk(spawnLevel, auraPos).drainAura(auraPos, 200000);
PacketHandler.sendToAllAround(spawnedPet.level, spawnedPet.getPosition(), 32, new PacketParticles((float) spawnedPet.getPosX(), (float) spawnedPet.getPosYEye(), (float) spawnedPet.getPosZ(), 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 TranslationTextComponent("info." + NaturesAura.MOD_ID + ".pet_reviver", spawnedPet.getDisplayName()).mergeStyle(TextFormatting.ITALIC, TextFormatting.GRAY), UUID.randomUUID()); owner.sendMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".pet_reviver", spawnedPet.getDisplayName()).withStyle(ChatFormatting.ITALIC, ChatFormatting.GRAY), UUID.randomUUID());
event.setCanceled(true); event.setCanceled(true);
} }
} }

View file

@ -4,19 +4,19 @@ import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap; 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.block.Block; import net.minecraft.core.BlockPos;
import net.minecraft.block.BlockState; import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.entity.Entity; import net.minecraft.resources.ResourceLocation;
import net.minecraft.entity.player.Player; import net.minecraft.world.InteractionHand;
import net.minecraft.item.ItemStack; import net.minecraft.world.InteractionResult;
import net.minecraft.item.ItemUseContext; import net.minecraft.world.InteractionResultHolder;
import net.minecraft.util.ActionResult; import net.minecraft.world.entity.Entity;
import net.minecraft.util.InteractionResult; import net.minecraft.world.entity.player.Player;
import net.minecraft.util.Hand; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.Level;
import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.level.block.Block;
import net.minecraft.level.Level; 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;
@ -28,7 +28,7 @@ public class ItemRangeVisualizer extends ItemImpl {
public static final ListMultimap<ResourceLocation, BlockPos> VISUALIZED_RAILS = ArrayListMultimap.create(); public static final ListMultimap<ResourceLocation, BlockPos> VISUALIZED_RAILS = ArrayListMultimap.create();
public ItemRangeVisualizer() { public ItemRangeVisualizer() {
super("range_visualizer", new Properties().maxStackSize(1)); super("range_visualizer", new Properties().stacksTo(1));
MinecraftForge.EVENT_BUS.register(new EventHandler()); MinecraftForge.EVENT_BUS.register(new EventHandler());
} }
@ -44,33 +44,33 @@ public class ItemRangeVisualizer extends ItemImpl {
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.sendStatusMessage(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".range_visualizer.end"), true); player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".range_visualizer.end"), true);
} else { } else {
map.put(dim, value); map.put(dim, value);
player.sendStatusMessage(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".range_visualizer.start"), true); player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".range_visualizer.start"), true);
} }
} }
@Override @Override
public ActionResult<ItemStack> onItemRightClick(Level levelIn, Player playerIn, Hand handIn) { public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, InteractionHand handIn) {
ItemStack stack = playerIn.getHeldItem(handIn); ItemStack stack = playerIn.getItemInHand(handIn);
if (playerIn.isSneaking()) { if (playerIn.isCrouching()) {
clear(); clear();
playerIn.sendStatusMessage(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".range_visualizer.end_all"), true); playerIn.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".range_visualizer.end_all"), true);
return new ActionResult<>(InteractionResult.SUCCESS, stack); return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack);
} }
return new ActionResult<>(InteractionResult.PASS, stack); return new InteractionResultHolder<>(InteractionResult.PASS, stack);
} }
@Override @Override
public InteractionResult onItemUse(ItemUseContext context) { public InteractionResult useOn(UseOnContext context) {
Level level = context.getLevel(); Level level = context.getLevel();
BlockPos pos = context.getPos(); BlockPos pos = context.getClickedPos();
BlockState state = level.getBlockState(pos); BlockState state = level.getBlockState(pos);
Block block = state.getBlock(); Block block = state.getBlock();
if (block instanceof IVisualizable) { if (block instanceof IVisualizable) {
if (level.isClientSide) if (level.isClientSide)
visualize(context.getPlayer(), VISUALIZED_BLOCKS, level.func_234923_W_().func_240901_a_(), pos); visualize(context.getPlayer(), VISUALIZED_BLOCKS, level.dimension().location(), pos);
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }
return InteractionResult.PASS; return InteractionResult.PASS;
@ -86,10 +86,10 @@ public class ItemRangeVisualizer extends ItemImpl {
Entity entity = event.getTarget(); Entity entity = event.getTarget();
if (entity instanceof IVisualizable) { if (entity instanceof IVisualizable) {
if (entity.level.isClientSide) { if (entity.level.isClientSide) {
ResourceLocation dim = entity.level.func_234923_W_().func_240901_a_(); ResourceLocation dim = entity.level.dimension().location();
visualize(event.getPlayer(), VISUALIZED_ENTITIES, dim, entity); visualize(event.getPlayer(), VISUALIZED_ENTITIES, dim, entity);
} }
event.getPlayer().swingArm(event.getHand()); event.getPlayer().swing(event.getHand());
event.setCancellationResult(InteractionResult.SUCCESS); event.setCancellationResult(InteractionResult.SUCCESS);
event.setCanceled(true); event.setCanceled(true);
} }

View file

@ -1,33 +1,33 @@
package de.ellpeck.naturesaura.items; package de.ellpeck.naturesaura.items;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.render.ITrinketItem; import de.ellpeck.naturesaura.api.render.ITrinketItem;
import de.ellpeck.naturesaura.items.tools.ItemArmor; import de.ellpeck.naturesaura.items.tools.ItemArmor;
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 de.ellpeck.naturesaura.reg.ModArmorMaterial; import de.ellpeck.naturesaura.reg.ModArmorMaterial;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.entity.Entity; import net.minecraft.core.BlockPos;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.Player;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.potion.EffectInstance; import net.minecraft.sounds.SoundSource;
import net.minecraft.potion.Effects; import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.util.DamageSource; import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.util.SoundCategory; import net.minecraft.world.effect.MobEffects;
import net.minecraft.util.math.AABB; import net.minecraft.world.entity.Entity;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.util.math.vector.Vector3f; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.level.Level; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.AABB;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@ -36,23 +36,22 @@ import java.util.List;
public class ItemShockwaveCreator extends ItemImpl implements ITrinketItem { public class ItemShockwaveCreator extends ItemImpl implements ITrinketItem {
public ItemShockwaveCreator() { public ItemShockwaveCreator() {
super("shockwave_creator", new Properties().maxStackSize(1)); super("shockwave_creator", new Properties().stacksTo(1));
} }
@Override @Override
public void inventoryTick(ItemStack stack, Level levelIn, Entity entityIn, int itemSlot, boolean isSelected) { public void inventoryTick(ItemStack stack, Level levelIn, Entity entityIn, int itemSlot, boolean isSelected) {
if (levelIn.isClientSide || !(entityIn instanceof LivingEntity)) if (levelIn.isClientSide || !(entityIn instanceof LivingEntity living))
return; return;
LivingEntity living = (LivingEntity) entityIn;
if (!living.isOnGround()) { if (!living.isOnGround()) {
CompoundTag compound = stack.getOrCreateTag(); CompoundTag compound = stack.getOrCreateTag();
if (compound.getBoolean("air")) if (compound.getBoolean("air"))
return; return;
compound.putBoolean("air", true); compound.putBoolean("air", true);
compound.putDouble("x", living.getPosX()); compound.putDouble("x", living.getX());
compound.putDouble("y", living.getPosY()); compound.putDouble("y", living.getY());
compound.putDouble("z", living.getPosZ()); compound.putDouble("z", living.getZ());
} else { } else {
if (!stack.hasTag()) if (!stack.hasTag())
return; return;
@ -62,59 +61,59 @@ public class ItemShockwaveCreator extends ItemImpl implements ITrinketItem {
compound.putBoolean("air", false); compound.putBoolean("air", false);
if (!living.isSneaking()) if (!living.isCrouching())
return; return;
if (living.getDistanceSq(compound.getDouble("x"), compound.getDouble("y"), compound.getDouble("z")) > 0.75F) if (living.distanceToSqr(compound.getDouble("x"), compound.getDouble("y"), compound.getDouble("z")) > 0.75F)
return; return;
if (living instanceof Player && !NaturesAuraAPI.instance().extractAuraFromPlayer((Player) living, 1000, false)) if (living instanceof Player && !NaturesAuraAPI.instance().extractAuraFromPlayer((Player) living, 1000, false))
return; return;
DamageSource source; DamageSource source;
if (living instanceof Player) if (living instanceof Player)
source = DamageSource.causePlayerDamage((Player) living); source = DamageSource.playerAttack((Player) living);
else else
source = DamageSource.MAGIC; source = DamageSource.MAGIC;
boolean infusedSet = ItemArmor.isFullSetEquipped(living, ModArmorMaterial.INFUSED); boolean infusedSet = ItemArmor.isFullSetEquipped(living, ModArmorMaterial.INFUSED);
int range = 5; int range = 5;
List<LivingEntity> mobs = levelIn.getEntitiesWithinAABB(LivingEntity.class, new AABB( List<LivingEntity> mobs = levelIn.getEntitiesOfClass(LivingEntity.class, new AABB(
living.getPosX() - range, living.getPosY() - 0.5, living.getPosZ() - range, living.getX() - range, living.getY() - 0.5, living.getZ() - range,
living.getPosX() + range, living.getPosY() + 0.5, living.getPosZ() + range)); living.getX() + range, living.getY() + 0.5, living.getZ() + range));
for (LivingEntity mob : mobs) { for (LivingEntity mob : mobs) {
if (!mob.isAlive() || mob == living) if (!mob.isAlive() || mob == living)
continue; continue;
if (living.getDistanceSq(mob) > range * range) if (living.distanceToSqr(mob) > range * range)
continue; continue;
if (living instanceof Player && !NaturesAuraAPI.instance().extractAuraFromPlayer((Player) living, 500, false)) if (living instanceof Player && !NaturesAuraAPI.instance().extractAuraFromPlayer((Player) living, 500, false))
break; break;
mob.attackEntityFrom(source, 4F); mob.hurt(source, 4F);
if (infusedSet) if (infusedSet)
mob.addPotionEffect(new EffectInstance(Effects.WITHER, 120)); mob.addEffect(new MobEffectInstance(MobEffects.WITHER, 120));
} }
BlockPos pos = living.getPosition(); BlockPos pos = living.blockPosition();
BlockPos down = pos.down(); BlockPos down = pos.below();
BlockState downState = levelIn.getBlockState(down); BlockState downState = levelIn.getBlockState(down);
if (downState.getMaterial() != Material.AIR) { if (downState.getMaterial() != Material.AIR) {
SoundType type = downState.getBlock().getSoundType(downState, levelIn, down, null); SoundType type = downState.getBlock().getSoundType(downState, levelIn, down, null);
levelIn.playSound(null, pos, type.getBreakSound(), SoundCategory.BLOCKS, type.getVolume() * 0.5F, type.getPitch() * 0.8F); levelIn.playSound(null, pos, type.getBreakSound(), SoundSource.BLOCKS, type.getVolume() * 0.5F, type.getPitch() * 0.8F);
} }
PacketHandler.sendToAllAround(levelIn, pos, 32, new PacketParticles((float) living.getPosX(), (float) living.getPosY(), (float) living.getPosZ(), PacketParticles.Type.SHOCKWAVE_CREATOR)); PacketHandler.sendToAllAround(levelIn, pos, 32, new PacketParticles((float) living.getX(), (float) living.getY(), (float) living.getZ(), PacketParticles.Type.SHOCKWAVE_CREATOR));
} }
} }
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void render(ItemStack stack, Player player, RenderType type, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight, boolean isHolding) { public void render(ItemStack stack, Player player, RenderType type, PoseStack matrices, MultiBufferSource buffer, int packedLight, boolean isHolding) {
if (type == RenderType.BODY && !isHolding) { if (type == RenderType.BODY && !isHolding) {
boolean armor = !player.inventory.armorInventory.get(EquipmentSlotType.CHEST.getIndex()).isEmpty(); boolean armor = !player.getInventory().armor.get(EquipmentSlot.CHEST.getIndex()).isEmpty();
matrices.translate(0, 0.125F, armor ? -0.195F : -0.1475F); matrices.translate(0, 0.125F, armor ? -0.195F : -0.1475F);
matrices.scale(0.3F, 0.3F, 0.3F); matrices.scale(0.3F, 0.3F, 0.3F);
matrices.rotate(Vector3f.XP.rotationDegrees(180)); matrices.mulPose(Vector3f.XP.rotationDegrees(180));
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.GROUND, packedLight, OverlayTexture.NO_OVERLAY, matrices, buffer); Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemTransforms.TransformType.GROUND, packedLight, OverlayTexture.NO_OVERLAY, matrices, buffer, 0);
} }
} }
} }

View file

@ -4,9 +4,8 @@ import de.ellpeck.naturesaura.entities.EntityStructureFinder;
import de.ellpeck.naturesaura.entities.ModEntities; import de.ellpeck.naturesaura.entities.ModEntities;
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.ActionResult;
import net.minecraft.util.InteractionResult;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -30,18 +29,18 @@ public class ItemStructureFinder extends ItemImpl {
public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, InteractionHand handIn) { public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, InteractionHand handIn) {
ItemStack stack = playerIn.getItemInHand(handIn); ItemStack stack = playerIn.getItemInHand(handIn);
if (!levelIn.isClientSide && ((ServerLevel) levelIn).structureFeatureManager().shouldGenerateFeatures()) { if (!levelIn.isClientSide && ((ServerLevel) levelIn).structureFeatureManager().shouldGenerateFeatures()) {
BlockPos pos = ((ServerLevel) levelIn).getChunkSource().getGenerator().findNearestMapFeature((ServerLevel) levelIn, this.structureName, playerIn.getPosition(), this.radius, false); BlockPos pos = ((ServerLevel) levelIn).getChunkSource().getGenerator().findNearestMapFeature((ServerLevel) levelIn, this.structureName, playerIn.blockPosition(), this.radius, false);
if (pos != null) { if (pos != null) {
EntityStructureFinder entity = new EntityStructureFinder(ModEntities.STRUCTURE_FINDER, levelIn); EntityStructureFinder entity = new EntityStructureFinder(ModEntities.STRUCTURE_FINDER, levelIn);
entity.setPosition(playerIn.getPosX(), playerIn.getPosYHeight(0.5D), playerIn.getPosZ()); entity.setPos(playerIn.getX(), playerIn.getY(0.5D), playerIn.getZ());
entity.func_213863_b(stack); entity.setItem(stack);
entity.getDataManager().set(EntityStructureFinder.COLOR, this.color); entity.getEntityData().set(EntityStructureFinder.COLOR, this.color);
entity.moveTowards(pos.up(64)); entity.signalTo(pos.above(64));
levelIn.addEntity(entity); levelIn.addFreshEntity(entity);
stack.shrink(1); stack.shrink(1);
} }
} }
return new ActionResult<>(InteractionResult.SUCCESS, stack); return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack);
} }
} }

View file

@ -75,7 +75,7 @@ public class ItemPickaxe extends PickaxeItem implements IModItem, ICustomItemMod
return; return;
if (!isSelected || levelIn.isClientSide) if (!isSelected || levelIn.isClientSide)
return; return;
AABB bounds = new AABB(entityIn.getOnPos()).inflate(3.5F); AABB bounds = new AABB(entityIn.blockPosition()).inflate(3.5F);
for (ItemEntity item : levelIn.getEntitiesOfClass(ItemEntity.class, bounds)) { for (ItemEntity item : levelIn.getEntitiesOfClass(ItemEntity.class, bounds)) {
// only pick up freshly dropped items // only pick up freshly dropped items
if (item.tickCount >= 5 || !item.isAlive()) if (item.tickCount >= 5 || !item.isAlive())

View file

@ -1,8 +1,8 @@
package de.ellpeck.naturesaura.misc; package de.ellpeck.naturesaura.misc;
import net.minecraft.block.Block; import net.minecraft.resources.ResourceLocation;
import net.minecraft.item.DyeColor; import net.minecraft.world.item.DyeColor;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.level.block.Block;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
import java.util.ArrayList; import java.util.ArrayList;
@ -24,7 +24,7 @@ public final class ColoredBlockHelper {
private static List<Block> collectBlocks(String name) { private static List<Block> collectBlocks(String name) {
List<Block> blocks = new ArrayList<>(); List<Block> blocks = new ArrayList<>();
for (DyeColor color : DyeColor.values()) for (DyeColor color : DyeColor.values())
blocks.add(ForgeRegistries.BLOCKS.getValue(new ResourceLocation(color.getString() + '_' + name))); blocks.add(ForgeRegistries.BLOCKS.getValue(new ResourceLocation(color.getName() + '_' + name)));
return Collections.unmodifiableList(blocks); return Collections.unmodifiableList(blocks);
} }

View file

@ -5,7 +5,6 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.chunk.AuraChunk; import de.ellpeck.naturesaura.chunk.AuraChunk;
import de.ellpeck.naturesaura.events.ClientEvents; import de.ellpeck.naturesaura.events.ClientEvents;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.level.chunk.Chunk;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunk;
@ -40,7 +39,7 @@ public class PacketAuraChunk {
int amount = buf.readInt(); int amount = buf.readInt();
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
packet.drainSpots.put( packet.drainSpots.put(
BlockPos.fromLong(buf.readLong()), BlockPos.of(buf.readLong()),
new MutableInt(buf.readInt()) new MutableInt(buf.readInt())
); );
} }
@ -54,7 +53,7 @@ public class PacketAuraChunk {
buf.writeInt(packet.drainSpots.size()); buf.writeInt(packet.drainSpots.size());
for (Map.Entry<BlockPos, MutableInt> entry : packet.drainSpots.entrySet()) { for (Map.Entry<BlockPos, MutableInt> entry : packet.drainSpots.entrySet()) {
buf.writeLong(entry.getKey().toLong()); buf.writeLong(entry.getKey().asLong());
buf.writeInt(entry.getValue().intValue()); buf.writeInt(entry.getValue().intValue());
} }
} }

View file

@ -3,19 +3,20 @@ package de.ellpeck.naturesaura.packet;
import de.ellpeck.naturesaura.items.ItemRangeVisualizer; import de.ellpeck.naturesaura.items.ItemRangeVisualizer;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity; import net.minecraft.core.BlockPos;
import net.minecraft.item.ItemStack; import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.particles.ParticleTypes; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.ResourceLocation; import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.SoundEvents; import net.minecraft.world.entity.Entity;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fml.network.NetworkEvent; import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier; import java.util.function.Supplier;
public class PacketClient { public class PacketClient {
private int type; private int type;
private CompoundTag data; private CompoundTag data;
@ -28,16 +29,16 @@ public class PacketClient {
} }
public static PacketClient fromBytes(PacketBuffer buf) { public static PacketClient fromBytes(FriendlyByteBuf buf) {
PacketClient client = new PacketClient(); PacketClient client = new PacketClient();
client.type = buf.readByte(); client.type = buf.readByte();
client.data = buf.readCompoundTag(); client.data = buf.readNbt();
return client; return client;
} }
public static void toBytes(PacketClient packet, PacketBuffer buf) { public static void toBytes(PacketClient packet, FriendlyByteBuf buf) {
buf.writeByte(packet.type); buf.writeByte(packet.type);
buf.writeCompoundTag(packet.data); buf.writeNbt(packet.data);
} }
// lambda causes classloading issues on a server here // lambda causes classloading issues on a server here
@ -51,12 +52,12 @@ public class PacketClient {
switch (message.type) { switch (message.type) {
case 0: // dimension rail visualization case 0: // dimension rail visualization
ResourceLocation goalDim = new ResourceLocation(message.data.getString("dim")); ResourceLocation goalDim = new ResourceLocation(message.data.getString("dim"));
BlockPos goalPos = BlockPos.fromLong(message.data.getLong("pos")); BlockPos goalPos = BlockPos.of(message.data.getLong("pos"));
ItemRangeVisualizer.visualize(mc.player, ItemRangeVisualizer.VISUALIZED_RAILS, goalDim, goalPos); ItemRangeVisualizer.visualize(mc.player, ItemRangeVisualizer.VISUALIZED_RAILS, goalDim, goalPos);
case 1: case 1:
Entity entity = mc.level.getEntityByID(message.data.getInt("id")); Entity entity = mc.level.getEntity(message.data.getInt("id"));
mc.particles.emitParticleAtEntity(entity, ParticleTypes.TOTEM_OF_UNDYING, 30); mc.particleEngine.createTrackingEmitter(entity, ParticleTypes.TOTEM_OF_UNDYING, 30);
mc.level.playSound(entity.getPosX(), entity.getPosY(), entity.getPosZ(), SoundEvents.ITEM_TOTEM_USE, entity.getSoundCategory(), 1.0F, 1.0F, false); mc.level.playLocalSound(entity.getX(), entity.getY(), entity.getZ(), SoundEvents.TOTEM_USE, entity.getSoundSource(), 1.0F, 1.0F, false);
if (entity == mc.player) { if (entity == mc.player) {
mc.gameRenderer.displayItemActivation(new ItemStack(ModItems.DEATH_RING)); mc.gameRenderer.displayItemActivation(new ItemStack(ModItems.DEATH_RING));
} }

View file

@ -4,7 +4,6 @@ import de.ellpeck.naturesaura.NaturesAura;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.NetworkRegistry;
@ -29,7 +28,7 @@ public final class PacketHandler {
} }
public static void sendToAllAround(Level level, BlockPos pos, int range, Object message) { public static void sendToAllAround(Level level, BlockPos pos, int range, Object message) {
network.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(pos.getX(), pos.getY(), pos.getZ(), range, level.func_234923_W_())), message); network.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(pos.getX(), pos.getY(), pos.getZ(), range, level.dimension())), message);
} }
public static void sendTo(Player player, Object message) { public static void sendTo(Player player, Object message) {

View file

@ -6,15 +6,12 @@ import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.entities.EntityStructureFinder; import de.ellpeck.naturesaura.entities.EntityStructureFinder;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.BiomeColors;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.level.biome.BiomeColors; import net.minecraft.core.particles.ItemParticleOption;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.particles.ItemParticleData;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraftforge.network.NetworkEvent; import net.minecraftforge.network.NetworkEvent;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
@ -40,7 +37,7 @@ public class PacketParticles {
} }
public static PacketParticles fromBytes(FriendlyByteBuf buf) { public static PacketParticles fromBytes(FriendlyByteBuf buf) {
PacketParticles packet = new PacketParticles(); var packet = new PacketParticles();
packet.posX = buf.readFloat(); packet.posX = buf.readFloat();
packet.posY = buf.readFloat(); packet.posY = buf.readFloat();
@ -48,7 +45,7 @@ public class PacketParticles {
packet.type = Type.values()[buf.readByte()]; packet.type = Type.values()[buf.readByte()];
packet.data = new int[buf.readByte()]; packet.data = new int[buf.readByte()];
for (int i = 0; i < packet.data.length; i++) { for (var i = 0; i < packet.data.length; i++) {
packet.data[i] = buf.readInt(); packet.data[i] = buf.readInt();
} }
@ -62,7 +59,7 @@ public class PacketParticles {
buf.writeByte(packet.type.ordinal()); buf.writeByte(packet.type.ordinal());
buf.writeByte(packet.data.length); buf.writeByte(packet.data.length);
for (int i : packet.data) { for (var i : packet.data) {
buf.writeInt(i); buf.writeInt(i);
} }
} }
@ -83,136 +80,136 @@ public class PacketParticles {
public enum Type { public enum Type {
TR_GOLD_POWDER((message, level) -> { TR_GOLD_POWDER((message, level) -> {
BlockPos pos = new BlockPos(message.posX, message.posY, message.posZ); var pos = new BlockPos(message.posX, message.posY, message.posZ);
Multiblocks.TREE_RITUAL.forEach(pos, 'G', (dustPos, matcher) -> { Multiblocks.TREE_RITUAL.forEach(pos, 'G', (dustPos, matcher) -> {
BlockState state = level.getBlockState(dustPos); var state = level.getBlockState(dustPos);
AABB box = state.getShape(level, dustPos).getBoundingBox(); var box = state.getShape(level, dustPos).bounds();
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
dustPos.getX() + box.minX + (box.maxX - box.minX) * level.rand.nextFloat(), dustPos.getX() + box.minX + (box.maxX - box.minX) * level.random.nextFloat(),
dustPos.getY() + 0.1F, dustPos.getY() + 0.1F,
dustPos.getZ() + box.minZ + (box.maxZ - box.minZ) * level.rand.nextFloat(), dustPos.getZ() + box.minZ + (box.maxZ - box.minZ) * level.random.nextFloat(),
(float) level.rand.nextGaussian() * 0.02F, (float) level.random.nextGaussian() * 0.02F,
level.rand.nextFloat() * 0.01F + 0.02F, level.random.nextFloat() * 0.01F + 0.02F,
(float) level.rand.nextGaussian() * 0.02F, (float) level.random.nextGaussian() * 0.02F,
0xf4cb42, 2F, 50, 0F, false, true); 0xf4cb42, 2F, 50, 0F, false, true);
return true; return true;
}); });
}), }),
TR_CONSUME_ITEM((message, level) -> { TR_CONSUME_ITEM((message, level) -> {
for (int i = level.rand.nextInt(20) + 10; i >= 0; i--) { for (var i = level.random.nextInt(20) + 10; i >= 0; i--) {
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + 0.5F, message.posY + 0.9F, message.posZ + 0.5F, message.posX + 0.5F, message.posY + 0.9F, message.posZ + 0.5F,
(float) level.rand.nextGaussian() * 0.04F, level.rand.nextFloat() * 0.04F, (float) level.rand.nextGaussian() * 0.04F, (float) level.random.nextGaussian() * 0.04F, level.random.nextFloat() * 0.04F, (float) level.random.nextGaussian() * 0.04F,
0x89cc37, 1.5F, 25, 0F, false, true); 0x89cc37, 1.5F, 25, 0F, false, true);
} }
}), }),
TR_DISAPPEAR((message, level) -> { TR_DISAPPEAR((message, level) -> {
for (int i = level.rand.nextInt(5) + 3; i >= 0; i--) { for (var i = level.random.nextInt(5) + 3; i >= 0; i--) {
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + level.rand.nextFloat(), message.posY + level.rand.nextFloat(), message.posZ + level.rand.nextFloat(), message.posX + level.random.nextFloat(), message.posY + level.random.nextFloat(), message.posZ + level.random.nextFloat(),
0F, 0F, 0F, 0F, 0F, 0F,
0x33FF33, 1F, 50, 0F, false, true); 0x33FF33, 1F, 50, 0F, false, true);
} }
}), }),
TR_SPAWN_RESULT((message, level) -> { TR_SPAWN_RESULT((message, level) -> {
for (int i = level.rand.nextInt(10) + 10; i >= 0; i--) { for (var i = level.random.nextInt(10) + 10; i >= 0; i--) {
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX, message.posY, message.posZ, message.posX, message.posY, message.posZ,
level.rand.nextGaussian() * 0.1F, level.rand.nextGaussian() * 0.1F, level.rand.nextGaussian() * 0.1F, level.random.nextGaussian() * 0.1F, level.random.nextGaussian() * 0.1F, level.random.nextGaussian() * 0.1F,
0x89cc37, 2F, 100, 0F, true, true); 0x89cc37, 2F, 100, 0F, true, true);
} }
}), }),
ALTAR_CONVERSION((message, level) -> { ALTAR_CONVERSION((message, level) -> {
int color = message.data[0]; var color = message.data[0];
for (int i = level.rand.nextInt(5) + 2; i >= 0; i--) { for (var i = level.random.nextInt(5) + 2; i >= 0; i--) {
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + 0.25F + level.rand.nextFloat() * 0.5F, message.posX + 0.25F + level.random.nextFloat() * 0.5F,
message.posY + 0.9F + 0.25F * level.rand.nextFloat(), message.posY + 0.9F + 0.25F * level.random.nextFloat(),
message.posZ + 0.25F + level.rand.nextFloat() * 0.5F, message.posZ + 0.25F + level.random.nextFloat() * 0.5F,
level.rand.nextGaussian() * 0.02F, level.rand.nextFloat() * 0.02F, level.rand.nextGaussian() * 0.02F, level.random.nextGaussian() * 0.02F, level.random.nextFloat() * 0.02F, level.random.nextGaussian() * 0.02F,
color, level.rand.nextFloat() * 1.5F + 0.75F, 20, 0F, false, true); color, level.random.nextFloat() * 1.5F + 0.75F, 20, 0F, false, true);
} }
}), }),
POTION_GEN((message, level) -> { POTION_GEN((message, level) -> {
int color = message.data[0]; var color = message.data[0];
boolean releaseAura = message.data[1] > 0; var releaseAura = message.data[1] > 0;
for (int i = level.rand.nextInt(5) + 5; i >= 0; i--) { for (var i = level.random.nextInt(5) + 5; i >= 0; i--) {
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + level.rand.nextFloat(), message.posX + level.random.nextFloat(),
message.posY + 1.1F, message.posY + 1.1F,
message.posZ + level.rand.nextFloat(), message.posZ + level.random.nextFloat(),
level.rand.nextGaussian() * 0.01F, level.rand.nextFloat() * 0.1F, level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F, level.random.nextFloat() * 0.1F, level.random.nextGaussian() * 0.01F,
color, 2F + level.rand.nextFloat(), 40, 0F, true, true); color, 2F + level.random.nextFloat(), 40, 0F, true, true);
if (releaseAura) if (releaseAura)
for (int x = -1; x <= 1; x += 2) for (var x = -1; x <= 1; x += 2)
for (int z = -1; z <= 1; z += 2) { for (var z = -1; z <= 1; z += 2) {
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + x * 3 + 0.5F, message.posX + x * 3 + 0.5F,
message.posY + 2.5, message.posY + 2.5,
message.posZ + z * 3 + 0.5F, message.posZ + z * 3 + 0.5F,
level.rand.nextGaussian() * 0.02F, level.random.nextGaussian() * 0.02F,
level.rand.nextFloat() * 0.04F, level.random.nextFloat() * 0.04F,
level.rand.nextGaussian() * 0.02F, level.random.nextGaussian() * 0.02F,
0xd6340c, 1F + level.rand.nextFloat() * 2F, 75, 0F, true, true); 0xd6340c, 1F + level.random.nextFloat() * 2F, 75, 0F, true, true);
} }
} }
}), }),
PLANT_BOOST((message, level) -> { PLANT_BOOST((message, level) -> {
for (int i = level.rand.nextInt(20) + 15; i >= 0; i--) for (var i = level.random.nextInt(20) + 15; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + level.rand.nextFloat(), message.posX + level.random.nextFloat(),
message.posY + 0.25F + level.rand.nextFloat() * 0.5F, message.posY + 0.25F + level.random.nextFloat() * 0.5F,
message.posZ + level.rand.nextFloat(), message.posZ + level.random.nextFloat(),
0F, level.rand.nextFloat() * 0.02F, 0F, 0F, level.random.nextFloat() * 0.02F, 0F,
0x5ccc30, 1F + level.rand.nextFloat() * 2F, 50, 0F, false, true); 0x5ccc30, 1F + level.random.nextFloat() * 2F, 50, 0F, false, true);
}), }),
FLOWER_GEN_CONSUME((message, level) -> { FLOWER_GEN_CONSUME((message, level) -> {
int color = message.data[0]; var color = message.data[0];
for (int i = level.rand.nextInt(10) + 10; i >= 0; i--) for (var i = level.random.nextInt(10) + 10; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + 0.25F + level.rand.nextFloat() * 0.5F, message.posX + 0.25F + level.random.nextFloat() * 0.5F,
message.posY + 0.25F + level.rand.nextFloat() * 0.5F, message.posY + 0.25F + level.random.nextFloat() * 0.5F,
message.posZ + 0.25F + level.rand.nextFloat() * 0.5F, message.posZ + 0.25F + level.random.nextFloat() * 0.5F,
level.rand.nextGaussian() * 0.02F, level.random.nextGaussian() * 0.02F,
level.rand.nextGaussian() * 0.02F, level.random.nextGaussian() * 0.02F,
level.rand.nextGaussian() * 0.02F, level.random.nextGaussian() * 0.02F,
color, level.rand.nextFloat() * 2F + 1F, 25, 0F, false, true); color, level.random.nextFloat() * 2F + 1F, 25, 0F, false, true);
}), }),
FLOWER_GEN_AURA_CREATION((message, level) -> { FLOWER_GEN_AURA_CREATION((message, level) -> {
for (int i = level.rand.nextInt(10) + 5; i >= 0; i--) for (var i = level.random.nextInt(10) + 5; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + 0.25F + level.rand.nextFloat() * 0.5F, message.posX + 0.25F + level.random.nextFloat() * 0.5F,
message.posY + 1.01F, message.posY + 1.01F,
message.posZ + 0.25F + level.rand.nextFloat() * 0.5F, message.posZ + 0.25F + level.random.nextFloat() * 0.5F,
level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F,
level.rand.nextFloat() * 0.04F + 0.02F, level.random.nextFloat() * 0.04F + 0.02F,
level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F,
0x5ccc30, 1F + level.rand.nextFloat() * 1.5F, 40, 0F, false, true); 0x5ccc30, 1F + level.random.nextFloat() * 1.5F, 40, 0F, false, true);
}), }),
PLACER_PLACING((message, level) -> { PLACER_PLACING((message, level) -> {
for (int i = level.rand.nextInt(20) + 20; i >= 0; i--) { for (var i = level.random.nextInt(20) + 20; i >= 0; i--) {
boolean side = level.rand.nextBoolean(); var side = level.random.nextBoolean();
float x = side ? level.rand.nextFloat() : level.rand.nextBoolean() ? 1.1F : -0.1F; var x = side ? level.random.nextFloat() : level.random.nextBoolean() ? 1.1F : -0.1F;
float z = !side ? level.rand.nextFloat() : level.rand.nextBoolean() ? 1.1F : -0.1F; var z = !side ? level.random.nextFloat() : level.random.nextBoolean() ? 1.1F : -0.1F;
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + x, message.posY + 0.1F + level.rand.nextFloat() * 0.98F, message.posZ + z, message.posX + x, message.posY + 0.1F + level.random.nextFloat() * 0.98F, message.posZ + z,
0F, 0F, 0F, 0F, 0F, 0F,
0xad7a37, level.rand.nextFloat() + 1F, 50, 0F, true, true); 0xad7a37, level.random.nextFloat() + 1F, 50, 0F, true, true);
} }
}), }),
HOPPER_UPGRADE((message, level) -> { HOPPER_UPGRADE((message, level) -> {
for (int i = level.rand.nextInt(20) + 10; i >= 0; i--) for (var i = level.random.nextInt(20) + 10; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX, message.posY + 0.45F, message.posZ, message.posX, message.posY + 0.45F, message.posZ,
level.rand.nextGaussian() * 0.015F, level.random.nextGaussian() * 0.015F,
level.rand.nextGaussian() * 0.015F, level.random.nextGaussian() * 0.015F,
level.rand.nextGaussian() * 0.015F, level.random.nextGaussian() * 0.015F,
0xdde7ff, level.rand.nextFloat() + 1F, 30, -0.06F, true, true); 0xdde7ff, level.random.nextFloat() + 1F, 30, -0.06F, true, true);
}), }),
SHOCKWAVE_CREATOR((message, level) -> { SHOCKWAVE_CREATOR((message, level) -> {
for (int i = 0; i < 360; i += 2) { for (var i = 0; i < 360; i += 2) {
double rad = Math.toRadians(i); var rad = Math.toRadians(i);
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX, message.posY + 0.01F, message.posZ, message.posX, message.posY + 0.01F, message.posZ,
(float) Math.sin(rad) * 0.65F, (float) Math.sin(rad) * 0.65F,
@ -222,359 +219,359 @@ public class PacketParticles {
} }
}), }),
OAK_GENERATOR((message, level) -> { OAK_GENERATOR((message, level) -> {
int sapX = message.data[0]; var sapX = message.data[0];
int sapY = message.data[1]; var sapY = message.data[1];
int sapZ = message.data[2]; var sapZ = message.data[2];
boolean releaseAura = message.data[3] > 0; var releaseAura = message.data[3] > 0;
for (int i = level.rand.nextInt(20) + 10; i >= 0; i--) for (var i = level.random.nextInt(20) + 10; i >= 0; i--)
NaturesAuraAPI.instance().spawnParticleStream( NaturesAuraAPI.instance().spawnParticleStream(
sapX + 0.5F + (float) level.rand.nextGaussian() * 3F, sapX + 0.5F + (float) level.random.nextGaussian() * 3F,
sapY + 0.5F + level.rand.nextFloat() * 4F, sapY + 0.5F + level.random.nextFloat() * 4F,
sapZ + 0.5F + (float) level.rand.nextGaussian() * 3F, sapZ + 0.5F + (float) level.random.nextGaussian() * 3F,
message.posX + 0.5F, message.posX + 0.5F,
message.posY + 0.5F, message.posY + 0.5F,
message.posZ + 0.5F, message.posZ + 0.5F,
0.6F, BiomeColors.getGrassColor(level, new BlockPos(sapX, sapY, sapZ)), 1.5F); 0.6F, BiomeColors.getAverageGrassColor(level, new BlockPos(sapX, sapY, sapZ)), 1.5F);
if (releaseAura) if (releaseAura)
for (int i = level.rand.nextInt(10) + 10; i >= 0; i--) for (var i = level.random.nextInt(10) + 10; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + 0.25F + level.rand.nextFloat() * 0.5F, message.posX + 0.25F + level.random.nextFloat() * 0.5F,
message.posY + 1.01F, message.posY + 1.01F,
message.posZ + 0.25F + level.rand.nextFloat() * 0.5F, message.posZ + 0.25F + level.random.nextFloat() * 0.5F,
level.rand.nextGaussian() * 0.03F, level.random.nextGaussian() * 0.03F,
level.rand.nextFloat() * 0.04F + 0.04F, level.random.nextFloat() * 0.04F + 0.04F,
level.rand.nextGaussian() * 0.03F, level.random.nextGaussian() * 0.03F,
0x5ccc30, 1F + level.rand.nextFloat() * 1.5F, 60, 0F, false, true); 0x5ccc30, 1F + level.random.nextFloat() * 1.5F, 60, 0F, false, true);
}), }),
OFFERING_TABLE((message, level) -> { OFFERING_TABLE((message, level) -> {
int genX = message.data[0]; var genX = message.data[0];
int genY = message.data[1]; var genY = message.data[1];
int genZ = message.data[2]; var genZ = message.data[2];
for (int i = level.rand.nextInt(20) + 10; i >= 0; i--) for (var i = level.random.nextInt(20) + 10; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX, message.posY + 0.5F, message.posZ, message.posX, message.posY + 0.5F, message.posZ,
level.rand.nextGaussian() * 0.02F, level.random.nextGaussian() * 0.02F,
level.rand.nextFloat() * 0.25F, level.random.nextFloat() * 0.25F,
level.rand.nextGaussian() * 0.02F, level.random.nextGaussian() * 0.02F,
0xffadfd, 1.5F, 40, 0F, false, true); 0xffadfd, 1.5F, 40, 0F, false, true);
for (int i = level.rand.nextInt(50) + 30; i >= 0; i--) for (var i = level.random.nextInt(50) + 30; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
genX + 0.5F + level.rand.nextGaussian() * 2.5F, genX + 0.5F + level.random.nextGaussian() * 2.5F,
genY + 0.1F, genY + 0.1F,
genZ + 0.5F + level.rand.nextGaussian() * 2.5F, genZ + 0.5F + level.random.nextGaussian() * 2.5F,
level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F,
level.rand.nextFloat() * 0.01F, level.random.nextFloat() * 0.01F,
level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F,
0xd3e4ff, 1.5F, 150, 0F, false, true); 0xd3e4ff, 1.5F, 150, 0F, false, true);
}), }),
PICKUP_STOPPER((message, level) -> { PICKUP_STOPPER((message, level) -> {
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX, message.posY + 0.4F, message.posZ, message.posX, message.posY + 0.4F, message.posZ,
level.rand.nextGaussian() * 0.005F, level.random.nextGaussian() * 0.005F,
level.rand.nextFloat() * 0.005F, level.random.nextFloat() * 0.005F,
level.rand.nextGaussian() * 0.005F, level.random.nextGaussian() * 0.005F,
0xcc3116, 1.5F, 40, 0F, false, true); 0xcc3116, 1.5F, 40, 0F, false, true);
}), }),
SPAWN_LAMP((message, level) -> { SPAWN_LAMP((message, level) -> {
for (int i = level.rand.nextInt(5) + 5; i >= 0; i--) for (var i = level.random.nextInt(5) + 5; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + 0.3F + level.rand.nextFloat() * 0.4F, message.posX + 0.3F + level.random.nextFloat() * 0.4F,
message.posY + 0.15F + level.rand.nextFloat() * 0.5F, message.posY + 0.15F + level.random.nextFloat() * 0.5F,
message.posZ + 0.3F + level.rand.nextFloat() * 0.4F, message.posZ + 0.3F + level.random.nextFloat() * 0.4F,
0F, 0F, 0F, 0F, 0F, 0F,
0xf4a142, 1F, 30, 0F, false, true); 0xf4a142, 1F, 30, 0F, false, true);
}), }),
ANIMAL_GEN_CREATE((message, level) -> { ANIMAL_GEN_CREATE((message, level) -> {
for (int i = level.rand.nextInt(5) + 5; i >= 0; i--) for (var i = level.random.nextInt(5) + 5; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + 0.25F + level.rand.nextFloat() * 0.5F, message.posX + 0.25F + level.random.nextFloat() * 0.5F,
message.posY + 1.01F, message.posY + 1.01F,
message.posZ + 0.25F + level.rand.nextFloat() * 0.5F, message.posZ + 0.25F + level.random.nextFloat() * 0.5F,
level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F,
level.rand.nextFloat() * 0.04F + 0.02F, level.random.nextFloat() * 0.04F + 0.02F,
level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F,
0xd13308, 1F + level.rand.nextFloat() * 1.5F, 40, 0F, false, true); 0xd13308, 1F + level.random.nextFloat() * 1.5F, 40, 0F, false, true);
}), }),
ANIMAL_GEN_CONSUME((message, level) -> { ANIMAL_GEN_CONSUME((message, level) -> {
boolean child = message.data[0] > 0; var child = message.data[0] > 0;
float height = message.data[1] / 10F; var height = message.data[1] / 10F;
int genX = message.data[2]; var genX = message.data[2];
int genY = message.data[3]; var genY = message.data[3];
int genZ = message.data[4]; var genZ = message.data[4];
for (int i = child ? level.rand.nextInt(10) + 10 : level.rand.nextInt(20) + 20; i >= 0; i--) for (var i = child ? level.random.nextInt(10) + 10 : level.random.nextInt(20) + 20; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + level.rand.nextGaussian() * 0.25F, message.posX + level.random.nextGaussian() * 0.25F,
message.posY + height * 0.75F + level.rand.nextGaussian() * 0.25F, message.posY + height * 0.75F + level.random.nextGaussian() * 0.25F,
message.posZ + level.rand.nextGaussian() * 0.25F, message.posZ + level.random.nextGaussian() * 0.25F,
level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F,
level.rand.nextFloat() * 0.01F, level.random.nextFloat() * 0.01F,
level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F,
0x42f4c8, level.rand.nextFloat() * (child ? 0.5F : 2F) + 1F, level.rand.nextInt(30) + 40, 0F, true, true); 0x42f4c8, level.random.nextFloat() * (child ? 0.5F : 2F) + 1F, level.random.nextInt(30) + 40, 0F, true, true);
NaturesAuraAPI.instance().spawnParticleStream( NaturesAuraAPI.instance().spawnParticleStream(
message.posX, message.posY + height * 0.75F, message.posZ, message.posX, message.posY + height * 0.75F, message.posZ,
genX + 0.5F, genY + 0.5F, genZ + 0.5F, genX + 0.5F, genY + 0.5F, genZ + 0.5F,
0.15F, 0x41c4f4, child ? 1.5F : 3F); 0.15F, 0x41c4f4, child ? 1.5F : 3F);
}), }),
END_FLOWER_DECAY((message, level) -> { END_FLOWER_DECAY((message, level) -> {
int color = message.data[0]; var color = message.data[0];
for (int i = level.rand.nextInt(10) + 20; i >= 0; i--) for (var i = level.random.nextInt(10) + 20; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + level.rand.nextFloat(), message.posX + level.random.nextFloat(),
message.posY + level.rand.nextFloat(), message.posY + level.random.nextFloat(),
message.posZ + level.rand.nextFloat(), message.posZ + level.random.nextFloat(),
level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F,
level.rand.nextFloat() * 0.01F, level.random.nextFloat() * 0.01F,
level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F,
color, 1.5F, 80, 0F, true, true); color, 1.5F, 80, 0F, true, true);
}), }),
ANIMAL_SPAWNER((message, level) -> { ANIMAL_SPAWNER((message, level) -> {
for (int i = level.rand.nextInt(20) + 10; i >= 0; i--) for (var i = level.random.nextInt(20) + 10; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX, message.posY + 0.5F, message.posZ, message.posX, message.posY + 0.5F, message.posZ,
level.rand.nextGaussian() * 0.02F, level.random.nextGaussian() * 0.02F,
level.rand.nextFloat() * 0.02F, level.random.nextFloat() * 0.02F,
level.rand.nextGaussian() * 0.02F, level.random.nextGaussian() * 0.02F,
0x16b7b2, 1.5F, 40, 0F, false, true); 0x16b7b2, 1.5F, 40, 0F, false, true);
}), }),
RF_CONVERTER((message, level) -> { RF_CONVERTER((message, level) -> {
for (int i = level.rand.nextInt(5) + 2; i >= 0; i--) for (var i = level.random.nextInt(5) + 2; i >= 0; i--)
Multiblocks.RF_CONVERTER.forEach(new BlockPos(message.posX, message.posY, message.posZ), 'R', (blockPos, matcher) -> { Multiblocks.RF_CONVERTER.forEach(new BlockPos(message.posX, message.posY, message.posZ), 'R', (blockPos, matcher) -> {
if (level.rand.nextFloat() < 0.35F) { if (level.random.nextFloat() < 0.35F) {
NaturesAuraAPI.instance().spawnParticleStream( NaturesAuraAPI.instance().spawnParticleStream(
blockPos.getX() + level.rand.nextFloat(), blockPos.getX() + level.random.nextFloat(),
blockPos.getY() + level.rand.nextFloat(), blockPos.getY() + level.random.nextFloat(),
blockPos.getZ() + level.rand.nextFloat(), blockPos.getZ() + level.random.nextFloat(),
message.posX + level.rand.nextFloat(), message.posX + level.random.nextFloat(),
message.posY + level.rand.nextFloat(), message.posY + level.random.nextFloat(),
message.posZ + level.rand.nextFloat(), message.posZ + level.random.nextFloat(),
0.05F, 0xff1a05, 1.5F); 0.05F, 0xff1a05, 1.5F);
} }
return true; return true;
}); });
}), }),
END_FLOWER_CONSUME((message, level) -> { END_FLOWER_CONSUME((message, level) -> {
int color = message.data[0]; var color = message.data[0];
for (int i = level.rand.nextInt(20) + 10; i >= 0; i--) for (var i = level.random.nextInt(20) + 10; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX, message.posY + 0.5F, message.posZ, message.posX, message.posY + 0.5F, message.posZ,
level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F,
level.rand.nextFloat() * 0.01F, level.random.nextFloat() * 0.01F,
level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F,
color, 1.5F, 40, 0F, false, true); color, 1.5F, 40, 0F, false, true);
}), }),
MOVER_CART((message, level) -> { MOVER_CART((message, level) -> {
float motionX = message.data[0] / 100F; var motionX = message.data[0] / 100F;
float motionY = message.data[1] / 100F; var motionY = message.data[1] / 100F;
float motionZ = message.data[2] / 100F; var motionZ = message.data[2] / 100F;
for (int i = level.rand.nextInt(60) + 30; i >= 0; i--) for (var i = level.random.nextInt(60) + 30; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + level.rand.nextGaussian() * 10F, message.posX + level.random.nextGaussian() * 10F,
message.posY + level.rand.nextGaussian() * 10F, message.posY + level.random.nextGaussian() * 10F,
message.posZ + level.rand.nextGaussian() * 10F, message.posZ + level.random.nextGaussian() * 10F,
motionX * 0.2F, motionY * 0.2F, motionZ * 0.2F, motionX * 0.2F, motionY * 0.2F, motionZ * 0.2F,
IAuraType.forLevel(level).getColor(), 2F, 30, 0F, false, true); IAuraType.forLevel(level).getColor(), 2F, 30, 0F, false, true);
}), }),
MOSS_GENERATOR((message, level) -> { MOSS_GENERATOR((message, level) -> {
for (int i = level.rand.nextInt(30) + 30; i >= 0; i--) { for (var i = level.random.nextInt(30) + 30; i >= 0; i--) {
int side = level.rand.nextInt(3); var side = level.random.nextInt(3);
float x = side != 0 ? level.rand.nextFloat() : level.rand.nextBoolean() ? 1.1F : -0.1F; var x = side != 0 ? level.random.nextFloat() : level.random.nextBoolean() ? 1.1F : -0.1F;
float y = side != 1 ? level.rand.nextFloat() : level.rand.nextBoolean() ? 1.1F : -0.1F; var y = side != 1 ? level.random.nextFloat() : level.random.nextBoolean() ? 1.1F : -0.1F;
float z = side != 2 ? level.rand.nextFloat() : level.rand.nextBoolean() ? 1.1F : -0.1F; var z = side != 2 ? level.random.nextFloat() : level.random.nextBoolean() ? 1.1F : -0.1F;
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + x, message.posX + x,
message.posY + y, message.posY + y,
message.posZ + z, message.posZ + z,
0F, 0F, 0F, 0F, 0F, 0F,
0x184c0d, level.rand.nextFloat() + 1F, 30, 0F, true, true); 0x184c0d, level.random.nextFloat() + 1F, 30, 0F, true, true);
} }
for (int i = level.rand.nextInt(20) + 10; i >= 0; i--) for (var i = level.random.nextInt(20) + 10; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + level.rand.nextFloat(), message.posX + level.random.nextFloat(),
message.posY + 1F, message.posY + 1F,
message.posZ + level.rand.nextFloat(), message.posZ + level.random.nextFloat(),
level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F,
level.rand.nextFloat() * 0.04F + 0.02F, level.random.nextFloat() * 0.04F + 0.02F,
level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F,
0x5ccc30, 1F + level.rand.nextFloat() * 1.5F, 40, 0F, true, true); 0x5ccc30, 1F + level.random.nextFloat() * 1.5F, 40, 0F, true, true);
}), }),
FIREWORK_GEN((message, level) -> { FIREWORK_GEN((message, level) -> {
int goalX = message.data[0]; var goalX = message.data[0];
int goalY = message.data[1]; var goalY = message.data[1];
int goalZ = message.data[2]; var goalZ = message.data[2];
NaturesAuraAPI.instance().setParticleSpawnRange(64); NaturesAuraAPI.instance().setParticleSpawnRange(64);
for (int i = level.rand.nextInt(30) + 30; i >= 0; i--) for (var i = level.random.nextInt(30) + 30; i >= 0; i--)
NaturesAuraAPI.instance().spawnParticleStream( NaturesAuraAPI.instance().spawnParticleStream(
message.posX + (float) level.rand.nextGaussian(), message.posX + (float) level.random.nextGaussian(),
message.posY + (float) level.rand.nextGaussian(), message.posY + (float) level.random.nextGaussian(),
message.posZ + (float) level.rand.nextGaussian(), message.posZ + (float) level.random.nextGaussian(),
goalX + 0.25F + level.rand.nextFloat() * 0.5F, goalX + 0.25F + level.random.nextFloat() * 0.5F,
goalY + 0.25F + level.rand.nextFloat() * 0.5F, goalY + 0.25F + level.random.nextFloat() * 0.5F,
goalZ + 0.25F + level.rand.nextFloat() * 0.5F, goalZ + 0.25F + level.random.nextFloat() * 0.5F,
0.65F, message.data[3 + level.rand.nextInt(message.data.length - 3)], 1F); 0.65F, message.data[3 + level.random.nextInt(message.data.length - 3)], 1F);
NaturesAuraAPI.instance().setParticleSpawnRange(32); NaturesAuraAPI.instance().setParticleSpawnRange(32);
}), }),
DIMENSION_RAIL((message, level) -> { DIMENSION_RAIL((message, level) -> {
float width = message.data[0] / 100F; var width = message.data[0] / 100F;
float height = message.data[1] / 100F; var height = message.data[1] / 100F;
float depth = message.data[2] / 100F; var depth = message.data[2] / 100F;
for (int i = level.rand.nextInt(100) + 50; i >= 0; i--) for (var i = level.random.nextInt(100) + 50; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + level.rand.nextFloat() * width, message.posX + level.random.nextFloat() * width,
message.posY + level.rand.nextFloat() * height, message.posY + level.random.nextFloat() * height,
message.posZ + level.rand.nextFloat() * depth, message.posZ + level.random.nextFloat() * depth,
0F, 0F, 0F, 0xd60cff, 1F + level.rand.nextFloat(), 60, 0F, false, true); 0F, 0F, 0F, 0xd60cff, 1F + level.random.nextFloat(), 60, 0F, false, true);
}), }),
PROJECTILE_GEN((message, level) -> { PROJECTILE_GEN((message, level) -> {
int x = message.data[0]; var x = message.data[0];
int y = message.data[1]; var y = message.data[1];
int z = message.data[2]; var z = message.data[2];
for (int i = level.rand.nextInt(10) + 5; i >= 0; i--) for (var i = level.random.nextInt(10) + 5; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
x + 0.25F + level.rand.nextFloat() * 0.5F, x + 0.25F + level.random.nextFloat() * 0.5F,
y + 1.01F, y + 1.01F,
z + 0.25F + level.rand.nextFloat() * 0.5F, z + 0.25F + level.random.nextFloat() * 0.5F,
level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F,
level.rand.nextFloat() * 0.04F + 0.02F, level.random.nextFloat() * 0.04F + 0.02F,
level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F,
0x5ccc30, 1F + level.rand.nextFloat() * 1.5F, 40, 0F, false, true); 0x5ccc30, 1F + level.random.nextFloat() * 1.5F, 40, 0F, false, true);
for (int i = level.rand.nextInt(10) + 10; i >= 0; i--) for (var i = level.random.nextInt(10) + 10; i >= 0; i--)
level.addParticle(ParticleTypes.FIREWORK, level.addParticle(ParticleTypes.FIREWORK,
message.posX, message.posY, message.posZ, message.posX, message.posY, message.posZ,
level.rand.nextGaussian() * 0.03F, level.random.nextGaussian() * 0.03F,
level.rand.nextGaussian() * 0.03F, level.random.nextGaussian() * 0.03F,
level.rand.nextGaussian() * 0.03F); level.random.nextGaussian() * 0.03F);
}), }),
BLAST_FURNACE_BOOSTER((message, level) -> { BLAST_FURNACE_BOOSTER((message, level) -> {
boolean worked = message.data[0] > 0; var worked = message.data[0] > 0;
for (int i = level.rand.nextInt(10) + 5; i >= 0; i--) for (var i = level.random.nextInt(10) + 5; i >= 0; i--)
level.addParticle(ParticleTypes.CAMPFIRE_COSY_SMOKE, level.addParticle(ParticleTypes.CAMPFIRE_COSY_SMOKE,
message.posX + 5 / 16F + level.rand.nextInt(6) / 16F, message.posX + 5 / 16F + level.random.nextInt(6) / 16F,
message.posY + 0.6F, message.posY + 0.6F,
message.posZ + 5 / 16F + level.rand.nextInt(6) / 16F, message.posZ + 5 / 16F + level.random.nextInt(6) / 16F,
level.rand.nextGaussian() * 0.005F, level.random.nextGaussian() * 0.005F,
level.rand.nextFloat() * 0.02F + 0.01F, level.random.nextFloat() * 0.02F + 0.01F,
level.rand.nextGaussian() * 0.005F); level.random.nextGaussian() * 0.005F);
if (worked) { if (worked) {
BlockPos pos = new BlockPos(message.posX, message.posY, message.posZ); var pos = new BlockPos(message.posX, message.posY, message.posZ);
int color = IAuraChunk.getAuraChunk(level, pos).getType().getColor(); var color = IAuraChunk.getAuraChunk(level, pos).getType().getColor();
for (int i = level.rand.nextInt(10) + 10; i >= 0; i--) for (var i = level.random.nextInt(10) + 10; i >= 0; i--)
NaturesAuraAPI.instance().spawnParticleStream( NaturesAuraAPI.instance().spawnParticleStream(
message.posX + (float) level.rand.nextGaussian() * 5, message.posX + (float) level.random.nextGaussian() * 5,
message.posY + level.rand.nextFloat() * 5, message.posY + level.random.nextFloat() * 5,
message.posZ + (float) level.rand.nextGaussian() * 5, message.posZ + (float) level.random.nextGaussian() * 5,
message.posX + 0.5F, message.posY + 0.5F, message.posZ + 0.5F, message.posX + 0.5F, message.posY + 0.5F, message.posZ + 0.5F,
0.25F, color, 0.5F + level.rand.nextFloat() 0.25F, color, 0.5F + level.random.nextFloat()
); );
} }
}), }),
ANIMAL_CONTAINER((message, level) -> { ANIMAL_CONTAINER((message, level) -> {
for (int i = level.rand.nextInt(2) + 1; i > 0; i--) for (var i = level.random.nextInt(2) + 1; i > 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + level.rand.nextGaussian() * 0.15F, message.posX + level.random.nextGaussian() * 0.15F,
message.posY - level.rand.nextFloat() * 0.5F, message.posY - level.random.nextFloat() * 0.5F,
message.posZ + level.rand.nextGaussian() * 0.15F, message.posZ + level.random.nextGaussian() * 0.15F,
0, 0, 0, 0x42e9f5, 1 + level.rand.nextFloat() * 2, 40, 0, false, true 0, 0, 0, 0x42e9f5, 1 + level.random.nextFloat() * 2, 40, 0, false, true
); );
}), }),
SNOW_CREATOR((message, level) -> { SNOW_CREATOR((message, level) -> {
BlockPos pos = new BlockPos(message.posX, message.posY, message.posZ); var pos = new BlockPos(message.posX, message.posY, message.posZ);
int color = IAuraChunk.getAuraChunk(level, pos).getType().getColor(); var color = IAuraChunk.getAuraChunk(level, pos).getType().getColor();
for (int i = level.rand.nextInt(3) + 1; i > 0; i--) for (var i = level.random.nextInt(3) + 1; i > 0; i--)
NaturesAuraAPI.instance().spawnParticleStream( NaturesAuraAPI.instance().spawnParticleStream(
message.posX + (float) level.rand.nextGaussian() * 5, message.posX + (float) level.random.nextGaussian() * 5,
message.posY + level.rand.nextFloat() * 5, message.posY + level.random.nextFloat() * 5,
message.posZ + (float) level.rand.nextGaussian() * 5, message.posZ + (float) level.random.nextGaussian() * 5,
message.posX + 0.5F, message.posY + 0.5F, message.posZ + 0.5F, message.posX + 0.5F, message.posY + 0.5F, message.posZ + 0.5F,
0.25F, color, 0.5F + level.rand.nextFloat() 0.25F, color, 0.5F + level.random.nextFloat()
); );
}), }),
CHORUS_GENERATOR((message, level) -> { CHORUS_GENERATOR((message, level) -> {
int chorusX = message.data[0]; var chorusX = message.data[0];
int chorusY = message.data[1]; var chorusY = message.data[1];
int chorusZ = message.data[2]; var chorusZ = message.data[2];
for (int i = level.rand.nextInt(5) + 3; i >= 0; i--) for (var i = level.random.nextInt(5) + 3; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
chorusX + level.rand.nextFloat(), chorusY + level.rand.nextFloat(), chorusZ + level.rand.nextFloat(), chorusX + level.random.nextFloat(), chorusY + level.random.nextFloat(), chorusZ + level.random.nextFloat(),
0F, 0F, 0F, 0F, 0F, 0F,
0xbb0be3, 1F + level.rand.nextFloat(), 50, 0F, false, true); 0xbb0be3, 1F + level.random.nextFloat(), 50, 0F, false, true);
for (int i = level.rand.nextInt(5) + 5; i >= 0; i--) for (var i = level.random.nextInt(5) + 5; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + 0.25F + level.rand.nextFloat() * 0.5F, message.posX + 0.25F + level.random.nextFloat() * 0.5F,
message.posY + 1.01F, message.posY + 1.01F,
message.posZ + 0.25F + level.rand.nextFloat() * 0.5F, message.posZ + 0.25F + level.random.nextFloat() * 0.5F,
level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F,
level.rand.nextFloat() * 0.04F + 0.02F, level.random.nextFloat() * 0.04F + 0.02F,
level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F,
IAuraType.forLevel(level).getColor(), 1F + level.rand.nextFloat() * 1.5F, 40, 0F, false, true); IAuraType.forLevel(level).getColor(), 1F + level.random.nextFloat() * 1.5F, 40, 0F, false, true);
}), }),
TIMER_RESET((message, level) -> { TIMER_RESET((message, level) -> {
int color = message.data[0]; var color = message.data[0];
for (int i = level.rand.nextInt(10) + 15; i >= 0; i--) for (var i = level.random.nextInt(10) + 15; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + 5 / 16F + level.rand.nextFloat() * 6 / 16F, message.posX + 5 / 16F + level.random.nextFloat() * 6 / 16F,
message.posY + 2 / 16F + level.rand.nextFloat() * 8 / 16F, message.posY + 2 / 16F + level.random.nextFloat() * 8 / 16F,
message.posZ + 5 / 16F + level.rand.nextFloat() * 6 / 16F, message.posZ + 5 / 16F + level.random.nextFloat() * 6 / 16F,
0, 0, 0, color, 2, 40 + level.rand.nextInt(20), 0, false, true); 0, 0, 0, color, 2, 40 + level.random.nextInt(20), 0, false, true);
}), }),
STRUCTURE_FINDER((message, level) -> { STRUCTURE_FINDER((message, level) -> {
EntityStructureFinder entity = (EntityStructureFinder) level.getEntityByID(message.data[0]); var entity = (EntityStructureFinder) level.getEntity(message.data[0]);
LevelRenderer renderer = Minecraft.getInstance().levelRenderer; var renderer = Minecraft.getInstance().levelRenderer;
double d0 = message.posX + 0.5D; var d0 = message.posX + 0.5D;
double d13 = message.posY; double d13 = message.posY;
double d18 = message.posZ + 0.5D; var d18 = message.posZ + 0.5D;
for (int j2 = 0; j2 < 8; ++j2) for (var j2 = 0; j2 < 8; ++j2)
renderer.addParticle(new ItemParticleData(ParticleTypes.ITEM, entity.getItem()), false, d0, d13, d18, level.rand.nextGaussian() * 0.15D, level.rand.nextDouble() * 0.2D, level.rand.nextGaussian() * 0.15D); renderer.addParticle(new ItemParticleOption(ParticleTypes.ITEM, entity.getItem()), false, d0, d13, d18, level.random.nextGaussian() * 0.15D, level.random.nextDouble() * 0.2D, level.random.nextGaussian() * 0.15D);
int color = entity.getDataManager().get(EntityStructureFinder.COLOR); int color = entity.getEntityData().get(EntityStructureFinder.COLOR);
for (double d24 = 0.0D; d24 < (Math.PI * 2D); d24 += 0.15707963267948966D) { for (var d24 = 0.0D; d24 < (Math.PI * 2D); d24 += 0.15707963267948966D) {
NaturesAuraAPI.instance().spawnMagicParticle(d0 + Math.cos(d24) * 5.0D, d13 - 0.4D, d18 + Math.sin(d24) * 5.0D, Math.cos(d24) * -2, 0.0D, Math.sin(d24) * -2, color, 2, 60, 0, false, true); NaturesAuraAPI.instance().spawnMagicParticle(d0 + Math.cos(d24) * 5.0D, d13 - 0.4D, d18 + Math.sin(d24) * 5.0D, Math.cos(d24) * -2, 0.0D, Math.sin(d24) * -2, color, 2, 60, 0, false, true);
NaturesAuraAPI.instance().spawnMagicParticle(d0 + Math.cos(d24) * 5.0D, d13 - 0.4D, d18 + Math.sin(d24) * 5.0D, Math.cos(d24) * -2.5, 0.0D, Math.sin(d24) * -2.5, color, 2, 60, 0, false, true); NaturesAuraAPI.instance().spawnMagicParticle(d0 + Math.cos(d24) * 5.0D, d13 - 0.4D, d18 + Math.sin(d24) * 5.0D, Math.cos(d24) * -2.5, 0.0D, Math.sin(d24) * -2.5, color, 2, 60, 0, false, true);
} }
}), }),
SLIME_SPLIT_GEN_CREATE((message, level) -> { SLIME_SPLIT_GEN_CREATE((message, level) -> {
for (int i = level.rand.nextInt(5) + 5; i >= 0; i--) for (var i = level.random.nextInt(5) + 5; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + 0.25F + level.rand.nextFloat() * 0.5F, message.posX + 0.25F + level.random.nextFloat() * 0.5F,
message.posY + 1.01F, message.posY + 1.01F,
message.posZ + 0.25F + level.rand.nextFloat() * 0.5F, message.posZ + 0.25F + level.random.nextFloat() * 0.5F,
level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F,
level.rand.nextFloat() * 0.04F + 0.02F, level.random.nextFloat() * 0.04F + 0.02F,
level.rand.nextGaussian() * 0.01F, level.random.nextGaussian() * 0.01F,
message.data[0], 1F + level.rand.nextFloat() * 1.5F, 40, 0F, false, true); message.data[0], 1F + level.random.nextFloat() * 1.5F, 40, 0F, false, true);
}), }),
SLIME_SPLIT_GEN_START((message, level) -> { SLIME_SPLIT_GEN_START((message, level) -> {
int x = message.data[0]; var x = message.data[0];
int y = message.data[1]; var y = message.data[1];
int z = message.data[2]; var z = message.data[2];
int color = message.data[3]; var color = message.data[3];
for (int i = level.rand.nextInt(10) + 5; i >= 0; i--) for (var i = level.random.nextInt(10) + 5; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + (float) level.rand.nextGaussian() * 0.5F, message.posX + (float) level.random.nextGaussian() * 0.5F,
message.posY + (float) level.rand.nextGaussian() * 0.5F, message.posY + (float) level.random.nextGaussian() * 0.5F,
message.posZ + (float) level.rand.nextGaussian() * 0.5F, message.posZ + (float) level.random.nextGaussian() * 0.5F,
level.rand.nextGaussian() * 0.02F, level.random.nextGaussian() * 0.02F,
level.rand.nextFloat() * 0.04F + 0.02F, level.random.nextFloat() * 0.04F + 0.02F,
level.rand.nextGaussian() * 0.02F, level.random.nextGaussian() * 0.02F,
color, level.rand.nextFloat() + 1, level.rand.nextInt(20) + 20, 0, false, true); color, level.random.nextFloat() + 1, level.random.nextInt(20) + 20, 0, false, true);
for (int i = level.rand.nextInt(10) + 5; i >= 0; i--) for (var i = level.random.nextInt(10) + 5; i >= 0; i--)
NaturesAuraAPI.instance().spawnParticleStream( NaturesAuraAPI.instance().spawnParticleStream(
message.posX + (float) level.rand.nextGaussian() * 0.5F, message.posX + (float) level.random.nextGaussian() * 0.5F,
message.posY + (float) level.rand.nextGaussian() * 0.5F, message.posY + (float) level.random.nextGaussian() * 0.5F,
message.posZ + (float) level.rand.nextGaussian() * 0.5F, message.posZ + (float) level.random.nextGaussian() * 0.5F,
x + 0.5F, y + 0.5F, z + 0.5F, 0.2F, color, level.rand.nextFloat() + 1); x + 0.5F, y + 0.5F, z + 0.5F, 0.2F, color, level.random.nextFloat() + 1);
}), }),
PET_REVIVER((message, level) -> { PET_REVIVER((message, level) -> {
for (int i = level.rand.nextInt(50) + 150; i >= 0; i--) for (var i = level.random.nextInt(50) + 150; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
message.posX + (float) level.rand.nextGaussian() * 0.4F, message.posX + (float) level.random.nextGaussian() * 0.4F,
message.posY + (float) level.rand.nextGaussian() * 0.4F, message.posY + (float) level.random.nextGaussian() * 0.4F,
message.posZ + (float) level.rand.nextGaussian() * 0.4F, message.posZ + (float) level.random.nextGaussian() * 0.4F,
level.rand.nextGaussian() * 0.002F, level.random.nextGaussian() * 0.002F,
level.rand.nextFloat() * 0.001F + 0.002F, level.random.nextFloat() * 0.001F + 0.002F,
level.rand.nextGaussian() * 0.002F, level.random.nextGaussian() * 0.002F,
message.data[0], level.rand.nextFloat() * 2 + 1, level.rand.nextInt(50) + 50, 0, false, true); message.data[0], level.random.nextFloat() * 2 + 1, level.random.nextInt(50) + 50, 0, false, true);
}); });
public final BiConsumer<PacketParticles, Level> action; public final BiConsumer<PacketParticles, Level> action;

View file

@ -17,7 +17,6 @@ import net.minecraft.client.color.item.ItemColor;
import net.minecraft.client.color.item.ItemColors; import net.minecraft.client.color.item.ItemColors;
import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.client.gui.screens.MenuScreens;
import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.EntityRenderers; import net.minecraft.client.renderer.entity.EntityRenderers;
@ -84,12 +83,6 @@ public class ClientProxy implements IProxy {
Minecraft.getInstance().getBlockColors().register(block.getBlockColor(), (Block) block); Minecraft.getInstance().getBlockColors().register(block.getBlockColor(), (Block) block);
} }
@Override
public void registerTESR(ITESRProvider<?> provider) {
var tesr = provider.getTESR();
BlockEntityRenderers.register(tesr.getA(), tesr.getB().get());
}
@Override @Override
public void spawnMagicParticle(double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade) { public void spawnMagicParticle(double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade) {
ParticleHandler.spawnParticle(() -> new ParticleMagic(Minecraft.getInstance().level, ParticleHandler.spawnParticle(() -> new ParticleMagic(Minecraft.getInstance().level,

View file

@ -2,7 +2,6 @@ package de.ellpeck.naturesaura.proxy;
import de.ellpeck.naturesaura.reg.IColorProvidingBlock; import de.ellpeck.naturesaura.reg.IColorProvidingBlock;
import de.ellpeck.naturesaura.reg.IColorProvidingItem; import de.ellpeck.naturesaura.reg.IColorProvidingItem;
import de.ellpeck.naturesaura.reg.ITESRProvider;
import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
@ -22,8 +21,6 @@ public interface IProxy {
void addColorProvidingBlock(IColorProvidingBlock block); void addColorProvidingBlock(IColorProvidingBlock block);
void registerTESR(ITESRProvider<?> provider);
void spawnMagicParticle(double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade); void spawnMagicParticle(double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade);
void setParticleDepth(boolean depth); void setParticleDepth(boolean depth);

View file

@ -2,7 +2,6 @@ package de.ellpeck.naturesaura.proxy;
import de.ellpeck.naturesaura.reg.IColorProvidingBlock; import de.ellpeck.naturesaura.reg.IColorProvidingBlock;
import de.ellpeck.naturesaura.reg.IColorProvidingItem; import de.ellpeck.naturesaura.reg.IColorProvidingItem;
import de.ellpeck.naturesaura.reg.ITESRProvider;
import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
@ -37,11 +36,6 @@ public class ServerProxy implements IProxy {
} }
@Override
public void registerTESR(ITESRProvider<?> provider) {
}
@Override @Override
public void spawnMagicParticle(double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade) { public void spawnMagicParticle(double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade) {

View file

@ -1,16 +1,11 @@
package de.ellpeck.naturesaura.reg; package de.ellpeck.naturesaura.reg;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.util.Tuple;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
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.function.Supplier;
public interface ITESRProvider<T extends BlockEntity> { public interface ITESRProvider<T extends BlockEntity> {
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
Tuple<BlockEntityType<? extends T>, Supplier<BlockEntityRendererProvider<T>>> getTESR(); void registerTESR();
} }

View file

@ -334,7 +334,7 @@ public final class ModRegistry {
if (item instanceof IColorProvidingItem) if (item instanceof IColorProvidingItem)
NaturesAura.proxy.addColorProvidingItem((IColorProvidingItem) item); NaturesAura.proxy.addColorProvidingItem((IColorProvidingItem) item);
if (item instanceof ITESRProvider provider) if (item instanceof ITESRProvider provider)
NaturesAura.proxy.registerTESR(provider); provider.registerTESR();
} }
// register features again for some reason // register features again for some reason

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