Compare commits

..

10 commits

11 changed files with 42 additions and 34 deletions

View file

@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
version = '37.5'
version = '37.6'
group = 'de.ellpeck.naturesaura' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'NaturesAura'

View file

@ -321,4 +321,16 @@ public final class Helper {
}
return ItemStack.EMPTY;
}
public static BlockPos getClosestAirAboveGround(Level level, BlockPos pos, int radius) {
for (var i = 0; i < radius; i++) {
var up = pos.above(i);
if (level.isEmptyBlock(up) && !level.isEmptyBlock(up.below()))
return up;
var dn = pos.below(i);
if (level.isEmptyBlock(dn) && !level.isEmptyBlock(dn.below()))
return dn;
}
return pos;
}
}

View file

@ -18,7 +18,6 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.BaseEntityBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
@ -127,19 +126,11 @@ public class BlockContainerImpl extends BaseEntityBlock implements IModItem {
}
@Override
public void onPlace(BlockState state, Level levelIn, BlockPos pos, BlockState newState, boolean isMoving) {
if (state.getBlock() != newState.getBlock()) {
var tile = levelIn.getBlockEntity(pos);
if (tile instanceof BlockEntityImpl)
((BlockEntityImpl) tile).dropInventory();
}
super.onPlace(state, levelIn, pos, newState, isMoving);
}
@Override
public void playerDestroy(Level levelIn, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity te, ItemStack stack) {
super.playerDestroy(levelIn, player, pos, state, te, stack);
levelIn.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState());
public void playerWillDestroy(Level p_49852_, BlockPos p_49853_, BlockState p_49854_, Player p_49855_) {
var tile = p_49852_.getBlockEntity(p_49853_);
if (tile instanceof BlockEntityImpl impl)
impl.dropInventory();
super.playerWillDestroy(p_49852_, p_49853_, p_49854_, p_49855_);
}
@Override

View file

@ -48,7 +48,7 @@ public class BlockEntityMossGenerator extends BlockEntityImpl implements ITickab
var state = this.level.getBlockState(offset);
var result = NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.inverse().get(state);
var toAdd = 7000;
var toAdd = 4000;
if (this.canGenerateRightNow(toAdd)) {
this.generateAura(toAdd);
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,

View file

@ -1,5 +1,6 @@
package de.ellpeck.naturesaura.chunk.effect;
import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
@ -16,9 +17,11 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BonemealableBlock;
import net.minecraft.world.level.block.DoublePlantBlock;
import net.minecraft.world.level.block.TallGrassBlock;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.levelgen.Heightmap;
public class PlantBoostEffect implements IDrainSpotEffect {
@ -34,7 +37,7 @@ public class PlantBoostEffect implements IDrainSpotEffect {
int aura = auraAndSpots.getLeft();
if (aura < 1500000)
return false;
this.amount = Math.min(45, Mth.ceil(Math.abs(aura) / 100000F / auraAndSpots.getRight()));
this.amount = Math.min(75, Mth.ceil(Math.abs(aura) / 50000F / auraAndSpots.getRight()));
if (this.amount <= 1)
return false;
this.dist = Mth.clamp(Math.abs(aura) / 150000, 5, 35);
@ -63,15 +66,16 @@ public class PlantBoostEffect implements IDrainSpotEffect {
return;
for (var i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) {
var x = Mth.floor(pos.getX() + (2 * level.random.nextFloat() - 1) * this.dist);
var y = Mth.floor(pos.getY() + (2 * level.random.nextFloat() - 1) * this.dist / 2);
var z = Mth.floor(pos.getZ() + (2 * level.random.nextFloat() - 1) * this.dist);
var plantPos = new BlockPos(x, level.getHeight(Heightmap.Types.WORLD_SURFACE, x, z), z).below();
var plantPos = Helper.getClosestAirAboveGround(level, new BlockPos(x, y, z), this.dist / 2).below();
if (plantPos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(plantPos)) {
if (NaturesAuraAPI.instance().isEffectPowderActive(level, plantPos, PlantBoostEffect.NAME))
continue;
var state = level.getBlockState(plantPos);
var block = state.getBlock();
if (block instanceof BonemealableBlock growable && !(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 && block != Blocks.MOSS_BLOCK) {
if (growable.isValidBonemealTarget(level, plantPos, state, false)) {
try {
growable.performBonemeal((ServerLevel) level, level.random, plantPos, state);

View file

@ -50,7 +50,7 @@ public class EntityLightProjectile extends ThrowableProjectile {
if (state.getMaterial().isReplaceable())
this.level.setBlockAndUpdate(pos, ModBlocks.LIGHT.defaultBlockState());
} else if (result instanceof EntityHitResult entity) {
entity.getEntity().setRemainingFireTicks(5);
entity.getEntity().setSecondsOnFire(5);
}
}
this.discard();

View file

@ -34,7 +34,6 @@ import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BonemealableBlock;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.MyceliumBlock;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ -110,8 +109,9 @@ public class ClientEvents {
var amount = Mth.floor(190 * ModConfig.instance.excessParticleAmount.get());
for (var i = 0; i < amount; i++) {
var x = Mth.floor(mc.player.getX()) + mc.level.random.nextInt(64) - 32;
var y = Mth.floor(mc.player.getY()) + mc.level.random.nextInt(32) - 16;
var z = Mth.floor(mc.player.getZ()) + mc.level.random.nextInt(64) - 32;
var pos = new BlockPos(x, mc.level.getHeight(Heightmap.Types.WORLD_SURFACE, x, z) - 1, z);
var pos = Helper.getClosestAirAboveGround(mc.level, new BlockPos(x, y, z), 16).below();
var state = mc.level.getBlockState(pos);
var block = state.getBlock();
if (block instanceof BonemealableBlock || block instanceof IPlantable || block instanceof LeavesBlock || block instanceof MyceliumBlock) {

View file

@ -21,11 +21,11 @@ import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.event.RegisterCommandsEvent;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.level.ChunkEvent;
import net.minecraftforge.event.level.ChunkWatchEvent;
import net.minecraftforge.event.server.ServerStartingEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
import net.minecraftforge.registries.ForgeRegistries;
@ -138,7 +138,7 @@ public class CommonEvents {
}
@SubscribeEvent
public void onServerStarting(ServerStartingEvent event) {
CommandAura.register(event.getServer().getCommands().getDispatcher());
public void onCommands(RegisterCommandsEvent event) {
CommandAura.register(event.getDispatcher());
}
}

View file

@ -40,6 +40,6 @@ public class GuiEnderCrate extends AbstractContainerScreen<ContainerEnderCrate>
var i = (this.width - this.imageWidth) / 2;
var j = (this.height - this.imageHeight) / 2;
this.blit(matrixStack, i, j, 0, 0, this.imageWidth, 3 * 18 + 17);
this.blit(matrixStack, i, j + 3 * 18 + 17, 0, 126, this.imageHeight, 96);
this.blit(matrixStack, i, j + 3 * 18 + 17, 0, 126, this.imageWidth, 96);
}
}

View file

@ -13,6 +13,7 @@ import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
@ -115,7 +116,9 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu
if (!player.level.isClientSide) {
held.shrink(1);
player.getInventory().add(ItemAuraBottle.setType(new ItemStack(ItemAuraBottle.this), IAuraType.forLevel(player.level)));
var stack = ItemAuraBottle.setType(new ItemStack(ItemAuraBottle.this), IAuraType.forLevel(player.level));
if (!player.addItem(stack))
player.level.addFreshEntity(new ItemEntity(player.level, player.getX(), player.getY(), player.getZ(), stack));
var spot = IAuraChunk.getHighestSpot(player.level, pos, 30, pos);
IAuraChunk.getAuraChunk(player.level, spot).drainAura(spot, 20000);

View file

@ -47,12 +47,10 @@ public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel {
@Override
public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, Player player) {
if (itemstack.getItem() == ModItems.SKY_AXE) {
if (player.level.getBlockState(pos).is(BlockTags.LOGS)) {
if (itemstack.getItem() == ModItems.SKY_AXE && !player.isShiftKeyDown() && player.level.getBlockState(pos).is(BlockTags.LOGS)) {
BlockEntityWoodStand.recurseTreeDestruction(player.level, pos, pos, false, true);
return true;
}
}
return false;
}