ItsAMysteriousYT Posted September 13, 2015 Posted September 13, 2015 I created a resourcepack but it won't load when i compiled my mod and try it in minecraft it wouldn't load. This is my resourcefile: package itsamysterious.mods.reallifemod; import java.awt.image.BufferedImage; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.Set; import com.google.common.collect.ImmutableSet; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.DefaultResourcePack; import net.minecraft.client.resources.FolderResourcePack; import net.minecraft.client.resources.IResourceManager; import net.minecraft.client.resources.IResourceManagerReloadListener; import net.minecraft.client.resources.IResourcePack; import net.minecraft.client.resources.data.IMetadataSection; import net.minecraft.client.resources.data.IMetadataSerializer; import net.minecraft.util.ResourceLocation; public class RLMPack extends FolderResourcePack implements IResourcePack,IResourceManagerReloadListener{ public static final Set defaultResourceDomains = ImmutableSet.of("RLM"); public static List<String> filenames=new ArrayList<String>(); public RLMPack() { super(new File(RealLifeMod.MinecraftDirectory+"/RLM")); } @Override public InputStream getInputStream(ResourceLocation p_110590_1_) throws IOException { return getResourceStream(p_110590_1_); } @Override public boolean resourceExists(ResourceLocation p_110589_1_) { return this.getResourceStream(p_110589_1_) != null; } private InputStream getResourceStream(ResourceLocation p_110605_1_) { try { return new FileInputStream(RealLifeMod.MinecraftDirectory+"/RLM/"+p_110605_1_.getResourcePath()); } catch (FileNotFoundException e) { e.printStackTrace(); } return null; } @Override public Set getResourceDomains() { return defaultResourceDomains; } @Override public IMetadataSection getPackMetadata(IMetadataSerializer p_135058_1_, String p_135058_2_) throws IOException { return null; } @Override public BufferedImage getPackImage() throws IOException { return null; } @Override public String getPackName() { return "RLMPack"; } @Override public void onResourceManagerReload(IResourceManager resourceManager) { } } Quote
ItsAMysteriousYT Posted September 13, 2015 Author Posted September 13, 2015 1. Forgot to remove it. 2. I do not know whic method to override so the methods automaticly work right 3.Like this: @EventHandler public void preInit(FMLPreInitializationEvent event) { MinecraftDirectory = event.getSourceFile().getPath().toString(); if (MinecraftDirectory.contains("bin")) { MinecraftDirectory = MinecraftDirectory.replace("bin", "run"); } else if (MinecraftDirectory.contains(".minecraft")) { } } 4.With this method in my clientproxy from preinit: @Override public void loadCoreModules() { List<IResourcePack> defaultResourcePacks = ObfuscationReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "defaultResourcePacks", "field_110449_ao"); defaultResourcePacks.add(new RLMPack()); File screenshots = new File(Minecraft.getMinecraft().mcDataDir, "screenshots"); for (File f : screenshots.listFiles()) { Screenshotspack.filenames.add(f.getName()); } defaultResourcePacks.add(new Screenshotspack()); Minecraft.getMinecraft().refreshResources(); } Quote
ItsAMysteriousYT Posted September 13, 2015 Author Posted September 13, 2015 Is everything alright with that? Quote
ItsAMysteriousYT Posted September 13, 2015 Author Posted September 13, 2015 Is it possible to load them dynamicly? Without reloading all resources? And i came out with that resourceDir detection because when i tried starting the server with it, it crashed because it tried to acces the client. First i tried to make the method in a clientcheck (if(event.getSide()==Side.CLIENT)) but it crashed too. Quote
ItsAMysteriousYT Posted September 13, 2015 Author Posted September 13, 2015 I have the method in the clientproxy and call it under a client check. Is that enough or do i have to call it in the constructor of the clientproxy? Quote
ItsAMysteriousYT Posted September 13, 2015 Author Posted September 13, 2015 Any Resourcepack related stuff must be client-proxy. Ah - OK. That explaines many things. Now, i don't wanna make a new thread for that problem - so is anything wrong with the method? Somehow the Gui shows up even if i have set the name/surname before. @SubscribeEvent public void updateRealLifeProps(PlayerTickEvent event) { tickrun++; if (tickrun>3&&RLMPlayerProps.get(event.player) != null) { RLMPlayerProps.get(event.player).circleOfLife(); if (RLMPlayerProps.get(event.player).getName() == null) { BlockPos p = event.player.getPosition(); event.player.openGui(RealLifeMod.instance, GuiModInit.ID, event.player.worldObj, 0, 0, 0); } else { if (RLMPlayerProps.get(event.player).getName().isEmpty()) { BlockPos p = event.player.getPosition(); event.player.openGui(RealLifeMod.instance, GuiModInit.ID, event.player.worldObj, p.getX(), p.getY(), p.getZ()); } } }else { RLMPlayerProps.register(event.player); } } @SubscribeEvent public void onEntityConstructing(EntityConstructing event) { if (event.entity instanceof EntityPlayer) { if (RLMPlayerProps.get((EntityPlayer) event.entity) == null) { RLMPlayerProps.register((EntityPlayer) event.entity); } } } PS - i tried the GuiOpen stuff in PlayerLoggedInEvent, but it did not open the gui. Quote
ItsAMysteriousYT Posted September 13, 2015 Author Posted September 13, 2015 Then what else should i use? ClientTickEvent? But not to update the IEEP, cuz they have to be updated on server too. Quote
ItsAMysteriousYT Posted September 13, 2015 Author Posted September 13, 2015 What do i have to check for event.phase? Quote
ItsAMysteriousYT Posted September 13, 2015 Author Posted September 13, 2015 It still does open when i rejoin in the world Quote
ItsAMysteriousYT Posted September 13, 2015 Author Posted September 13, 2015 Anf the resourcepack still does not work outside of the modding workpsace These are the methods in which i load additional items/blocks. private void loadVehicles() { System.out.println("loaded vehicles"); if (vehiclefile.exists()) { if (vehiclefile.isDirectory()) { for (File vehicle : vehiclefile.listFiles()) { if (vehicle.getName().endsWith(".rlm")) { Vehicles.addVehicle(new VehicleFile(vehicle)); } } } } else { vehiclefile.mkdirs(); } } Thats why i use that weird MCDirectory stuff, cuz i have too define the directory in which the VehicleFiles are located. But when in minecraft, they do not work. Quote
ItsAMysteriousYT Posted September 14, 2015 Author Posted September 14, 2015 Ah - never heard of that MinecraftServer.getDataDir() befor thanks Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.