Skip to content

Commit

Permalink
update to 1.1.3-alpha.3
Browse files Browse the repository at this point in the history
修复了有概率碰上连接已丢失的 bug
修复了往浮空的红石火把投影上轻松放置时导致游戏崩溃的 bug
修复了轻松放置时原木方向不对的 bug
  • Loading branch information
plusls committed Feb 11, 2021
1 parent 6cf1ce0 commit 886c201
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 27 deletions.
18 changes: 9 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.16.4
yarn_mappings=1.16.4+build.7
loader_version=0.10.8
minecraft_version=1.16.5
yarn_mappings=1.16.5+build.3
loader_version=0.11.1

# Mod Properties
mod_version = 1.1.3-alpha.1
mod_version = 1.1.3-alpha.3
maven_group = io.github.plusls
archives_base_name = MasaGadget

# malilib version
malilib_version = 0.10.0-dev.21+arne.2
malilib_version = 0.10.0-dev.21+arne.3
# minihud version
minihud_version = 0.19.0-dev.20201103.184029
minihud_version = 0.19.0-dev.20210129.142059
# tweakeroo version
tweakeroo_version = 0.10.0-dev.20201213.222846
tweakeroo_version = 0.10.0-dev.20210209.145902
# litematica version
litematica_version = 0.0.0-dev.20210104.135541
litematica_version = 0.0.0-dev.20210120.213004
# multiconnect version
multiconnect_version = 1.3.34

# 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.29.3+1.16
fabric_version=0.30.0+1.16
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import net.minecraft.util.registry.Registry;

import java.util.HashMap;
import java.util.concurrent.locks.ReentrantLock;

public class BborProtocol {
private static final String NAMESPACE = "bbor";
Expand All @@ -42,6 +43,7 @@ private static Identifier id(String path) {
public static BlockPos spawnPos = null;
public static boolean enable = false;
public static boolean carpetOrServux = false;
public static final ReentrantLock lock = new ReentrantLock(true);

private static final ClientboundIdentifierCustomPayloadListener clientboundIdentifierCustomPayloadListener =
new ClientboundIdentifierCustomPayloadListener();
Expand Down Expand Up @@ -97,6 +99,10 @@ private static void onDisconnect() {
BborProtocol.structuresCache = null;
BborProtocol.enable = false;
BborProtocol.carpetOrServux = false;
// 为了鲁棒性考虑 断开连接时应该确保当前的锁已解开
while (BborProtocol.lock.isLocked()) {
BborProtocol.lock.unlock();
}
}

private static void onJoinServer(ClientPlayNetworkHandler handler, PacketSender sender, MinecraftClient client) {
Expand All @@ -120,6 +126,8 @@ private static void bborInitializeHandler(PacketByteBuf data) {
BborProtocol.seedCache = seed;
BborProtocol.spawnPos = new BlockPos(spawnX, 0, spawnZ);
BborProtocol.structuresCache = new ListTag();
// 若是未加载 MiniHUD,则不会去 mixin CustomPayloadS2CPacket,因此不会有机会调用该函数
// 因此无需对是否加载 MiniHUD 进行特判
if (!BborProtocol.carpetOrServux) {
BborProtocol.enable = true;
DataStorage.getInstance().setWorldSeed(BborProtocol.seedCache);
Expand Down Expand Up @@ -147,7 +155,9 @@ static public void parse(PacketByteBuf buf) {
structures.add(tag);
structuresCache.add(tag);
if (enable) {
BborProtocol.lock.lock();
DataStorage.getInstance().addOrUpdateStructuresFromServer(structures, 0x7fffffff - 0x1000, false);
BborProtocol.lock.unlock();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.state.property.Properties;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
Expand All @@ -28,7 +29,7 @@
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(value = WorldUtils.class)
@Mixin(value = WorldUtils.class, priority = 900)
public class MixinWorldUtils {
/**
* @author plusls
Expand Down Expand Up @@ -159,18 +160,25 @@ private static ActionResult doEasyPlaceAction(MinecraftClient mc) {
// TODO
Direction newSide = BlockUtils.getFirstPropertyFacingValue(stateSchematic);
float oldYaw = mc.player.yaw;
if (newSide == null && stateSchematic.contains(Properties.AXIS)) {
// 原木之类的
newSide = Direction.from(stateSchematic.get(Properties.AXIS), Direction.AxisDirection.POSITIVE);

}
if (newSide != null && !(stateSchematic.getBlock() instanceof SlabBlock)) {
// fuck mojang
// 有时候放的东西是反向的,需要特判
side = newSide;
mc.player.yaw = side.asRotation();
ItemStack itemStack = new ItemStack(stateSchematic.getBlock().asItem());
ItemPlacementContext itemPlacementContext = new ItemPlacementContext(mc.player, hand, itemStack, new BlockHitResult(hitPos, side, pos, false));
BlockState testState = stateSchematic.getBlock().getPlacementState(itemPlacementContext);
assert (testState != null);
Direction testDirection = BlockUtils.getFirstPropertyFacingValue(testState);
assert (testDirection != null);
if (testDirection != side) {
side = side.getOpposite();
mc.player.yaw = side.asRotation();
if (testState != null) {
Direction testDirection = BlockUtils.getFirstPropertyFacingValue(testState);
if (testDirection != null && testDirection != side) {
side = side.getOpposite();
mc.player.yaw = side.asRotation();
}
}
mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookOnly(mc.player.yaw, mc.player.pitch, mc.player.isOnGround()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ private void postReset(boolean isLogout, CallbackInfo ci) {
DataStorage.getInstance().setWorldSeed(BborProtocol.seedCache);
if (BborProtocol.spawnPos != null)
DataStorage.getInstance().setWorldSpawn(BborProtocol.spawnPos);
if (BborProtocol.structuresCache != null)
if (BborProtocol.structuresCache != null) {
BborProtocol.lock.lock();
DataStorage.getInstance().addOrUpdateStructuresFromServer(BborProtocol.structuresCache, 0x7fffffff - 0x1000, false);
BborProtocol.lock.unlock();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ void redirectOnPlayerRespawn(ClientPlayPacketListener listener, PlayerRespawnS2C
RegistryKey<World> newDimension = packet.getDimension();
if (oldDimension != newDimension && BborProtocol.structuresCache != null) {
// reload minihud struct when dimension change
BborProtocol.lock.lock();
DataStorage.getInstance().addOrUpdateStructuresFromServer(BborProtocol.structuresCache, 0x7fffffff - 0x1000, false);
BborProtocol.lock.unlock();
}
}
}
4 changes: 0 additions & 4 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"homepage": "https://blog.plusls.com/",
"sources": "https://github.com/uestclug/MasaGadget"
},

"license": "CC0-1.0",
"environment": "client",
"entrypoints": {
Expand All @@ -31,8 +30,5 @@
},
"suggests": {
"flamingo": "*"
},
"custom": {
"modmenu:clientsideOnly": true
}
}
13 changes: 7 additions & 6 deletions src/main/resources/masa_gadget_mod.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@
"minihud.feature.compactBborProtocol.MixinDataStorage",
"minihud.feature.compactBborProtocol.MixinPlayerRespawnS2CPacket",
"tweakeroo.feature.pcaSyncProtocol.MixinRenderHandler",
"tweakeroo.feature.pcaSyncProtocol.MixinRenderUtils"
],
"injectors": {
"defaultRequire": 1
},
"mixins": [
"tweakeroo.feature.pcaSyncProtocol.MixinRenderUtils",
"litematica.feature.nudgeSelectionSupportFreeCamera.MixinInputHandler",
"litematica.fix.carpetAccurateProtocol.MixinWorldUtils",
"malilib.feature.optimizeConfigWidgetSearch.MixinWidgetListConfigOptions",
"malilib.fix.configWidgetWidth.MixinWidgetListConfigOptions",
"tweakeroo.feature.inventoryPreviewSupportFreeCamera.MixinRenderUtils",
"tweakeroo.feature.inventoryPreviewSupportPlayer.MixinRenderUtils",
"util.MixinMinecraftClient"
],
"injectors": {
"defaultRequire": 1
},
"mixins": [

]
}

0 comments on commit 886c201

Please sign in to comment.