-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
168 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 41 additions & 1 deletion
42
src/main/java/com/moulberry/axiom/viaversion/ViaVersionHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,42 @@ | ||
package com.moulberry.axiom.viaversion;public class ViaVersionHelper { | ||
package com.moulberry.axiom.viaversion; | ||
|
||
import com.moulberry.axiom.buffer.BlockBuffer; | ||
import com.viaversion.viaversion.api.data.BiMappings; | ||
import com.viaversion.viaversion.api.data.Mappings; | ||
import net.minecraft.core.IdMapper; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
|
||
public class ViaVersionHelper { | ||
|
||
public static IdMapper<BlockState> applyMappings(IdMapper<BlockState> registry, BiMappings mappings) { | ||
IdMapper<BlockState> newBlockRegistry = new IdMapper<>(); | ||
|
||
// Add empty mappings for non-existent blocks | ||
int size = mappings.mappedSize(); | ||
for (int i = 0; i < size; i++) { | ||
newBlockRegistry.addMapping(BlockBuffer.EMPTY_STATE, i); | ||
} | ||
|
||
// Map blocks | ||
for (int i = 0; i < registry.size(); i++) { | ||
BlockState blockState = registry.byId(i); | ||
|
||
if (blockState != null) { | ||
int newId = mappings.getNewId(i); | ||
if (newId >= 0) { | ||
newBlockRegistry.addMapping(blockState, newId); | ||
} | ||
} | ||
} | ||
|
||
// Ensure block -> id is correct for the empty state | ||
int newEmptyStateId = mappings.getNewId(registry.getId(BlockBuffer.EMPTY_STATE)); | ||
if (newEmptyStateId >= 0) { | ||
newBlockRegistry.addMapping(BlockBuffer.EMPTY_STATE, newEmptyStateId); | ||
} | ||
|
||
return newBlockRegistry; | ||
} | ||
|
||
} |
Oops, something went wrong.