Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** disieben's guide to getting custom compass behavior:
- - Make a class implementing IItemPropertyGetter. Make it return the compass angle you want or -1 for vanilla behavior.
- - Register it with Items.COMPASS.addPropertyOverride with a ResourceLocation that has your ModID.
- - For every possible angle (see compass.json for the list) create an ItemOverride instance. The ResourceLocation parameter is the model to use for that angle, the Map needs to contain one entry; key is the ResourceLocation from the 2nd step, value is the angle for this model.
- - Add all those ItemOverride instances to the compass model (Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager().getModel to get it) by grabbing the ItemOverrideList with IBakedModel::getOverrides and then adding to the list in that (you will need reflection, ItemOverrideList::overrides is private).
- ----------java start----------------- */
- package net.secknv.nkmod.item;
- import java.util.HashMap;
- import java.util.Map;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.renderer.block.model.ItemOverride;
- import net.minecraft.client.renderer.block.model.ModelResourceLocation;
- import net.minecraft.init.Items;
- import net.minecraft.item.IItemPropertyGetter;
- import net.minecraft.util.ResourceLocation;
- public class NkOverrideCompass{
- /*
- * READ COMMENT BELLOW FIRST TO MAKE SENSE OF THIS COMMENT
- *
- * Add all those ItemOverride instances to the compass model
- * (Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager().getModel to get it)
- * by grabbing the ItemOverrideList with IBakedModel::getOverrides and then adding to the list in that
- * (you will need reflection, ItemOverrideList::overrides is private).
- *
- */
- public static void overrideCompass(){
- ResourceLocation myres = new ResourceLocation("nkmod_angle");
- IItemPropertyGetter myIItemPG = new NkCompass();
- Items.COMPASS.addPropertyOverride(myres , myIItemPG);
- /*
- * Creates and array of 33 maps and in the for loop below fills them with
- * key = myres; value = float that IItemPropertyGetter returns for the compass angle
- * then makes an array of 33 ItemOverride and fills it with 33 instances of ItemOverride
- * with constructor (compass ResourceLocation, and each one of the maps)
- * the last step he told me I had to do is the comment above this method but idk how to add the instances to the model
- */
- Map mapArray[] = new HashMap[33];
- float angleArray[] = {0.484375f, 0.515625f, 0.546875f, 0.578125f, 0.609375f, 0.640625f, 0.671875f, 0.703125f, 0.734375f, 0.765625f, 0.796875f, 0.828125f, 0.859375f, 0.890625f, 0.921875f, 0.953125f, 0.984375f, 0.000000f, 0.015625f, 0.046875f, 0.078125f, 0.109375f, 0.140625f, 0.171875f, 0.203125f, 0.234375f, 0.265625f, 0.296875f, 0.328125f, 0.359375f, 0.390625f, 0.421875f, 0.453125f};
- for(int x = 0; x<33; x++){
- mapArray[x] = new HashMap<ResourceLocation, Float>();
- mapArray[x].put(myres, angleArray[x]);
- }
- ItemOverride compassNkOverrides[] = new ItemOverride[33];
- for(int x = 0; x<33; x++){
- compassNkOverrides[x] = new ItemOverride(Items.COMPASS.getRegistryName(), mapArray[x]);
- }
- Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager().getModel((ModelResourceLocation) Items.COMPASS.getRegistryName());
- }
- }
Add Comment
Please, Sign In to add comment