Updated to 1.17

This commit is contained in:
hhhzzzsss 2021-06-22 23:44:34 -05:00 committed by GitHub
parent 529aecac0c
commit 2198917229
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 43 additions and 35 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,2 @@
v1 named intermediary
FIELD com/github/hhhzzzsss/songplayer/mixin/ClientPlayNetworkHandlerMixin Lnet/minecraft/network/ClientConnection; connection field_3689

View file

@ -0,0 +1 @@
v1 named intermediary

View file

@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "songplayer",
"version": "1.0.0",
"version": "1.1.0",
"name": "Song Player",
"description": "Builds and plays noteblocks",
@ -29,7 +29,7 @@
"depends": {
"fabricloader": ">=0.7.4",
"fabric": "*",
"minecraft": "1.16.x"
"minecraft": "1.17.x"
},
"suggests": {
"flamingo": "*"

View file

@ -1,8 +1,8 @@
com/github/hhhzzzsss/songplayer/mixin/ClientPlayerEntityMixin.java
com.github.hhhzzzsss.songplayer.mixin.ClientPlayerEntityMixin
com/github/hhhzzzsss/songplayer/SongPlayer.java
com.github.hhhzzzsss.songplayer.SongPlayer
com.github.hhhzzzsss.songplayer.SongPlayer$Mode
com/github/hhhzzzsss/songplayer/mixin/ClientPlayerEntityMixin.java
com.github.hhhzzzsss.songplayer.mixin.ClientPlayerEntityMixin
com/github/hhhzzzsss/songplayer/mixin/KeyboardMixin.java
com.github.hhhzzzsss.songplayer.mixin.KeyboardMixin
com/github/hhhzzzsss/songplayer/mixin/MinecraftClientMixin.java
@ -24,7 +24,6 @@ com/github/hhhzzzsss/songplayer/song/Song.java
com.github.hhhzzzsss.songplayer.song.Song
com/github/hhhzzzsss/songplayer/CommandProcessor.java
com.github.hhhzzzsss.songplayer.CommandProcessor
com.github.hhhzzzsss.songplayer.CommandProcessor$1
com.github.hhhzzzsss.songplayer.CommandProcessor$Command
com.github.hhhzzzsss.songplayer.CommandProcessor$currentCommand
com.github.hhhzzzsss.songplayer.CommandProcessor$gotoCommand
@ -37,9 +36,9 @@ com/github/hhhzzzsss/songplayer/CommandProcessor.java
com.github.hhhzzzsss.songplayer.CommandProcessor$songsCommand
com.github.hhhzzzsss.songplayer.CommandProcessor$stopCommand
com.github.hhhzzzsss.songplayer.CommandProcessor$toggleFakePlayerCommand
com/github/hhhzzzsss/songplayer/mixin/ClientPlayNetworkHandlerMixin.java
com.github.hhhzzzsss.songplayer.mixin.ClientPlayNetworkHandlerMixin
com/github/hhhzzzsss/songplayer/noteblocks/PlayingThread.java
com.github.hhhzzzsss.songplayer.noteblocks.PlayingThread
com/github/hhhzzzsss/songplayer/mixin/ClientPlayNetworkHandlerMixin.java
com.github.hhhzzzsss.songplayer.mixin.ClientPlayNetworkHandlerMixin
com/github/hhhzzzsss/songplayer/song/DownloadingThread.java
com.github.hhhzzzsss.songplayer.song.DownloadingThread

View file

@ -12,6 +12,8 @@ import com.github.hhhzzzsss.songplayer.noteblocks.Stage;
import com.github.hhhzzzsss.songplayer.song.DownloadingThread;
import com.github.hhhzzzsss.songplayer.song.Song;
import net.minecraft.entity.Entity;
public class CommandProcessor {
public static ArrayList<Command> commands = new ArrayList<>();
@ -178,7 +180,7 @@ public class CommandProcessor {
}
if (args.length() == 0) {
if (SongPlayer.fakePlayer != null) {
SongPlayer.fakePlayer.remove();
SongPlayer.fakePlayer.remove(Entity.RemovalReason.DISCARDED);
SongPlayer.fakePlayer = null;
}
SongPlayer.stage.movePlayerToStagePosition();
@ -382,7 +384,7 @@ public class CommandProcessor {
if (SongPlayer.showFakePlayer) {
if (SongPlayer.mode == Mode.PLAYING || SongPlayer.mode == Mode.BUILDING) {
if (SongPlayer.fakePlayer != null) {
SongPlayer.fakePlayer.remove();
SongPlayer.fakePlayer.remove(Entity.RemovalReason.DISCARDED);
}
SongPlayer.fakePlayer = new FakePlayerEntity();
}
@ -390,7 +392,7 @@ public class CommandProcessor {
}
else {
if (SongPlayer.fakePlayer != null) {
SongPlayer.fakePlayer.remove();
SongPlayer.fakePlayer.remove(Entity.RemovalReason.DISCARDED);
}
SongPlayer.addChatMessage("§6Disabled fake player");
}

View file

@ -14,7 +14,7 @@ public class FakePlayerEntity extends OtherClientPlayerEntity {
copyStagePosAndPlayerLook();
inventory.clone(player.inventory);
getInventory().clone(player.getInventory());
Byte playerModel = player.getDataTracker().get(PlayerEntity.PLAYER_MODEL_PARTS);
getDataTracker().set(PlayerEntity.PLAYER_MODEL_PARTS, playerModel);
@ -26,16 +26,16 @@ public class FakePlayerEntity extends OtherClientPlayerEntity {
capeY = getY();
capeZ = getZ();
world.addEntity(getEntityId(), this);
world.addEntity(getId(), this);
}
public void resetPlayerPosition() {
player.refreshPositionAndAngles(getX(), getY(), getZ(), yaw, pitch);
player.refreshPositionAndAngles(getX(), getY(), getZ(), getYaw(), getPitch());
}
public void copyStagePosAndPlayerLook() {
if (SongPlayer.stage != null) {
refreshPositionAndAngles(SongPlayer.stage.position.getX()+0.5, SongPlayer.stage.position.getY(), SongPlayer.stage.position.getZ()+0.5, player.yaw, player.pitch);
refreshPositionAndAngles(SongPlayer.stage.position.getX()+0.5, SongPlayer.stage.position.getY(), SongPlayer.stage.position.getZ()+0.5, player.getYaw(), player.getPitch());
headYaw = player.headYaw;
bodyYaw = player.bodyYaw;
}

View file

@ -1,6 +1,7 @@
package com.github.hhhzzzsss.songplayer;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.Entity;
import net.minecraft.text.LiteralText;
import net.minecraft.util.math.Vec3d;
@ -31,7 +32,7 @@ public class Freecam {
enabled = false;
if (fakePlayer != null) {
fakePlayer.resetPlayerPosition();
fakePlayer.remove();
fakePlayer.remove(Entity.RemovalReason.DISCARDED);
fakePlayer = null;
player.setVelocity(Vec3d.ZERO);
}

View file

@ -30,7 +30,7 @@ public class ClientPlayNetworkHandlerMixin {
ci.cancel();
}*/
if (SongPlayer.mode != SongPlayer.Mode.IDLE && packet instanceof PlayerMoveC2SPacket) {
connection.send(new PlayerMoveC2SPacket.Both(SongPlayer.stage.position.getX()+0.5, SongPlayer.stage.position.getY(), SongPlayer.stage.position.getZ()+0.5, SongPlayer.MC.player.yaw, SongPlayer.MC.player.pitch, true));
connection.send(new PlayerMoveC2SPacket.Full(SongPlayer.stage.position.getX()+0.5, SongPlayer.stage.position.getY(), SongPlayer.stage.position.getZ()+0.5, SongPlayer.MC.player.getYaw(), SongPlayer.MC.player.getPitch(), true));
if (SongPlayer.fakePlayer != null) {
SongPlayer.fakePlayer.copyStagePosAndPlayerLook();
}

View file

@ -18,4 +18,4 @@ public class ClientPlayerEntityMixin {
ci.cancel();
}
}
}
}

View file

@ -8,11 +8,13 @@ import com.github.hhhzzzsss.songplayer.song.Song;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
@ -22,12 +24,12 @@ import net.minecraft.world.GameMode;
public class BuildingThread extends Thread {
private final ClientPlayerEntity player = SongPlayer.MC.player;
private final PlayerInventory inventory = SongPlayer.MC.player.inventory;
private final PlayerInventory inventory = SongPlayer.MC.player.getInventory();
private final ClientWorld world = SongPlayer.MC.world;
private final Stage stage = SongPlayer.stage;
private final BlockPos stagePos = SongPlayer.stage.position;
private final Song song = SongPlayer.song;
private final int NOTEBLOCK_BASE_ID = 249;
private final int NOTEBLOCK_BASE_ID = Block.getRawIdFromState(Blocks.NOTE_BLOCK.getDefaultState());
private final String[] instrumentNames = {"harp", "basedrum", "snare", "hat", "bass", "flute", "bell", "guitar", "chime", "xylophone", "iron_xylophone", "cow_bell", "didgeridoo", "bit", "banjo", "pling"};
private boolean[] missingNotes = new boolean[400];
@ -44,7 +46,7 @@ public class BuildingThread extends Thread {
BlockPos pos = new BlockPos(stagePos.getX()+dx, stagePos.getY()+dy, stagePos.getZ()+dz);
BlockState bs = world.getBlockState(pos);
int blockId = Block.getRawIdFromState(bs);
if (blockId >= 249 && blockId <= 1048) {
if (blockId >= NOTEBLOCK_BASE_ID && blockId < NOTEBLOCK_BASE_ID+800) {
int noteId = (blockId-NOTEBLOCK_BASE_ID)/2;
if (missingNotes[noteId]) {
stage.tunedNoteblocks[noteId] = pos;
@ -89,12 +91,12 @@ public class BuildingThread extends Thread {
return;
}
}
player.abilities.allowFlying = true;
player.abilities.flying = true;
player.getAbilities().allowFlying = true;
player.getAbilities().flying = true;
SongPlayer.stage.movePlayerToStagePosition();
if (SongPlayer.showFakePlayer) {
if (SongPlayer.fakePlayer != null) {
SongPlayer.fakePlayer.remove();
SongPlayer.fakePlayer.remove(Entity.RemovalReason.DISCARDED);
}
SongPlayer.fakePlayer = new FakePlayerEntity();
}
@ -167,16 +169,16 @@ public class BuildingThread extends Thread {
private void holdNoteblock(int id) {
int instrument = id/25;
int note = id%25;
CompoundTag nbt = new CompoundTag();
NbtCompound nbt = new NbtCompound();
nbt.putString("id", "minecraft:note_block");
nbt.putByte("Count", (byte) 1);
CompoundTag tag = new CompoundTag();
CompoundTag bsTag = new CompoundTag();
NbtCompound tag = new NbtCompound();
NbtCompound bsTag = new NbtCompound();
bsTag.putString("instrument", instrumentNames[instrument]);
bsTag.putString("note", Integer.toString(note));
tag.put("BlockStateTag", bsTag);
nbt.put("tag", tag);
inventory.main.set(inventory.selectedSlot, ItemStack.fromTag(nbt));
inventory.main.set(inventory.selectedSlot, ItemStack.fromNbt(nbt));
SongPlayer.MC.interactionManager.clickCreativeStack(player.getStackInHand(Hand.MAIN_HAND), 36 + inventory.selectedSlot);
}

View file

@ -4,6 +4,7 @@ import com.github.hhhzzzsss.songplayer.SongPlayer;
import com.github.hhhzzzsss.songplayer.song.Song;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.Direction;
import net.minecraft.world.GameMode;
@ -25,8 +26,8 @@ public class PlayingThread extends Thread{
}
stage.rebuild = false;
player.abilities.allowFlying = true;
player.abilities.flying = true;
player.getAbilities().allowFlying = true;
player.getAbilities().flying = true;
SongPlayer.stage.movePlayerToStagePosition();
long songStartTime = System.currentTimeMillis() - song.get(song.position).time;
@ -82,11 +83,11 @@ public class PlayingThread extends Thread{
}
}
player.abilities.allowFlying = true;
player.abilities.flying = true;
player.getAbilities().allowFlying = true;
player.getAbilities().flying = true;
SongPlayer.stage.movePlayerToStagePosition();
if (SongPlayer.fakePlayer != null) {
SongPlayer.fakePlayer.remove();
SongPlayer.fakePlayer.remove(Entity.RemovalReason.DISCARDED);
SongPlayer.fakePlayer = null;
}

View file

@ -21,7 +21,7 @@ public class Stage {
}
public void movePlayerToStagePosition() {
player.refreshPositionAndAngles(position.getX() + 0.5, position.getY() + 0.0, position.getZ() + 0.5, player.yaw, player.pitch);
player.refreshPositionAndAngles(position.getX() + 0.5, position.getY() + 0.0, position.getZ() + 0.5, player.getYaw(), player.getPitch());
player.setVelocity(Vec3d.ZERO);
}
}

View file

@ -29,7 +29,7 @@
"depends": {
"fabricloader": ">=0.7.4",
"fabric": "*",
"minecraft": "1.16.x"
"minecraft": "1.17.x"
},
"suggests": {
"flamingo": "*"