-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
95 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...in/java/io/github/rektroth/whiteout/mixin/entity/projectile/ProjectileEntityAccessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/io/github/rektroth/whiteout/mixin/entity/projectile/ProjectileEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters