Skip to content

Commit

Permalink
update to 1.16.2
Browse files Browse the repository at this point in the history
  • Loading branch information
plusls committed Aug 13, 2020
1 parent 3050648 commit c4a6fc2
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 63 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ bin/
# fabric

run/

# log

logs/
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.16.1
yarn_mappings=1.16.1+build.18
loader_version=0.8.8+build.202
minecraft_version=1.16.2
yarn_mappings=1.16.2+build.6
loader_version=0.9.1+build.205

# Mod Properties
mod_version = 1.0.0-alpha.4
Expand All @@ -14,4 +14,4 @@ org.gradle.jvmargs=-Xmx1G

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.14.0+build.371-1.16
fabric_version=0.17.2+build.396-1.16

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(ChunkDataS2CPacket.class)
public abstract class ChunkDataS2CPacketMixin extends Object {
public abstract class MixinChunkDataS2CPacket extends Object {

// hook block entity packet
@Redirect(method="<init>(Lnet/minecraft/world/chunk/WorldChunk;IZ)V",
at=@At(value = "INVOKE", target="Lnet/minecraft/block/entity/BlockEntity;toInitialChunkDataTag()Lnet/minecraft/nbt/CompoundTag;", ordinal=0))
private CompoundTag upgradeCompoundTag(BlockEntity blockEntity){
@Redirect(method = "<init>(Lnet/minecraft/world/chunk/WorldChunk;I)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/block/entity/BlockEntity;toInitialChunkDataTag()Lnet/minecraft/nbt/CompoundTag;", ordinal = 0))
private CompoundTag upgradeCompoundTag(BlockEntity blockEntity) {

if (blockEntity instanceof FakeBlockEntity) {
return ((FakeBlockEntity) blockEntity).toInitialClientChunkDataTag();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.github.plusls.gravestone.mixin;

import io.github.plusls.gravestone.GravestoneMod;
import io.github.plusls.gravestone.block.FakeBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.network.Packet;
import net.minecraft.network.listener.ClientPlayPacketListener;
import net.minecraft.network.packet.s2c.play.ChunkDeltaUpdateS2CPacket;
import net.minecraft.world.chunk.ChunkSection;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(ChunkDeltaUpdateS2CPacket.class)
public abstract class MixinChunkDeltaUpdateS2CPacket implements Packet<ClientPlayPacketListener> {

// hook BlockState packet
@Redirect(method = "<init>(Lnet/minecraft/util/math/ChunkSectionPos;Lit/unimi/dsi/fastutil/shorts/ShortSet;Lnet/minecraft/world/chunk/ChunkSection;Z)V",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/ChunkSection;getBlockState(III)Lnet/minecraft/block/BlockState;",
ordinal = 0))
private BlockState redirectGetBlockState(ChunkSection section, int x, int y, int z) {
BlockState blockState = section.getBlockState(x, y, z);
Block block = blockState.getBlock();
if (block instanceof FakeBlock) {
GravestoneMod.LOGGER.info("ChunkDeltaUpdateS2CPacket hook BlockState packet");
blockState = ((FakeBlock) block).getClientBlockState(blockState);
}
return blockState;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,23 @@

import io.github.plusls.gravestone.GravestoneMod;
import io.github.plusls.gravestone.block.FakeBlock;
import io.github.plusls.gravestone.util.GravestoneUtil;
import net.fabricmc.fabric.impl.registry.sync.RegistrySyncManager;
import net.minecraft.block.Block;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
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.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.fabricmc.fabric.impl.registry.sync.RegistrySyncManager;

@Mixin(RegistrySyncManager.class)
public class RegistrySyncManagerMixin {
// @Inject(method = "createPacket", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/fabricmc/fabric/impl/registry/sync/RegistrySyncManager;toTag(ZLnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/nbt/CompoundTag;"))
// private static void onCreatePacket(CallbackInfoReturnable callbackInfoReturnable) {
//
// }
public class MixinRegistrySyncManager {
// target = "Lnet/fabricmc/fabric/impl/registry/sync/RegistrySyncManager;toTag(ZLnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/nbt/CompoundTag;",
// 目前没有同步事件,因此不再mixin
@ModifyVariable(method = "createPacket",
at = @At(value = "INVOKE_ASSIGN", target = "Lnet/fabricmc/fabric/impl/registry/sync/RegistrySyncManager;toTag",
ordinal=0, remap=false),
ordinal=0, remap=false)
at = @At(value = "INVOKE",
target = "Lnet/fabricmc/fabric/impl/registry/sync/RegistrySyncManager;toTag(ZLnet/minecraft/class_2487;)Lnet/minecraft/class_2487;",
ordinal = 0, remap = false),
ordinal = 0, remap = false)
private static CompoundTag updateCompoundTag(CompoundTag tag) {
GravestoneMod.LOGGER.info("Try to update Registry.BLOCK sync data.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.world.World;
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;

@Mixin(ServerPlayerEntity.class)
public abstract class PlayerEntityMixin extends PlayerEntity {
public abstract class MixinServerPlayerEntity extends PlayerEntity {

private PlayerEntityMixin() {
super(null, null, null);
throw new RuntimeException("wtf");
private MixinServerPlayerEntity(World world) {
super(null, null, 0, null);
}

// hook death
Expand Down
7 changes: 3 additions & 4 deletions src/main/resources/gravestone.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
"package": "io.github.plusls.gravestone.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
"RegistrySyncManagerMixin",
"PalettedContainerMixin",
"ChunkDataS2CPacketMixin",
"ChunkDeltaRecordMixin",
"MixinChunkDataS2CPacket",
"MixinChunkDeltaUpdateS2CPacket",
"PlayerActionResponseS2CPacketMixin",
"PlayerEntityMixin",
"MixinServerPlayerEntity",
"BlockUpdateS2CPacketMixin",
"invoker.PlayerEntityInvoker"
],
Expand Down

0 comments on commit c4a6fc2

Please sign in to comment.