Skip to content
This repository has been archived by the owner on Jan 4, 2024. It is now read-only.

Commit

Permalink
Fix dedicated server crash
Browse files Browse the repository at this point in the history
+ bump version
  • Loading branch information
florensie committed Mar 16, 2021
1 parent 4d46f62 commit 29b5401
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.0.1] - 2021-03-16
### Fixed
- Crash on dedicated server

## [3.0.0] - 2021-03-16
### Added
- Vampiric Glove artifact
Expand Down Expand Up @@ -136,7 +140,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Initial release

[Unreleased]: https://github.com/florensie/artifacts-fabric/compare/v3.0.0...HEAD
[Unreleased]: https://github.com/florensie/artifacts-fabric/compare/v3.0.1...HEAD
[3.0.0]: https://github.com/florensie/artifacts-fabric/compare/v3.0.0...v3.0.1
[3.0.0]: https://github.com/florensie/artifacts-fabric/compare/v2.3.0...v3.0.0
[2.3.0]: https://github.com/florensie/artifacts-fabric/compare/v2.2.1...v2.3.0
[2.2.1]: https://github.com/florensie/artifacts-fabric/compare/v2.2.0...v2.2.1
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ yarn_mappings=1.16.5+build.5
loader_version=0.11.2

# Mod Properties
mod_version=3.0.0+fabric
mod_version=3.0.1+fabric
maven_group=artifacts
archives_base_name=artifacts

Expand Down
8 changes: 0 additions & 8 deletions src/main/java/artifacts/item/UmbrellaItem.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
package artifacts.item;

import artifacts.Artifacts;
import artifacts.init.Items;
import net.minecraft.block.DispenserBlock;
import net.minecraft.client.util.ModelIdentifier;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.UseAction;
import net.minecraft.world.World;

public class UmbrellaItem extends ArtifactItem {

public static final ModelIdentifier UMBRELLA_HELD_MODEL = new ModelIdentifier(
new Identifier(Artifacts.MODID, "umbrella_in_hand"), "inventory");
public static final ModelIdentifier UMBRELLA_ICON_MODEL = new ModelIdentifier(
new Identifier(Artifacts.MODID, "umbrella"), "inventory");

public UmbrellaItem() {
DispenserBlock.registerBehavior(this, ArmorItem.DISPENSER_BEHAVIOR);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
package artifacts.mixin.mixins.item.umbrella.client;

import artifacts.Artifacts;
import artifacts.init.Items;
import artifacts.item.UmbrellaItem;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.item.ItemModels;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.util.ModelIdentifier;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

@Mixin(ItemRenderer.class)
public abstract class ItemRendererMixin {

@Shadow @Final private ItemModels models;
@Unique
private static final ModelIdentifier UMBRELLA_HELD_MODEL = new ModelIdentifier(
new Identifier(Artifacts.MODID, "umbrella_in_hand"), "inventory");
@Unique
private static final ModelIdentifier UMBRELLA_ICON_MODEL = new ModelIdentifier(
new Identifier(Artifacts.MODID, "umbrella"), "inventory");

@ModifyVariable(method = "getHeldItemModel", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/render/item/ItemModels;getModel(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/client/render/model/BakedModel;"))
private BakedModel setUmbrellaHeldModel(BakedModel model, ItemStack stack) {
return stack.getItem() == Items.UMBRELLA ? this.models.getModelManager().getModel(UmbrellaItem.UMBRELLA_HELD_MODEL) : model;
return stack.getItem() == Items.UMBRELLA ? this.models.getModelManager().getModel(UMBRELLA_HELD_MODEL) : model;
}

@ModifyVariable(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformation$Mode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;)V",
Expand All @@ -31,6 +43,6 @@ private BakedModel setUmbrellaIconModel(BakedModel model, ItemStack stack, Model
renderMode == ModelTransformation.Mode.FIXED;

return stack.getItem() == Items.UMBRELLA && shouldUseIcon
? this.models.getModelManager().getModel(UmbrellaItem.UMBRELLA_ICON_MODEL) : model;
? this.models.getModelManager().getModel(UMBRELLA_ICON_MODEL) : model;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package artifacts.mixin.mixins.item.umbrella.client;

import artifacts.Artifacts;
import artifacts.item.UmbrellaItem;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.util.ModelIdentifier;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand All @@ -13,9 +16,12 @@
public abstract class ModelLoaderMixin {

@Shadow protected abstract void addModel(ModelIdentifier modelId);
@Unique
private static final ModelIdentifier UMBRELLA_HELD_MODEL = new ModelIdentifier(
new Identifier(Artifacts.MODID, "umbrella_in_hand"), "inventory");

@Inject(method = "<init>", at = @At(value = "INVOKE_STRING", shift = At.Shift.AFTER, target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", args = {"ldc=special"}))
private void addUmbrellaHeldModel(CallbackInfo info) {
this.addModel(UmbrellaItem.UMBRELLA_HELD_MODEL);
this.addModel(UMBRELLA_HELD_MODEL);
}
}

0 comments on commit 29b5401

Please sign in to comment.