This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
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
4 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
patchwork-events-entity/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.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,79 @@ | ||
/* | ||
* Minecraft Forge, Patchwork Project | ||
* Copyright (c) 2016-2020, 2019-2020 | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation version 2.1 | ||
* of the License. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
package net.minecraftforge.client.event; | ||
|
||
import net.minecraftforge.event.entity.player.PlayerEvent; | ||
|
||
import net.minecraft.client.render.entity.PlayerEntityRenderer; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
|
||
public abstract class RenderPlayerEvent extends PlayerEvent { | ||
private final PlayerEntityRenderer renderer; | ||
private final float partialRenderTick; | ||
private final double x; | ||
private final double y; | ||
private final double z; | ||
|
||
public RenderPlayerEvent(PlayerEntity player, PlayerEntityRenderer renderer, float partialRenderTick, double x, double y, double z) { | ||
super(player); | ||
this.renderer = renderer; | ||
this.partialRenderTick = partialRenderTick; | ||
this.x = x; | ||
this.y = y; | ||
this.z = z; | ||
} | ||
|
||
public PlayerEntityRenderer getRenderer() { | ||
return renderer; | ||
} | ||
|
||
public float getPartialRenderTick() { | ||
return partialRenderTick; | ||
} | ||
|
||
public double getX() { | ||
return x; | ||
} | ||
|
||
public double getY() { | ||
return y; | ||
} | ||
|
||
public double getZ() { | ||
return z; | ||
} | ||
|
||
public static class Pre extends RenderPlayerEvent { | ||
public Pre(PlayerEntity player, PlayerEntityRenderer renderer, float tick, double x, double y, double z) { | ||
super(player, renderer, tick, x, y, z); | ||
} | ||
|
||
@Override | ||
public boolean isCancelable() { | ||
return true; | ||
} | ||
} | ||
|
||
public static class Post extends RenderPlayerEvent { | ||
public Post(PlayerEntity player, PlayerEntityRenderer renderer, float tick, double x, double y, double z) { | ||
super(player, renderer, tick, x, y, z); | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...ts-entity/src/main/java/net/patchworkmc/mixin/event/entity/MixinPlayerEntityRenderer.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,50 @@ | ||
/* | ||
* Minecraft Forge, Patchwork Project | ||
* Copyright (c) 2016-2020, 2019-2020 | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation version 2.1 | ||
* of the License. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
package net.patchworkmc.mixin.event.entity; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.At.Shift; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import net.minecraftforge.client.event.RenderPlayerEvent; | ||
import net.minecraftforge.common.MinecraftForge; | ||
|
||
import net.minecraft.client.network.AbstractClientPlayerEntity; | ||
import net.minecraft.client.render.entity.PlayerEntityRenderer; | ||
|
||
@Mixin(PlayerEntityRenderer.class) | ||
public class MixinPlayerEntityRenderer { | ||
@Inject(method = "render", at = @At(value = "INVOKE", ordinal = 0, shift = Shift.BEFORE, | ||
target = "net/minecraft/client/network/AbstractClientPlayerEntity.isInSneakingPose()Z"), cancellable = true) | ||
private void preRender(AbstractClientPlayerEntity playerEntity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) { | ||
PlayerEntityRenderer me = (PlayerEntityRenderer) (Object) this; | ||
|
||
if (MinecraftForge.EVENT_BUS.post(new RenderPlayerEvent.Pre(playerEntity, me, partialTicks, x, y, z))) { | ||
ci.cancel(); | ||
} | ||
} | ||
|
||
@Inject(method = "render", at = @At("RETURN")) | ||
private void postRender(AbstractClientPlayerEntity playerEntity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) { | ||
PlayerEntityRenderer me = (PlayerEntityRenderer) (Object) this; | ||
MinecraftForge.EVENT_BUS.post(new RenderPlayerEvent.Post(playerEntity, me, partialTicks, x, y, z)); | ||
} | ||
} |
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