Porting Lib

Porting Lib

455k Downloads

Incompatible with other mods.

Yefancy opened this issue ยท 0 comments

commented

public TerrainParticle updateSprite(BlockState state, BlockPos pos) {
Minecraft mc = Minecraft.getInstance();
BakedModel model = mc.getModelManager().getBlockModelShaper().getBlockModel(state);
TextureAtlasSprite sprite;
if (model instanceof CustomParticleIconModel custom && mc.level instanceof RenderAttachedBlockView view) {
Object data = view.getBlockEntityRenderAttachment(pos);
sprite = custom.getParticleIcon(data);
} else {
sprite = model.getParticleIcon();
}
setSprite(sprite);
return (TerrainParticle) (Object) this;
}

Issue:

other mods might also hook custom particle sprite for TerrianParticle. When they have already set a correct sprite. This mod will break it by sprite = model.getParticleIcon().

Expectation:

Do not affect other mods.

Solution:

Do not do anything if the modle is not an instance of CustomParticleIconModel.

@Override
public TerrainParticle updateSprite(BlockState state, BlockPos pos) {
	Minecraft mc = Minecraft.getInstance();
	BakedModel model = mc.getModelManager().getBlockModelShaper().getBlockModel(state);
	TextureAtlasSprite sprite;
	if (model instanceof CustomParticleIconModel custom && mc.level instanceof RenderAttachedBlockView view) {
		Object data = view.getBlockEntityRenderAttachment(pos);
		sprite = custom.getParticleIcon(data);
                setSprite(sprite);
	} 
	return (TerrainParticle) (Object) this;
}