版本信息
你使用的系统:Ubuntu20.04 x64
你是用的JDK: openjdk-8u252
你使用的IDE:IntelliJ IDEA
你使用的IDE版本: 2020.2
Forge版本: 31.2.0
Minecraft版本: 1.15.2
Mapping 文件版本: 20200717-1.15.1
出错图
(无法用图片描述)
错误情况简述
我想在MC加入一种新的流体,在继承ForgeFlowingFluid之后,通过ForgeFlowingFluid自带的一些方法,指定了流体的粘度、密度等内容。但在游戏中,玩家浸入流体后,却像在空气中一样(即流体粘度为0)。
相关代码
ShitFluid.java
public abstract class ShitFluid extends ForgeFlowingFluid {
private static final ResourceLocation STILL = new ResourceLocation(Hamburger.MODID, "block/shit_still");
private static final ResourceLocation FLOWING = new ResourceLocation(Hamburger.MODID, "block/shit_flow");
private static final ResourceLocation OVERLAY = new ResourceLocation(Hamburger.MODID, "block/shit_overlay");
protected ShitFluid() {
super(new Properties(() -> Fluids.SHIT, () -> Fluids.FLOWING_SHIT, FluidAttributes.builder(STILL, FLOWING)
// .color(0xff643c00)
.density(2000) // 粘度
.viscosity(4000) // 密度
.overlay(OVERLAY)
.translationKey("block.hamburger.shit")
.temperature(300)
)
.canMultiply()
.slopeFindDistance(4)
.levelDecreasePerBlock(1)
.bucket(() -> Items.SHIT_BUCKET)
.tickRate(6)
.explosionResistance(100.0F)
.block(() -> (FlowingFluidBlock) Blocks.SHIT_FLUID_BLOCK)
);
}
@Override
protected void animateTick(World worldIn, BlockPos pos, IFluidState state, Random random) {
if (!state.isSource() && !state.get(FALLING)) {
if (random.nextInt(64) == 0) {
worldIn.playSound((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, SoundEvents.BLOCK_WATER_AMBIENT, SoundCategory.BLOCKS, random.nextFloat() * 0.25F + 0.75F, random.nextFloat() + 0.5F, false);
}
} else if (random.nextInt(10) == 0) {
worldIn.addParticle(ParticleTypes.UNDERWATER, (double)pos.getX() + (double)random.nextFloat(), (double)pos.getY() + (double)random.nextFloat(), (double)pos.getZ() + (double)random.nextFloat(), 0.0D, 0.0D, 0.0D);
}
}
public static class Flowing extends ShitFluid {
protected void fillStateContainer(@Nonnull StateContainer.Builder<Fluid, IFluidState> builder) {
super.fillStateContainer(builder);
builder.add(LEVEL_1_8);
}
@Override
public int getLevel(IFluidState state) {
return state.get(LEVEL_1_8);
}
@Override
public boolean isSource(IFluidState state) {
return false;
}
}
public static class Source extends ShitFluid {
public int getLevel(@Nonnull IFluidState p_207192_1_) {
return 8;
}
public boolean isSource(IFluidState state) {
return true;
}
}
}