mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 11:53:29 +01:00
moss generator, part 1
This commit is contained in:
parent
cbe9b18757
commit
cbf21d38ce
7 changed files with 96 additions and 3 deletions
|
@ -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<IBlockState, IBlockState> BOTANIST_PICKAXE_CONVERSIONS = new HashMap<>();
|
||||
public static final BiMap<IBlockState, IBlockState> 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
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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<BlockPos> 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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue