Added Mansion Compass and fixed issue where models were loaded twice
This commit is contained in:
@@ -80,19 +80,6 @@ public class ClientProxy extends CommonProxy {
|
||||
ModItems.registerModels();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onModelRegistry(ModelRegistryEvent event) {
|
||||
registerModel(ModItems.ENDER_COMPASS);
|
||||
registerModel(ModItems.VILLAGE_COMPASS);
|
||||
registerModel(ModItems.FORTRESS_COMPASS);
|
||||
registerModel(ModItems.MONUMENT_COMPASS);
|
||||
}
|
||||
|
||||
private void registerModel(ItemCompassBase compass) {
|
||||
compass.addPropertyOverride(new ResourceLocation("angle"), new AngleGetter());
|
||||
ModelLoader.setCustomModelResourceLocation(compass, 0, new ModelResourceLocation(FindYourWay.modId + ":" + compass.getUnlocalizedName()));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onClientTick(TickEvent.ClientTickEvent event) {
|
||||
for(int i = 0; i < CommonProxy.compassList.size(); i++) {
|
||||
|
||||
@@ -48,10 +48,7 @@ public class CommonProxy {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event) {
|
||||
event.getRegistry().register(ModItems.ENDER_COMPASS);
|
||||
event.getRegistry().register(ModItems.VILLAGE_COMPASS);
|
||||
event.getRegistry().register(ModItems.FORTRESS_COMPASS);
|
||||
event.getRegistry().register(ModItems.MONUMENT_COMPASS);
|
||||
ModItems.registerItems(event);
|
||||
}
|
||||
|
||||
public static boolean containsCompass(IInventory inventory, ItemCompassBase compass) {
|
||||
@@ -63,26 +60,4 @@ public class CommonProxy {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int setCompassId(ItemCompassBase compass) {
|
||||
switch (compass.getStructureType()){
|
||||
case "Stronghold": return 1;
|
||||
case "Village": return 2;
|
||||
case "Fortress": return 3;
|
||||
case "Monument": return 4;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemCompassBase getCompassId(int id) {
|
||||
switch (id) {
|
||||
case 1: return ModItems.ENDER_COMPASS;
|
||||
case 2: return ModItems.VILLAGE_COMPASS;
|
||||
case 3: return ModItems.FORTRESS_COMPASS;
|
||||
case 4: return ModItems.MONUMENT_COMPASS;
|
||||
default:
|
||||
ItemCompassBase ERROR_COMPASS = new ItemCompassBase("error", "");
|
||||
return ERROR_COMPASS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
@@ -16,6 +17,7 @@ import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.yseven.findyourway.Client.AngleGetter;
|
||||
import net.yseven.findyourway.Client.ClientProxy;
|
||||
import net.yseven.findyourway.CommonProxy;
|
||||
import net.yseven.findyourway.FindYourWay;
|
||||
@@ -89,7 +91,8 @@ public class ItemCompassBase extends Item {
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void registerItemModel() {
|
||||
ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(getRegistryName(), "inventory"));
|
||||
this.addPropertyOverride(new ResourceLocation("angle"), new AngleGetter());
|
||||
ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(FindYourWay.modId + ":" + this.getUnlocalizedName(), "inventory"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.yseven.findyourway.item;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -12,12 +14,14 @@ public class ModItems {
|
||||
public static ItemCompassBase VILLAGE_COMPASS;
|
||||
public static ItemCompassBase FORTRESS_COMPASS;
|
||||
public static ItemCompassBase MONUMENT_COMPASS;
|
||||
public static ItemCompassBase MANSION_COMPASS;
|
||||
|
||||
public static void init(){
|
||||
ENDER_COMPASS = new ItemCompassBase("ender_compass", "Stronghold");
|
||||
VILLAGE_COMPASS = new ItemCompassBase("village_compass", "Village");
|
||||
FORTRESS_COMPASS = new ItemCompassBase("fortress_compass", "Fortress");
|
||||
MONUMENT_COMPASS = new ItemCompassBase("monument_compass", "Monument");
|
||||
MANSION_COMPASS = new ItemCompassBase("mansion_compass", "Mansion");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -26,5 +30,14 @@ public class ModItems {
|
||||
VILLAGE_COMPASS.registerItemModel();
|
||||
FORTRESS_COMPASS.registerItemModel();
|
||||
MONUMENT_COMPASS.registerItemModel();
|
||||
MANSION_COMPASS.registerItemModel();
|
||||
}
|
||||
|
||||
public static void registerItems(RegistryEvent.Register<Item> event) {
|
||||
event.getRegistry().register(ENDER_COMPASS);
|
||||
event.getRegistry().register(VILLAGE_COMPASS);
|
||||
event.getRegistry().register(FORTRESS_COMPASS);
|
||||
event.getRegistry().register(MONUMENT_COMPASS);
|
||||
event.getRegistry().register(MANSION_COMPASS);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user