Skip to content

Commit

Permalink
fix wall-clinging to fluids, add serverside check for leveling up
Browse files Browse the repository at this point in the history
  • Loading branch information
LemmaEOF committed May 19, 2019
1 parent e0c0b6b commit 0fb08c2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if(rootProject.file('private.gradle').exists()) { //Publishing details

archivesBaseName = "skillcheck"
group = "io.github.cottonmc"
version = "1.0.6+1.14.1"
version = "1.0.7+1.14.1"

minecraft {
refmapName = 'mixins.skillcheck.refmap.json'
Expand All @@ -58,7 +58,7 @@ dependencies {
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.4:1") { transitive = false }
modCompile "crochet:Crochet:1.0.4:1"
include "crochet:Crochet:1.0.4:1"
modCompile "cloth-config:ClothConfig:0.2.1.14"
include "cloth-config:ClothConfig:0.2.1.14"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ public boolean mouseDragged(double double_1, double double_2, int int_1, double
int listTop = this.top + 18;
int listBottom = listTop + 139;
int offscreen = amount - 7;
float float_1 = ((float)double_2 - (float)listTop - 13.5F) / ((float)(listBottom - listTop) - 27.0F);
float_1 = float_1 * (float)offscreen + 0.5F;
this.scroll = MathHelper.clamp((int)float_1, 0, offscreen);
float scrollAmount = ((float)double_2 - (float)listTop - 13.5F) / ((float)(listBottom - listTop) - 27.0F);
scrollAmount = scrollAmount * (float)offscreen + 0.5F;
this.scroll = MathHelper.clamp((int)scrollAmount, 0, offscreen);
return true;
} else {
return super.mouseDragged(double_1, double_2, int_1, double_3, double_4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.github.cottonmc.skillcheck.api.traits.ClassManager;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.FluidBlock;
import net.minecraft.client.input.Input;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerEntity;
Expand Down Expand Up @@ -37,6 +38,8 @@ public abstract class MixinThiefClient extends AbstractClientPlayerEntity {

@Shadow public Input input;

@Shadow public abstract boolean isInWater();

//Wall-Jump config default values
private static float wallJumpHeight = 0.8f;
private static int wallSlideDelay = 15;
Expand Down Expand Up @@ -223,7 +226,9 @@ private static boolean canWallCling(PlayerEntity player) {

if (walls.size() == 0) return false;

if (SkillCheck.SLIPPERY_BLOCKS.contains(player.world.getBlockState(getWallPos(player)).getBlock()) ^ SkillCheck.config.invertSlipperyTag) return false;
if (SkillCheck.SLIPPERY_BLOCKS.contains(player.world.getBlockState(getWallPos(player)).getBlock()) ^ SkillCheck.config.invertSlipperyTag
|| player.world.getBlockState(getWallPos(player)).getBlock() instanceof FluidBlock) return false;


if (ClassManager.hasClass(player, SkillCheck.THIEF) || player.getPos().getY() < lastJumpY) return true; //TODO: change to use levels later?

Expand Down Expand Up @@ -285,7 +290,7 @@ private static void spawnWallParticle(Entity entity, BlockPos pos) {
}

private void handleDoubleJump() {
if (this.onGround) {
if (this.onGround || !world.getFluidState(this.getBlockPos()).isEmpty()) {

airTime = 0;
jumpCount = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ public static void init() {
}

public static void initClient() {
ClientSidePacketRegistry.INSTANCE.register(SYNC_PLAYER_LEVEL, (packetContext, packetByteBuf) -> {
packetContext.getPlayer().experienceLevel = packetByteBuf.readInt();
});
ClientSidePacketRegistry.INSTANCE.register(SYNC_PLAYER_LEVEL, (packetContext, packetByteBuf) ->
packetContext.getPlayer().experienceLevel = packetByteBuf.readInt());
}

public static void initServer() {
Expand All @@ -44,13 +43,15 @@ public static void initServer() {
}
});
ServerSidePacketRegistry.INSTANCE.register(SYNC_LEVELUP, (packetContext, packetByteBuf) -> {
Identifier id = packetByteBuf.readIdentifier();
int xpCost = packetByteBuf.readInt();
if (!packetContext.getPlayer().isCreative()) {
packetContext.getPlayer().experienceLevel -= xpCost;
setSyncPlayerLevel(packetContext.getPlayer().experienceLevel, (ServerPlayerEntity)packetContext.getPlayer());
if (((CharacterSheetContainer)packetContext.getPlayer().container).canLevelUp()) {
Identifier id = packetByteBuf.readIdentifier();
int xpCost = packetByteBuf.readInt();
if (!packetContext.getPlayer().isCreative()) {
packetContext.getPlayer().experienceLevel -= xpCost;
syncPlayerLevel(packetContext.getPlayer().experienceLevel, (ServerPlayerEntity) packetContext.getPlayer());
}
ClassManager.levelUp(packetContext.getPlayer(), id);
}
ClassManager.levelUp(packetContext.getPlayer(), id);
});
}

Expand All @@ -70,7 +71,7 @@ public static void syncLevelup(Identifier id, int xpCost) {
}

@Environment(EnvType.CLIENT)
public static void setSyncPlayerLevel(int level, ServerPlayerEntity player) {
public static void syncPlayerLevel(int level, ServerPlayerEntity player) {
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
buf.writeInt(level);
player.networkHandler.sendPacket(new CustomPayloadS2CPacket(SYNC_PLAYER_LEVEL, buf));
Expand Down

0 comments on commit 0fb08c2

Please sign in to comment.