diff --git a/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java b/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java index 8c1de715..f1acf670 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java +++ b/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java @@ -1,5 +1,7 @@ package de.ellpeck.naturesaura.api; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; @@ -40,7 +42,7 @@ public final class NaturesAuraAPI { public static final String MOD_ID = "naturesaura"; public static final String API_ID = MOD_ID + "api"; - public static final String VERSION = "7"; + public static final String VERSION = "8"; /** * The list of all {@link AltarRecipe} instances which are the recipes used @@ -72,7 +74,7 @@ public final class NaturesAuraAPI { * into their mossy variations. Contains mossy brick and mossy cobblestone * by default, along with all blocks specified in the config file */ - public static final Map BOTANIST_PICKAXE_CONVERSIONS = new HashMap<>(); + public static final BiMap BOTANIST_PICKAXE_CONVERSIONS = HashBiMap.create(); /** * A map of all {@link IAuraType} instances which are types of Aura present * in different types of worlds. {@link BasicAuraType} instances can be diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockMossGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockMossGenerator.java new file mode 100644 index 00000000..99a64aa2 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockMossGenerator.java @@ -0,0 +1,10 @@ +package de.ellpeck.naturesaura.blocks; + +import de.ellpeck.naturesaura.blocks.tiles.TileEntityMossGenerator; +import net.minecraft.block.material.Material; + +public class BlockMossGenerator extends BlockContainerImpl { + public BlockMossGenerator() { + super(Material.ROCK, "moss_generator", TileEntityMossGenerator.class, "moss_generator"); + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java index b801fa76..59a69afe 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java @@ -46,4 +46,5 @@ public final class ModBlocks { public static final Block AUTO_CRAFTER = new BlockAutoCrafter(); public static final Block GOLD_BRICK = new BlockImpl("gold_brick", Material.ROCK).setSoundType(SoundType.STONE).setHardness(2F); public static final Block RF_CONVERTER = ModConfig.enabledFeatures.rfConverter ? new BlockRFConverter() : null; + public static final Block MOSS_GENERATOR = new BlockMossGenerator(); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityMossGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityMossGenerator.java new file mode 100644 index 00000000..e1d71407 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityMossGenerator.java @@ -0,0 +1,53 @@ +package de.ellpeck.naturesaura.blocks.tiles; + +import de.ellpeck.naturesaura.api.NaturesAuraAPI; +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; +import de.ellpeck.naturesaura.packet.PacketHandler; +import de.ellpeck.naturesaura.packet.PacketParticles; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.ITickable; +import net.minecraft.util.math.BlockPos; + +import java.util.ArrayList; +import java.util.List; + +public class TileEntityMossGenerator extends TileEntityImpl implements ITickable { + + @Override + public void update() { + if (!this.world.isRemote) { + if (this.world.getTotalWorldTime() % 20 != 0) + return; + + List possibleOffsets = new ArrayList<>(); + int range = 2; + for (int x = -range; x <= range; x++) + for (int y = -range; y <= range; y++) + for (int z = -range; z <= range; z++) { + BlockPos offset = this.pos.add(x, y, z); + IBlockState state = this.world.getBlockState(offset); + if (NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.inverse().containsKey(state)) + possibleOffsets.add(offset); + } + + if (possibleOffsets.isEmpty()) + return; + BlockPos offset = possibleOffsets.get(this.world.rand.nextInt(possibleOffsets.size())); + IBlockState state = this.world.getBlockState(offset); + IBlockState result = NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.inverse().get(state); + + int toAdd = 15000; + while (toAdd > 0) { + BlockPos spot = IAuraChunk.getLowestSpot(this.world, this.pos, 35, this.pos); + toAdd -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, toAdd); + } + + this.world.playEvent(2001, offset, Block.getStateId(state)); + PacketHandler.sendToAllAround(this.world, this.pos, 32, + new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), 23)); + + this.world.setBlockState(offset, result); + } + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxeNA.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxeNA.java index 5b970656..f1886d41 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxeNA.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxeNA.java @@ -65,7 +65,7 @@ public class ItemPickaxeNA extends ItemPickaxe implements IModItem, ICreativeIte if (!worldIn.isRemote) worldIn.setBlockState(pos, result); worldIn.playSound(player, pos, SoundEvents.BLOCK_STONE_PLACE, SoundCategory.BLOCKS, 1.0F, 1.0F); - stack.damageItem(3, player); + stack.damageItem(15, player); return EnumActionResult.SUCCESS; } } diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java index fcedf5ac..bc3f67d8 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java @@ -360,6 +360,29 @@ public class PacketParticles implements IMessage { motionX * 0.2F, motionY * 0.2F, motionZ * 0.2F, IAuraType.forWorld(world).getColor(), 2F, 30, 0F, false, true); break; + case 23: // Moss generator + for (int i = world.rand.nextInt(30) + 30; i >= 0; i--) { + int side = world.rand.nextInt(3); + float x = side != 0 ? world.rand.nextFloat() : (world.rand.nextBoolean() ? 1.1F : -0.1F); + float y = side != 1 ? world.rand.nextFloat() : (world.rand.nextBoolean() ? 1.1F : -0.1F); + float z = side != 2 ? world.rand.nextFloat() : (world.rand.nextBoolean() ? 1.1F : -0.1F); + NaturesAuraAPI.instance().spawnMagicParticle( + message.posX + x, + message.posY + y, + message.posZ + z, + 0F, 0F, 0F, + 0x184c0d, world.rand.nextFloat() + 1F, 30, 0F, true, true); + } + for (int i = world.rand.nextInt(20) + 10; i >= 0; i--) + NaturesAuraAPI.instance().spawnMagicParticle( + message.posX + world.rand.nextFloat(), + message.posY + 1F, + message.posZ + world.rand.nextFloat(), + world.rand.nextGaussian() * 0.01F, + world.rand.nextFloat() * 0.04F + 0.02F, + world.rand.nextGaussian() * 0.01F, + 0x5ccc30, 1F + world.rand.nextFloat() * 1.5F, 40, 0F, true, true); + break; } } }); diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java index ab03c1e9..fad9abcd 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java @@ -19,6 +19,7 @@ import de.ellpeck.naturesaura.items.ModItems; import net.minecraft.block.Block; import net.minecraft.block.BlockFlower; import net.minecraft.block.BlockStoneBrick; +import net.minecraft.block.BlockWall; import net.minecraft.entity.Entity; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.init.Blocks; @@ -166,6 +167,9 @@ public final class ModRecipes { NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.put( Blocks.STONEBRICK.getDefaultState().withProperty(BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.DEFAULT), Blocks.STONEBRICK.getDefaultState().withProperty(BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.MOSSY)); + NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.put( + Blocks.COBBLESTONE_WALL.getDefaultState().withProperty(BlockWall.VARIANT, BlockWall.EnumType.NORMAL), + Blocks.COBBLESTONE_WALL.getDefaultState().withProperty(BlockWall.VARIANT, BlockWall.EnumType.MOSSY)); for (Block block : ForgeRegistries.BLOCKS) if (block instanceof BlockFlower)