Search in sources :

Example 1 with MCAWrappedPalettedContainer

use of com.volmit.iris.util.nbt.mca.palette.MCAWrappedPalettedContainer in project Iris by VolmitSoftware.

the class NMSBinding18_1 method createPalette.

@Override
public MCAPaletteAccess createPalette() {
    MCAIdMapper<BlockState> registry = registryCache.aquireNasty(() -> {
        Field cf = net.minecraft.core.IdMapper.class.getDeclaredField("tToId");
        Field df = net.minecraft.core.IdMapper.class.getDeclaredField("idToT");
        Field bf = net.minecraft.core.IdMapper.class.getDeclaredField("nextId");
        cf.setAccessible(true);
        df.setAccessible(true);
        bf.setAccessible(true);
        net.minecraft.core.IdMapper<BlockState> blockData = Block.BLOCK_STATE_REGISTRY;
        int b = bf.getInt(blockData);
        Object2IntMap<BlockState> c = (Object2IntMap<BlockState>) cf.get(blockData);
        List<BlockState> d = (List<BlockState>) df.get(blockData);
        return new MCAIdMapper<BlockState>(c, d, b);
    });
    MCAPalette<BlockState> global = globalCache.aquireNasty(() -> new MCAGlobalPalette<>(registry, ((CraftBlockData) AIR).getState()));
    MCAPalettedContainer<BlockState> container = new MCAPalettedContainer<>(global, registry, i -> ((CraftBlockData) NBTWorld.getBlockData(i)).getState(), i -> NBTWorld.getCompound(CraftBlockData.fromData(i)), ((CraftBlockData) AIR).getState());
    return new MCAWrappedPalettedContainer<>(container, i -> NBTWorld.getCompound(CraftBlockData.fromData(i)), i -> ((CraftBlockData) NBTWorld.getBlockData(i)).getState());
}
Also used : Object2IntMap(it.unimi.dsi.fastutil.objects.Object2IntMap) Field(java.lang.reflect.Field) CraftBlockData(org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData) BlockState(net.minecraft.world.level.block.state.BlockState) List(java.util.List) MCAPalettedContainer(com.volmit.iris.util.nbt.mca.palette.MCAPalettedContainer) MCAWrappedPalettedContainer(com.volmit.iris.util.nbt.mca.palette.MCAWrappedPalettedContainer) MCAIdMapper(com.volmit.iris.util.nbt.mca.palette.MCAIdMapper)

Aggregations

MCAIdMapper (com.volmit.iris.util.nbt.mca.palette.MCAIdMapper)1 MCAPalettedContainer (com.volmit.iris.util.nbt.mca.palette.MCAPalettedContainer)1 MCAWrappedPalettedContainer (com.volmit.iris.util.nbt.mca.palette.MCAWrappedPalettedContainer)1 Object2IntMap (it.unimi.dsi.fastutil.objects.Object2IntMap)1 Field (java.lang.reflect.Field)1 List (java.util.List)1 BlockState (net.minecraft.world.level.block.state.BlockState)1 CraftBlockData (org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData)1