Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
*/
dependencies {
// ========================= Real Deps ========================= //
implementation("com.github.GTNewHorizons:GTNHLib:0.8.15:dev")
implementation("com.github.GTNewHorizons:RegionLib:v0.1.0-GTNH:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.8.40-GTNH:dev")

compileOnly("com.falsepattern:chunkapi-mc1.7.10:0.7.0:dev")
compileOnly("com.falsepattern:endlessids-mc1.7.10:1.6.14:dev")
// ========================= Test Deps ========================= //
devOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.8.40-GTNH:dev")

// runtimeOnlyNonPublishable("com.falsepattern:chunkapi-mc1.7.10:0.7.0-1-g67006b5-dirty:dev")
// implementation("com.falsepattern:endlessids-mc1.7.10:1.6.14-dirty:dev")
devOnlyNonPublishable("com.falsepattern:chunkapi-mc1.7.10:0.8.0:dev")
devOnlyNonPublishable("com.falsepattern:endlessids-mc1.7.10:1.7.0:dev")

compileOnly("org.jetbrains:annotations:26.0.2")

Expand Down
24 changes: 19 additions & 5 deletions src/main/java/com/cardinalstar/cubicchunks/mixin/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public enum Mixins implements IMixins {
.setPhase(Phase.EARLY)
.setApplyIf(() -> true)),
MIXIN_WORLD_GEN_CANOPY_TREE(
new MixinBuilder("Allowing generation and growing of dark oak saplings above 256 adn below 0.")
new MixinBuilder("Allowing generation and growing of dark oak saplings above 256 and below 0.")
.addCommonMixins("common.MixinWorldGenCanopyTree")
.setPhase(Phase.EARLY)
.setApplyIf(() -> true)),
Expand All @@ -64,7 +64,7 @@ public enum Mixins implements IMixins {
new MixinBuilder("Allowing lilypads to stay above 256 adn below 0.").addCommonMixins("common.MixinBlockLilyPad")
.setPhase(Phase.EARLY)
.setApplyIf(() -> true)),
MIXIN_S01PACKET_JOIN_GAME(new MixinBuilder("Giving the packet info to initailize cubicWorlds for clients.")
MIXIN_S01PACKET_JOIN_GAME(new MixinBuilder("Giving the packet info to initialize cubicWorlds for clients.")
.addCommonMixins("common.vanillaclient.MixinS01PacketJoinGame")
.setPhase(Phase.EARLY)
.setApplyIf(() -> true)),
Expand All @@ -82,6 +82,15 @@ public enum Mixins implements IMixins {
.addCommonMixins("common.AccessorS23PacketBlockChange")
.setPhase(Phase.EARLY)
.setApplyIf(() -> true)),
MIXIN_S23_HEIGHTLIMITS(new MixinBuilder("Changing packet S23 for reading and writing ints to Y values")
.addCommonMixins("common.MixinS23PacketBlockChange")
.setPhase(Phase.LATE)
.addExcludedMod(Mods.ChunkAPI)
.setApplyIf(() -> true)),
MIXIN_BIOME_GEN_BASE(
new MixinBuilder("Removes bedrock for pure cubic worlds.").addCommonMixins("common.MixinBiomeGenBase")
.setPhase(Phase.EARLY)
.setApplyIf(() -> true)),

// CHUNK
MIXIN_CHUNK_COLUMN(
Expand Down Expand Up @@ -284,11 +293,16 @@ public enum Mixins implements IMixins {
// =============================================================
// Mod Mixins
// =============================================================
MIXIN_COORD_PACKER(new MixinBuilder("Overwrite GTNHLib CoordinatePacker algorithm with a CC-compatible one")
.addCommonMixins("common.MixinCoordinatePacker")
MIXIN_COORD_PACKER_HODGE(new MixinBuilder("Overwrite GTNHLib CoordinatePacker algorithm with a CC-compatible one")
.addCommonMixins("mod.MixinCoordinatePacker")
.setPhase(Phase.EARLY)
.setApplyIf(() -> true)),

MIXIN_COORD_PACKER_CHUNKAPI(
new MixinBuilder("Overwrite ChunkAPI CoordiantePacker algorithm with a CC-compatible one")
.addCommonMixins("mod.MixinBlockPosUtil")
.setPhase(Phase.LATE)
.addRequiredMod(Mods.ChunkAPI)
.setApplyIf(() -> true))
//
;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.cardinalstar.cubicchunks.mixin.early.common;

import java.util.Random;

import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

import com.cardinalstar.cubicchunks.api.worldtype.VanillaCubicWorldType;
import com.llamalad7.mixinextras.expression.Definition;
import com.llamalad7.mixinextras.expression.Expression;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.sugar.Local;

@Mixin(BiomeGenBase.class)
public class MixinBiomeGenBase {

@Definition(id = "l1", local = @Local(name = "l1", type = int.class))
@Definition(id = "rand", local = @Local(argsOnly = true, ordinal = 0, name = "p_150560_2_"), type = Random.class)
@Definition(id = "nextInt", method = "Ljava/util/Random;nextInt(I)I")
@Expression("l1 <= ?")
@ModifyExpressionValue(method = "genBiomeTerrain", at = @At(value = "MIXINEXTRAS:EXPRESSION", ordinal = 0))
boolean RemoveBedrockForCubicGen(boolean original, @Local(argsOnly = true) World world) {
if (world.getWorldInfo()
.getTerrainType() == VanillaCubicWorldType.INSTANCE) {
return false;
}
return original;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,6 @@ private void recheckGaps_CubicChunks_Replace(boolean p_150803_1_, CallbackInfo c
}
}

// private void checkSkylightNeighborHeight(int x, int zPosition, int maxValue) - shouldn't be used by anyone

// private void updateSkylightNeighborHeight(int x, int zPosition, int startY, int endY) - shouldn't be used by
// anyone

// ==============================================
// relightBlock
// ==============================================
Expand Down Expand Up @@ -447,7 +442,7 @@ private void setBlockState_CubicChunks_relightBlockReplace(int localX, int local
if (isColumn && ((IColumn) this).getCube(blockToCube(localY))
.isInitialLightingDone()) {
if (oldHeightValue == localY + 1) { // oldHeightValue is the previous block Y above the top block, so this
// is the "removing to block" case
// is the "removing a block" case
getWorldObj().getLightingManager()
.doOnBlockSetLightUpdates(
(Chunk) (Object) this,
Expand All @@ -457,7 +452,7 @@ private void setBlockState_CubicChunks_relightBlockReplace(int localX, int local
localZ);
} else {
getWorldObj().getLightingManager()
.doOnBlockSetLightUpdates((Chunk) (Object) this, localX, oldHeightValue, localY, localZ);
.doOnBlockSetLightUpdates((Chunk) (Object) this, localX, oldHeightValue, localY + 1, localZ);
}
}
}
Expand Down Expand Up @@ -501,14 +496,6 @@ private void relightBlock_CubicChunks_Replace(int x, int y, int z, CallbackInfo
// getBlock
// ==============================================

// This check isn't made in 1.7.10
// @ModifyConstant(method = "getBlock(III)Lnet/minecraft/block/Block;",
// constant = @Constant(expandZeroConditions = Constant.Condition.GREATER_THAN_OR_EQUAL_TO_ZERO),
// require = 1)
// private int getBlockState_getMinHeight(int zero) {
// return isColumn ? Integer.MIN_VALUE : getWorldObj().getMinHeight(); // this one is in block coords, max is in
// cube coords. Mojang logic.
// }
@Redirect(
method = "getBlock(III)Lnet/minecraft/block/Block;",
at = @At(
Expand Down Expand Up @@ -576,7 +563,7 @@ private void onEBSSet_setBlockWithMeta_setOpacity(int x, int y, int z, Block blo
if (cube.isSurfaceTracked()) {
opacityIndex.onOpacityChange(blockToLocal(x), y, blockToLocal(z), block.getLightOpacity());
getWorldObj().getLightingManager()
.onHeightUpdate(x, y, z);
.onHeightUpdate(x + 16 * this.xPosition, y, z + 16 * this.zPosition);
} else {
stagingHeightMap.onOpacityChange(blockToLocal(x), y, blockToLocal(z), block.getLightOpacity());
}
Expand Down Expand Up @@ -640,7 +627,7 @@ private void onEBSSet_setBlockMetadata_setOpacity(int x, int y, int z, int meta,
if (cube.isSurfaceTracked()) {
opacityIndex.onOpacityChange(blockToLocal(x), y, blockToLocal(z), block.getLightOpacity());
getWorldObj().getLightingManager()
.onHeightUpdate(x, y, z);
.onHeightUpdate(x + 16 * this.xPosition, y, z + 16 * this.zPosition);
} else {
stagingHeightMap.onOpacityChange(blockToLocal(x), y, blockToLocal(z), block.getLightOpacity());
}
Expand All @@ -656,32 +643,6 @@ private ExtendedBlockStorage setBlockMetadata_CubicChunks_EBSGetRedirect(Extende
return getEBS_CubicChunks(index);
}

// TODO Not sure how these got here.

// @Redirect(method = "setBlockMetadata", at = @At(
// value = "FIELD",
// target =
// "Lnet/minecraft/world/chunk/Chunk;storageArrays:[Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;",
// args = "array=set"
// ))
// private void setBlockMetadata_CubicChunks_EBSSetRedirect(ExtendedBlockStorage[] array, int index,
// ExtendedBlockStorage val) {
// setEBS_CubicChunks(index, val);
// }
//
// @Inject(method = "setBlockMetadata", at = @At(
// value = "FIELD",
// target =
// "Lnet/minecraft/world/chunk/Chunk;storageArrays:[Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;",
// args = "array=set"
// ), cancellable = true)
// private void setBlockMetadata_CubicChunks_EBSSetInject(int x, int y, int z, Block block, int meta,
// CallbackInfoReturnable<Boolean> cir) {
// if (isColumn && getWorldObj().getCubeCache().getLoadedCube(CubePos.fromBlockCoords(x, y, z)) == null) {
// cir.setReturnValue(null);
// }
// }

@Redirect(
method = "setBlockMetadata",
at = @At(value = "FIELD", target = "Lnet/minecraft/world/chunk/Chunk;isModified:Z"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.cardinalstar.cubicchunks.mixin.early.common;

import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.server.S23PacketBlockChange;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import com.llamalad7.mixinextras.expression.Definition;
import com.llamalad7.mixinextras.expression.Expression;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;

import io.netty.buffer.ByteBuf;

@Mixin(S23PacketBlockChange.class)
public class MixinS23PacketBlockChange {

@Shadow
private int field_148885_b;

@Redirect(
method = "readPacketData",
at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketBuffer;readUnsignedByte()S", ordinal = 0))
private short noopReadUnsignedByte(PacketBuffer instance, @Local(argsOnly = true) PacketBuffer data) {
return 0;
}

@Inject(
method = "readPacketData",
at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketBuffer;readInt()I", ordinal = 1))
private void assignYValue(PacketBuffer data, CallbackInfo ci) {
this.field_148885_b = data.readInt();
}

@Definition(
id = "field_148885_b",
field = "Lnet/minecraft/network/play/server/S23PacketBlockChange;field_148885_b:I")
@Expression("?.?(this.field_148885_b)")
@WrapOperation(method = "writePacketData", at = @At("MIXINEXTRAS:EXPRESSION"))
private ByteBuf wrapWriteByte(PacketBuffer instance, int p_writeByte_1_, Operation<ByteBuf> original,
@Local(argsOnly = true) PacketBuffer data) {
data.writeInt(field_148885_b);
return data;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.cardinalstar.cubicchunks.mixin.early.mod;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;

import com.cardinalstar.cubicchunks.util.Coords;
import com.falsepattern.chunk.internal.BlockPosUtil;

@Mixin(BlockPosUtil.class)
public class MixinBlockPosUtil {

/**
* @author Cardinalstar16
* @reason Performance
*/
@Overwrite(remap = false)
public static long packToLong(int x, int y, int z) {
return Coords.key(x, y, z);
}

/**
* @author Cardinalstar16
* @reason Performance
*/
@Overwrite(remap = false)
public static int getX(long packed) {
return Coords.x(packed);
}

/**
* @author Cardinalstar16
* @reason Performance
*/
@Overwrite(remap = false)
public static int getY(long packed) {
return Coords.y(packed);
}

/**
* @author Cardinalstar16
* @reason Performance
*/
@Overwrite(remap = false)
public static int getZ(long packed) {
return Coords.z(packed);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cardinalstar.cubicchunks.mixin.early.common;
package com.cardinalstar.cubicchunks.mixin.early.mod;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ public void writePacket(CCPacketBuffer buffer, PacketCubes packet) {

buffer.writeByteArray(packet.data);

buffer.writeList(
packet.tileEntityTags,
(buf2, list) -> { buf2.writeList(list, CCPacketBuffer::writeCompoundTag); });
buffer.writeList(packet.tileEntityTags, (buf2, list) -> buf2.writeList(list, CCPacketBuffer::writeCompoundTag));
}

@Override
Expand All @@ -128,7 +126,7 @@ public PacketCubes readPacket(CCPacketBuffer buf) {
byte[] data = buf.readByteArray();

List<List<NBTTagCompound>> tileEntityTags = buf
.readList(buf2 -> { return buf2.readList(CCPacketBuffer::readCompoundTag); });
.readList(buf2 -> buf2.readList(CCPacketBuffer::readCompoundTag));

return new PacketCubes(cubePos, data, tileEntityTags);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,12 @@ static void decodeColumn(CCPacketBuffer in, Chunk column) {
static void encodeCubes(CCPacketBuffer out, Collection<Cube> cubes) {
final boolean capi = Mods.ChunkAPI.isModLoaded();

byte[] buffer = new byte[0]; // getBuffer(DataRegistryImpl.maxPacketSizeCubic());

byte[] buffer;
if (capi) {
buffer = getBuffer(DataRegistryImpl.maxPacketSizeCubic());
} else {
buffer = new byte[0];
}
for (Cube cube : cubes) {
ExtendedBlockStorage storage = cube.getStorage();

Expand Down Expand Up @@ -124,9 +128,9 @@ static void encodeCubes(CCPacketBuffer out, Collection<Cube> cubes) {
cube.writeBiomeArray(out);

if (!empty && capi) {
// int written = DataRegistryImpl.writeToBufferCubic(cube.getColumn(), storage, buffer);
int written = DataRegistryImpl.writeToBufferCubic(cube.getColumn(), storage, buffer);

// out.writeByteArray(buffer, 0, written);
out.writeByteArray(buffer, 0, written);
}
}
}
Expand All @@ -147,7 +151,12 @@ static void decodeCube(CCPacketBuffer in, List<Cube> cubes) {

int[] oldHeights = new int[Cube.SIZE * Cube.SIZE];

byte[] buffer = new byte[0]; // getBuffer(DataRegistryImpl.maxPacketSizeCubic());
byte[] buffer;
if (capi) {
buffer = getBuffer(DataRegistryImpl.maxPacketSizeCubic());
} else {
buffer = new byte[0];
}

for (int i = 0; i < cubes.size(); i++) {
Cube cube = cubes.get(i);
Expand Down Expand Up @@ -226,7 +235,7 @@ static void decodeCube(CCPacketBuffer in, List<Cube> cubes) {

if (!empty && capi) {
try {
// DataRegistryImpl.readFromBufferCubic(cube.getColumn(), storage, in.readByteArray(buffer));
DataRegistryImpl.readFromBufferCubic(cube.getColumn(), storage, in.readByteArray(buffer));
} catch (Throwable t) {
CubicChunks.LOGGER
.error("Error decoding ChunkAPI data ({},{},{})", cube.getX(), cube.getY(), cube.getZ(), t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ public void markBlockForUpdate(int x, int y, int z) {
}
}

// Note these arguments are in global block coordinates
public void heightUpdated(int x, int z) {
WatchedColumn column = watchedColumns.get(x >> 4, z >> 4);

Expand Down

This file was deleted.

Loading