Compare commits

..
6 Commits
Author SHA1 Message Date
FalsePattern e8e77766c4 fixed crash with HBM NTM nukes 2024-12-23 15:37:52 +01:00
FalsePattern 4d221c864b bump gradle and buildscript 2024-12-09 19:13:38 +01:00
FalsePattern 55dbe6f4b9 update to chunkapi 0.6 2024-12-09 19:12:56 +01:00
FalsePattern 1ea745c8a4 eid$ prefix for SubChunkBlockHook 2024-12-09 19:05:00 +01:00
FalsePattern 85c7e8ad25 update buildscript 2024-11-14 21:25:53 +01:00
FalsePattern a9e8554f18 lmao how did i manage to mess this up 2024-11-14 21:22:04 +01:00
17 changed files with 554 additions and 122 deletions

No files matched your search

+3 -3
View File
@@ -1,5 +1,5 @@
plugins {
id("fpgradle-minecraft") version ("0.8.0")
id("fpgradle-minecraft") version ("0.8.3")
}
group = "com.falsepattern"
@@ -63,9 +63,9 @@ repositories {
dependencies {
////////////////Our dependencies////////////////
implementationSplit("com.falsepattern:falsepatternlib-mc1.7.10:1.4.1")
implementationSplit("com.falsepattern:falsepatternlib-mc1.7.10:1.5.5")
implementation("it.unimi.dsi:fastutil:8.5.13")
implementationSplit("com.falsepattern:chunkapi-mc1.7.10:0.5.1")
implementationSplit("com.falsepattern:chunkapi-mc1.7.10:0.6.0")
////////////////Patched mods////////////////
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
@@ -43,8 +43,8 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
version = Tags.VERSION,
name = Tags.MODNAME,
acceptedMinecraftVersions = "[1.7.10]",
dependencies = "required-after:chunkapi@[0.5.0,0.6.0);" +
"required-after:falsepatternlib@[1.4.1,);" +
dependencies = "required-after:chunkapi@[0.6.0,);" +
"required-after:falsepatternlib@[1.5.5,);" +
"after:antiidconflict")
public class EndlessIDs {
public static final byte[] ZERO_LENGTH_BIOME_ARRAY_PLACEHOLDER = new byte[0];
@@ -27,13 +27,15 @@ import com.falsepattern.chunk.api.ArrayUtil;
import com.falsepattern.chunk.api.DataManager;
import com.falsepattern.endlessids.Tags;
import com.falsepattern.endlessids.mixin.helpers.SubChunkBlockHook;
import com.falsepattern.endlessids.util.DataUtil;
import lombok.val;
import lombok.var;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.server.S23PacketBlockChange;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
@@ -44,7 +46,7 @@ import static com.falsepattern.endlessids.constants.ExtendedConstants.blocksPerS
import static com.falsepattern.endlessids.util.DataUtil.*;
//NOTE: Also change the save logic in MapWriter mod if changing this
public class BlockIDManager implements DataManager.PacketDataManager, DataManager.SubChunkDataManager {
public class BlockIDManager implements DataManager.PacketDataManager, DataManager.SubChunkDataManager, DataManager.BlockPacketDataManager {
@Override
public String domain() {
@@ -73,24 +75,24 @@ public class BlockIDManager implements DataManager.PacketDataManager, DataManage
}
val subChunk = (SubChunkBlockHook) subChunkList[i];
storageFlags |= subChunk.getBlockMask() << (i * 2);
storageFlags |= subChunk.eid$getBlockMask() << (i * 2);
val b1 = subChunk.getB1();
val b1 = subChunk.eid$getB1();
data.put(b1);
val b2Low = subChunk.getB2Low();
val b2Low = subChunk.eid$getB2Low();
if (b2Low == null) {
continue;
}
data.put(b2Low.data);
val b2High = subChunk.getB2High();
val b2High = subChunk.eid$getB2High();
if (b2High == null) {
continue;
}
data.put(b2High.data);
val b3 = subChunk.getB3();
val b3 = subChunk.eid$getB3();
if (b3 != null) {
data.put(b3);
}
@@ -108,36 +110,36 @@ public class BlockIDManager implements DataManager.PacketDataManager, DataManage
}
val subChunk = (SubChunkBlockHook) subChunkList[i];
val storageFlag = (storageFlags >>> (i * 2)) & 3;
val b1 = subChunk.getB1();
val b1 = subChunk.eid$getB1();
buffer.get(b1);
if (storageFlag == 0b00) {
subChunk.setB2Low(null);
subChunk.setB2High(null);
subChunk.setB3(null);
subChunk.eid$setB2Low(null);
subChunk.eid$setB2High(null);
subChunk.eid$setB3(null);
continue;
}
var b2Low = subChunk.getB2Low();
var b2Low = subChunk.eid$getB2Low();
if (b2Low == null) {
b2Low = subChunk.createB2Low();
b2Low = subChunk.eid$createB2Low();
}
buffer.get(b2Low.data);
if (storageFlag == 0b01) {
subChunk.setB2High(null);
subChunk.setB3(null);
subChunk.eid$setB2High(null);
subChunk.eid$setB3(null);
continue;
}
var b2High = subChunk.getB2High();
var b2High = subChunk.eid$getB2High();
if (b2High == null) {
b2High = subChunk.createB2High();
b2High = subChunk.eid$createB2High();
}
buffer.get(b2High.data);
if (storageFlag == 0b10) {
subChunk.setB3(null);
subChunk.eid$setB3(null);
continue;
}
var b3 = subChunk.getB3();
var b3 = subChunk.eid$getB3();
if (b3 == null) {
b3 = subChunk.createB3();
b3 = subChunk.eid$createB3();
}
buffer.get(b3);
}
@@ -152,10 +154,10 @@ public class BlockIDManager implements DataManager.PacketDataManager, DataManage
@Override
public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) {
val subChunk = (SubChunkBlockHook) subChunkVanilla;
val b1 = subChunk.getB1();
val b2Low = subChunk.getB2Low();
val b2High = subChunk.getB2High();
val b3 = subChunk.getB3();
val b1 = subChunk.eid$getB1();
val b2Low = subChunk.eid$getB2Low();
val b2High = subChunk.eid$getB2High();
val b3 = subChunk.eid$getB3();
nbt.setByteArray("Blocks", b1);
if (b2Low != null) {
nbt.setByteArray("Add", b2Low.data);
@@ -184,9 +186,9 @@ public class BlockIDManager implements DataManager.PacketDataManager, DataManage
b2L[nI] |= (byte) (((s & 0x0F00) >>> 8) << mI);
b2H[nI] |= (byte) (((s & 0xF000) >>> 12) << mI);
}
subChunk.setB1(b1);
subChunk.setB2Low(new NibbleArray(b2L, 4));
subChunk.setB2High(new NibbleArray(b2H, 4));
subChunk.eid$setB1(b1);
subChunk.eid$setB2Low(new NibbleArray(b2L, 4));
subChunk.eid$setB2High(new NibbleArray(b2H, 4));
}
@Override
@@ -202,10 +204,10 @@ public class BlockIDManager implements DataManager.PacketDataManager, DataManage
final byte[] b2High = nbt.hasKey("BlocksB2Hi") ? nbt.getByteArray("BlocksB2Hi") : null;
final byte[] b3 = nbt.hasKey("BlocksB3") ? nbt.getByteArray("BlocksB3") : null;
subChunk.setB1(ensureSubChunkByteArray(b1));
subChunk.setB2Low(ensureSubChunkNibbleArray(b2Low));
subChunk.setB2High(ensureSubChunkNibbleArray(b2High));
subChunk.setB3(ensureSubChunkByteArray(b3));
subChunk.eid$setB1(ensureSubChunkByteArray(b1));
subChunk.eid$setB2Low(ensureSubChunkNibbleArray(b2Low));
subChunk.eid$setB2High(ensureSubChunkNibbleArray(b2High));
subChunk.eid$setB3(ensureSubChunkByteArray(b3));
}
@Override
@@ -213,10 +215,10 @@ public class BlockIDManager implements DataManager.PacketDataManager, DataManage
val from = (SubChunkBlockHook) fromVanilla;
val to = (SubChunkBlockHook) toVanilla;
to.setB1(ArrayUtil.copyArray(from.getB1(), to.getB1()));
to.setB2Low(ArrayUtil.copyArray(from.getB2Low(), to.getB2Low()));
to.setB2High(ArrayUtil.copyArray(from.getB2High(), to.getB2High()));
to.setB3(ArrayUtil.copyArray(from.getB3(), to.getB3()));
to.eid$setB1(ArrayUtil.copyArray(from.eid$getB1(), to.eid$getB1()));
to.eid$setB2Low(ArrayUtil.copyArray(from.eid$getB2Low(), to.eid$getB2Low()));
to.eid$setB2High(ArrayUtil.copyArray(from.eid$getB2High(), to.eid$getB2High()));
to.eid$setB3(ArrayUtil.copyArray(from.eid$getB3(), to.eid$getB3()));
}
@Override
@@ -238,4 +240,24 @@ public class BlockIDManager implements DataManager.PacketDataManager, DataManage
public @Nullable String versionChangeMessage(String priorVersion) {
return null;
}
@Override
public void writeBlockToPacket(Chunk chunk, int x, int y, int z, S23PacketBlockChange packet) {
}
@Override
public void readBlockFromPacket(Chunk chunk, int x, int y, int z, S23PacketBlockChange packet) {
}
@Override
public void writeBlockPacketToBuffer(S23PacketBlockChange packet, PacketBuffer buffer) {
buffer.writeInt(Block.getIdFromBlock(packet.field_148883_d));
}
@Override
public void readBlockPacketFromBuffer(S23PacketBlockChange packet, PacketBuffer buffer) {
packet.field_148883_d = Block.getBlockById(buffer.readInt());
}
}
@@ -34,6 +34,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.server.S23PacketBlockChange;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
@@ -43,7 +45,7 @@ import java.nio.ByteBuffer;
import static com.falsepattern.endlessids.constants.ExtendedConstants.blocksPerSubChunk;
//NOTE: Also change the save logic in MapWriter mod if changing this
public class BlockMetaManager implements DataManager.PacketDataManager, DataManager.SubChunkDataManager {
public class BlockMetaManager implements DataManager.PacketDataManager, DataManager.SubChunkDataManager, DataManager.BlockPacketDataManager {
@Override
public String domain() {
@@ -72,18 +74,18 @@ public class BlockMetaManager implements DataManager.PacketDataManager, DataMana
}
val subChunk = (SubChunkBlockHook) subChunkList[i];
storageFlags |= subChunk.getMetadataMask() << (i * 2);
storageFlags |= subChunk.eid$getMetadataMask() << (i * 2);
val m1Low = subChunk.getM1Low();
val m1Low = subChunk.eid$getM1Low();
data.put(m1Low.data);
val m1High = subChunk.getM1High();
val m1High = subChunk.eid$getM1High();
if (m1High == null) {
continue;
}
data.put(m1High.data);
val m2 = subChunk.getM2();
val m2 = subChunk.eid$getM2();
if (m2 != null) {
data.put(m2);
}
@@ -101,25 +103,25 @@ public class BlockMetaManager implements DataManager.PacketDataManager, DataMana
}
val subChunk = (SubChunkBlockHook) subChunkList[i];
val storageFlag = (storageFlags >>> (i * 2)) & 3;
val m1Low = subChunk.getM1Low();
val m1Low = subChunk.eid$getM1Low();
buffer.get(m1Low.data);
if (storageFlag == 0b01) {
subChunk.setM1High(null);
subChunk.setM2(null);
subChunk.eid$setM1High(null);
subChunk.eid$setM2(null);
continue;
}
var m1High = subChunk.getM1High();
var m1High = subChunk.eid$getM1High();
if (m1High == null) {
m1High = subChunk.createM1High();
m1High = subChunk.eid$createM1High();
}
buffer.get(m1High.data);
if (storageFlag == 0b10) {
subChunk.setM2(null);
subChunk.eid$setM2(null);
continue;
}
var m2 = subChunk.getM2();
var m2 = subChunk.eid$getM2();
if (m2 == null) {
m2 = subChunk.createM2();
m2 = subChunk.eid$createM2();
}
buffer.get(m2);
}
@@ -133,9 +135,9 @@ public class BlockMetaManager implements DataManager.PacketDataManager, DataMana
@Override
public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) {
val subChunk = (SubChunkBlockHook) subChunkVanilla;
val m1Low = subChunk.getM1Low();
val m1High = subChunk.getM1High();
val m2 = subChunk.getM2();
val m1Low = subChunk.eid$getM1Low();
val m1High = subChunk.eid$getM1High();
val m2 = subChunk.eid$getM2();
nbt.setByteArray("Data", m1Low.data);
if (m1High != null) {
nbt.setByteArray("Data1High", m1High.data);
@@ -161,9 +163,9 @@ public class BlockMetaManager implements DataManager.PacketDataManager, DataMana
m1High[nI] |= (byte) (((s & 0x00F0) >>> 4) << mI);
m2[i] = (byte) ((s & 0xFF00) >>> 8);
}
subChunk.setM1Low(new NibbleArray(m1Low, 4));
subChunk.setM1High(new NibbleArray(m1High, 4));
subChunk.setM2(m2);
subChunk.eid$setM1Low(new NibbleArray(m1Low, 4));
subChunk.eid$setM1High(new NibbleArray(m1High, 4));
subChunk.eid$setM2(m2);
}
@Override
@@ -178,9 +180,9 @@ public class BlockMetaManager implements DataManager.PacketDataManager, DataMana
final byte[] m1High = nbt.hasKey("Data1High") ? nbt.getByteArray("Data1High") : null;
final byte[] m2 = nbt.hasKey("Data2") ? nbt.getByteArray("Data2") : null;
subChunk.setM1Low(DataUtil.ensureSubChunkNibbleArray(m1Low));
subChunk.setM1High(DataUtil.ensureSubChunkNibbleArray(m1High));
subChunk.setM2(DataUtil.ensureSubChunkByteArray(m2));
subChunk.eid$setM1Low(DataUtil.ensureSubChunkNibbleArray(m1Low));
subChunk.eid$setM1High(DataUtil.ensureSubChunkNibbleArray(m1High));
subChunk.eid$setM2(DataUtil.ensureSubChunkByteArray(m2));
}
@Override
@@ -188,9 +190,9 @@ public class BlockMetaManager implements DataManager.PacketDataManager, DataMana
val from = (SubChunkBlockHook) fromVanilla;
val to = (SubChunkBlockHook) toVanilla;
to.setM1Low(ArrayUtil.copyArray(from.getM1Low(), to.getM1Low()));
to.setM1High(ArrayUtil.copyArray(from.getM1High(), to.getM1High()));
to.setM2(ArrayUtil.copyArray(from.getM2(), to.getM2()));
to.eid$setM1Low(ArrayUtil.copyArray(from.eid$getM1Low(), to.eid$getM1Low()));
to.eid$setM1High(ArrayUtil.copyArray(from.eid$getM1High(), to.eid$getM1High()));
to.eid$setM2(ArrayUtil.copyArray(from.eid$getM2(), to.eid$getM2()));
}
@Override
@@ -212,4 +214,24 @@ public class BlockMetaManager implements DataManager.PacketDataManager, DataMana
public @Nullable String versionChangeMessage(String priorVersion) {
return null;
}
@Override
public void writeBlockToPacket(Chunk chunk, int x, int y, int z, S23PacketBlockChange packet) {
}
@Override
public void readBlockFromPacket(Chunk chunk, int x, int y, int z, S23PacketBlockChange packet) {
}
@Override
public void writeBlockPacketToBuffer(S23PacketBlockChange packet, PacketBuffer buffer) {
buffer.writeShort(packet.field_148884_e & 0xFFFF);
}
@Override
public void readBlockPacketFromBuffer(S23PacketBlockChange packet, PacketBuffer buffer) {
packet.field_148884_e = buffer.readUnsignedShort();
}
}
@@ -0,0 +1,32 @@
/*
* EndlessIDs
*
* Copyright (C) 2022-2024 FalsePattern
* All Rights Reserved
*
* The above copyright notice, this permission notice and the words "MEGA"
* shall be included in all copies or substantial portions of the Software.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.falsepattern.endlessids.mixin.helpers;
public interface IHBMBiomeSyncPacket {
void eid$setBiome(short biome);
short eid$getBiome();
void eid$setBiomeArray(short[] biomeArray);
short[] eid$getBiomeArray();
}
@@ -26,47 +26,53 @@ package com.falsepattern.endlessids.mixin.helpers;
import net.minecraft.world.chunk.NibbleArray;
public interface SubChunkBlockHook {
byte[] getB1();
byte[] eid$getB1();
void setB1(byte[] data);
void eid$setB1(byte[] data);
NibbleArray getB2Low();
NibbleArray eid$getB2Low();
void setB2Low(NibbleArray data);
void eid$setB2Low(NibbleArray data);
NibbleArray createB2Low();
NibbleArray eid$createB2Low();
NibbleArray getB2High();
NibbleArray eid$getB2High();
void setB2High(NibbleArray data);
void eid$setB2High(NibbleArray data);
NibbleArray createB2High();
NibbleArray eid$createB2High();
byte[] getB3();
byte[] eid$getB3();
void setB3(byte[] data);
void eid$setB3(byte[] data);
byte[] createB3();
byte[] eid$createB3();
int getMetadataMask();
int eid$getBlockMask();
int getBlockMask();
int eid$getID(int x, int y, int z);
int getID(int x, int y, int z);
void eid$setID(int x, int y, int z, int id);
NibbleArray getM1Low();
NibbleArray eid$getM1Low();
void setM1Low(NibbleArray m1Low);
void eid$setM1Low(NibbleArray m1Low);
NibbleArray getM1High();
NibbleArray eid$getM1High();
void setM1High(NibbleArray m1High);
void eid$setM1High(NibbleArray m1High);
NibbleArray createM1High();
NibbleArray eid$createM1High();
byte[] getM2();
byte[] eid$getM2();
void setM2(byte[] m2);
void eid$setM2(byte[] m2);
byte[] createM2();
byte[] eid$createM2();
int eid$getMetadataMask();
int eid$getMetadata(int x, int y, int z);
void eid$setMetadata(int x, int y, int z, int id);
}
@@ -0,0 +1,33 @@
/*
* EndlessIDs
*
* Copyright (C) 2022-2024 FalsePattern
* All Rights Reserved
*
* The above copyright notice, this permission notice and the words "MEGA"
* shall be included in all copies or substantial portions of the Software.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.falsepattern.endlessids.mixin.helpers.stubpackage.com.hbm.packet;
import com.falsepattern.endlessids.mixin.helpers.IHBMBiomeSyncPacket;
public abstract class BiomeSyncPacket extends com.hbm.packet.BiomeSyncPacket implements IHBMBiomeSyncPacket {
public int chunkX;
public int chunkZ;
public byte blockX;
public byte blockZ;
}
@@ -0,0 +1,119 @@
/*
* EndlessIDs
*
* Copyright (C) 2022-2024 FalsePattern
* All Rights Reserved
*
* The above copyright notice, this permission notice and the words "MEGA"
* shall be included in all copies or substantial portions of the Software.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.falsepattern.endlessids.mixin.mixins.common.biome.ntm;
import com.falsepattern.endlessids.EndlessIDs;
import com.falsepattern.endlessids.mixin.helpers.IHBMBiomeSyncPacket;
import com.hbm.packet.BiomeSyncPacket;
import io.netty.buffer.ByteBuf;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Arrays;
@Mixin(value = BiomeSyncPacket.class,
remap = false)
public abstract class BiomeSyncPacketMixin implements IHBMBiomeSyncPacket {
@Shadow
int chunkX;
@Shadow
int chunkZ;
@Shadow
byte[] biomeArray;
@Shadow
byte blockX;
@Shadow
byte blockZ;
@Unique
private short eid$biome;
@Unique
private short[] eid$biomeArray;
@Override
public void eid$setBiome(short biome) {
eid$biome = biome;
}
@Override
public short eid$getBiome() {
return eid$biome;
}
@Override
public void eid$setBiomeArray(short[] biomeArray) {
this.biomeArray = EndlessIDs.FAKE_BIOME_ARRAY_PLACEHOLDER;
eid$biomeArray = Arrays.copyOf(biomeArray, biomeArray.length);
}
@Override
public short[] eid$getBiomeArray() {
return eid$biomeArray;
}
@Inject(method = "toBytes",
at = @At("HEAD"),
cancellable = true,
require = 1)
private void toBytes(ByteBuf buf, CallbackInfo ci) {
ci.cancel();
buf.writeInt(chunkX);
buf.writeInt(chunkZ);
if (eid$biomeArray == null) {
buf.writeBoolean(false);
buf.writeShort(eid$biome);
buf.writeByte(blockX);
buf.writeByte(blockZ);
} else {
buf.writeBoolean(true);
for (int i = 0; i < 256; i++) {
buf.writeShort(eid$biomeArray[i]);
}
}
}
@Inject(method = "fromBytes",
at = @At(value = "HEAD"),
cancellable = true,
require = 1)
private void fromBytes(ByteBuf buf, CallbackInfo ci) {
ci.cancel();
chunkX = buf.readInt();
chunkZ = buf.readInt();
if (!buf.readBoolean()) {
eid$biome = buf.readShort();
blockX = buf.readByte();
blockZ = buf.readByte();
} else {
eid$biomeArray = new short[256];
for (int i = 0; i < 256; i++) {
eid$biomeArray[i] = buf.readShort();
}
}
}
}
@@ -0,0 +1,71 @@
/*
* EndlessIDs
*
* Copyright (C) 2022-2024 FalsePattern
* All Rights Reserved
*
* The above copyright notice, this permission notice and the words "MEGA"
* shall be included in all copies or substantial portions of the Software.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.falsepattern.endlessids.mixin.mixins.common.biome.ntm;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import com.falsepattern.endlessids.mixin.helpers.stubpackage.com.hbm.packet.BiomeSyncPacket;
import lombok.val;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.client.Minecraft;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
@Mixin(value = com.hbm.packet.BiomeSyncPacket.Handler.class,
remap = false)
public abstract class BiomeSyncPacket_HandlerMixin implements IMessageHandler<com.hbm.packet.BiomeSyncPacket, IMessage> {
@Inject(method = "onMessage(Lcom/hbm/packet/BiomeSyncPacket;Lcpw/mods/fml/common/network/simpleimpl/MessageContext;)Lcpw/mods/fml/common/network/simpleimpl/IMessage;",
at = @At(value = "HEAD"),
cancellable = true,
require = 1)
private void onMessage(com.hbm.packet.BiomeSyncPacket $m, MessageContext ctx, CallbackInfoReturnable<IMessage> cir) {
val world = Minecraft.getMinecraft().theWorld;
val m = (BiomeSyncPacket) $m;
if (world.getChunkProvider().chunkExists(m.chunkX, m.chunkZ)) {
val chunk = world.getChunkFromChunkCoords(m.chunkX, m.chunkZ);
val chunkHook = (ChunkBiomeHook) chunk;
chunk.isModified = true;
val biomeArray = m.eid$getBiomeArray();
val chunkBiomeArray = chunkHook.getBiomeShortArray();
if (biomeArray == null) {
val bX = m.blockX & 0xf;
val bZ = m.blockZ & 0xf;
chunkBiomeArray[bZ << 4 | bX] = m.eid$getBiome();
val cX = (m.chunkX << 4) + bX;
val cZ = (m.chunkZ << 4) + bZ;
world.markBlockRangeForRenderUpdate(cX, 0, cZ, cX, 255, cZ);
} else {
System.arraycopy(biomeArray, 0, chunkBiomeArray, 0, 256);
val cX = m.chunkX << 4;
val cZ = m.chunkZ << 4;
world.markBlockRangeForRenderUpdate(cX, 0, cZ, cX + 15, 255, cZ + 15);
}
}
cir.setReturnValue(null);
}
}
@@ -0,0 +1,103 @@
/*
* EndlessIDs
*
* Copyright (C) 2022-2024 FalsePattern
* All Rights Reserved
*
* The above copyright notice, this permission notice and the words "MEGA"
* shall be included in all copies or substantial portions of the Software.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.falsepattern.endlessids.mixin.mixins.common.biome.ntm;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import com.falsepattern.endlessids.mixin.helpers.IHBMBiomeSyncPacket;
import com.hbm.packet.BiomeSyncPacket;
import com.hbm.packet.PacketDispatcher;
import com.hbm.world.WorldUtil;
import lombok.val;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import cpw.mods.fml.common.network.NetworkRegistry;
@Mixin(value = WorldUtil.class,
remap = false)
public abstract class WorldUtilMixin {
@Inject(method = "setBiome",
at = @At("HEAD"),
cancellable = true,
require = 1)
private static void extendSetBiome(World world, int x, int z, BiomeGenBase biome, CallbackInfo ci) {
ci.cancel();
val chunk = world.getChunkFromBlockCoords(x, z);
((ChunkBiomeHook)chunk).getBiomeShortArray()[(z & 0xf) << 4 | x & 0xf] =
(short) (biome.biomeID & ExtendedConstants.biomeIDMask);
chunk.isModified = true;
}
@Inject(method = "syncBiomeChange(Lnet/minecraft/world/World;II)V",
at = @At("HEAD"),
cancellable = true,
require = 1)
private static void extendSyncBiomeChange(World world, int x, int z, CallbackInfo ci) {
ci.cancel();
Chunk chunk = world.getChunkFromBlockCoords(x, z);
val packet = new BiomeSyncPacket(x >> 4, z >> 4, null);
((IHBMBiomeSyncPacket)packet).eid$setBiomeArray(((ChunkBiomeHook)chunk).getBiomeShortArray());
PacketDispatcher.wrapper.sendToAllAround(packet, new NetworkRegistry.TargetPoint(world.provider.dimensionId,
x, 128.0F, z,
1024.0F));
}
@Inject(method = "syncBiomeChangeBlock",
at = @At("HEAD"),
cancellable = true,
require = 1)
private static void extendSyncBiomeChangeBlock(World world, int x, int z, CallbackInfo ci) {
ci.cancel();
Chunk chunk = world.getChunkFromBlockCoords(x, z);
short biome = ((ChunkBiomeHook)chunk).getBiomeShortArray()[(z & 15) << 4 | x & 15];
val packet = new BiomeSyncPacket(x, z, (byte)0);
((IHBMBiomeSyncPacket)packet).eid$setBiome(biome);
PacketDispatcher.wrapper.sendToAllAround(packet, new NetworkRegistry.TargetPoint(world.provider.dimensionId,
x, 128.0F, z,
1024.0F));
}
@Inject(method = "syncBiomeChange(Lnet/minecraft/world/World;Lnet/minecraft/world/chunk/Chunk;)V",
at = @At("HEAD"),
cancellable = true,
require = 1)
private static void extendSyncBiomeChange(World world, Chunk chunk, CallbackInfo ci) {
ci.cancel();
ChunkCoordIntPair coord = chunk.getChunkCoordIntPair();
val packet = new BiomeSyncPacket(coord.chunkXPos, coord.chunkZPos, null);
((IHBMBiomeSyncPacket)packet).eid$setBiomeArray(((ChunkBiomeHook)chunk).getBiomeShortArray());
PacketDispatcher.wrapper.sendToAllAround(packet, new NetworkRegistry.TargetPoint(world.provider.dimensionId,
coord.getCenterXPos(),
128.0F,
coord.getCenterZPosition(),
1024.0F));
}
}
@@ -38,6 +38,6 @@ public abstract class ChunkRadiationHandlerPRISMMixin {
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B"),
require = 1)
private byte[] extendLSBArray(ExtendedBlockStorage instance) {
return ((SubChunkBlockHook)instance).getB1();
return ((SubChunkBlockHook)instance).eid$getB1();
}
}
@@ -38,6 +38,6 @@ public abstract class ChunkRadiationHandlerPRISM_SubChunkMixin {
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B"),
require = 1)
private byte[] extendLSBArray(ExtendedBlockStorage instance) {
return ((SubChunkBlockHook)instance).getB1();
return ((SubChunkBlockHook)instance).eid$getB1();
}
}
@@ -50,7 +50,7 @@ public abstract class BiomeUndergroundDecoratorMixin {
private byte[] returnLSB(ExtendedBlockStorage subChunkVanilla) {
SubChunkBlockHook subChunk = (SubChunkBlockHook) subChunkVanilla;
this.subChunk = subChunk;
return subChunk.getB1();
return subChunk.eid$getB1();
}
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V",
@@ -70,7 +70,7 @@ public abstract class BiomeUndergroundDecoratorMixin {
remap = true),
require = 2)
private int returnRestOfID(NibbleArray instance, int x, int y, int z) {
val id = subChunk.getID(x, y, z) >>> 8;
val id = subChunk.eid$getID(x, y, z) >>> 8;
subChunk = null;
return id;
}
@@ -65,7 +65,7 @@ public abstract class ExtendedBlockStorageMixin implements SubChunkBlockHook {
private NibbleArray m1High;
private byte[] m2;
public int getID(int x, int y, int z) {
public int eid$getID(int x, int y, int z) {
int index = y << 8 | z << 4 | x;
int id = blockLSBArray[index] & 0xFF;
if (blockMSBArray != null) {
@@ -80,19 +80,19 @@ public abstract class ExtendedBlockStorageMixin implements SubChunkBlockHook {
return id;
}
private void setID(int x, int y, int z, int id) {
public void eid$setID(int x, int y, int z, int id) {
int index = y << 8 | z << 4 | x;
blockLSBArray[index] = (byte) (id & 0xFF);
if (id > 0xFF) {
if (blockMSBArray == null) {
createB2Low();
eid$createB2Low();
}
if (id > 0xFFF) {
if (b2High == null) {
createB2High();
eid$createB2High();
}
if (id > 0xFFFF && b3 == null) {
createB3();
eid$createB3();
}
}
}
@@ -113,7 +113,7 @@ public abstract class ExtendedBlockStorageMixin implements SubChunkBlockHook {
*/
@Overwrite
public Block getBlockByExtId(int x, int y, int z) {
return Block.getBlockById(getID(x, y, z));
return Block.getBlockById(eid$getID(x, y, z));
}
/**
@@ -138,7 +138,7 @@ public abstract class ExtendedBlockStorageMixin implements SubChunkBlockHook {
}
int blockID = Hooks.getIdFromBlockWithCheck(newBlock, oldBlock);
setID(x, y, z, blockID);
eid$setID(x, y, z, blockID);
}
/**
@@ -166,10 +166,10 @@ public abstract class ExtendedBlockStorageMixin implements SubChunkBlockHook {
blockMetadataArray.set(x, y, z, meta & 0xF);
if (meta > 0xF) {
if (m1High == null) {
createM1High();
eid$createM1High();
}
if (meta > 0xFF && m2 == null) {
createM2();
eid$createM2();
}
}
if (m1High != null) {
@@ -180,6 +180,16 @@ public abstract class ExtendedBlockStorageMixin implements SubChunkBlockHook {
}
}
@Override
public int eid$getMetadata(int x, int y, int z) {
return getExtBlockMetadata(x, y, z);
}
@Override
public void eid$setMetadata(int x, int y, int z, int id) {
setExtBlockMetadata(x, y, z, id);
}
@Redirect(method = "removeInvalidBlocks",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockByExtId(III)Lnet/minecraft/block/Block;"),
@@ -202,102 +212,102 @@ public abstract class ExtendedBlockStorageMixin implements SubChunkBlockHook {
}
@Override
public byte[] getB1() {
public byte[] eid$getB1() {
return blockLSBArray;
}
@Override
public void setB1(byte[] data) {
public void eid$setB1(byte[] data) {
blockLSBArray = data;
}
@Override
public NibbleArray getB2Low() {
public NibbleArray eid$getB2Low() {
return blockMSBArray;
}
@Override
public void setB2Low(NibbleArray data) {
public void eid$setB2Low(NibbleArray data) {
blockMSBArray = data;
}
@Override
public NibbleArray createB2Low() {
public NibbleArray eid$createB2Low() {
return (blockMSBArray = new NibbleArray(blocksPerSubChunk, 4));
}
@Override
public NibbleArray getB2High() {
public NibbleArray eid$getB2High() {
return b2High;
}
@Override
public void setB2High(NibbleArray data) {
public void eid$setB2High(NibbleArray data) {
b2High = data;
}
@Override
public NibbleArray createB2High() {
public NibbleArray eid$createB2High() {
return (b2High = new NibbleArray(blocksPerSubChunk, 4));
}
@Override
public byte[] getB3() {
public byte[] eid$getB3() {
return b3;
}
@Override
public void setB3(byte[] data) {
public void eid$setB3(byte[] data) {
b3 = data;
}
@Override
public byte[] createB3() {
public byte[] eid$createB3() {
return b3 = new byte[blocksPerSubChunk];
}
@Override
public NibbleArray getM1Low() {
public NibbleArray eid$getM1Low() {
return blockMetadataArray;
}
@Override
public void setM1Low(NibbleArray m1Low) {
public void eid$setM1Low(NibbleArray m1Low) {
blockMetadataArray = m1Low;
}
@Override
public NibbleArray getM1High() {
public NibbleArray eid$getM1High() {
return m1High;
}
@Override
public void setM1High(NibbleArray m1High) {
public void eid$setM1High(NibbleArray m1High) {
this.m1High = m1High;
}
@Override
public NibbleArray createM1High() {
public NibbleArray eid$createM1High() {
return (m1High = new NibbleArray(blocksPerSubChunk, 4));
}
@Override
public byte[] getM2() {
public byte[] eid$getM2() {
return m2;
}
@Override
public void setM2(byte[] m2) {
public void eid$setM2(byte[] m2) {
this.m2 = m2;
}
@Override
public byte[] createM2() {
public byte[] eid$createM2() {
return (m2 = new byte[blocksPerSubChunk]);
}
@Override
public int getBlockMask() {
public int eid$getBlockMask() {
if (blockMSBArray == null) {
return 0b00;
}
@@ -311,7 +321,7 @@ public abstract class ExtendedBlockStorageMixin implements SubChunkBlockHook {
}
@Override
public int getMetadataMask() {
public int eid$getMetadataMask() {
if (m1High == null) {
return 0b01;
}
@@ -57,6 +57,15 @@ public abstract class S0FPacketSpawnMobMixin {
return 0;
}
@Redirect(method = "readPacketData",
at = @At(value = "FIELD",
target = "Lnet/minecraft/network/play/server/S0FPacketSpawnMob;field_149040_b:I",
ordinal = 0),
require = 1)
private void noReadByte2(S0FPacketSpawnMob instance, int value) {
}
@Inject(method = "readPacketData",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/network/PacketBuffer;readByte()B",
@@ -152,6 +152,11 @@ public enum Mixin implements IMixin {
GSChunkProviderSpaceLakesMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.GALAXYSPACE)), "biome.galaxyspace.ChunkProviderSpaceLakesMixin"),
GSChunkProviderVenusSSMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.GALAXYSPACE)), "biome.galaxyspace.ChunkProviderVenusSSMixin"),
//endregion GalaxySpace
//region HBM's Nuclear Tech Nod
NTMBiomeSyncPacket_HandlerMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.HBM_NTM)), "biome.ntm.BiomeSyncPacket_HandlerMixin"),
NTMBiomeSyncPacketMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.HBM_NTM)), "biome.ntm.BiomeSyncPacketMixin"),
NTMWorldUtilMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.HBM_NTM)), "biome.ntm.WorldUtilMixin"),
//endregion HBM's Nuclear Tech Nod
//region Highlands
HighlandsConfigMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.HIGHLANDS)), "biome.highlands.ConfigMixin"),
//endregion Highlands