Skip to content

Commit

Permalink
Fixed weird crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro270707 committed Feb 3, 2024
1 parent 31ee9bc commit ca61330
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class HeadCollisionMixin {
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
private void headedrewritten$getAccurateOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (HeadedRewritten.CONFIG.changeHeadCollisions() && world.getBlockEntity(pos) instanceof SkullBlockEntity blockEntity && blockEntity.getOwner() != null && blockEntity.getOwner().getProperties().containsKey("textures") && TextureToHeadMap.MAP.containsKey(MinecraftClient.getInstance().getSkinProvider().getTextures(blockEntity.getOwner()).get(MinecraftProfileTexture.Type.SKIN).getUrl())) {
if (HeadedRewritten.CONFIG.changeHeadCollisions() && world.getBlockEntity(pos) instanceof SkullBlockEntity blockEntity && blockEntity.getOwner() != null && blockEntity.getOwner().getProperties().containsKey("textures") && MinecraftClient.getInstance().getSkinProvider().getTextures(blockEntity.getOwner()).containsKey(MinecraftProfileTexture.Type.SKIN) && TextureToHeadMap.MAP.containsKey(MinecraftClient.getInstance().getSkinProvider().getTextures(blockEntity.getOwner()).get(MinecraftProfileTexture.Type.SKIN).getUrl())) {
SkullBlockEntityModel model = TextureToHeadMap.MAP.get(MinecraftClient.getInstance().getSkinProvider().getTextures(blockEntity.getOwner()).get(MinecraftProfileTexture.Type.SKIN).getUrl()).getModel(MinecraftClient.getInstance().getEntityModelLoader());
Vector3f boxSize;
if (model instanceof HeadedRewrittenModel headedRewrittenModel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public class RenderHeadedHeadItemMixin {
@ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/block/entity/SkullBlockEntityRenderer;renderSkull(Lnet/minecraft/util/math/Direction;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/block/entity/SkullBlockEntityModel;Lnet/minecraft/client/render/RenderLayer;)V"), index = 6)
private SkullBlockEntityModel headedrewritten$replaceItemModel(SkullBlockEntityModel model, @Local(ordinal = 0) SkullBlock.SkullType skullType, @Local(ordinal = 0) GameProfile gameProfile) {
if (skullType == SkullBlock.Type.PLAYER && gameProfile != null && gameProfile.getProperties().containsKey("textures") && TextureToHeadMap.MAP.containsKey(MinecraftClient.getInstance().getSkinProvider().getTextures(gameProfile).get(MinecraftProfileTexture.Type.SKIN).getUrl())) {
if (skullType == SkullBlock.Type.PLAYER && gameProfile != null && gameProfile.getProperties().containsKey("textures") && MinecraftClient.getInstance().getSkinProvider().getTextures(gameProfile).containsKey(MinecraftProfileTexture.Type.SKIN) && TextureToHeadMap.MAP.containsKey(MinecraftClient.getInstance().getSkinProvider().getTextures(gameProfile).get(MinecraftProfileTexture.Type.SKIN).getUrl())) {
HeadedContext.currentProfile = gameProfile;
return TextureToHeadMap.MAP.get(MinecraftClient.getInstance().getSkinProvider().getTextures(gameProfile).get(MinecraftProfileTexture.Type.SKIN).getUrl()).getModel(MinecraftClient.getInstance().getEntityModelLoader());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public class RenderHeadedHeadMixin {
@ModifyArg(method = "render(Lnet/minecraft/block/entity/SkullBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/block/entity/SkullBlockEntityRenderer;renderSkull(Lnet/minecraft/util/math/Direction;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/block/entity/SkullBlockEntityModel;Lnet/minecraft/client/render/RenderLayer;)V"), index = 6)
private SkullBlockEntityModel headedrewritten$replaceModel(SkullBlockEntityModel model, @Local(ordinal = 0) SkullBlock.SkullType skullType, @Local(ordinal = 0) SkullBlockEntity blockEntity) {
HeadedContext.currentProfile = blockEntity.getOwner();
if (skullType == SkullBlock.Type.PLAYER && blockEntity.getOwner() != null && blockEntity.getOwner().getProperties().containsKey("textures") && TextureToHeadMap.MAP.containsKey(MinecraftClient.getInstance().getSkinProvider().getTextures(blockEntity.getOwner()).get(MinecraftProfileTexture.Type.SKIN).getUrl())) {
if (skullType == SkullBlock.Type.PLAYER && blockEntity.getOwner() != null && blockEntity.getOwner().getProperties().containsKey("textures") && MinecraftClient.getInstance().getSkinProvider().getTextures(blockEntity.getOwner()).containsKey(MinecraftProfileTexture.Type.SKIN) && TextureToHeadMap.MAP.containsKey(MinecraftClient.getInstance().getSkinProvider().getTextures(blockEntity.getOwner()).get(MinecraftProfileTexture.Type.SKIN).getUrl())) {
return TextureToHeadMap.MAP.get(MinecraftClient.getInstance().getSkinProvider().getTextures(blockEntity.getOwner()).get(MinecraftProfileTexture.Type.SKIN).getUrl()).getModel(MinecraftClient.getInstance().getEntityModelLoader());
}
return model;
}

@Inject(method = "getRenderLayer", at = @At(value = "HEAD"), cancellable = true)
private static void headedrewritten$replaceTexture(SkullBlock.SkullType type, GameProfile profile, CallbackInfoReturnable<RenderLayer> cir) {
if (type == SkullBlock.Type.PLAYER && profile != null && profile.getProperties().containsKey("textures") && TextureToHeadMap.MAP.containsKey(MinecraftClient.getInstance().getSkinProvider().getTextures(profile).get(MinecraftProfileTexture.Type.SKIN).getUrl())) {
if (type == SkullBlock.Type.PLAYER && profile != null && profile.getProperties().containsKey("textures") && MinecraftClient.getInstance().getSkinProvider().getTextures(profile).containsKey(MinecraftProfileTexture.Type.SKIN) && TextureToHeadMap.MAP.containsKey(MinecraftClient.getInstance().getSkinProvider().getTextures(profile).get(MinecraftProfileTexture.Type.SKIN).getUrl())) {
cir.setReturnValue(TextureToHeadMap.MAP.get(MinecraftClient.getInstance().getSkinProvider().getTextures(profile).get(MinecraftProfileTexture.Type.SKIN).getUrl()).getRenderLayer());
}
}
Expand All @@ -62,7 +62,7 @@ public class RenderHeadedHeadMixin {

@Inject(method = "renderSkull", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;pop()V", shift = At.Shift.AFTER))
private static void headedrewritten$renderFeatures(Direction direction, float yaw, float animationProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, SkullBlockEntityModel model, RenderLayer renderLayer, CallbackInfo ci) {
if (HeadedContext.currentProfile != null && HeadedContext.currentProfile.getProperties().containsKey("textures") && TextureToHeadMap.MAP.containsKey(MinecraftClient.getInstance().getSkinProvider().getTextures(HeadedContext.currentProfile).get(MinecraftProfileTexture.Type.SKIN).getUrl())) {
if (HeadedContext.currentProfile != null && HeadedContext.currentProfile.getProperties().containsKey("textures") && MinecraftClient.getInstance().getSkinProvider().getTextures(HeadedContext.currentProfile).containsKey(MinecraftProfileTexture.Type.SKIN) && TextureToHeadMap.MAP.containsKey(MinecraftClient.getInstance().getSkinProvider().getTextures(HeadedContext.currentProfile).get(MinecraftProfileTexture.Type.SKIN).getUrl())) {
HeadedHead head = TextureToHeadMap.MAP.get(MinecraftClient.getInstance().getSkinProvider().getTextures(HeadedContext.currentProfile).get(MinecraftProfileTexture.Type.SKIN).getUrl());
HeadedContext.currentProfile = null;
for (Function<EntityModelLoader, HeadedFeatureRenderer> featureRenderer : head.getFeatureRenderers()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class RenderHeadedHeadOnHeadMixin {
@ModifyArg(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/entity/LivingEntity;FFFFFF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/block/entity/SkullBlockEntityRenderer;renderSkull(Lnet/minecraft/util/math/Direction;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/block/entity/SkullBlockEntityModel;Lnet/minecraft/client/render/RenderLayer;)V"), index = 6)
private SkullBlockEntityModel headedrewritten$replaceItemModel(SkullBlockEntityModel model, @Local(ordinal = 0) GameProfile gameProfile, @Local(ordinal = 0) SkullBlock.SkullType skullType) {
if (skullType == SkullBlock.Type.PLAYER && gameProfile != null && gameProfile.getProperties().containsKey("textures") && TextureToHeadMap.MAP.containsKey(MinecraftClient.getInstance().getSkinProvider().getTextures(gameProfile).get(MinecraftProfileTexture.Type.SKIN).getUrl())) {
if (skullType == SkullBlock.Type.PLAYER && gameProfile != null && gameProfile.getProperties().containsKey("textures") && MinecraftClient.getInstance().getSkinProvider().getTextures(gameProfile).containsKey(MinecraftProfileTexture.Type.SKIN) && TextureToHeadMap.MAP.containsKey(MinecraftClient.getInstance().getSkinProvider().getTextures(gameProfile).get(MinecraftProfileTexture.Type.SKIN).getUrl())) {
HeadedContext.currentProfile = gameProfile;
return TextureToHeadMap.MAP.get(MinecraftClient.getInstance().getSkinProvider().getTextures(gameProfile).get(MinecraftProfileTexture.Type.SKIN).getUrl()).getModel(MinecraftClient.getInstance().getEntityModelLoader());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
public class WallHeadCollisionMixin {
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
private void headedrewritten$getAccurateWallOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (HeadedRewritten.CONFIG.changeHeadCollisions() && world.getBlockEntity(pos) instanceof SkullBlockEntity blockEntity && blockEntity.getOwner() != null && blockEntity.getOwner().getProperties().containsKey("textures") && TextureToHeadMap.MAP.containsKey(MinecraftClient.getInstance().getSkinProvider().getTextures(blockEntity.getOwner()).get(MinecraftProfileTexture.Type.SKIN).getUrl())) {
if (HeadedRewritten.CONFIG.changeHeadCollisions() && world.getBlockEntity(pos) instanceof SkullBlockEntity blockEntity && blockEntity.getOwner() != null && blockEntity.getOwner().getProperties().containsKey("textures") && MinecraftClient.getInstance().getSkinProvider().getTextures(blockEntity.getOwner()).containsKey(MinecraftProfileTexture.Type.SKIN) && TextureToHeadMap.MAP.containsKey(MinecraftClient.getInstance().getSkinProvider().getTextures(blockEntity.getOwner()).get(MinecraftProfileTexture.Type.SKIN).getUrl())) {
SkullBlockEntityModel model = TextureToHeadMap.MAP.get(MinecraftClient.getInstance().getSkinProvider().getTextures(blockEntity.getOwner()).get(MinecraftProfileTexture.Type.SKIN).getUrl()).getModel(MinecraftClient.getInstance().getEntityModelLoader());
Vector3f boxSize;
if (model instanceof HeadedRewrittenModel headedRewrittenModel) {
Expand Down

0 comments on commit ca61330

Please sign in to comment.