diff --git a/src/generated/resources/data/naturesaura/loot_tables/blocks/blast_furnace_booster.json b/src/generated/resources/data/naturesaura/loot_tables/blocks/blast_furnace_booster.json new file mode 100644 index 00000000..aa978a59 --- /dev/null +++ b/src/generated/resources/data/naturesaura/loot_tables/blocks/blast_furnace_booster.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "naturesaura:blast_furnace_booster" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockBlastFurnaceBooster.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockBlastFurnaceBooster.java index eff03bce..42bbd13e 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockBlastFurnaceBooster.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockBlastFurnaceBooster.java @@ -2,10 +2,28 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.blocks.tiles.TileEntityBlastFurnaceBooster; import net.minecraft.block.Block; +import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.block.HorizontalBlock; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.state.DirectionProperty; +import net.minecraft.state.StateContainer; public class BlockBlastFurnaceBooster extends BlockContainerImpl { + public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING; + public BlockBlastFurnaceBooster() { super("blast_furnace_booster", TileEntityBlastFurnaceBooster::new, Block.Properties.from(Blocks.BLAST_FURNACE)); } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + builder.add(FACING); + } + + @Override + public BlockState getStateForPlacement(BlockItemUseContext context) { + return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite()); + } + } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityBlastFurnaceBooster.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityBlastFurnaceBooster.java index 6b05d5c6..71d80577 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityBlastFurnaceBooster.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityBlastFurnaceBooster.java @@ -1,16 +1,18 @@ package de.ellpeck.naturesaura.blocks.tiles; +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; +import de.ellpeck.naturesaura.packet.PacketHandler; +import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.tileentity.BlastFurnaceTileEntity; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIntArray; +import net.minecraft.util.math.BlockPos; public class TileEntityBlastFurnaceBooster extends TileEntityImpl implements ITickableTileEntity { - private int waitTime; - public TileEntityBlastFurnaceBooster() { super(ModTileEntities.BLAST_FURNACE_BOOSTER); } @@ -19,10 +21,6 @@ public class TileEntityBlastFurnaceBooster extends TileEntityImpl implements ITi public void tick() { if (this.world.isRemote) return; - if (this.waitTime > 0) { - this.waitTime--; - return; - } TileEntity below = this.world.getTileEntity(this.pos.down()); if (!(below instanceof BlastFurnaceTileEntity)) @@ -34,22 +32,30 @@ public class TileEntityBlastFurnaceBooster extends TileEntityImpl implements ITi IIntArray data = TileEntityFurnaceHeater.getFurnaceData(tile); int doneDiff = data.get(3) - data.get(2); - if (doneDiff > 1) { - this.waitTime = doneDiff - 2; + if (doneDiff > 1) + return; + + if (this.world.rand.nextFloat() > 0.45F) { + PacketHandler.sendToAllAround(this.world, this.pos, 32, + new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.BLAST_FURNACE_BOOSTER, 0)); return; } - if (this.world.rand.nextFloat() > 0.35F) - return; - ItemStack output = tile.getStackInSlot(2); if (output.getCount() >= output.getMaxStackSize()) return; + if (output.isEmpty()) { ItemStack result = recipe.getRecipeOutput(); tile.setInventorySlotContents(2, result.copy()); } else { output.grow(1); } + + BlockPos pos = IAuraChunk.getHighestSpot(this.world, this.pos, 30, this.pos); + IAuraChunk.getAuraChunk(this.world, pos).drainAura(pos, 6500); + + PacketHandler.sendToAllAround(this.world, this.pos, 32, + new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.BLAST_FURNACE_BOOSTER, 1)); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFurnaceHeater.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFurnaceHeater.java index 0b029050..7085b747 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFurnaceHeater.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFurnaceHeater.java @@ -46,14 +46,13 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable if (burnTime <= 0) this.world.setBlockState(tilePos, this.world.getBlockState(tilePos).with(AbstractFurnaceBlock.LIT, true)); - int totalCookTime = data.get(3); - data.set(0, totalCookTime); + data.set(0, 200); //if set higher than 199, it'll never finish because the furnace does ++ and then == - data.set(2, Math.min(totalCookTime - 1, data.get(2) + 5)); + data.set(2, Math.min(data.get(3) - 1, data.get(2) + 5)); BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 20, this.pos); IAuraChunk chunk = IAuraChunk.getAuraChunk(this.world, spot); - chunk.drainAura(spot, MathHelper.ceil((totalCookTime - burnTime) * 16.6F)); + chunk.drainAura(spot, MathHelper.ceil((200 - burnTime) * 16.6F)); did = true; if (this.world.getGameTime() % 15 == 0) { diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java index 278798b4..6ace5c63 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java @@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.packet; import de.ellpeck.naturesaura.api.NaturesAuraAPI; +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import net.minecraft.block.BlockState; @@ -425,6 +426,30 @@ public class PacketParticles { world.rand.nextGaussian() * 0.03F, world.rand.nextGaussian() * 0.03F, world.rand.nextGaussian() * 0.03F); + }), + BLAST_FURNACE_BOOSTER((message, world) -> { + boolean worked = message.data[0] > 0; + for (int i = world.rand.nextInt(10) + 5; i >= 0; i--) + world.addParticle(ParticleTypes.CAMPFIRE_COSY_SMOKE, + message.posX + 5 / 16F + world.rand.nextInt(6) / 16F, + message.posY + 0.6F, + message.posZ + 5 / 16F + world.rand.nextInt(6) / 16F, + world.rand.nextGaussian() * 0.005F, + world.rand.nextFloat() * 0.02F + 0.01F, + world.rand.nextGaussian() * 0.005F); + + if (worked) { + BlockPos pos = new BlockPos(message.posX, message.posY, message.posZ); + int color = IAuraChunk.getAuraChunk(world, pos).getType().getColor(); + for (int i = world.rand.nextInt(10) + 10; i >= 0; i--) + NaturesAuraAPI.instance().spawnParticleStream( + message.posX + (float) world.rand.nextGaussian() * 5, + message.posY + world.rand.nextFloat() * 5, + message.posZ + (float) world.rand.nextGaussian() * 5, + message.posX + 0.5F, message.posY + 0.5F, message.posZ + 0.5F, + 0.25F, color, 0.5F + world.rand.nextFloat() + ); + } }); public final BiConsumer action; diff --git a/src/main/resources/assets/naturesaura/blockstates/blast_furnace_booster.json b/src/main/resources/assets/naturesaura/blockstates/blast_furnace_booster.json new file mode 100644 index 00000000..057896d6 --- /dev/null +++ b/src/main/resources/assets/naturesaura/blockstates/blast_furnace_booster.json @@ -0,0 +1,21 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "naturesaura:block/blast_furnace_booster", + "transform": "forge:default-block" + }, + "variants": { + "facing": { + "north": {}, + "east": { + "y": 90 + }, + "south": { + "y": 180 + }, + "west": { + "y": 270 + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/models/block/blast_furnace_booster.json b/src/main/resources/assets/naturesaura/models/block/blast_furnace_booster.json new file mode 100644 index 00000000..166447b7 --- /dev/null +++ b/src/main/resources/assets/naturesaura/models/block/blast_furnace_booster.json @@ -0,0 +1,103 @@ +{ + "credit": "Made with Blockbench", + "parent": "minecraft:block/block", + "textures": { + "0": "naturesaura:blocks/blast_furnace_booster_side", + "1": "naturesaura:blocks/blast_furnace_booster_top", + "2": "naturesaura:blocks/blast_furnace_booster_top_side", + "particle": "naturesaura:blocks/blast_furnace_booster_side" + }, + "elements": [ + { + "name": "base", + "from": [0, 0, 0], + "to": [16, 3, 16], + "faces": { + "north": {"uv": [0, 6, 16, 9], "texture": "#0"}, + "east": {"uv": [0, 6, 16, 9], "texture": "#0"}, + "south": {"uv": [0, 6, 16, 9], "texture": "#0"}, + "west": {"uv": [0, 6, 16, 9], "texture": "#0"}, + "up": {"uv": [0, 0, 16, 16], "texture": "#1"}, + "down": {"uv": [0, 0, 16, 16], "texture": "#1"} + } + }, + { + "name": "base2", + "from": [1, 3, 1], + "to": [15, 5, 15], + "faces": { + "north": {"uv": [1, 13, 15, 15], "texture": "#0"}, + "east": {"uv": [1, 13, 15, 15], "texture": "#0"}, + "south": {"uv": [1, 13, 15, 15], "texture": "#0"}, + "west": {"uv": [1, 13, 15, 15], "texture": "#0"}, + "up": {"uv": [1, 1, 15, 15], "texture": "#1"}, + "down": {"uv": [1, 1, 15, 15], "texture": "#1"} + } + }, + { + "name": "high", + "from": [1, 5, 3], + "to": [15, 9, 13], + "faces": { + "north": {"uv": [1, 11, 15, 15], "texture": "#2"}, + "east": {"uv": [3, 11, 13, 15], "texture": "#0"}, + "south": {"uv": [1, 11, 15, 15], "texture": "#2"}, + "west": {"uv": [3, 11, 13, 15], "texture": "#0"}, + "up": {"uv": [1, 3, 15, 13], "texture": "#1"}, + "down": {"uv": [1, 3, 15, 13], "texture": "#1"} + } + }, + { + "name": "top1", + "from": [1, 9, 3], + "to": [15, 16, 5], + "faces": { + "north": {"uv": [1, 4, 15, 11], "texture": "#2"}, + "east": {"uv": [1, 4, 3, 11], "texture": "#0"}, + "south": {"uv": [1, 4, 15, 11], "texture": "#0"}, + "west": {"uv": [1, 4, 3, 11], "texture": "#0"}, + "up": {"uv": [1, 2, 15, 4], "texture": "#1"}, + "down": {"uv": [1, 2, 15, 4], "texture": "#1"} + } + }, + { + "name": "top2", + "from": [1, 9, 11], + "to": [15, 16, 13], + "faces": { + "north": {"uv": [1, 4, 15, 11], "texture": "#0"}, + "east": {"uv": [1, 4, 3, 11], "texture": "#0"}, + "south": {"uv": [1, 4, 15, 11], "texture": "#2"}, + "west": {"uv": [1, 4, 3, 11], "texture": "#0"}, + "up": {"uv": [1, 2, 15, 4], "texture": "#1"}, + "down": {"uv": [1, 2, 15, 4], "texture": "#1"} + } + }, + { + "name": "top3", + "from": [1, 9, 5], + "to": [3, 16, 11], + "faces": { + "north": {"uv": [1, 4, 3, 11], "texture": "#0"}, + "east": {"uv": [1, 4, 7, 11], "texture": "#0"}, + "south": {"uv": [1, 4, 3, 11], "texture": "#0"}, + "west": {"uv": [1, 4, 7, 11], "texture": "#0"}, + "up": {"uv": [1, 2, 3, 8], "texture": "#1"}, + "down": {"uv": [1, 2, 3, 8], "texture": "#1"} + } + }, + { + "name": "top4", + "from": [13, 9, 5], + "to": [15, 16, 11], + "faces": { + "north": {"uv": [1, 4, 3, 11], "texture": "#0"}, + "east": {"uv": [1, 4, 7, 11], "texture": "#0"}, + "south": {"uv": [1, 4, 3, 11], "texture": "#0"}, + "west": {"uv": [1, 4, 7, 11], "texture": "#0"}, + "up": {"uv": [1, 2, 3, 8], "texture": "#1"}, + "down": {"uv": [1, 2, 3, 8], "texture": "#1"} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/models/item/blast_furnace_booster.json b/src/main/resources/assets/naturesaura/models/item/blast_furnace_booster.json new file mode 100644 index 00000000..036dfeb6 --- /dev/null +++ b/src/main/resources/assets/naturesaura/models/item/blast_furnace_booster.json @@ -0,0 +1,3 @@ +{ + "parent": "naturesaura:block/blast_furnace_booster" +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/textures/blocks/blast_furnace_booster_side.png b/src/main/resources/assets/naturesaura/textures/blocks/blast_furnace_booster_side.png new file mode 100644 index 00000000..68ff61ca Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/blocks/blast_furnace_booster_side.png differ diff --git a/src/main/resources/assets/naturesaura/textures/blocks/blast_furnace_booster_top.png b/src/main/resources/assets/naturesaura/textures/blocks/blast_furnace_booster_top.png new file mode 100644 index 00000000..6c8d3856 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/blocks/blast_furnace_booster_top.png differ diff --git a/src/main/resources/assets/naturesaura/textures/blocks/blast_furnace_booster_top_side.png b/src/main/resources/assets/naturesaura/textures/blocks/blast_furnace_booster_top_side.png new file mode 100644 index 00000000..94c942c6 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/blocks/blast_furnace_booster_top_side.png differ