mirror of
https://github.com/GTNewHorizons/Postea.git
synced 2026-11-24 05:54:31 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
82349735e4 | ||
|
|
42b5e4d38c |
No files matched your search
@@ -12,16 +12,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
import com.gtnewhorizons.postea.utility.ChunkFixerUtility;
|
import com.gtnewhorizons.postea.utility.ChunkFixerUtility;
|
||||||
import com.llamalad7.mixinextras.sugar.Local;
|
|
||||||
|
|
||||||
@Mixin(value = AnvilChunkLoader.class, priority = 1100)
|
@Mixin(value = AnvilChunkLoader.class, priority = 1100)
|
||||||
public abstract class MixinAnvilChunkLoader {
|
public abstract class MixinAnvilChunkLoader {
|
||||||
|
|
||||||
// This hook is compatible with Vanilla/NEID/EIDs
|
// This hook is compatible with Vanilla/NEID/EIDs
|
||||||
@Inject(method = "readChunkFromNBT", at = @At("RETURN"), require = 1)
|
@Inject(method = "readChunkFromNBT", at = @At("RETURN"), require = 1)
|
||||||
private void postea$chunkHook(CallbackInfoReturnable<Chunk> cir, @Local Chunk chunk,
|
private void postea$chunkHook(World world, NBTTagCompound tag, CallbackInfoReturnable<Chunk> cir) {
|
||||||
@Local(argsOnly = true) World world, @Local(ordinal = 0, argsOnly = true) NBTTagCompound tag) {
|
ChunkFixerUtility.onChunkRead(cir.getReturnValue(), world, tag);
|
||||||
ChunkFixerUtility.onChunkRead(chunk, world, tag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "loadChunk", at = @At("RETURN"))
|
@Inject(method = "loadChunk", at = @At("RETURN"))
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class ChunkFixerUtility {
|
|||||||
|
|
||||||
BlockConversionInfo output = getBlockReplacement(
|
BlockConversionInfo output = getBlockReplacement(
|
||||||
blockId,
|
blockId,
|
||||||
(byte) metadata,
|
metadata,
|
||||||
world,
|
world,
|
||||||
x + chunkXPos + 1,
|
x + chunkXPos + 1,
|
||||||
y + sectionY,
|
y + sectionY,
|
||||||
|
|||||||
@@ -49,13 +49,13 @@ class SimpleTransformationMap<T> {
|
|||||||
* The target meta/damage value for the transformation.
|
* The target meta/damage value for the transformation.
|
||||||
* If the value is {@link OreDictionary#WILDCARD_VALUE}, It maintains the old meta/damage value.
|
* If the value is {@link OreDictionary#WILDCARD_VALUE}, It maintains the old meta/damage value.
|
||||||
*/
|
*/
|
||||||
public final short targetMeta;
|
public final int targetMeta;
|
||||||
/**
|
/**
|
||||||
* The numeric id of the target block, updated during the FMLMappingUpdate event
|
* The numeric id of the target block, updated during the FMLMappingUpdate event
|
||||||
*/
|
*/
|
||||||
public int targetRuntimeId;
|
public int targetRuntimeId;
|
||||||
|
|
||||||
public Value(T target, short targetMeta) {
|
public Value(T target, int targetMeta) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.targetMeta = targetMeta;
|
this.targetMeta = targetMeta;
|
||||||
this.targetRuntimeId = -1;
|
this.targetRuntimeId = -1;
|
||||||
@@ -73,7 +73,7 @@ class SimpleTransformationMap<T> {
|
|||||||
* When querying, the value will be replaced, which will
|
* When querying, the value will be replaced, which will
|
||||||
* be used when ever no other specific meta match is found.
|
* be used when ever no other specific meta match is found.
|
||||||
*/
|
*/
|
||||||
public void put(String originalId, int originalMeta, T target, short targetMeta) {
|
public void put(String originalId, int originalMeta, T target, int targetMeta) {
|
||||||
if (originalMeta == -1) originalMeta = OreDictionary.WILDCARD_VALUE;
|
if (originalMeta == -1) originalMeta = OreDictionary.WILDCARD_VALUE;
|
||||||
this.registry.computeIfAbsent(originalId, k -> new Int2ObjectOpenHashMap<>())
|
this.registry.computeIfAbsent(originalId, k -> new Int2ObjectOpenHashMap<>())
|
||||||
.put(originalMeta, new Value<>(target, targetMeta));
|
.put(originalMeta, new Value<>(target, targetMeta));
|
||||||
|
|||||||
@@ -100,11 +100,11 @@ public class SimpleTransformationRegistry {
|
|||||||
public static void addSimpleTransformer(String originalId, int originalMeta, Block newBlock, int newMeta,
|
public static void addSimpleTransformer(String originalId, int originalMeta, Block newBlock, int newMeta,
|
||||||
boolean skipStackRemap) {
|
boolean skipStackRemap) {
|
||||||
if (newMeta == -1) newMeta = OreDictionary.WILDCARD_VALUE;
|
if (newMeta == -1) newMeta = OreDictionary.WILDCARD_VALUE;
|
||||||
SIMPLE_BLOCK_TRANSFORMATION_MAP.put(originalId, originalMeta, newBlock, (short) newMeta);
|
SIMPLE_BLOCK_TRANSFORMATION_MAP.put(originalId, originalMeta, newBlock, newMeta);
|
||||||
if (!skipStackRemap) {
|
if (!skipStackRemap) {
|
||||||
Item item = Item.getItemFromBlock(newBlock);
|
Item item = Item.getItemFromBlock(newBlock);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
SIMPLE_ITEM_TRANSFORMATION_MAP.put(originalId, originalMeta, item, (short) newMeta);
|
SIMPLE_ITEM_TRANSFORMATION_MAP.put(originalId, originalMeta, item, newMeta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,9 +166,9 @@ public class SimpleTransformationRegistry {
|
|||||||
boolean skipBlockRemap) {
|
boolean skipBlockRemap) {
|
||||||
if (newMeta == -1) newMeta = OreDictionary.WILDCARD_VALUE;
|
if (newMeta == -1) newMeta = OreDictionary.WILDCARD_VALUE;
|
||||||
if (!skipBlockRemap && newItem instanceof ItemBlock ib) {
|
if (!skipBlockRemap && newItem instanceof ItemBlock ib) {
|
||||||
SIMPLE_BLOCK_TRANSFORMATION_MAP.put(originalId, originalMeta, ib.field_150939_a, (short) newMeta);
|
SIMPLE_BLOCK_TRANSFORMATION_MAP.put(originalId, originalMeta, ib.field_150939_a, newMeta);
|
||||||
}
|
}
|
||||||
SIMPLE_ITEM_TRANSFORMATION_MAP.put(originalId, originalMeta, newItem, (short) newMeta);
|
SIMPLE_ITEM_TRANSFORMATION_MAP.put(originalId, originalMeta, newItem, newMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -191,7 +191,8 @@ public class SimpleTransformationRegistry {
|
|||||||
if (mapping == null || mapping.targetRuntimeId <= -1) return false;
|
if (mapping == null || mapping.targetRuntimeId <= -1) return false;
|
||||||
IDExtenderCompat.setItemStackID(tag, mapping.targetRuntimeId);
|
IDExtenderCompat.setItemStackID(tag, mapping.targetRuntimeId);
|
||||||
if (mapping.targetMeta != OreDictionary.WILDCARD_VALUE) {
|
if (mapping.targetMeta != OreDictionary.WILDCARD_VALUE) {
|
||||||
tag.setShort("Damage", mapping.targetMeta);
|
// Damage is a vanilla short NBT field, unrelated to EndlessIDs block metadata width.
|
||||||
|
tag.setShort("Damage", (short) mapping.targetMeta);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ public class TransformerRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// region transformation handlers
|
// region transformation handlers
|
||||||
public static @Nullable BlockConversionInfo getBlockReplacement(int blockId, byte metadata, World world, int x,
|
public static @Nullable BlockConversionInfo getBlockReplacement(int blockId, int metadata, World world, int x,
|
||||||
int y, int z) {
|
int y, int z) {
|
||||||
Pair<String, List<IBlockTransformationHandler>> data = RUNTIME_BLOCK_REPLACEMENT_MAP.get(blockId);
|
Pair<String, List<IBlockTransformationHandler>> data = RUNTIME_BLOCK_REPLACEMENT_MAP.get(blockId);
|
||||||
if (data == null) return null;
|
if (data == null) return null;
|
||||||
|
|||||||
Reference in new issue
Block a user