Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #42 #43

Open
wants to merge 2 commits into
base: mc1.20.1/dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package fr.lucreeper74.createmetallurgy.content.fluids;

import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.material.FluidState;
import net.minecraftforge.fluids.ForgeFlowingFluid;

public class MoltenFluidSource extends ForgeFlowingFluid.Source {
public MoltenFluidSource(Properties properties) {
super(properties);
}

@Override
public void animateTick(Level pLevel, BlockPos pPos, FluidState pState, RandomSource pRandom) {
super.animateTick(pLevel, pPos, pState, pRandom);

BlockPos blockpos = pPos.above();
if (pLevel.getBlockState(blockpos).isAir() && !pLevel.getBlockState(blockpos).isSolidRender(pLevel, blockpos)) {
if (pRandom.nextInt(100) == 0) {
double d0 = (double)pPos.getX() + pRandom.nextDouble();
double d1 = (double)pPos.getY() + (double)1.0F;
double d2 = (double)pPos.getZ() + pRandom.nextDouble();
pLevel.addParticle(ParticleTypes.LAVA, d0, d1, d2, 0.0F, 0.0F, 0.0F);
pLevel.playLocalSound(d0, d1, d2, SoundEvents.LAVA_POP, SoundSource.BLOCKS, 0.2F + pRandom.nextFloat() * 0.2F, 0.9F + pRandom.nextFloat() * 0.15F, false);
}

if (pRandom.nextInt(200) == 0) {
pLevel.playLocalSound(pPos.getX(), pPos.getY(), pPos.getZ(), SoundEvents.LAVA_AMBIENT, SoundSource.BLOCKS, 0.2F + pRandom.nextFloat() * 0.2F, 0.9F + pRandom.nextFloat() * 0.15F, false);
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
import fr.lucreeper74.createmetallurgy.registries.CMDamageTypes;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.vehicle.Boat;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.fluids.FluidStack;
Expand All @@ -29,13 +34,34 @@ protected int getTintColor(FluidState state, BlockAndTintGetter getter, BlockPos

@Override
public boolean move(FluidState state, LivingEntity entity, Vec3 movementVector, double gravity) {
entity.setDeltaMovement(entity.getDeltaMovement().scale(0.6d));
entity.setDeltaMovement(entity.getDeltaMovement().multiply(0.6F, 1.0F, 0.6F));
entity.hurt(CMDamageTypes.moltenFluid(entity.level()), 4.0F);
entity.setSecondsOnFire(15);

return false;
}

@Override
public void setItemMovement(ItemEntity entity) {
BlockPos pos = entity.getOnPos();
Level level = entity.level();
double pX = pos.getX();
double pY = pos.getY();
double pZ = pos.getZ();
entity.setSecondsOnFire(15);
if(entity.fireImmune()){
Vec3 vec3 = entity.getDeltaMovement();
entity.setDeltaMovement(vec3.x * (double)0.99F, vec3.y + (double)(vec3.y < (double)0.06F ? 5.0E-4F : 0.0F), vec3.z * (double)0.99F);
} else {
level.playLocalSound(pX, pY, pZ, SoundEvents.LAVA_EXTINGUISH, SoundSource.BLOCKS, 0.3F, 3.0F, false);
}
}

@Override
public boolean supportsBoating(Boat boat) {
boat.setSecondsOnFire(10);
return super.supportsBoating(boat);
}

public boolean canExtinguish(Entity entity) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.tterrag.registrate.util.entry.FluidEntry;
import fr.lucreeper74.createmetallurgy.CreateMetallurgy;
import fr.lucreeper74.createmetallurgy.content.fluids.MoltenFluidSource;
import fr.lucreeper74.createmetallurgy.content.fluids.MoltenFluidType;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
Expand Down Expand Up @@ -53,7 +54,7 @@ private static FluidEntry<ForgeFlowingFluid.Flowing> moltenFluid(String name, in
.slopeFindDistance(slopeDistance)
.explosionResistance(explosionResistance))
.tag(forgeFluidTag("molten_" + name), forgeFluidTag("molten_materials"))
.source(ForgeFlowingFluid.Source::new)
.source(MoltenFluidSource::new)
.bucket()
.build()
.register();
Expand Down