Skip to content

Commit

Permalink
not working
Browse files Browse the repository at this point in the history
  • Loading branch information
Rektroth committed Jul 12, 2023
1 parent 9ab1e40 commit b1ff141
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 10 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ Whiteout is an attempt to implement the bug fixes offered by the [Paper](https:/
## Patches
### Present

| Bug | Lazy? | Name |
|-----------|-------|---------------------------------------------------------|
| MC-4 | Yes | Item drops sometimes appear at the wrong location |
| MC-158900 | No | "bad packet id 26" upon connecting after tempban expire |
| Bug | Lazy? | Name |
|-----------|-------|---------------------------------------------------------------------------|
| MC-4 | Yes | Item drops sometimes appear at the wrong location |
| MC-50319 | No | Player owned projectiles lose their player ownership when exiting portals |
| MC-158900 | No | "bad packet id 26" upon connecting after tempban expire |

Some of the patches are "lazy". This means that the Paper maintainers are not incredibly pleased with the manner in which the bug was patched, but the patch works nonetheless. These patches will be disabled by default when configurability is implemented.

Expand All @@ -18,8 +19,6 @@ Some of the patches are "lazy". This means that the Paper maintainers are not in
|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| MC-11193 | The order in which powerable blocks (e.g. redstone dust blocks) along a wire are powered or de-powered is not clearly defined and causes a non-deterministic behavior for redstone contraptions |
| MC-27056 | You can blow the extension off a piston |
| MC-33041 | Dedicated server logs "java.io.IOException: The handle is invalid" on startup |
| MC-50319 | Player owned projectiles lose their player ownership when exiting portals |
| MC-50647 | Slime mob spawners spawn slimes only in slime chunks |
| MC-81098 | Redstone dust updates cause lag |
| MC-99075 | Cancelled block place (spawn protection) causes inventory desync |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Patch for MC-50319
*
* Authored for CraftBukkit/Spigot by Aikar <[email protected]> on October 17, 2018.
* Ported to Fabric by Rektroth <[email protected]> on July 11, 2023.
*/

package io.github.rektroth.whiteout.mixin.entity.projectile;

import java.util.UUID;
import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.ProjectileEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(ProjectileEntity.class)
public interface ProjectileEntityAccessor {
@Accessor
Entity getOwner();

@Accessor
UUID getOwnerUuid();

@Accessor
void setOwner(Entity owner);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Patch for MC-50319
*
* Authored for CraftBukkit/Spigot by Aikar <[email protected]> on October 17, 2018.
* Ported to Fabric by Rektroth <[email protected]> on July 11, 2023.
*/

package io.github.rektroth.whiteout.mixin.entity.projectile;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.Ownable;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.World;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import io.github.rektroth.whiteout.Whiteout;

@Mixin(ProjectileEntity.class)
public abstract class ProjectileEntityMixin extends Entity implements Ownable {
public ProjectileEntityMixin(EntityType<? extends ProjectileEntity> entityType, World world) {
super(entityType, world);
}

@Inject(
at = @At(
value = "FIELD",
target = "Lnet/minecraft/entity/projectile/ProjectileEntity;owner:Lnet/minecraft/entity/Entity;",
opcode = Opcodes.PUTFIELD,
shift = At.Shift.AFTER),
method = "getOwner()Lnet/minecraft/entity/Entity;")
private void setOwnerWhenChangingDimensions(CallbackInfoReturnable<Entity> cir) {
if (((ProjectileEntityAccessor)(ProjectileEntity)(Object)this).getOwner() == null) {
for (final ServerWorld world : ((ProjectileEntity)(Object)this).getWorld().getServer().getWorlds()) {
if (world == ((ProjectileEntity)(Object)this).getWorld()) {
continue;
}

final Entity entity = world.getEntity(((ProjectileEntityAccessor)(ProjectileEntity)(Object)this).getOwnerUuid());

if (entity != null) {
((ProjectileEntityAccessor)(ProjectileEntity)(Object)this).setOwner(entity);
break;
}
}
}
}

@Inject(at = @At("RETURN"), method = "getOwner()Lnet/minecraft/entity/Entity;")
private void testMethod(CallbackInfoReturnable<Entity> cir) {
Whiteout.LOGGER.info("TESTTESTTEST!");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public abstract class PlayerManagerMixin {
private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");

@Inject(at = @At("HEAD"), method = "checkCanJoin(Ljava/net/SocketAddress;Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/text/Text;", cancellable = true)
private void fixedBanCheck(SocketAddress address, GameProfile profile, CallbackInfoReturnable<Text> ci)
private void fixedBanCheck(SocketAddress address, GameProfile profile, CallbackInfoReturnable<Text> cir)
{
if (((PlayerManagerAccessor)((PlayerManager)(Object)this)).getBannedProfiles().contains(profile)) {
BannedPlayerEntry bannedPlayerEntry = (BannedPlayerEntry)((PlayerManagerAccessor)((PlayerManager)(Object)this)).getBannedProfiles().get(profile);
if (((PlayerManagerAccessor)(PlayerManager)(Object)this).getBannedProfiles().contains(profile)) {
BannedPlayerEntry bannedPlayerEntry = (BannedPlayerEntry)((PlayerManagerAccessor)(PlayerManager)(Object)this).getBannedProfiles().get(profile);

if (bannedPlayerEntry != null) {
MutableText mutableText = Text.translatable("multiplayer.disconnect.banned.reason", bannedPlayerEntry.getReason());
Expand All @@ -38,7 +38,7 @@ private void fixedBanCheck(SocketAddress address, GameProfile profile, CallbackI
mutableText.append(Text.translatable("multiplayer.disconnect.banned.expiration", DATE_FORMATTER.format(bannedPlayerEntry.getExpiryDate())));
}

ci.setReturnValue(mutableText);
cir.setReturnValue(mutableText);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/whiteout.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"compatibilityLevel": "JAVA_17",
"mixins": [
"entity.EntityMixin",
"entity.projectile.ProjectileEntityAccessor",
"entity.projectile.ProjectileEntityMixin",
"server.PlayerManagerAccessor",
"server.PlayerManagerMixin"
],
Expand Down

0 comments on commit b1ff141

Please sign in to comment.