1
0
mirror of https://github.com/chylex/Better-Sprinting.git synced 2025-01-01 04:42:44 +01:00

Fix compile errors for 1.12

This commit is contained in:
chylex 2017-06-13 02:19:26 +02:00
parent 74b329c46e
commit e90d596d48
9 changed files with 52 additions and 40 deletions

View File

@ -2,11 +2,11 @@ package chylex.bettersprinting.client;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import chylex.bettersprinting.client.player.PlayerLogicHandler;
import chylex.bettersprinting.system.PacketPipeline;
import chylex.bettersprinting.system.PacketPipeline.INetworkHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ClientNetwork implements INetworkHandler{

View File

@ -2,7 +2,6 @@ package chylex.bettersprinting.client.gui;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiControls;
import net.minecraft.client.gui.GuiOptionButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.GameSettings;
@ -59,7 +58,7 @@ public class GuiSprint extends GuiScreen{
int left = getLeftColumnX(), top = height/6;
for(int a = 0; a < sprintBindings.length; a++){
GuiOptionButton btn = new GuiOptionButton(a, left+160*(a%2), top+24*(a/2), 70, 20, getKeyCodeString(a));
GuiButton btn = new GuiButton(a, left+160*(a%2), top+24*(a/2), 70, 20, getKeyCodeString(a));
buttonList.add(btn);
if ((a == 1 || a == 2) && ClientModManager.isModDisabled()){
@ -185,7 +184,7 @@ public class GuiSprint extends GuiScreen{
@Override
public void drawScreen(int mouseX, int mouseY, float partialTickTime){
drawDefaultBackground();
drawCenteredString(fontRendererObj, "Better Sprinting", width/2, 20, 16777215);
drawCenteredString(fontRenderer, "Better Sprinting", width/2, 20, 16777215);
final int maxWidthLeft = 82;
final int maxWidthRight = 124;
@ -230,12 +229,12 @@ public class GuiSprint extends GuiScreen{
for(int a = 0, top = height/6; a < buttonList.size(); a++){
GuiButton btn = buttonList.get(a);
if (mouseX >= btn.xPosition && mouseX < btn.xPosition+btn.getButtonWidth() && mouseY >= btn.yPosition && mouseY < btn.yPosition+20){
if (mouseX >= btn.x && mouseX < btn.x+btn.width && mouseY >= btn.y && mouseY < btn.y+20){
String info = a < buttonTitles.length ? buttonTitles[a] : "";
String[] spl = I18n.format(info).split("#");
for(int line = 0; line < spl.length; line++){
drawCenteredString(fontRendererObj, spl[line], width/2, top+148+10*line-(fontRendererObj.FONT_HEIGHT*spl.length/2), -1);
drawCenteredString(fontRenderer, spl[line], width/2, top+148+10*line-(fontRenderer.FONT_HEIGHT*spl.length/2), -1);
}
break;
@ -254,7 +253,7 @@ public class GuiSprint extends GuiScreen{
}
private void drawButtonTitle(String title, GuiButton btn, int maxWidth){
int lines = fontRendererObj.listFormattedStringToWidth(title, maxWidth).size();
fontRendererObj.drawSplitString(title, btn.xPosition+76, btn.yPosition+7-5*(lines-1), maxWidth, -1);
int lines = fontRenderer.listFormattedStringToWidth(title, maxWidth).size();
fontRenderer.drawSplitString(title, btn.x+76, btn.y+7-5*(lines-1), maxWidth, -1);
}
}

View File

@ -8,6 +8,17 @@ public class ModGuiFactory implements IModGuiFactory{
@Override
public void initialize(Minecraft minecraftInstance){}
@Override
public boolean hasConfigGui(){
return true;
}
@Override
public GuiScreen createConfigGui(GuiScreen parentScreen){
return new GuiGeneralConfig(parentScreen);
}
@SuppressWarnings("deprecation")
@Override
public Class<? extends GuiScreen> mainConfigGuiClass(){
return GuiGeneralConfig.class;

View File

@ -14,10 +14,10 @@ public class CustomMovementInput{
GameSettings settings = mc.gameSettings;
$this.moveStrafe = 0F;
$this.moveForward = 0F;
$this.field_192832_b = 0F;
if (settings.keyBindForward.isKeyDown()){
++$this.moveForward;
++$this.field_192832_b;
$this.forwardKeyDown = true;
}
else{
@ -25,7 +25,7 @@ public class CustomMovementInput{
}
if (settings.keyBindBack.isKeyDown()){
--$this.moveForward;
--$this.field_192832_b;
$this.backKeyDown = true;
}
else{
@ -81,7 +81,7 @@ public class CustomMovementInput{
if ($this.sneak){
$this.moveStrafe = $this.moveStrafe*0.3F;
$this.moveForward = $this.moveForward*0.3F;
$this.field_192832_b = $this.field_192832_b*0.3F;
}
if (ClientModManager.isModDisabled()){

View File

@ -32,7 +32,7 @@ public class PlayerLogicHandler{
// UPDATE | EntityPlayerSP.onLivingUpdate | 1.11.2
public void updateMovementInput(){
wasMovingForward = player.movementInput.moveForward >= 0.8F;
wasMovingForward = player.movementInput.field_192832_b >= 0.8F;
wasSneaking = player.movementInput.sneak;
customMovementInput.update(mc, (MovementInputFromOptions)player.movementInput);
}
@ -42,7 +42,7 @@ public class PlayerLogicHandler{
boolean enoughHunger = player.getFoodStats().getFoodLevel() > 6F || player.capabilities.allowFlying;
if (ClientModManager.isModDisabled()){
if (player.onGround && !wasSneaking && !wasMovingForward && player.movementInput.moveForward >= 0.8F && !player.isSprinting() && enoughHunger && !player.isHandActive() && !player.isPotionActive(MobEffects.BLINDNESS)){
if (player.onGround && !wasSneaking && !wasMovingForward && player.movementInput.field_192832_b >= 0.8F && !player.isSprinting() && enoughHunger && !player.isHandActive() && !player.isPotionActive(MobEffects.BLINDNESS)){
if (player.sprintToggleTimer <= 0 && !ClientModManager.keyBindSprintHold.isKeyDown()){
player.sprintToggleTimer = 7;
}
@ -51,7 +51,7 @@ public class PlayerLogicHandler{
}
}
if (!player.isSprinting() && player.movementInput.moveForward >= 0.8F && enoughHunger && !player.isHandActive() && !player.isPotionActive(MobEffects.BLINDNESS) && ClientModManager.keyBindSprintHold.isKeyDown()){
if (!player.isSprinting() && player.movementInput.field_192832_b >= 0.8F && enoughHunger && !player.isHandActive() && !player.isPotionActive(MobEffects.BLINDNESS) && ClientModManager.keyBindSprintHold.isKeyDown()){
player.setSprinting(true);
}
}
@ -71,7 +71,7 @@ public class PlayerLogicHandler{
customMovementInput.held = sprint;
if (dblTap && !customMovementInput.held && customMovementInput.stoptime == 0 && player.onGround && !wasSneaking && !wasMovingForward && player.movementInput.moveForward >= 0.8F && !player.isSprinting() && enoughHunger && !player.isHandActive() && !player.isPotionActive(MobEffects.BLINDNESS)){
if (dblTap && !customMovementInput.held && customMovementInput.stoptime == 0 && player.onGround && !wasSneaking && !wasMovingForward && player.movementInput.field_192832_b >= 0.8F && !player.isSprinting() && enoughHunger && !player.isHandActive() && !player.isPotionActive(MobEffects.BLINDNESS)){
if (player.sprintToggleTimer == 0){
player.sprintToggleTimer = 7;
}
@ -117,8 +117,8 @@ public class PlayerLogicHandler{
player.setSprinting(false);
}
if (player.isSprinting() && (player.movementInput.moveForward < 0.8F || player.isCollidedHorizontally || !enoughHunger)){
if ((ClientModManager.canRunInAllDirs(mc) && ClientSettings.enableAllDirs) == false || (player.movementInput.moveForward == 0F && player.movementInput.moveStrafe == 0F)){
if (player.isSprinting() && (player.movementInput.field_192832_b < 0.8F || player.isCollidedHorizontally || !enoughHunger)){
if ((ClientModManager.canRunInAllDirs(mc) && ClientSettings.enableAllDirs) == false || (player.movementInput.field_192832_b == 0F && player.movementInput.moveStrafe == 0F)){
player.setSprinting(false);
}
}

View File

@ -68,7 +68,7 @@ final class LivingUpdate{
if (player.isHandActive() && !player.isRiding()){
player.movementInput.moveStrafe *= 0.2F;
player.movementInput.moveForward *= 0.2F;
player.movementInput.field_192832_b *= 0.2F;
player.sprintToggleTimer = 0;
}
@ -110,7 +110,7 @@ final class LivingUpdate{
if (player.movementInput.jump && !wasJumping && !player.onGround && player.motionY < 0D && !player.isElytraFlying() && !player.capabilities.isFlying){
ItemStack chestIS = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
if (chestIS.getItem() == Items.ELYTRA && ItemElytra.isBroken(chestIS)){
if (chestIS.getItem() == Items.ELYTRA && ItemElytra.isUsable(chestIS)){
player.connection.sendPacket(new CPacketEntityAction(player, CPacketEntityAction.Action.START_FALL_FLYING));
}
}
@ -120,7 +120,7 @@ final class LivingUpdate{
if (player.capabilities.isFlying && mc.getRenderViewEntity() == player){ // uses isCurrentViewEntity but it is protected
if (player.movementInput.sneak){
player.movementInput.moveStrafe = player.movementInput.moveStrafe/0.3F;
player.movementInput.moveForward = player.movementInput.moveForward/0.3F;
player.movementInput.field_192832_b = player.movementInput.field_192832_b/0.3F;
player.motionY -= 0.15D; // ignore capabilities.getFlySpeed()
}

View File

@ -5,6 +5,7 @@ import net.minecraft.client.gui.GuiDownloadTerrain;
import net.minecraft.client.multiplayer.PlayerControllerMP;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.client.resources.I18n;
import net.minecraft.stats.RecipeBook;
import net.minecraft.stats.StatisticsManager;
import net.minecraft.util.MovementInputFromOptions;
import net.minecraft.util.text.TextComponentString;
@ -42,7 +43,7 @@ public final class LogicImplOverride{
mc.world.removeEntity(prevPlayer);
mc.setRenderViewEntity(null);
mc.player = mc.playerController.createClientPlayer(prevPlayer.world, prevPlayer.getStatFileWriter());
mc.player = mc.playerController.func_192830_a(prevPlayer.world, prevPlayer.getStatFileWriter(), prevPlayer.func_192035_E());
mc.player.getDataManager().setEntryValues(prevPlayer.getDataManager().getAll());
mc.player.dimension = prevPlayer.dimension;
mc.setRenderViewEntity(mc.player);
@ -84,8 +85,8 @@ public final class LogicImplOverride{
}
@Override
public EntityPlayerSP createClientPlayer(World world, StatisticsManager statFile){
return new PlayerOverride(mc, world, netHandler, statFile);
public EntityPlayerSP func_192830_a(World world, StatisticsManager statFile, RecipeBook recipeBook){
return new PlayerOverride(mc, world, netHandler, statFile, recipeBook);
}
}
}

View File

@ -9,6 +9,7 @@ import net.minecraft.init.Items;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemElytra;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.RecipeBook;
import net.minecraft.stats.StatisticsManager;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.MathHelper;
@ -25,8 +26,8 @@ public class PlayerOverride extends EntityPlayerSP{
// UPDATE | EntityLivingBase.jumpTicks | Check if still only used in onLivingUpdate | 1.11
private int jumpTicks;
public PlayerOverride(Minecraft mc, World world, NetHandlerPlayClient netHandler, StatisticsManager statFile){
super(mc, world, netHandler, statFile);
public PlayerOverride(Minecraft mc, World world, NetHandlerPlayClient netHandler, StatisticsManager statFile, RecipeBook recipeBook){
super(mc, world, netHandler, statFile, recipeBook);
logic = new PlayerLogicHandler();
logic.setPlayer(this);
@ -131,7 +132,7 @@ public class PlayerOverride extends EntityPlayerSP{
if (Math.abs(motionY) < 0.003D)motionY = 0D;
if (Math.abs(motionZ) < 0.003D)motionZ = 0D;
world.theProfiler.startSection("ai");
world.profiler.startSection("ai");
if (isMovementBlocked()){
isJumping = false;
@ -140,13 +141,13 @@ public class PlayerOverride extends EntityPlayerSP{
randomYawVelocity = 0F;
}
else if (isServerWorld()){ // isAIEnabled is false
world.theProfiler.startSection("newAi");
world.profiler.startSection("newAi");
updateEntityActionState();
world.theProfiler.endSection();
world.profiler.endSection();
}
world.theProfiler.endSection();
world.theProfiler.startSection("jump");
world.profiler.endSection();
world.profiler.startSection("jump");
if (isJumping){
if (isInWater()){
@ -164,21 +165,21 @@ public class PlayerOverride extends EntityPlayerSP{
jumpTicks = 0;
}
world.theProfiler.endSection();
world.theProfiler.startSection("travel");
world.profiler.endSection();
world.profiler.startSection("travel");
moveStrafing *= 0.98F;
moveForward *= 0.98F;
randomYawVelocity *= 0.9F;
updateElytra$EntityLivingBase();
moveEntityWithHeading(moveStrafing, moveForward);
func_191986_a(moveStrafing, moveForward, field_191988_bg);
world.theProfiler.endSection();
world.theProfiler.startSection("push");
world.profiler.endSection();
world.profiler.startSection("push");
collideWithNearbyEntities();
world.theProfiler.endSection();
world.profiler.endSection();
}
// UPDATE | EntityLivingBase.updateElytra | 1.11
@ -188,7 +189,7 @@ public class PlayerOverride extends EntityPlayerSP{
if (flag && !onGround && !isRiding()){
ItemStack is = getItemStackFromSlot(EntityEquipmentSlot.CHEST);
if (is.getItem() == Items.ELYTRA && ItemElytra.isBroken(is)){
if (is.getItem() == Items.ELYTRA && ItemElytra.isUsable(is)){
flag = true;
if (!world.isRemote && (ticksElytraFlying+1)%20 == 0){

View File

@ -40,7 +40,7 @@ public class PacketPipeline{
@SubscribeEvent
public void onServerPacket(ServerCustomPacketEvent e){
handler.onPacket(Side.SERVER, e.getPacket().payload(), ((NetHandlerPlayServer)e.getHandler()).playerEntity);
handler.onPacket(Side.SERVER, e.getPacket().payload(), ((NetHandlerPlayServer)e.getHandler()).player);
}
@SideOnly(Side.CLIENT)