Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4d2c1ba
Add support for multiple mods remapping the same item/block/tile entity.
C0bra5 Jan 19, 2026
36de68e
add dummy item auto-creation
C0bra5 Jan 20, 2026
5d4b657
Move dummy item creation to the load complete event.
C0bra5 Jan 20, 2026
6d58c41
move internal stuff to a non-api endpoint and clean-up added structures
C0bra5 Jan 20, 2026
5c524c2
typo fix
C0bra5 Jan 20, 2026
1f5a792
add helper functions to api to stream development
C0bra5 Jan 20, 2026
bd30015
add stack handlers for item -> item+meta
C0bra5 Jan 21, 2026
b81f3d5
spotless apply
C0bra5 Jan 21, 2026
0fb3c22
Speedup simple transformers by caching meta map into lambda capture.
C0bra5 Jan 23, 2026
bc3d26e
transformer optimisations and improve public API clarity.
C0bra5 Jan 23, 2026
d20a5fe
doc cleanup
C0bra5 Jan 23, 2026
9672270
isolate simple transformations to own file + more doc + cleanup
C0bra5 Jan 23, 2026
ccb579f
spotless bad
C0bra5 Jan 23, 2026
78e3f79
replacement -> transformer refactor
C0bra5 Jan 24, 2026
3868d13
any mentions of nuke dummies, add new interfaces that better serve go…
C0bra5 Jan 27, 2026
8fec8f2
properly handle the result of TE NBT transformers.
C0bra5 Jan 27, 2026
2b56022
spotless apply
C0bra5 Jan 27, 2026
99f6158
Add proper examples to readme.
C0bra5 Jan 28, 2026
3b03d62
copy paste errors are funny.
C0bra5 Jan 28, 2026
494da5c
fix typos
C0bra5 Jan 28, 2026
4ebaff3
readme 2nd pass
C0bra5 Jan 28, 2026
d3d42d2
Update README.md
C0bra5 Jan 28, 2026
3f8beb3
add disabled example file
C0bra5 Jan 31, 2026
74dc712
remove deprecated endpoints
C0bra5 Jan 31, 2026
cf3d0c2
god i love typos
C0bra5 Jan 31, 2026
4916cc2
fix doc
C0bra5 Jan 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package com.gtnewhorizons.postea.api;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;

import net.minecraft.world.World;

import com.google.common.collect.LinkedListMultimap;
import com.gtnewhorizons.postea.utility.BlockConversionInfo;

import it.unimi.dsi.fastutil.ints.IntOpenHashSet;

public class BlockReplacementManager {

public static final Map<String, BiFunction<BlockConversionInfo, World, BlockConversionInfo>> blockReplacementMap = new HashMap<>();
public static final LinkedListMultimap<String, BiFunction<BlockConversionInfo, World, BlockConversionInfo>> blockReplacementMap = LinkedListMultimap
.create();
public static final IntOpenHashSet posteaMarkedIDs = new IntOpenHashSet();

@SuppressWarnings("unused")
Expand All @@ -22,15 +22,12 @@ public static void addBlockReplacement(String blockNameIn,
}

public static BlockConversionInfo getBlockReplacement(BlockConversionInfo blockConversionInfo, World world) {

BiFunction<BlockConversionInfo, World, BlockConversionInfo> transformer = blockReplacementMap
.getOrDefault(blockConversionInfo.blockName, null);

if (transformer == null) {
return null;
} else {
return transformer.apply(blockConversionInfo, world);
for (BiFunction<BlockConversionInfo, World, BlockConversionInfo> transformer : blockReplacementMap
.get(blockConversionInfo.blockName)) {
BlockConversionInfo result = transformer.apply(blockConversionInfo, world);
if (result != null) return result;
}
return null;
}

// We need this to save reprocessing blocks.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package com.gtnewhorizons.postea.api;

import java.util.HashMap;
import java.util.Map;
import java.util.Collection;
import java.util.function.Function;

import net.minecraft.nbt.NBTTagCompound;

import com.google.common.collect.LinkedListMultimap;

public class ItemStackReplacementManager {

private static final Map<String, Function<NBTTagCompound, NBTTagCompound>> replacementMap = new HashMap<>();
private static final LinkedListMultimap<String, Function<NBTTagCompound, NBTTagCompound>> replacementMap = LinkedListMultimap
.create();

// Public API for converting ItemStacks.

Expand All @@ -18,7 +20,7 @@ public static void addItemReplacement(String itemName, Function<NBTTagCompound,
}

@SuppressWarnings("unused")
public static Function<NBTTagCompound, NBTTagCompound> getItemReplacement(String itemNameInternal) {
public static Collection<Function<NBTTagCompound, NBTTagCompound>> getItemReplacement(String itemNameInternal) {
return replacementMap.get(itemNameInternal);
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package com.gtnewhorizons.postea.api;

import java.util.HashMap;
import java.util.Collection;
import java.util.function.BiFunction;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;

import com.google.common.collect.LinkedListMultimap;
import com.gtnewhorizons.postea.utility.BlockInfo;

@SuppressWarnings("unused")
public class TileEntityReplacementManager {

private static final HashMap<String, TriFunction<NBTTagCompound, World, Chunk, BlockInfo>> tileEntityToNormalBlockTransformer = new HashMap<>();
private static final LinkedListMultimap<String, TriFunction<NBTTagCompound, World, Chunk, BlockInfo>> tileEntityToNormalBlockTransformer = LinkedListMultimap
.create();

/**
* @deprecated Superseded by {@link #tileEntityTransformer(String, TriFunction)}.
Expand All @@ -38,8 +40,8 @@ public static void tileEntityTransformer(String tileEntityId,
tileEntityToNormalBlockTransformer.put(tileEntityId, transformerFunction);
}

public static TriFunction<NBTTagCompound, World, Chunk, BlockInfo> getTileEntityToNormalBlockTransformerFunction(
public static Collection<TriFunction<NBTTagCompound, World, Chunk, BlockInfo>> getTileEntityToNormalBlockTransformerFunction(
String tileEntityId) {
return tileEntityToNormalBlockTransformer.getOrDefault(tileEntityId, null);
return tileEntityToNormalBlockTransformer.get(tileEntityId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,27 +128,26 @@ private static Pair<List<ConversionInfo>, NBTTagList> adjustTileEntities(NBTTagL
String tileEntityId = tileEntity.getString("id");

// Check if we have a transformer registered for this tile entity ID
TriFunction<NBTTagCompound, World, Chunk, BlockInfo> transformationFunction = TileEntityReplacementManager
.getTileEntityToNormalBlockTransformerFunction(tileEntityId);
boolean found = false;
for (TriFunction<NBTTagCompound, World, Chunk, BlockInfo> transformationFunction : TileEntityReplacementManager
.getTileEntityToNormalBlockTransformerFunction(tileEntityId)) {

if (transformationFunction != null) {
int x = tileEntity.getInteger("x");
int y = tileEntity.getInteger("y");
int z = tileEntity.getInteger("z");

BlockInfo blockInfo = transformationFunction.apply(tileEntity, world, chunk);
if (blockInfo == null) {
// Do nothing.
tileEntitiesCopy.appendTag(tileEntity);
continue;
}
if (blockInfo == null) continue;

if (blockInfo.tileTransformer != null) {
tileEntitiesCopy.appendTag(blockInfo.tileTransformer.apply(tileEntity));
} // Otherwise they are removed, therefore not appended.

conversionInfo.add(new ConversionInfo(x, y, z, blockInfo));
} else {
found = true;
break;
}
if (!found) {
// Do nothing.
tileEntitiesCopy.appendTag(tileEntity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ public static void fixItemStack(NBTTagCompound tag) {
String itemNameInternal = GameRegistry.findUniqueIdentifierFor(item).modId + ":"
+ GameRegistry.findUniqueIdentifierFor(item).name;

Function<NBTTagCompound, NBTTagCompound> transformer = ItemStackReplacementManager
.getItemReplacement(itemNameInternal);

if (transformer != null) {
transformer.apply(tag);
for (Function<NBTTagCompound, NBTTagCompound> transformer : ItemStackReplacementManager
.getItemReplacement(itemNameInternal)) {
if (transformer.apply(tag) != null) break;
}
}
}
Expand Down