43 lines
		
	
	
	
		
			1.4 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
	
		
			1.4 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package net.minecraft.util.datafix.fixes;
 | |
| 
 | |
| import com.mojang.datafixers.DSL;
 | |
| import com.mojang.datafixers.Typed;
 | |
| import com.mojang.datafixers.schemas.Schema;
 | |
| import com.mojang.serialization.Dynamic;
 | |
| import java.util.Optional;
 | |
| 
 | |
| public class AreaEffectCloudPotionFix extends NamedEntityFix {
 | |
| 	public AreaEffectCloudPotionFix(Schema outputSchema) {
 | |
| 		super(outputSchema, false, "AreaEffectCloudPotionFix", References.ENTITY, "minecraft:area_effect_cloud");
 | |
| 	}
 | |
| 
 | |
| 	@Override
 | |
| 	protected Typed<?> fix(Typed<?> typed) {
 | |
| 		return typed.update(DSL.remainderFinder(), this::fix);
 | |
| 	}
 | |
| 
 | |
| 	private <T> Dynamic<T> fix(Dynamic<T> tag) {
 | |
| 		Optional<Dynamic<T>> optional = tag.get("Color").result();
 | |
| 		Optional<Dynamic<T>> optional2 = tag.get("effects").result();
 | |
| 		Optional<Dynamic<T>> optional3 = tag.get("Potion").result();
 | |
| 		tag = tag.remove("Color").remove("effects").remove("Potion");
 | |
| 		if (optional.isEmpty() && optional2.isEmpty() && optional3.isEmpty()) {
 | |
| 			return tag;
 | |
| 		} else {
 | |
| 			Dynamic<T> dynamic = tag.emptyMap();
 | |
| 			if (optional.isPresent()) {
 | |
| 				dynamic = dynamic.set("custom_color", (Dynamic<?>)optional.get());
 | |
| 			}
 | |
| 
 | |
| 			if (optional2.isPresent()) {
 | |
| 				dynamic = dynamic.set("custom_effects", (Dynamic<?>)optional2.get());
 | |
| 			}
 | |
| 
 | |
| 			if (optional3.isPresent()) {
 | |
| 				dynamic = dynamic.set("potion", (Dynamic<?>)optional3.get());
 | |
| 			}
 | |
| 
 | |
| 			return tag.set("potion_contents", dynamic);
 | |
| 		}
 | |
| 	}
 | |
| }
 |