mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 11:53:29 +01:00
finished tree ritual
This commit is contained in:
parent
af46854bc7
commit
d290eb3eff
8 changed files with 111 additions and 81 deletions
|
@ -134,7 +134,7 @@ public class BlockAncientLeaves extends BlockLeaves implements
|
|||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
|
||||
super.randomDisplayTick(stateIn, worldIn, pos, rand);
|
||||
if (rand.nextFloat() >= 0.9F && !worldIn.getBlockState(pos.down()).isFullBlock()) {
|
||||
if (rand.nextFloat() >= 0.95F && !worldIn.getBlockState(pos.down()).isFullBlock()) {
|
||||
TileEntity tile = worldIn.getTileEntity(pos);
|
||||
if (tile instanceof TileEntityAncientLeaves) {
|
||||
if (((TileEntityAncientLeaves) tile).container().getStoredAura() > 0) {
|
||||
|
@ -143,7 +143,7 @@ public class BlockAncientLeaves extends BlockLeaves implements
|
|||
0F, 0F, 0F, 0xc46df9,
|
||||
rand.nextFloat() * 2F + 0.5F,
|
||||
rand.nextInt(100) + 150,
|
||||
rand.nextFloat() * 0.05F + 0.005F, true, true);
|
||||
rand.nextFloat() * 0.01F + 0.001F, true, true);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock {
|
|||
|
||||
@Override
|
||||
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
|
||||
if (rand.nextFloat() >= 0.8F) {
|
||||
if (rand.nextFloat() >= 0.9F) {
|
||||
for (BlockPos offsetToOrigin : TileEntityWoodStand.GOLD_POWDER_POSITIONS) {
|
||||
BlockPos origin = pos.subtract(offsetToOrigin);
|
||||
if (Helper.checkMultiblock(worldIn, origin, TileEntityWoodStand.GOLD_POWDER_POSITIONS, ModBlocks.GOLD_POWDER.getDefaultState(), true)) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import de.ellpeck.naturesaura.recipes.TreeRitualRecipe;
|
|||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -68,38 +69,31 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable {
|
|||
}
|
||||
}
|
||||
if (this.timer % 5 == 0) {
|
||||
for (BlockPos offset : TileEntityWoodStand.GOLD_POWDER_POSITIONS) {
|
||||
BlockPos dustPos = this.ritualPos.add(offset);
|
||||
PacketHandler.sendToAllAround(this.world, this.ritualPos, 32,
|
||||
new PacketParticles(
|
||||
(float) dustPos.getX() + 0.375F + this.world.rand.nextFloat() * 0.25F,
|
||||
(float) dustPos.getY() + 0.1F,
|
||||
(float) dustPos.getZ() + 0.375F + this.world.rand.nextFloat() * 0.25F,
|
||||
(float) this.world.rand.nextGaussian() * 0.01F,
|
||||
this.world.rand.nextFloat() * 0.005F + 0.01F,
|
||||
(float) this.world.rand.nextGaussian() * 0.01F,
|
||||
0xf4cb42, 2F, 100, 0F, false, true
|
||||
));
|
||||
}
|
||||
PacketHandler.sendToAllAround(this.world, this.ritualPos, 32,
|
||||
new PacketParticles(this.ritualPos.getX(), this.ritualPos.getY(), this.ritualPos.getZ(), 0));
|
||||
}
|
||||
|
||||
if (this.timer >= this.recipe.time) {
|
||||
this.recurseTreeDestruction(this.ritualPos, this.ritualPos);
|
||||
//TODO Spawn item and stuff here, make some more nice particles probably
|
||||
for (BlockPos offset : GOLD_POWDER_POSITIONS) {
|
||||
this.world.setBlockToAir(this.ritualPos.add(offset));
|
||||
}
|
||||
|
||||
EntityItem item = new EntityItem(this.world,
|
||||
this.ritualPos.getX() + 0.5, this.ritualPos.getY() + 4.5, this.ritualPos.getZ() + 0.5,
|
||||
this.recipe.result.copy());
|
||||
this.world.spawnEntity(item);
|
||||
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 3));
|
||||
|
||||
this.ritualPos = null;
|
||||
this.involvedStands = null;
|
||||
this.recipe = null;
|
||||
this.timer = 0;
|
||||
} else if (this.timer >= this.recipe.time / 2) {
|
||||
} else if (this.timer >= this.recipe.time / 2 && !this.involvedStands.isEmpty()) {
|
||||
for (TileEntityWoodStand stand : this.involvedStands.keySet()) {
|
||||
//TODO Turn this into a single packet that just randomly spawns a certain amount of particles
|
||||
for (int j = this.world.rand.nextInt(20) + 10; j >= 0; j--) {
|
||||
PacketHandler.sendToAllAround(this.world, this.ritualPos, 32, new PacketParticles(
|
||||
(float) stand.pos.getX() + 0.5F, (float) stand.pos.getY() + 1.25F, (float) stand.pos.getZ() + 0.5F,
|
||||
(float) this.world.rand.nextGaussian() * 0.05F, this.world.rand.nextFloat() * 0.05F, (float) this.world.rand.nextGaussian() * 0.05F,
|
||||
0xFF00FF, 1.5F, 50, 0F, false, true));
|
||||
}
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(stand.pos.getX(), stand.pos.getY(), stand.pos.getZ(), 1));
|
||||
stand.stack = ItemStack.EMPTY;
|
||||
stand.sendToClients();
|
||||
}
|
||||
|
@ -126,7 +120,7 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable {
|
|||
IBlockState state = this.world.getBlockState(offset);
|
||||
if (state.getBlock() instanceof BlockLog || state.getBlock() instanceof BlockLeaves) {
|
||||
this.world.setBlockToAir(offset);
|
||||
//TODO Spawn particles around the block outline here, probably with the same packet as above
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), 2));
|
||||
|
||||
this.recurseTreeDestruction(offset, start);
|
||||
}
|
||||
|
|
|
@ -57,8 +57,10 @@ public class TerrainGenEvents {
|
|||
}
|
||||
}
|
||||
|
||||
toPick.setRitual(pos, recipe, actuallyInvolved);
|
||||
break;
|
||||
if (stillRequired.isEmpty()) {
|
||||
toPick.setRitual(pos, recipe, actuallyInvolved);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package de.ellpeck.naturesaura.packet;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
@ -14,29 +17,13 @@ public class PacketParticles implements IMessage {
|
|||
private float posX;
|
||||
private float posY;
|
||||
private float posZ;
|
||||
private float motionX;
|
||||
private float motionY;
|
||||
private float motionZ;
|
||||
private int color;
|
||||
private float scale;
|
||||
private int maxAge;
|
||||
private float gravity;
|
||||
private boolean collision;
|
||||
private boolean fade;
|
||||
private int type;
|
||||
|
||||
public PacketParticles(float posX, float posY, float posZ, float motionX, float motionY, float motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade) {
|
||||
public PacketParticles(float posX, float posY, float posZ, int type) {
|
||||
this.posX = posX;
|
||||
this.posY = posY;
|
||||
this.posZ = posZ;
|
||||
this.motionX = motionX;
|
||||
this.motionY = motionY;
|
||||
this.motionZ = motionZ;
|
||||
this.color = color;
|
||||
this.scale = scale;
|
||||
this.maxAge = maxAge;
|
||||
this.gravity = gravity;
|
||||
this.collision = collision;
|
||||
this.fade = fade;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public PacketParticles() {
|
||||
|
@ -48,15 +35,7 @@ public class PacketParticles implements IMessage {
|
|||
this.posX = buf.readFloat();
|
||||
this.posY = buf.readFloat();
|
||||
this.posZ = buf.readFloat();
|
||||
this.motionX = buf.readFloat();
|
||||
this.motionY = buf.readFloat();
|
||||
this.motionZ = buf.readFloat();
|
||||
this.color = buf.readInt();
|
||||
this.scale = buf.readFloat();
|
||||
this.maxAge = buf.readInt();
|
||||
this.gravity = buf.readFloat();
|
||||
this.collision = buf.readBoolean();
|
||||
this.fade = buf.readBoolean();
|
||||
this.type = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,15 +43,7 @@ public class PacketParticles implements IMessage {
|
|||
buf.writeFloat(this.posX);
|
||||
buf.writeFloat(this.posY);
|
||||
buf.writeFloat(this.posZ);
|
||||
buf.writeFloat(this.motionX);
|
||||
buf.writeFloat(this.motionY);
|
||||
buf.writeFloat(this.motionZ);
|
||||
buf.writeInt(this.color);
|
||||
buf.writeFloat(this.scale);
|
||||
buf.writeInt(this.maxAge);
|
||||
buf.writeFloat(this.gravity);
|
||||
buf.writeBoolean(this.collision);
|
||||
buf.writeBoolean(this.fade);
|
||||
buf.writeInt(this.type);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<PacketParticles, IMessage> {
|
||||
|
@ -80,11 +51,51 @@ public class PacketParticles implements IMessage {
|
|||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IMessage onMessage(PacketParticles message, MessageContext ctx) {
|
||||
NaturesAura.proxy.scheduleTask(() ->
|
||||
NaturesAura.proxy.spawnMagicParticle(Minecraft.getMinecraft().world,
|
||||
message.posX, message.posY, message.posZ,
|
||||
message.motionX, message.motionY, message.motionZ,
|
||||
message.color, message.scale, message.maxAge, message.gravity, message.collision, message.fade));
|
||||
NaturesAura.proxy.scheduleTask(() -> {
|
||||
World world = Minecraft.getMinecraft().world;
|
||||
if (world != null) {
|
||||
switch (message.type) {
|
||||
case 0:
|
||||
BlockPos pos = new BlockPos(message.posX, message.posY, message.posZ);
|
||||
for (BlockPos offset : TileEntityWoodStand.GOLD_POWDER_POSITIONS) {
|
||||
BlockPos dustPos = pos.add(offset);
|
||||
NaturesAura.proxy.spawnMagicParticle(world,
|
||||
dustPos.getX() + 0.375F + world.rand.nextFloat() * 0.25F,
|
||||
dustPos.getY() + 0.1F,
|
||||
dustPos.getZ() + 0.375F + world.rand.nextFloat() * 0.25F,
|
||||
(float) world.rand.nextGaussian() * 0.01F,
|
||||
world.rand.nextFloat() * 0.005F + 0.01F,
|
||||
(float) world.rand.nextGaussian() * 0.01F,
|
||||
0xf4cb42, 2F, 100, 0F, false, true);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
for (int i = world.rand.nextInt(20) + 10; i >= 0; i--) {
|
||||
NaturesAura.proxy.spawnMagicParticle(world,
|
||||
message.posX + 0.5F, message.posY + 1.25F, message.posZ + 0.5F,
|
||||
(float) world.rand.nextGaussian() * 0.05F, world.rand.nextFloat() * 0.05F, (float) world.rand.nextGaussian() * 0.05F,
|
||||
0xFF00FF, 1.5F, 50, 0F, false, true);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
for (int i = world.rand.nextInt(5) + 3; i >= 0; i--) {
|
||||
NaturesAura.proxy.spawnMagicParticle(world,
|
||||
message.posX + world.rand.nextFloat(), message.posY + world.rand.nextFloat(), message.posZ + world.rand.nextFloat(),
|
||||
0F, 0F, 0F,
|
||||
0x33FF33, 1F, 100, 0F, false, true);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
for (int i = world.rand.nextInt(10) + 10; i >= 0; i--) {
|
||||
NaturesAura.proxy.spawnMagicParticle(world,
|
||||
message.posX, message.posY, message.posZ,
|
||||
world.rand.nextGaussian() * 0.05F, world.rand.nextGaussian() * 0.05F, world.rand.nextGaussian() * 0.05F,
|
||||
0xFF00FF, 2F, 200, 0F, true, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package de.ellpeck.naturesaura.recipes;
|
||||
|
||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -7,6 +9,16 @@ import net.minecraft.item.ItemStack;
|
|||
public final class ModRecipes {
|
||||
|
||||
public static void init() {
|
||||
new TreeRitualRecipe(new ItemStack(Blocks.SAPLING), new ItemStack(Items.APPLE, 16), 300, new ItemStack(Items.BEETROOT), new ItemStack(Items.ITEM_FRAME), new ItemStack(Items.COMMAND_BLOCK_MINECART)).add();
|
||||
new TreeRitualRecipe(new ItemStack(Blocks.SAPLING), new ItemStack(ModItems.EYE), 250,
|
||||
new ItemStack(Items.SPIDER_EYE),
|
||||
new ItemStack(Items.GOLD_INGOT),
|
||||
new ItemStack(ModItems.GOLD_LEAF),
|
||||
new ItemStack(ModItems.GOLD_LEAF)).add();
|
||||
new TreeRitualRecipe(new ItemStack(Blocks.SAPLING), new ItemStack(ModBlocks.NATURE_ALTAR), 500,
|
||||
new ItemStack(Blocks.STONE),
|
||||
new ItemStack(Blocks.STONE),
|
||||
new ItemStack(Blocks.STONE),
|
||||
new ItemStack(ModItems.GOLD_LEAF),
|
||||
new ItemStack(Items.DIAMOND)).add();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"type": "forge:ore_shaped",
|
||||
"pattern": [
|
||||
"L"
|
||||
],
|
||||
"key": {
|
||||
"L": {
|
||||
"item": "naturesaura:gold_leaf"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "naturesaura:gold_powder",
|
||||
"count": 2
|
||||
}
|
||||
}
|
|
@ -1,23 +1,19 @@
|
|||
{
|
||||
"type": "forge:ore_shaped",
|
||||
"pattern": [
|
||||
"WLW",
|
||||
"LEL",
|
||||
"WLW"
|
||||
"L",
|
||||
"W"
|
||||
],
|
||||
"key": {
|
||||
"E": {
|
||||
"item": "minecraft:spider_eye"
|
||||
},
|
||||
"L": {
|
||||
"item": "naturesaura:gold_leaf"
|
||||
},
|
||||
"W": {
|
||||
"type": "forge:ore_dict",
|
||||
"ore": "logWood"
|
||||
},
|
||||
"L": {
|
||||
"item": "naturesaura:gold_leaf"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "naturesaura:eye"
|
||||
"item": "naturesaura:wood_stand"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue