mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-25 20:58:34 +01:00
blast furnace booster, part 2
This commit is contained in:
parent
ef257e7f80
commit
73a925794f
11 changed files with 209 additions and 15 deletions
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:block",
|
||||||
|
"pools": [
|
||||||
|
{
|
||||||
|
"rolls": 1,
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"type": "minecraft:item",
|
||||||
|
"name": "naturesaura:blast_furnace_booster"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"conditions": [
|
||||||
|
{
|
||||||
|
"condition": "minecraft:survives_explosion"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -2,10 +2,28 @@ package de.ellpeck.naturesaura.blocks;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityBlastFurnaceBooster;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityBlastFurnaceBooster;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
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 class BlockBlastFurnaceBooster extends BlockContainerImpl {
|
||||||
|
public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
|
||||||
|
|
||||||
public BlockBlastFurnaceBooster() {
|
public BlockBlastFurnaceBooster() {
|
||||||
super("blast_furnace_booster", TileEntityBlastFurnaceBooster::new, Block.Properties.from(Blocks.BLAST_FURNACE));
|
super("blast_furnace_booster", TileEntityBlastFurnaceBooster::new, Block.Properties.from(Blocks.BLAST_FURNACE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||||
|
builder.add(FACING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||||
|
return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles;
|
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.ItemStack;
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
import net.minecraft.item.crafting.IRecipe;
|
||||||
import net.minecraft.tileentity.BlastFurnaceTileEntity;
|
import net.minecraft.tileentity.BlastFurnaceTileEntity;
|
||||||
import net.minecraft.tileentity.ITickableTileEntity;
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.IIntArray;
|
import net.minecraft.util.IIntArray;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
public class TileEntityBlastFurnaceBooster extends TileEntityImpl implements ITickableTileEntity {
|
public class TileEntityBlastFurnaceBooster extends TileEntityImpl implements ITickableTileEntity {
|
||||||
|
|
||||||
private int waitTime;
|
|
||||||
|
|
||||||
public TileEntityBlastFurnaceBooster() {
|
public TileEntityBlastFurnaceBooster() {
|
||||||
super(ModTileEntities.BLAST_FURNACE_BOOSTER);
|
super(ModTileEntities.BLAST_FURNACE_BOOSTER);
|
||||||
}
|
}
|
||||||
|
@ -19,10 +21,6 @@ public class TileEntityBlastFurnaceBooster extends TileEntityImpl implements ITi
|
||||||
public void tick() {
|
public void tick() {
|
||||||
if (this.world.isRemote)
|
if (this.world.isRemote)
|
||||||
return;
|
return;
|
||||||
if (this.waitTime > 0) {
|
|
||||||
this.waitTime--;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TileEntity below = this.world.getTileEntity(this.pos.down());
|
TileEntity below = this.world.getTileEntity(this.pos.down());
|
||||||
if (!(below instanceof BlastFurnaceTileEntity))
|
if (!(below instanceof BlastFurnaceTileEntity))
|
||||||
|
@ -34,22 +32,30 @@ public class TileEntityBlastFurnaceBooster extends TileEntityImpl implements ITi
|
||||||
|
|
||||||
IIntArray data = TileEntityFurnaceHeater.getFurnaceData(tile);
|
IIntArray data = TileEntityFurnaceHeater.getFurnaceData(tile);
|
||||||
int doneDiff = data.get(3) - data.get(2);
|
int doneDiff = data.get(3) - data.get(2);
|
||||||
if (doneDiff > 1) {
|
if (doneDiff > 1)
|
||||||
this.waitTime = doneDiff - 2;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.world.rand.nextFloat() > 0.35F)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ItemStack output = tile.getStackInSlot(2);
|
ItemStack output = tile.getStackInSlot(2);
|
||||||
if (output.getCount() >= output.getMaxStackSize())
|
if (output.getCount() >= output.getMaxStackSize())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (output.isEmpty()) {
|
if (output.isEmpty()) {
|
||||||
ItemStack result = recipe.getRecipeOutput();
|
ItemStack result = recipe.getRecipeOutput();
|
||||||
tile.setInventorySlotContents(2, result.copy());
|
tile.setInventorySlotContents(2, result.copy());
|
||||||
} else {
|
} else {
|
||||||
output.grow(1);
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,14 +46,13 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable
|
||||||
if (burnTime <= 0)
|
if (burnTime <= 0)
|
||||||
this.world.setBlockState(tilePos, this.world.getBlockState(tilePos).with(AbstractFurnaceBlock.LIT, true));
|
this.world.setBlockState(tilePos, this.world.getBlockState(tilePos).with(AbstractFurnaceBlock.LIT, true));
|
||||||
|
|
||||||
int totalCookTime = data.get(3);
|
data.set(0, 200);
|
||||||
data.set(0, totalCookTime);
|
|
||||||
//if set higher than 199, it'll never finish because the furnace does ++ and then ==
|
//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);
|
BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 20, this.pos);
|
||||||
IAuraChunk chunk = IAuraChunk.getAuraChunk(this.world, spot);
|
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;
|
did = true;
|
||||||
|
|
||||||
if (this.world.getGameTime() % 15 == 0) {
|
if (this.world.getGameTime() % 15 == 0) {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
package de.ellpeck.naturesaura.packet;
|
package de.ellpeck.naturesaura.packet;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
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.api.aura.type.IAuraType;
|
||||||
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
||||||
import net.minecraft.block.BlockState;
|
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,
|
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<PacketParticles, World> action;
|
public final BiConsumer<PacketParticles, World> action;
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"parent": "naturesaura:block/blast_furnace_booster"
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 470 B |
Binary file not shown.
After Width: | Height: | Size: 247 B |
Binary file not shown.
After Width: | Height: | Size: 533 B |
Loading…
Reference in a new issue