BiomePicker mixin
This commit is contained in:
parent
46c6e9b936
commit
3bc88af019
6 changed files with 62 additions and 43 deletions
|
@ -0,0 +1,38 @@
|
|||
package ru.betterend.mixin.common;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.fabricmc.fabric.impl.biome.InternalBiomeData;
|
||||
import net.fabricmc.fabric.impl.biome.WeightedBiomePicker;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.BiomeKeys;
|
||||
import ru.betterend.interfaces.IBiomeList;
|
||||
|
||||
@Mixin(value = WeightedBiomePicker.class, remap = false)
|
||||
public class WeightedBiomePickerMixin implements IBiomeList {
|
||||
private List<RegistryKey<Biome>> biomes = Lists.newArrayList();
|
||||
|
||||
@Inject(method = "addBiome", at = @At("TAIL"))
|
||||
private void be_addBiome(final RegistryKey<Biome> biome, final double weight, CallbackInfo info) {
|
||||
if (be_isCorrectPicker((WeightedBiomePicker) (Object) this)) {
|
||||
biomes.add(biome);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RegistryKey<Biome>> getBiomes() {
|
||||
return biomes;
|
||||
}
|
||||
|
||||
private boolean be_isCorrectPicker(WeightedBiomePicker picker) {
|
||||
return picker == InternalBiomeData.getEndBiomesMap().get(BiomeKeys.SMALL_END_ISLANDS) || picker == InternalBiomeData.getEndBarrensMap().get(BiomeKeys.END_BARRENS);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue