dont use vanilla registries

This commit is contained in:
dfsek
2021-05-01 22:21:27 -07:00
parent fddf0c51b7
commit 9956cab507
6 changed files with 18 additions and 28 deletions

View File

@@ -4,6 +4,7 @@ import com.dfsek.terra.api.platform.inventory.ItemStack;
import com.dfsek.terra.api.platform.inventory.item.Enchantment;
import com.dfsek.terra.forge.world.ForgeAdapter;
import net.minecraft.util.registry.Registry;
import net.minecraftforge.registries.ForgeRegistries;
import java.util.Objects;
@@ -26,7 +27,7 @@ public class ForgeEnchantment implements Enchantment {
@Override
public String getID() {
return Objects.requireNonNull(Registry.ENCHANTMENT.getKey(enchantment)).toString();
return Objects.requireNonNull(ForgeRegistries.ENCHANTMENTS.getKey(enchantment)).toString();
}
@Override

View File

@@ -9,6 +9,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.command.arguments.ItemArgument;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import net.minecraftforge.registries.ForgeRegistries;
import java.util.Set;
import java.util.stream.Collectors;
@@ -26,11 +27,11 @@ public class ForgeItemHandle implements ItemHandle {
@Override
public Enchantment getEnchantment(String id) {
return ForgeAdapter.adapt(Registry.ENCHANTMENT.get(ResourceLocation.tryParse(id)));
return ForgeAdapter.adapt(ForgeRegistries.ENCHANTMENTS.getValue(ResourceLocation.tryParse(id)));
}
@Override
public Set<Enchantment> getEnchantments() {
return Registry.ENCHANTMENT.stream().map(ForgeAdapter::adapt).collect(Collectors.toSet());
return ForgeRegistries.ENCHANTMENTS.getEntries().stream().map(entry -> ForgeAdapter.adapt(entry.getValue())).collect(Collectors.toSet());
}
}

View File

@@ -1,11 +1,6 @@
package com.dfsek.terra.forge.mixin;
import net.minecraft.client.audio.BackgroundMusicSelector;
import net.minecraft.util.SoundEvent;
import net.minecraft.world.biome.BiomeAmbience;
import net.minecraft.world.biome.MoodSoundAmbience;
import net.minecraft.world.biome.ParticleEffectAmbience;
import net.minecraft.world.biome.SoundAdditionsAmbience;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@@ -33,19 +28,4 @@ public interface BiomeAmbienceAccessor {
@Accessor
BiomeAmbience.GrassColorModifier getGrassColorModifier();
@Accessor
Optional<ParticleEffectAmbience> getAmbientParticleSettings();
@Accessor
Optional<SoundEvent> getAmbientLoopSoundEvent();
@Accessor
Optional<MoodSoundAmbience> getAmbientMoodSettings();
@Accessor
Optional<SoundAdditionsAmbience> getAmbientAdditionsSettings();
@Accessor
Optional<BackgroundMusicSelector> getBackgroundMusic();
}

View File

@@ -9,6 +9,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.command.arguments.BlockStateParser;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import net.minecraftforge.registries.ForgeRegistries;
import java.util.Locale;
@@ -30,6 +31,6 @@ public class ForgeWorldHandle implements WorldHandle {
public EntityType getEntity(String id) {
ResourceLocation identifier = ResourceLocation.tryParse(id);
if(identifier == null) identifier = ResourceLocation.tryParse("minecraft:" + id.toLowerCase(Locale.ROOT));
return ForgeAdapter.adapt(Registry.ENTITY_TYPE.get(identifier));
return ForgeAdapter.adapt(ForgeRegistries.ENTITIES.getValue(identifier));
}
}

View File

@@ -8,6 +8,7 @@ import com.dfsek.terra.forge.world.ForgeAdapter;
import net.minecraft.tileentity.MobSpawnerTileEntity;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.IWorld;
import net.minecraftforge.registries.ForgeRegistries;
import org.jetbrains.annotations.NotNull;
public class ForgeMobSpawner extends ForgeBlockState implements MobSpawner { // TODO: finish implementation / refactor API because bukkit doesnt expose most of the stuff spawners can do
@@ -19,7 +20,7 @@ public class ForgeMobSpawner extends ForgeBlockState implements MobSpawner { //
@Override
public EntityType getSpawnedType() {
return ForgeAdapter.adapt(Registry.ENTITY_TYPE.get(((MobSpawnerTileEntity) blockEntity).getSpawner().getSpawnerEntity().getType().getRegistryName()));
return ForgeAdapter.adapt(ForgeRegistries.ENTITIES.getValue(((MobSpawnerTileEntity) blockEntity).getSpawner().getSpawnerEntity().getType().getRegistryName()));
}
@Override