Skip to content

Commit

Permalink
update to 1.14.1, fix level-sync issue
Browse files Browse the repository at this point in the history
  • Loading branch information
LemmaEOF committed May 14, 2019
1 parent 0b271c3 commit 885acea
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
25 changes: 17 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,27 @@ repositories {
}

dependencies {
minecraft "com.mojang:minecraft:1.14"
mappings "net.fabricmc:yarn:1.14+build.21"
modCompile "net.fabricmc:fabric-loader:0.4.4+build.138"
modCompile "net.fabricmc:fabric:0.2.7+build.127"

modCompile "io.github.prospector.modmenu:ModMenu:1.5.1-81"
modCompile "io.github.cottonmc:cotton:0.6.1+1.14-SNAPSHOT"
include "io.github.cottonmc:cotton:0.6.1+1.14-SNAPSHOT"
minecraft "com.mojang:minecraft:1.14.1"
mappings "net.fabricmc:yarn:1.14.1+build.4"
modCompile "net.fabricmc:fabric-loader:0.4.7+build.147"
modCompile "net.fabricmc.fabric-api:fabric-api:0.3.0-pre+build.156"

modCompile "io.github.prospector.modmenu:ModMenu:1.5.3-84"
modCompile "io.github.cottonmc:cotton:0.6.6+1.14.1-SNAPSHOT"
include "io.github.cottonmc:cotton:0.6.6+1.14.1-SNAPSHOT"
modCompile "crochet:Crochet:1.0.2"
include "crochet:Crochet:1.0.2"
modCompile "cloth-config:ClothConfig:0.2.1.14"
include "cloth-config:ClothConfig:0.2.1.14"

include "net.fabricmc.fabric-api:fabric-api-base:0.1.0+f1618918"
include "net.fabricmc.fabric-api:fabric-commands-v0:0.1.0+f1618918"
include "net.fabricmc.fabric-api:fabric-containers-v0:0.1.0+f1618918"
include "net.fabricmc.fabric-api:fabric-events-interaction-v0:0.1.0+f1618918"
include "net.fabricmc.fabric-api:fabric-item-groups-v0:0.1.0+f1618918"
include "net.fabricmc.fabric-api:fabric-networking-v0:0.1.0+f1618918"
include "net.fabricmc.fabric-api:fabric-resource-loader-v0:0.1.0+f1618918"
include "net.fabricmc.fabric-api:fabric-tag-extensions-v0:0.1.0+f1618918"
}

processResources {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ private void syncClassIndex() {
}

private void syncLevelUp() {
if (!playerInventory.player.isCreative()) playerInventory.player.experienceLevel -= container.getLevelCost();
SkillCheckNetworking.syncLevelup(container.classes.get(index));
SkillCheckNetworking.syncLevelup(container.classes.get(index), container.getLevelCost());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public static void init() {
}));
ServerSidePacketRegistry.INSTANCE.register(SYNC_LEVELUP, (((packetContext, packetByteBuf) -> {
Identifier id = packetByteBuf.readIdentifier();
int xpCost = packetByteBuf.readInt();
if (!packetContext.getPlayer().isCreative()) packetContext.getPlayer().experienceLevel -= xpCost;
ClassManager.levelUp(packetContext.getPlayer(), id);
})));
}
Expand All @@ -40,9 +42,10 @@ public static void syncSelection(int index) {
MinecraftClient.getInstance().getNetworkHandler().getClientConnection().send(new CustomPayloadC2SPacket(SYNC_SELECTION, buf));
}

public static void syncLevelup(Identifier id) {
public static void syncLevelup(Identifier id, int xpCost) {
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
buf.writeIdentifier(id);
buf.writeInt(xpCost);
MinecraftClient.getInstance().getNetworkHandler().getClientConnection().send(new CustomPayloadC2SPacket(SYNC_LEVELUP, buf));
}
}

0 comments on commit 885acea

Please sign in to comment.