From 73a925794fecf8fb4e296165f25fe356c493e15d Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 26 Jan 2020 15:52:16 +0100 Subject: [PATCH] blast furnace booster, part 2 --- .../blocks/blast_furnace_booster.json | 19 ++++ .../blocks/BlockBlastFurnaceBooster.java | 18 +++ .../tiles/TileEntityBlastFurnaceBooster.java | 28 +++-- .../blocks/tiles/TileEntityFurnaceHeater.java | 7 +- .../naturesaura/packet/PacketParticles.java | 25 +++++ .../blockstates/blast_furnace_booster.json | 21 ++++ .../models/block/blast_furnace_booster.json | 103 ++++++++++++++++++ .../models/item/blast_furnace_booster.json | 3 + .../blocks/blast_furnace_booster_side.png | Bin 0 -> 470 bytes .../blocks/blast_furnace_booster_top.png | Bin 0 -> 247 bytes .../blocks/blast_furnace_booster_top_side.png | Bin 0 -> 533 bytes 11 files changed, 209 insertions(+), 15 deletions(-) create mode 100644 src/generated/resources/data/naturesaura/loot_tables/blocks/blast_furnace_booster.json create mode 100644 src/main/resources/assets/naturesaura/blockstates/blast_furnace_booster.json create mode 100644 src/main/resources/assets/naturesaura/models/block/blast_furnace_booster.json create mode 100644 src/main/resources/assets/naturesaura/models/item/blast_furnace_booster.json create mode 100644 src/main/resources/assets/naturesaura/textures/blocks/blast_furnace_booster_side.png create mode 100644 src/main/resources/assets/naturesaura/textures/blocks/blast_furnace_booster_top.png create mode 100644 src/main/resources/assets/naturesaura/textures/blocks/blast_furnace_booster_top_side.png 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 0000000000000000000000000000000000000000..68ff61ca34bcacef956af6124051763b487105cc GIT binary patch literal 470 zcmV;{0V)28P)Px$kV!;AR5*>DlFe?^FcgJ9swhr8nJSgqE`~~U#i;Cfka>i8DTKrm&4vnA2$WfY znwe~h>f$(#vw=nGOJ;-+!kc@2e9ry#v(0AnbKmT#?`i<5s-h?g0NS<{Ki=2tHB)}F zZ}z->^A4?3UR+<(Gz~)tblm`e)~N*Ox`AVUQs32Rol=%1`YdJm8UQHI<|5R24nV3r z$NXfs+i~;yB>x!@;{#^8HTp5^%7%R{sg z2k^beIVbkfm~oBHIVman&N-ZO%w{tH?!VuQKjkL?ySo0jvH#)x0@p4R3rc-b1ONa4 M07*qoM6N<$g2|HDlK=n! literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..6c8d38562169a8f1c4ae56222df6b8ce298cff5a GIT binary patch literal 247 zcmV4v_m#vEc38NSjOtQT(^NA_dew-4XG;JIfJvb{&+TwsN+z1_seFSpL2$gNM?zt3*ldQ-)+geKj9+DCiIq`em*Dst<@j%g@;~fA1002ovPDHLkV1m>TXfFT& literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..94c942c693316779b7e6dd4ac7bdad9ea87284c6 GIT binary patch literal 533 zcmV+w0_y#VP)Px$&q+iKoo{Q+L0Y!s8XpEDO9B^qOzha`VdrkguFrgG9(f&!IB4H z6IBAi3V{q8P@RN@OQv{y8OI0~j)z=8JsZzC`ftZGcgExK@9AtxbQJ**h9SQ11E7>L z=ce!X`>f){bT(!5`~|LS@$lq?*=$CsHCa{y;JTI($g+}6yojzMT-T!AZsYD-lwUOf z?ftuk=sFGnmYuVS7n8|^)3Zka9PV{^mwmu>ElRD8tDGlBa1$?-QhfUOdFlF%PUnz4 z$Khw5*RwWcd2R&XzIktwojxuRCg#$$)EX(}GO}%mO>fz@SqVV+zK`o#Ti`(uuv(+x zaP5C&dCr5QqdGyO+6WASfbUOUtqBZ*fYESBsr8!Kj#3IaPfYB8kpaFOzvS7)1psoM zkYy!GDMYv1rPu3i5t>SV6aXxA#V!~TfU2qxVHlzd&B46`k|aS0!LQ@OfEK!16HHZ# z-LirD)$SOlBtaLN+sba)W?kT~Kr@WvnBCV;S?Frby>)p`s#2tsI4#HE#f_BY_j8<< zLtfP1RHb;A=UdV9A}3ALx=&MXq^z&883M%DF`nlUU&jD=o@WTF=cWX}B#Lg`{eSfb X_Z|Sld m00000NkvXXu0mjfz{&U5 literal 0 HcmV?d00001