Comments (3)
That's because you're trying to load ModelMask
server-side even though it's a client-only class. There are a few ways to avoid loading it server-side. You can do what I did (it's in the code above), which is to declare it as a generic Object
object and then initialize it to the right instance in the doRender
method. Alternatively, you can add @OnlyIn(Dist.CLIENT)
annotations to your ModelMask
variable and your doRender
method to have them only load on the client.
from curios.
Don't implement ICurio
directly on your item, use a capability provider to attach an implementation. Like this:
Ignore the fact that the item itself also implements ICurio
, that's some legacy code.
You don't need to use CapCurioItem#createProvider
, and you probably shouldn't since it's an internal helper method, as long as you return your own ICapabilityProvider
implementation.
If you need an example of that, I have a basic implementation in one of my Curio mods, although the context is slightly different because it's in an AttachCapabilitiesEvent
event:
https://github.com/TheIllusiveC4/CurioOfUndying/blob/e92796467ad33abf80eaa7d6273446b81b9e3b26/src/main/java/top/theillusivec4/curioofundying/CurioOfUndying.java#L65-L84
from curios.
Thanks. Something I wonder though is how I make it run on a server. Whenever I try and join an account and I spawn in my item I get disconnected.
java.lang.RuntimeException: Attempted to load class net/minecraft/client/renderer/entity/model/EntityModel for invalid dist DEDICATED_SERVER
ItemMask
public class ItemMask extends Item
{
private final ResourceLocation texture;
private final boolean hideName;
public ItemMask(String name, ResourceLocation texture, boolean hideName)
{
super(new Item.Properties().group(ItemGroup.REDSTONE));
this.texture = texture;
this.hideName = hideName;
setRegistryName(name);
}
public boolean hidesIdentity()
{
return hideName;
}
@Nullable
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt)
{
ICurio curio = new ICurio() {
private final ModelMask model = ModelMask.modelMask;
@Override
public void onEquipped(String identifier, LivingEntity entityLivingBase)
{
if (hidesIdentity())
entityLivingBase.setCustomNameVisible(false);
}
@Override
public void onUnequipped(String identifier, LivingEntity entityLivingBase)
{
if (hidesIdentity())
entityLivingBase.setCustomNameVisible(true);
}
@Override
public void doRender(String identifier, LivingEntity entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
Minecraft.getInstance().getTextureManager().bindTexture(texture);
ICurio.RenderHelper.followHeadRotations(entitylivingbaseIn,model.mask);
model.render(entitylivingbaseIn,limbSwing,limbSwingAmount,ageInTicks,netHeadYaw,headPitch,scale);
}
@Override
public boolean canRightClickEquip()
{
return true;
}
@Override
public boolean hasRender(String identifier, LivingEntity entityLivingBase)
{
return true;
}
};
ICapabilityProvider provider = new ICapabilityProvider() {
private final LazyOptional<ICurio> curioOpt =
LazyOptional.of(() -> curio);
@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap,
@Nullable Direction side) {
return CuriosCapability.ITEM.orEmpty(cap, curioOpt);
}
};
return provider;
}
}
ModelMask
public class ModelMask extends EntityModel
{
public RendererModel mask;
public static final ModelMask modelMask = new ModelMask();
public ModelMask()
{
this.textureWidth = 24;
this.textureHeight = 16;
this.mask = new RendererModel(this,0,0);
this.mask.setRotationPoint(0,0,0);
this.mask.addBox(-4.0F, -8.0F, -4F, 8, 8, 8, 0.0F);
}
@Override
public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
this.mask.render(scale);
}
}
I thought I could avoid it by not initiating it in the capability provider, but that didn't work obviosly.
from curios.
Related Issues (20)
- [Bug]: Build error on fresh clone
- [Bug]: "curio" slots aren't validated as expected HOT 3
- [Bug]: Ifinity backpack (Industrial Foregoing) Not working on added slot HOT 3
- [Bug]: Copy eqipped items after respawning HOT 2
- [Bug]: "/clear"command cannot clear irons-spells-n-spellbooks mod's magic book HOT 1
- [Bug]: ItemStack changes not synced if LocalPlayer HOT 8
- [Bug]: the game crashes with the last version of embeddium++ HOT 3
- [Bug]: Attempted to load a class for invalid dist DEDICATED_SERVER
- [Bug]: Latest Curios & EMI causes error loading EMI ? HOT 2
- [Feature]: Allow Datafixers to Run on Items in the Curios Inventory HOT 3
- [Bug]: Crash
- [Bug]: The game crashed when i die HOT 5
- [Bug]: Crash since Neoforge 20.6.78-beta
- [Bug]: Curios Causing "EMI experienced a critical exception while reloading, check log" HOT 2
- [Bug]: Held Inventory Item Deleted in 1.20.4+ NeoForge
- [Bug]: Diet Button Disappears When Using New Curios Menu HOT 1
- [Bug]: 20.6.113-BETA neoforge crash HOT 6
- Seo1raposo[Feature]:
- [Bug]: Singleplayer - Only first item for each slot is saved, others are lost after relogging
- [Bug]: Curios accessories do not show Quark's custom enchant glint HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from curios.