From 1e88851c6b24924eedfc38c8238ab534ffdb51df Mon Sep 17 00:00:00 2001
From: khj xiaogu <54445543+khjxiaogu@users.noreply.github.com>
Date: Fri, 3 Dec 2021 19:13:15 +0800
Subject: [PATCH] steam particles for engine and boilers and fix #12
---
.../teammoeg/steampowered/SteamPowered.java | 14 +-
.../steampowered/client/ParticleBase.java | 81 ++++++++++
.../steampowered/client/Particles.java | 33 +++++
.../steampowered/client/SteamParticle.java | 51 +++++++
.../client/SteamPoweredClient.java | 12 +-
.../content/boiler/BoilerBlock.java | 139 +++++++++++-------
.../content/boiler/BoilerTileEntity.java | 20 +--
.../content/burner/BurnerBlock.java | 26 ++++
.../content/burner/BurnerTileEntity.java | 22 +--
.../content/engine/SteamEngineBlock.java | 26 ++--
.../assets/steampowered/particles/steam.json | 8 +
.../textures/particle/steam_0.png | Bin 0 -> 106 bytes
.../textures/particle/steam_1.png | Bin 0 -> 105 bytes
.../textures/particle/steam_2.png | Bin 0 -> 101 bytes
.../textures/particle/steam_3.png | Bin 0 -> 106 bytes
15 files changed, 316 insertions(+), 116 deletions(-)
create mode 100644 src/main/java/com/teammoeg/steampowered/client/ParticleBase.java
create mode 100644 src/main/java/com/teammoeg/steampowered/client/Particles.java
create mode 100644 src/main/java/com/teammoeg/steampowered/client/SteamParticle.java
create mode 100644 src/main/resources/assets/steampowered/particles/steam.json
create mode 100644 src/main/resources/assets/steampowered/textures/particle/steam_0.png
create mode 100644 src/main/resources/assets/steampowered/textures/particle/steam_1.png
create mode 100644 src/main/resources/assets/steampowered/textures/particle/steam_2.png
create mode 100644 src/main/resources/assets/steampowered/textures/particle/steam_3.png
diff --git a/src/main/java/com/teammoeg/steampowered/SteamPowered.java b/src/main/java/com/teammoeg/steampowered/SteamPowered.java
index 5acea29..910ab49 100644
--- a/src/main/java/com/teammoeg/steampowered/SteamPowered.java
+++ b/src/main/java/com/teammoeg/steampowered/SteamPowered.java
@@ -18,15 +18,21 @@
package com.teammoeg.steampowered;
-import com.simibubi.create.foundation.block.BlockStressDefaults;
+import javax.annotation.Nonnull;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
import com.simibubi.create.foundation.block.BlockStressValues;
import com.simibubi.create.foundation.data.CreateRegistrate;
import com.simibubi.create.repack.registrate.util.NonNullLazyValue;
+import com.teammoeg.steampowered.client.Particles;
import com.teammoeg.steampowered.client.SteamPoweredClient;
import com.teammoeg.steampowered.network.PacketHandler;
import com.teammoeg.steampowered.registrate.SPBlocks;
import com.teammoeg.steampowered.registrate.SPItems;
import com.teammoeg.steampowered.registrate.SPTiles;
+
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
@@ -39,10 +45,6 @@ import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-import javax.annotation.Nonnull;
// The value here should match an entry in the META-INF/mods.toml file
@Mod("steampowered")
@@ -78,7 +80,7 @@ public class SteamPowered {
FluidRegistry.FLUIDS.register(FMLJavaModLoadingContext.get().getModEventBus());
BlockRegistry.BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus());
ItemRegistry.ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
-
+ Particles.REGISTER.register(FMLJavaModLoadingContext.get().getModEventBus());
SPBlocks.register();
SPTiles.register();
SPItems.register();
diff --git a/src/main/java/com/teammoeg/steampowered/client/ParticleBase.java b/src/main/java/com/teammoeg/steampowered/client/ParticleBase.java
new file mode 100644
index 0000000..00b7983
--- /dev/null
+++ b/src/main/java/com/teammoeg/steampowered/client/ParticleBase.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2021 TeamMoeg
+ *
+ * This file is part of Frosted Heart.
+ *
+ * Frosted Heart is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * Frosted Heart is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Frosted Heart. If not, see .
+ */
+
+package com.teammoeg.steampowered.client;
+
+import com.mojang.blaze3d.vertex.IVertexBuilder;
+
+import net.minecraft.client.particle.IParticleRenderType;
+import net.minecraft.client.particle.SpriteTexturedParticle;
+import net.minecraft.client.renderer.ActiveRenderInfo;
+import net.minecraft.client.world.ClientWorld;
+import net.minecraft.util.math.MathHelper;
+
+public class ParticleBase extends SpriteTexturedParticle {
+ protected float originalScale = 1.3F;
+
+ protected ParticleBase(ClientWorld world, double x, double y, double z) {
+ super(world, x, y, z);
+ }
+
+ public ParticleBase(ClientWorld world, double x, double y, double z, double motionX, double motionY, double motionZ) {
+ super(world, x, y, z, motionX, motionY, motionZ);
+ }
+
+ public IParticleRenderType getRenderType() {
+ return IParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
+ }
+
+ @Override
+ public void render(IVertexBuilder worldRendererIn, ActiveRenderInfo entityIn, float pt) {
+ float age = (this.age + pt) / lifetime * 32.0F;
+
+ age = MathHelper.clamp(age, 0.0F, 1.0F);
+
+ super.quadSize = originalScale * age;
+ super.render(worldRendererIn, entityIn, pt);
+ }
+
+ public void tick() {
+ super.xo = x;
+ super.yo = y;
+ super.zo = z;
+ if (age >= lifetime)
+ super.remove();
+ this.age++;
+
+ this.yd -= 0.04D * gravity;
+ move(xd,yd, zd);
+
+ if (y == yo) {
+ this.xd *= 1.1D;
+ this.zd *= 1.1D;
+ }
+
+ this.xd *= 0.96D;
+ this.yd *= 0.96D;
+ this.zd *= 0.96D;
+
+ if (onGround) {
+ this.xd *= 0.67D;
+ this.zd *= 0.67D;
+ }
+ }
+
+
+}
diff --git a/src/main/java/com/teammoeg/steampowered/client/Particles.java b/src/main/java/com/teammoeg/steampowered/client/Particles.java
new file mode 100644
index 0000000..9ff2d1c
--- /dev/null
+++ b/src/main/java/com/teammoeg/steampowered/client/Particles.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2021 TeamMoeg
+ *
+ * This file is part of Frosted Heart.
+ *
+ * Frosted Heart is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * Frosted Heart is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Frosted Heart. If not, see .
+ */
+
+package com.teammoeg.steampowered.client;
+
+import com.teammoeg.steampowered.SteamPowered;
+
+import net.minecraft.particles.BasicParticleType;
+import net.minecraft.particles.ParticleType;
+import net.minecraftforge.fml.RegistryObject;
+import net.minecraftforge.registries.DeferredRegister;
+import net.minecraftforge.registries.ForgeRegistries;
+
+public class Particles {
+ public static final DeferredRegister> REGISTER = DeferredRegister.create(ForgeRegistries.PARTICLE_TYPES, SteamPowered.MODID);
+
+ public static final RegistryObject STEAM = REGISTER.register("steam", () -> new BasicParticleType(false));
+}
diff --git a/src/main/java/com/teammoeg/steampowered/client/SteamParticle.java b/src/main/java/com/teammoeg/steampowered/client/SteamParticle.java
new file mode 100644
index 0000000..939f796
--- /dev/null
+++ b/src/main/java/com/teammoeg/steampowered/client/SteamParticle.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2021 TeamMoeg
+ *
+ * This file is part of Frosted Heart.
+ *
+ * Frosted Heart is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * Frosted Heart is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Frosted Heart. If not, see .
+ */
+
+package com.teammoeg.steampowered.client;
+
+import net.minecraft.client.particle.IAnimatedSprite;
+import net.minecraft.client.particle.IParticleFactory;
+import net.minecraft.client.particle.Particle;
+import net.minecraft.client.world.ClientWorld;
+import net.minecraft.particles.BasicParticleType;
+
+public class SteamParticle extends ParticleBase {
+
+ public SteamParticle(ClientWorld world, double x, double y, double z, double motionX, double motionY, double motionZ) {
+ super(world, x, y, z, motionX, motionY, motionZ);
+ this.gravity = -0.1F;
+ this.rCol = this.gCol = this.bCol = (float) (Math.random() * 0.4) + 0.4f;
+ this.originalScale = 0.25F;
+ this.lifetime= (int) (12.0D / (Math.random() * 0.8D + 0.2D));
+ }
+
+ public static class Factory implements IParticleFactory {
+ private final IAnimatedSprite spriteSet;
+
+ public Factory(IAnimatedSprite spriteSet) {
+ this.spriteSet = spriteSet;
+ }
+
+ @Override
+ public Particle createParticle(BasicParticleType typeIn, ClientWorld worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
+ SteamParticle steamParticle = new SteamParticle(worldIn, x, y, z, xSpeed, ySpeed, zSpeed);
+ steamParticle.pickSprite(this.spriteSet);
+ return steamParticle;
+ }
+ }
+}
diff --git a/src/main/java/com/teammoeg/steampowered/client/SteamPoweredClient.java b/src/main/java/com/teammoeg/steampowered/client/SteamPoweredClient.java
index 12f1bbf..cf5446e 100644
--- a/src/main/java/com/teammoeg/steampowered/client/SteamPoweredClient.java
+++ b/src/main/java/com/teammoeg/steampowered/client/SteamPoweredClient.java
@@ -22,13 +22,10 @@ import com.teammoeg.steampowered.FluidRegistry;
import com.teammoeg.steampowered.block.SPBlockPartials;
import com.teammoeg.steampowered.ponder.SPPonderIndex;
import com.teammoeg.steampowered.registrate.SPBlocks;
-import com.teammoeg.steampowered.registrate.SPItems;
+import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;
-import net.minecraft.item.Item;
-import net.minecraft.util.text.TextFormatting;
-import net.minecraft.util.text.TranslationTextComponent;
-import net.minecraftforge.event.entity.player.ItemTooltipEvent;
+import net.minecraftforge.client.event.ParticleFactoryRegisterEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
@@ -37,12 +34,15 @@ public class SteamPoweredClient {
SPBlockPartials.clientInit();
modEventBus.addListener(SteamPoweredClient::clientInit);
modEventBus.addListener(SteamPoweredClient::setupRenderType);
+ modEventBus.addListener(SteamPoweredClient::registerParticleFactories);
}
public static void clientInit(FMLClientSetupEvent event) {
SPPonderIndex.register();
}
-
+ public static void registerParticleFactories(ParticleFactoryRegisterEvent event) {
+ Minecraft.getInstance().particleEngine.register(Particles.STEAM.get(), SteamParticle.Factory::new);
+ }
public static void setupRenderType(FMLClientSetupEvent event) {
event.enqueueWork(() -> {
RenderTypeLookup.setRenderLayer(FluidRegistry.steam.get(), RenderType.translucent());
diff --git a/src/main/java/com/teammoeg/steampowered/content/boiler/BoilerBlock.java b/src/main/java/com/teammoeg/steampowered/content/boiler/BoilerBlock.java
index 8971f53..cff0351 100644
--- a/src/main/java/com/teammoeg/steampowered/content/boiler/BoilerBlock.java
+++ b/src/main/java/com/teammoeg/steampowered/content/boiler/BoilerBlock.java
@@ -19,11 +19,13 @@
package com.teammoeg.steampowered.content.boiler;
import java.util.List;
+import java.util.Random;
import com.simibubi.create.foundation.item.ItemDescription.Palette;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.item.TooltipHelper;
import com.teammoeg.steampowered.client.ClientUtils;
+import com.teammoeg.steampowered.client.Particles;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
@@ -37,6 +39,9 @@ import net.minecraft.fluid.FluidState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
+import net.minecraft.util.Direction;
+import net.minecraft.util.SoundCategory;
+import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
@@ -47,86 +52,106 @@ import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
-public abstract class BoilerBlock extends Block implements ILiquidContainer{
- @Override
- public boolean canPlaceLiquid(IBlockReader w, BlockPos p, BlockState s,Fluid f) {
- TileEntity te=w.getBlockEntity(p);
- if(te instanceof BoilerTileEntity) {
- BoilerTileEntity boiler=(BoilerTileEntity)te;
- if(boiler.input.fill(new FluidStack(f,1000),FluidAction.SIMULATE)==1000)
+public abstract class BoilerBlock extends Block implements ILiquidContainer {
+ @Override
+ public boolean canPlaceLiquid(IBlockReader w, BlockPos p, BlockState s, Fluid f) {
+ TileEntity te = w.getBlockEntity(p);
+ if (te instanceof BoilerTileEntity) {
+ BoilerTileEntity boiler = (BoilerTileEntity) te;
+ if (boiler.input.fill(new FluidStack(f, 1000), FluidAction.SIMULATE) == 1000)
return true;
- }
- return false;
+ }
+ return false;
}
@Override
- public boolean placeLiquid(IWorld w, BlockPos p, BlockState s,
- FluidState f){
- TileEntity te=w.getBlockEntity(p);
- if(te instanceof BoilerTileEntity) {
- BoilerTileEntity boiler=(BoilerTileEntity)te;
- if(boiler.input.fill(new FluidStack(f.getType(),1000),FluidAction.SIMULATE)==1000) {
- boiler.input.fill(new FluidStack(f.getType(),1000),FluidAction.EXECUTE);
+ public boolean placeLiquid(IWorld w, BlockPos p, BlockState s, FluidState f) {
+ TileEntity te = w.getBlockEntity(p);
+ if (te instanceof BoilerTileEntity) {
+ BoilerTileEntity boiler = (BoilerTileEntity) te;
+ if (boiler.input.fill(new FluidStack(f.getType(), 1000), FluidAction.SIMULATE) == 1000) {
+ boiler.input.fill(new FluidStack(f.getType(), 1000), FluidAction.EXECUTE);
return true;
}
}
return false;
}
+ @Override
+ public void animateTick(BlockState p_180655_1_, World p_180655_2_, BlockPos p_180655_3_, Random p_180655_4_) {
+ TileEntity te = p_180655_2_.getBlockEntity(p_180655_3_);
+ if (te instanceof BoilerTileEntity) {
+ BoilerTileEntity boiler = (BoilerTileEntity) te;
+ if (boiler.output.getFluidAmount()>=10000) {//steam leaking
+ double d0 = p_180655_3_.getX();
+ double d1 = p_180655_3_.getY() + 1;
+ double d2 = p_180655_3_.getZ();
+ if(p_180655_4_.nextDouble()<0.1D)
+ p_180655_2_.playLocalSound(d0, d1, d2, SoundEvents.FIRE_EXTINGUISH, SoundCategory.BLOCKS, 1.0F, 0.25F, false);
+ p_180655_2_.addParticle(Particles.STEAM.get(), d0+p_180655_4_.nextFloat(), d1, d2+p_180655_4_.nextFloat(), 0.0D, 0.0D, 0.0D);
+ }
+ }
+ }
+
@Override
public boolean hasAnalogOutputSignal(BlockState p_149740_1_) {
return true;
}
public BoilerBlock(Properties properties) {
- super(properties);
- }
-
- @Override
- public int getAnalogOutputSignal(BlockState b, World w, BlockPos p) {
- TileEntity te=w.getBlockEntity(p);
- if(te instanceof BoilerTileEntity) {
- BoilerTileEntity boiler=(BoilerTileEntity)te;
- return boiler.output.getFluidAmount()*15/boiler.output.getCapacity();
- }
- return super.getAnalogOutputSignal(b,w,p);
+ super(properties);
}
@Override
- public boolean hasTileEntity(BlockState state) {
- return true;
- }
- public abstract int getHuConsume() ;
- @Override
- public void appendHoverText(ItemStack i, IBlockReader w, List t,
- ITooltipFlag f) {
- if(Screen.hasShiftDown()) {
- t.add(new TranslationTextComponent("tooltip.steampowered.boiler.brief").withStyle(TextFormatting.GOLD));
- if(ClientUtils.hasGoggles()) {
- t.add(new TranslationTextComponent("tooltip.steampowered.boiler.danger").withStyle(TextFormatting.RED));
- t.add(new TranslationTextComponent("tooltip.steampowered.boiler.huconsume",this.getHuConsume()).withStyle(TextFormatting.GOLD));
- t.add(new TranslationTextComponent("tooltip.steampowered.boiler.waterconsume",((int)Math.ceil(this.getHuConsume()/120.0))).withStyle(TextFormatting.AQUA));
- t.add(new TranslationTextComponent("tooltip.steampowered.boiler.steamproduce",this.getHuConsume()/10).withStyle(TextFormatting.GOLD));
- }
- }else {
- t.add(TooltipHelper.holdShift(Palette.Gray,false));
- }
- if(Screen.hasControlDown()) {
- t.add(new TranslationTextComponent("tooltip.steampowered.boiler.redstone").withStyle(TextFormatting.RED));
- }else {
- t.add(Lang.translate("tooltip.holdForControls", Lang.translate("tooltip.keyCtrl")
- .withStyle(TextFormatting.GRAY))
- .withStyle(TextFormatting.DARK_GRAY));
- }
- super.appendHoverText(i,w,t,f);
+ public int getAnalogOutputSignal(BlockState b, World w, BlockPos p) {
+ TileEntity te = w.getBlockEntity(p);
+ if (te instanceof BoilerTileEntity) {
+ BoilerTileEntity boiler = (BoilerTileEntity) te;
+ return boiler.output.getFluidAmount() * 15 / boiler.output.getCapacity();
+ }
+ return super.getAnalogOutputSignal(b, w, p);
+ }
+
+ @Override
+ public boolean hasTileEntity(BlockState state) {
+ return true;
+ }
+
+ public abstract int getHuConsume();
+
+ @Override
+ public void appendHoverText(ItemStack i, IBlockReader w, List t, ITooltipFlag f) {
+ if (Screen.hasShiftDown()) {
+ t.add(new TranslationTextComponent("tooltip.steampowered.boiler.brief").withStyle(TextFormatting.GOLD));
+ if (ClientUtils.hasGoggles()) {
+ t.add(new TranslationTextComponent("tooltip.steampowered.boiler.danger").withStyle(TextFormatting.RED));
+ t.add(new TranslationTextComponent("tooltip.steampowered.boiler.huconsume", this.getHuConsume())
+ .withStyle(TextFormatting.GOLD));
+ t.add(new TranslationTextComponent("tooltip.steampowered.boiler.waterconsume",
+ ((int) Math.ceil(this.getHuConsume() / 120.0))).withStyle(TextFormatting.AQUA));
+ t.add(new TranslationTextComponent("tooltip.steampowered.boiler.steamproduce", this.getHuConsume() / 10)
+ .withStyle(TextFormatting.GOLD));
+ }
+ } else {
+ t.add(TooltipHelper.holdShift(Palette.Gray, false));
+ }
+ if (Screen.hasControlDown()) {
+ t.add(new TranslationTextComponent("tooltip.steampowered.boiler.redstone").withStyle(TextFormatting.RED));
+ } else {
+ t.add(Lang
+ .translate("tooltip.holdForControls",
+ Lang.translate("tooltip.keyCtrl").withStyle(TextFormatting.GRAY))
+ .withStyle(TextFormatting.DARK_GRAY));
+ }
+ super.appendHoverText(i, w, t, f);
}
@Override
public void stepOn(World w, BlockPos bp, Entity e) {
- TileEntity te=w.getBlockEntity(bp);
- if(te instanceof BoilerTileEntity&&e instanceof LivingEntity) {
- if(((BoilerTileEntity) te).lastheat>0||(!((BoilerTileEntity) te).output.isEmpty())) {
- e.hurt(DamageSource.HOT_FLOOR,2);
+ TileEntity te = w.getBlockEntity(bp);
+ if (te instanceof BoilerTileEntity && e instanceof LivingEntity) {
+ if (((BoilerTileEntity) te).lastheat > 0 || (!((BoilerTileEntity) te).output.isEmpty())) {
+ e.hurt(DamageSource.HOT_FLOOR, 2);
}
}
}
diff --git a/src/main/java/com/teammoeg/steampowered/content/boiler/BoilerTileEntity.java b/src/main/java/com/teammoeg/steampowered/content/boiler/BoilerTileEntity.java
index 21ee2fa..ca486b7 100644
--- a/src/main/java/com/teammoeg/steampowered/content/boiler/BoilerTileEntity.java
+++ b/src/main/java/com/teammoeg/steampowered/content/boiler/BoilerTileEntity.java
@@ -43,19 +43,8 @@ import net.minecraftforge.fluids.capability.templates.FluidTank;
import java.util.List;
public abstract class BoilerTileEntity extends TileEntity implements IHeatReceiver, ITickableTileEntity, IHaveGoggleInformation {
- FluidTank input = new FluidTank(10000,s->s.getFluid() == Fluids.WATER) {
-
- @Override
- public FluidStack getFluid() {
- return new FluidStack(Fluids.WATER,this.getFluidAmount());
- }
- };
- FluidTank output = new FluidTank(10000) {
- @Override
- public FluidStack getFluid() {
- return new FluidStack(FluidRegistry.steam.get().getFluid(),this.getFluidAmount());
- }
- };
+ FluidTank input = new FluidTank(10000,s->s.getFluid() == Fluids.WATER);
+ FluidTank output = new FluidTank(10000);
private IFluidHandler ft = new IFluidHandler() {
@Override
public int getTanks() {
@@ -114,6 +103,7 @@ public abstract class BoilerTileEntity extends TileEntity implements IHeatReceiv
input.readFromNBT(nbt.getCompound("in"));
output.readFromNBT(nbt.getCompound("out"));
heatreceived = nbt.getInt("hu");
+ lastheat=nbt.getInt("lasthu");
}
// Easy, easy
@@ -121,6 +111,7 @@ public abstract class BoilerTileEntity extends TileEntity implements IHeatReceiv
nbt.put("in", input.writeToNBT(new CompoundNBT()));
nbt.put("out", output.writeToNBT(new CompoundNBT()));
nbt.putInt("hu", heatreceived);
+ nbt.putInt("lasthu", lastheat);
}
@Override
@@ -159,7 +150,7 @@ public abstract class BoilerTileEntity extends TileEntity implements IHeatReceiv
public void tick() {
lastheat=heatreceived;
//debug
- if (this.level != null && !this.level.isClientSide) {
+ if (this.level != null && !this.level.isClientSide&&heatreceived!=0) {
int consume = Math.min(getHUPerTick(), heatreceived);
heatreceived = 0;
double waterconsume=(SPConfig.COMMON.steamPerWater.get()*10);
@@ -167,6 +158,7 @@ public abstract class BoilerTileEntity extends TileEntity implements IHeatReceiv
this.output.fill(new FluidStack(FluidRegistry.steam.get().getFluid(), consume / 10), FluidAction.EXECUTE);
this.level.sendBlockUpdated(this.getBlockPos(),this.getBlockState(),this.getBlockState(), 3);
+ this.setChanged();
}
}
diff --git a/src/main/java/com/teammoeg/steampowered/content/burner/BurnerBlock.java b/src/main/java/com/teammoeg/steampowered/content/burner/BurnerBlock.java
index 3ad0121..d44134c 100644
--- a/src/main/java/com/teammoeg/steampowered/content/burner/BurnerBlock.java
+++ b/src/main/java/com/teammoeg/steampowered/content/burner/BurnerBlock.java
@@ -37,6 +37,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
+import net.minecraft.particles.ParticleTypes;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
@@ -46,6 +47,8 @@ import net.minecraft.util.ActionResultType;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
+import net.minecraft.util.SoundCategory;
+import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.text.ITextComponent;
@@ -67,6 +70,29 @@ public abstract class BurnerBlock extends Block {
}
@Override
+ public void animateTick(BlockState bs, World w, BlockPos bp, Random r) {
+ super.animateTick(bs, w, bp, r);
+ if (bs.getValue(BurnerBlock.LIT)) {
+ double d0 = bp.getX() + 0.5D;
+ double d1 = bp.getY();
+ double d2 = bp.getZ() + 0.5D;
+ if (r.nextDouble() < 0.2D) {
+ w.playLocalSound(d0, d1, d2, SoundEvents.FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
+ }
+ if (r.nextDouble() < 0.5D) {
+ Direction direction = bs.getValue(BurnerBlock.FACING);
+ Direction.Axis direction$axis = direction.getAxis();
+ double d4 = w.getRandom().nextDouble() * 0.6D - 0.3D;
+ double d5 = direction$axis == Direction.Axis.X ? direction.getStepX() * 0.52D : d4;
+ double d6 = w.getRandom().nextDouble() * 6.0D / 16.0D;
+ double d7 = direction$axis == Direction.Axis.Z ? direction.getStepZ() * 0.52D : d4;
+ w.addParticle(ParticleTypes.SMOKE, d0 + d5, d1 + d6, d2 + d7, 0.0D, 0.0D, 0.0D);
+ w.addParticle(ParticleTypes.FLAME, d0 + d5, d1 + d6, d2 + d7, 0.0D, 0.0D, 0.0D);
+ }
+ }
+ }
+
+ @Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
Direction facing = context.getClickedFace();
return this.defaultBlockState().setValue(FACING, facing.getAxis().isVertical() ? context.getHorizontalDirection().getOpposite() : facing).setValue(LIT, Boolean.valueOf(false)).setValue(REDSTONE_LOCKED,false);
diff --git a/src/main/java/com/teammoeg/steampowered/content/burner/BurnerTileEntity.java b/src/main/java/com/teammoeg/steampowered/content/burner/BurnerTileEntity.java
index e37fa1e..cbd8b08 100644
--- a/src/main/java/com/teammoeg/steampowered/content/burner/BurnerTileEntity.java
+++ b/src/main/java/com/teammoeg/steampowered/content/burner/BurnerTileEntity.java
@@ -125,27 +125,6 @@ public abstract class BurnerTileEntity extends TileEntity implements ITickableTi
@Override
public void tick() {
- if (level != null && level.isClientSide) {
- BlockState state = this.level.getBlockState(this.worldPosition);
- if (state.getValue(BurnerBlock.LIT)) {
- double d0 = (double)getBlockPos().getX() + 0.5D;
- double d1 = (double)getBlockPos().getY();
- double d2 = (double)getBlockPos().getZ() + 0.5D;
- if (this.level.getRandom().nextDouble() < 0.1D) {
- this.level.playLocalSound(d0, d1, d2, SoundEvents.FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
- }
-
- Direction direction = state.getValue(BurnerBlock.FACING);
- Direction.Axis direction$axis = direction.getAxis();
- double d3 = 0.52D;
- double d4 = this.level.getRandom().nextDouble() * 0.6D - 0.3D;
- double d5 = direction$axis == Direction.Axis.X ? (double)direction.getStepX() * 0.52D : d4;
- double d6 = this.level.getRandom().nextDouble() * 6.0D / 16.0D;
- double d7 = direction$axis == Direction.Axis.Z ? (double)direction.getStepZ() * 0.52D : d4;
- this.level.addParticle(ParticleTypes.SMOKE, d0 + d5, d1 + d6, d2 + d7, 0.0D, 0.0D, 0.0D);
- this.level.addParticle(ParticleTypes.FLAME, d0 + d5, d1 + d6, d2 + d7, 0.0D, 0.0D, 0.0D);
- }
- }
if (level != null && !level.isClientSide) {
BlockState state = this.level.getBlockState(this.worldPosition);
int emit = getHuPerTick();
@@ -186,6 +165,7 @@ public abstract class BurnerTileEntity extends TileEntity implements ITickableTi
@Override
public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) {
tooltip.add(componentSpacing.plainCopy().append(new TranslationTextComponent("tooltip.steampowered.burner.hu", HURemain).withStyle(TextFormatting.GOLD)));
+ if(!inv.getStackInSlot(0).isEmpty())
tooltip.add(componentSpacing.plainCopy().append(new TranslationTextComponent("tooltip.steampowered.burner.item", inv.getStackInSlot(0).getCount(), inv.getStackInSlot(0).getItem().getName(inv.getStackInSlot(0))).withStyle(TextFormatting.GRAY)));
return true;
}
diff --git a/src/main/java/com/teammoeg/steampowered/content/engine/SteamEngineBlock.java b/src/main/java/com/teammoeg/steampowered/content/engine/SteamEngineBlock.java
index 09d9ab4..95e8cb2 100644
--- a/src/main/java/com/teammoeg/steampowered/content/engine/SteamEngineBlock.java
+++ b/src/main/java/com/teammoeg/steampowered/content/engine/SteamEngineBlock.java
@@ -24,14 +24,15 @@ import com.simibubi.create.AllShapes;
import com.simibubi.create.content.contraptions.components.flywheel.engine.EngineBlock;
import com.teammoeg.steampowered.FluidRegistry;
import com.teammoeg.steampowered.ItemRegistry;
+import com.teammoeg.steampowered.client.Particles;
import com.teammoeg.steampowered.registrate.SPTiles;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
+import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
-import net.minecraft.particles.ParticleTypes;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
@@ -95,9 +96,9 @@ public class SteamEngineBlock extends EngineBlock {
@OnlyIn(Dist.CLIENT)
public void animateTick(BlockState p_180655_1_, World p_180655_2_, BlockPos p_180655_3_, Random p_180655_4_) {
if (p_180655_1_.getValue(LIT)) {
- double d0 = (double) p_180655_3_.getX() + 0.5D;
- double d1 = (double) p_180655_3_.getY();
- double d2 = (double) p_180655_3_.getZ() + 0.5D;
+ double d0 = p_180655_3_.getX() + 0.5D;
+ double d1 = p_180655_3_.getY();
+ double d2 = p_180655_3_.getZ() + 0.5D;
if (p_180655_4_.nextDouble() < 0.1D) {
p_180655_2_.playLocalSound(d0, d1, d2, SoundEvents.BLASTFURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
}
@@ -106,10 +107,10 @@ public class SteamEngineBlock extends EngineBlock {
Direction.Axis direction$axis = direction.getAxis();
double d3 = 0.52D;
double d4 = p_180655_4_.nextDouble() * 0.6D - 0.3D;
- double d5 = direction$axis == Direction.Axis.X ? (double) direction.getStepX() * 0.52D : d4;
+ double d5 = direction$axis == Direction.Axis.X ? direction.getStepX() * 0.52D : d4;
double d6 = p_180655_4_.nextDouble() * 9.0D / 16.0D;
- double d7 = direction$axis == Direction.Axis.Z ? (double) direction.getStepZ() * 0.52D : d4;
- p_180655_2_.addParticle(ParticleTypes.LAVA, d0 + d5, d1 + d6, d2 + d7, 0.0D, 0.0D, 0.0D);
+ double d7 = direction$axis == Direction.Axis.Z ? direction.getStepZ() * 0.52D : d4;
+ p_180655_2_.addParticle(Particles.STEAM.get(), d0 + d5, d1 + d6, d2 + d7, 0.0D, 0.0D, 0.0D);
}
}
@@ -121,13 +122,14 @@ public class SteamEngineBlock extends EngineBlock {
SteamEngineTileEntity steamEngine = (SteamEngineTileEntity) te;
IFluidHandler cap = steamEngine.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY).resolve().get();
cap.fill(new FluidStack(FluidRegistry.steam.get(), 1000), IFluidHandler.FluidAction.EXECUTE);
- player.setItemInHand(hand, new ItemStack(ItemRegistry.pressurizedGasContainer.get()));
+ player.getItemInHand(hand).shrink(1);
+ ItemStack ret=new ItemStack(ItemRegistry.pressurizedGasContainer.get());
+ if(!player.addItem(ret))
+ world.addFreshEntity(new ItemEntity(world, pos.getX(),pos.getY(),pos.getZ(),ret));
return ActionResultType.SUCCESS;
- } else {
- return ActionResultType.PASS;
}
- } else {
- return super.use(state, world, pos, player, hand, blockRayTraceResult);
+ return ActionResultType.PASS;
}
+ return super.use(state, world, pos, player, hand, blockRayTraceResult);
}
}
diff --git a/src/main/resources/assets/steampowered/particles/steam.json b/src/main/resources/assets/steampowered/particles/steam.json
new file mode 100644
index 0000000..9e90fe4
--- /dev/null
+++ b/src/main/resources/assets/steampowered/particles/steam.json
@@ -0,0 +1,8 @@
+{
+ "textures": [
+ "steampowered:steam_0",
+ "steampowered:steam_1",
+ "steampowered:steam_2",
+ "steampowered:steam_3"
+ ]
+}
\ No newline at end of file
diff --git a/src/main/resources/assets/steampowered/textures/particle/steam_0.png b/src/main/resources/assets/steampowered/textures/particle/steam_0.png
new file mode 100644
index 0000000000000000000000000000000000000000..8dc83cbd002ddecf7f9239899f7de31e6f011a98
GIT binary patch
literal 106
zcmeAS@N?(olHy`uVBq!ia0vp^93afZ3?z3ZhDiV^&H$efS0MfL|Nk%Fze^`&f;fyN
yL4Lsu4$p3+0Xh7hE{-7;w~`OA=Kr~
literal 0
HcmV?d00001
diff --git a/src/main/resources/assets/steampowered/textures/particle/steam_1.png b/src/main/resources/assets/steampowered/textures/particle/steam_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..ccb945211c212206af1ca9ba736cf7a7948ecd4b
GIT binary patch
literal 105
zcmeAS@N?(olHy`uVBq!ia0vp^93afZ3?z3ZhDiV^&H$efS0MfL|Nk%Fze^`&f;fyN
wL4Lsu4$p3+0Xcl0E{-7;w~`OA=s4T~^4Bo5#w~ex0LWtSboFyt=akR{0O?p9EC2ui
literal 0
HcmV?d00001
diff --git a/src/main/resources/assets/steampowered/textures/particle/steam_2.png b/src/main/resources/assets/steampowered/textures/particle/steam_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..581561452f8e6593c08a02d7e1fb01dd829801ca
GIT binary patch
literal 101
zcmeAS@N?(olHy`uVBq!ia0vp^93afW3?x5a^xFxf*aCb)T!HkL@89$Lir9cG#*!ev
uU&t;ucLK6Vpq#CIJ
literal 0
HcmV?d00001