Skip to content
Open
Show file tree
Hide file tree
Changes from 22 commits
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
528 changes: 475 additions & 53 deletions README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ dependencies {
compileOnly('com.github.GTNewHorizons:NotEnoughIds:2.1.10:dev')
compileOnly('com.falsepattern:chunkapi-mc1.7.10:0.6.0:dev')
compileOnly('com.falsepattern:endlessids-mc1.7.10:1.6.0:dev')
compileOnly("com.github.GTNewHorizons:NotEnoughItems:2.8.48-GTNH:dev") { transitive = false }
}
37 changes: 23 additions & 14 deletions src/main/java/com/gtnewhorizons/postea/Postea.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package com.gtnewhorizons.postea;

import static com.gtnewhorizons.postea.api.BlockReplacementManager.blockReplacementMap;
import static com.gtnewhorizons.postea.api.BlockReplacementManager.posteaMarkedIDs;
import net.minecraftforge.event.world.ChunkEvent;

import net.minecraft.block.Block;
import com.gtnewhorizons.postea.utility.ChunkFixerUtility;
import com.gtnewhorizons.postea.utility.IDRegistry;
import com.gtnewhorizons.postea.utility.MissingMappingHandler;
import com.gtnewhorizons.postea.utility.SimpleTransformationRegistry;
import com.gtnewhorizons.postea.utility.TransformerRegistry;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.event.FMLModIdMappingEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;

@Mod(
modid = Postea.MODID,
Expand All @@ -25,21 +29,26 @@ public class Postea {
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {}

@Mod.EventHandler
public void chunkLoaded(ChunkEvent.Load event) {
ChunkFixerUtility.onChunkLoaded(event.getChunk());
}

@Mod.EventHandler
public void onIdMappingsChanged(FMLModIdMappingEvent event) {
posteaMarkedIDs.clear();
for (String name : blockReplacementMap.keySet()) {
Block block = Block.getBlockFromName(name);
if (block != null) {
int id = Block.getIdFromBlock(block);
posteaMarkedIDs.add(id);
}
}
SimpleTransformationRegistry.onIdMappingsChanged();
TransformerRegistry.onIdMappingsChanged();
IDRegistry.onMappingUpdated();
}

@Mod.EventHandler
public void onMissingMapping(FMLMissingMappingsEvent event) {
MissingMappingHandler.onMissingMapping(event);
}

@Mod.EventHandler
public void onServerStopping(FMLServerStoppingEvent event) {
posteaMarkedIDs.clear();
public void onLoadCompleted(FMLLoadCompleteEvent event) {
SimpleTransformationRegistry.onLoadCompleted();
}

}
95 changes: 95 additions & 0 deletions src/main/java/com/gtnewhorizons/postea/api/BlockAccessCompat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package com.gtnewhorizons.postea.api;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;

import com.gtnewhorizons.postea.compat.Compat;
import com.gtnewhorizons.postea.compat.SubChunkAccess;

/**
* Public API for accessing information related to a block located at the location of a tile entity inside a
* tile entity transformer registered via
* {@link TileEntityReplacementManager#tileEntityTransformer(String, TriFunction)}
*/
@SuppressWarnings("unused")
public abstract class BlockAccessCompat {

/**
* Fetches the id of the block that is (or used to be) at the position of the TE stored in the given tag.
*
* @apiNote This method is intended for use withing TileEntityTransformers declared via
* {@link TileEntityReplacementManager#tileEntityTransformer(String, TriFunction)}
*
* @param tag The tag for the tile entity
* @param chunk The chunk containing the tile entity
* @return The id of the block that exists (or used to exist) at that location.
*/
@SuppressWarnings("unused")
public static int getBlockIDAtTE(NBTTagCompound tag, Chunk chunk) {
// fetch the block accessor
ExtendedBlockStorage[] ebsArray = chunk.getBlockStorageArray();
// abort if y is oob
int y = tag.getInteger("y");
if (y >> 4 >= ebsArray.length) return 0;
SubChunkAccess access = Compat.getSubChunkAccess(ebsArray[y >> 4]);

// identify the block
int x = tag.getInteger("x") & 0xf;
y &= 0xf;
int z = tag.getInteger("z") & 0xf;
return access.getBlockId(x, y, z);
}

/**
* Fetches the meta of the block that is (or used to be) at the position of the TE stored in the given tag.
*
* @apiNote This method is intended for use withing TileEntityTransformers declared via
* {@link TileEntityReplacementManager#tileEntityTransformer(String, TriFunction)}
*
* @param tag The tag for the tile entity
* @param chunk The chunk containing the tile entity
* @return The id of the block that exists (or used to exist) at that location.
*/
@SuppressWarnings("unused")
public static int getBlockMetaAtTE(NBTTagCompound tag, Chunk chunk) {
// fetch the block accessor
ExtendedBlockStorage[] ebsArray = chunk.getBlockStorageArray();
// abort if y is oob
int y = tag.getInteger("y");
if (y >> 4 >= ebsArray.length) return 0;
SubChunkAccess access = Compat.getSubChunkAccess(ebsArray[y >> 4]);

// identify the block
int x = tag.getInteger("x") & 0xf;
y &= 0xf;
int z = tag.getInteger("z") & 0xf;
return access.getMeta(x, y, z);
}

/**
* Fetches the id and meta of the block that is (or used to be) at the position of the TE stored in the given tag.
*
* @apiNote This method is intended for use withing TileEntityTransformers declared via
* {@link TileEntityReplacementManager#tileEntityTransformer(String, TriFunction)}
*
* @param tag The tag for the tile entity
* @param chunk The chunk containing the tile entity
* @return An array with th eid of the block that exists (or used to exist) at that location.
*/
@SuppressWarnings("unused")
public static int[] getBlockIDAndMetaAtTE(NBTTagCompound tag, Chunk chunk) {
// fetch the block accessor
ExtendedBlockStorage[] ebsArray = chunk.getBlockStorageArray();
// abort if y is oob
int y = tag.getInteger("y");
if (y >> 4 >= ebsArray.length) return new int[] { 0, 0 };
SubChunkAccess access = Compat.getSubChunkAccess(ebsArray[y >> 4]);

// identify the block
int x = tag.getInteger("x") & 0xf;
y &= 0xf;
int z = tag.getInteger("z") & 0xf;
return new int[] { access.getBlockId(x, y, z), access.getMeta(x, y, z) };
}
}
Loading