finished tree ritual

This commit is contained in:
Ellpeck 2018-10-16 17:48:36 +02:00
parent af46854bc7
commit d290eb3eff
8 changed files with 111 additions and 81 deletions

View file

@ -134,7 +134,7 @@ public class BlockAncientLeaves extends BlockLeaves implements
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
super.randomDisplayTick(stateIn, worldIn, pos, 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); TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntityAncientLeaves) { if (tile instanceof TileEntityAncientLeaves) {
if (((TileEntityAncientLeaves) tile).container().getStoredAura() > 0) { if (((TileEntityAncientLeaves) tile).container().getStoredAura() > 0) {
@ -143,7 +143,7 @@ public class BlockAncientLeaves extends BlockLeaves implements
0F, 0F, 0F, 0xc46df9, 0F, 0F, 0F, 0xc46df9,
rand.nextFloat() * 2F + 0.5F, rand.nextFloat() * 2F + 0.5F,
rand.nextInt(100) + 150, rand.nextInt(100) + 150,
rand.nextFloat() * 0.05F + 0.005F, true, true); rand.nextFloat() * 0.01F + 0.001F, true, true);
} }
} }

View file

@ -59,7 +59,7 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock {
@Override @Override
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { 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) { for (BlockPos offsetToOrigin : TileEntityWoodStand.GOLD_POWDER_POSITIONS) {
BlockPos origin = pos.subtract(offsetToOrigin); BlockPos origin = pos.subtract(offsetToOrigin);
if (Helper.checkMultiblock(worldIn, origin, TileEntityWoodStand.GOLD_POWDER_POSITIONS, ModBlocks.GOLD_POWDER.getDefaultState(), true)) { if (Helper.checkMultiblock(worldIn, origin, TileEntityWoodStand.GOLD_POWDER_POSITIONS, ModBlocks.GOLD_POWDER.getDefaultState(), true)) {

View file

@ -9,6 +9,7 @@ import de.ellpeck.naturesaura.recipes.TreeRitualRecipe;
import net.minecraft.block.BlockLeaves; import net.minecraft.block.BlockLeaves;
import net.minecraft.block.BlockLog; import net.minecraft.block.BlockLog;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
@ -68,38 +69,31 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable {
} }
} }
if (this.timer % 5 == 0) { 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, PacketHandler.sendToAllAround(this.world, this.ritualPos, 32,
new PacketParticles( new PacketParticles(this.ritualPos.getX(), this.ritualPos.getY(), this.ritualPos.getZ(), 0));
(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
));
}
} }
if (this.timer >= this.recipe.time) { if (this.timer >= this.recipe.time) {
this.recurseTreeDestruction(this.ritualPos, this.ritualPos); 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.ritualPos = null;
this.involvedStands = null; this.involvedStands = null;
this.recipe = null; this.recipe = null;
this.timer = 0; 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()) { for (TileEntityWoodStand stand : this.involvedStands.keySet()) {
//TODO Turn this into a single packet that just randomly spawns a certain amount of particles PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(stand.pos.getX(), stand.pos.getY(), stand.pos.getZ(), 1));
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));
}
stand.stack = ItemStack.EMPTY; stand.stack = ItemStack.EMPTY;
stand.sendToClients(); stand.sendToClients();
} }
@ -126,7 +120,7 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable {
IBlockState state = this.world.getBlockState(offset); IBlockState state = this.world.getBlockState(offset);
if (state.getBlock() instanceof BlockLog || state.getBlock() instanceof BlockLeaves) { if (state.getBlock() instanceof BlockLog || state.getBlock() instanceof BlockLeaves) {
this.world.setBlockToAir(offset); 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); this.recurseTreeDestruction(offset, start);
} }

View file

@ -57,6 +57,7 @@ public class TerrainGenEvents {
} }
} }
if (stillRequired.isEmpty()) {
toPick.setRitual(pos, recipe, actuallyInvolved); toPick.setRitual(pos, recipe, actuallyInvolved);
break; break;
} }
@ -66,3 +67,4 @@ public class TerrainGenEvents {
} }
} }
} }
}

View file

@ -1,8 +1,11 @@
package de.ellpeck.naturesaura.packet; package de.ellpeck.naturesaura.packet;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft; 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.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
@ -14,29 +17,13 @@ public class PacketParticles implements IMessage {
private float posX; private float posX;
private float posY; private float posY;
private float posZ; private float posZ;
private float motionX; private int type;
private float motionY;
private float motionZ;
private int color;
private float scale;
private int maxAge;
private float gravity;
private boolean collision;
private boolean fade;
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.posX = posX;
this.posY = posY; this.posY = posY;
this.posZ = posZ; this.posZ = posZ;
this.motionX = motionX; this.type = type;
this.motionY = motionY;
this.motionZ = motionZ;
this.color = color;
this.scale = scale;
this.maxAge = maxAge;
this.gravity = gravity;
this.collision = collision;
this.fade = fade;
} }
public PacketParticles() { public PacketParticles() {
@ -48,15 +35,7 @@ public class PacketParticles implements IMessage {
this.posX = buf.readFloat(); this.posX = buf.readFloat();
this.posY = buf.readFloat(); this.posY = buf.readFloat();
this.posZ = buf.readFloat(); this.posZ = buf.readFloat();
this.motionX = buf.readFloat(); this.type = buf.readInt();
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();
} }
@Override @Override
@ -64,15 +43,7 @@ public class PacketParticles implements IMessage {
buf.writeFloat(this.posX); buf.writeFloat(this.posX);
buf.writeFloat(this.posY); buf.writeFloat(this.posY);
buf.writeFloat(this.posZ); buf.writeFloat(this.posZ);
buf.writeFloat(this.motionX); buf.writeInt(this.type);
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);
} }
public static class Handler implements IMessageHandler<PacketParticles, IMessage> { public static class Handler implements IMessageHandler<PacketParticles, IMessage> {
@ -80,11 +51,51 @@ public class PacketParticles implements IMessage {
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IMessage onMessage(PacketParticles message, MessageContext ctx) { public IMessage onMessage(PacketParticles message, MessageContext ctx) {
NaturesAura.proxy.scheduleTask(() -> NaturesAura.proxy.scheduleTask(() -> {
NaturesAura.proxy.spawnMagicParticle(Minecraft.getMinecraft().world, 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, message.posX, message.posY, message.posZ,
message.motionX, message.motionY, message.motionZ, world.rand.nextGaussian() * 0.05F, world.rand.nextGaussian() * 0.05F, world.rand.nextGaussian() * 0.05F,
message.color, message.scale, message.maxAge, message.gravity, message.collision, message.fade)); 0xFF00FF, 2F, 200, 0F, true, true);
}
break;
}
}
});
return null; return null;
} }

View file

@ -1,5 +1,7 @@
package de.ellpeck.naturesaura.recipes; 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.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -7,6 +9,16 @@ import net.minecraft.item.ItemStack;
public final class ModRecipes { public final class ModRecipes {
public static void init() { 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();
} }
} }

View file

@ -0,0 +1,15 @@
{
"type": "forge:ore_shaped",
"pattern": [
"L"
],
"key": {
"L": {
"item": "naturesaura:gold_leaf"
}
},
"result": {
"item": "naturesaura:gold_powder",
"count": 2
}
}

View file

@ -1,23 +1,19 @@
{ {
"type": "forge:ore_shaped", "type": "forge:ore_shaped",
"pattern": [ "pattern": [
"WLW", "L",
"LEL", "W"
"WLW"
], ],
"key": { "key": {
"E": {
"item": "minecraft:spider_eye"
},
"L": {
"item": "naturesaura:gold_leaf"
},
"W": { "W": {
"type": "forge:ore_dict", "type": "forge:ore_dict",
"ore": "logWood" "ore": "logWood"
},
"L": {
"item": "naturesaura:gold_leaf"
} }
}, },
"result": { "result": {
"item": "naturesaura:eye" "item": "naturesaura:wood_stand"
} }
} }