diff --git a/Changelog.md b/Changelog.md index 34e984677..2dc11b5eb 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,13 +5,28 @@ 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 follows to [Ragnarök Versioning Convention](https://gist.github.com/JustDesoroxxx/5d4a45785ce19a6653ba99f72325c703). +## Modern Warfare Cubed Version 0.1.1 Changelog - 2024-03-13 + +### Warning + +[**MWC 0.1 NOW REQUIRES RED CORE 0.5.1 AND ABOVE**](https://www.curseforge.com/minecraft/mc-mods/red-core/files/all) + +[**MWC 0.1 NOW REQUIRES MIXINBOOTER**](https://www.curseforge.com/minecraft/mc-mods/mixin-booter/files/all) + +**BEFORE UPDATING TO MWC 0.1 MAKE SURE TO BACKUP YOUR WORLDS, THINGS WILL DISAPPEAR** + +### Fixed + +- Fixed crash when reloading +- Fixed custom skins not working + ## Modern Warfare Cubed Version 0.1 Changelog - 2024-03-13 ### Warning -[**MWC 0.1 NOW REQUIRE RED CORE 0.5.1 AND ABOVE**](https://www.curseforge.com/minecraft/mc-mods/red-core/files/all) +[**MWC 0.1 NOW REQUIRES RED CORE 0.5.1 AND ABOVE**](https://www.curseforge.com/minecraft/mc-mods/red-core/files/all) -[**MWC 0.1 NOW REQUIRE MIXINBOOTER AND ABOVE**](https://www.curseforge.com/minecraft/mc-mods/mixin-booter/files/all) +[**MWC 0.1 NOW REQUIRES MIXINBOOTER**](https://www.curseforge.com/minecraft/mc-mods/mixin-booter/files/all) **BEFORE UPDATING TO MWC 0.1 MAKE SURE TO BACKUP YOUR WORLDS, THINGS WILL DISAPPEAR** diff --git a/src/main/java/com/paneedah/mwc/asm/Interceptors.java b/src/main/java/com/paneedah/mwc/asm/Interceptors.java index 6dc22dde5..310e3a04e 100644 --- a/src/main/java/com/paneedah/mwc/asm/Interceptors.java +++ b/src/main/java/com/paneedah/mwc/asm/Interceptors.java @@ -699,21 +699,21 @@ public static void render2(ModelBase modelBase, Entity entityIn, float limbSwing EquipmentInventory equipmentInventory = EquipmentCapability.getInventory(player); if(equipmentInventory != null) { ItemStack backpackStack = equipmentInventory.getStackInSlot(BACKPACK_SLOT); - if(backpackStack != null) { + if(!backpackStack.isEmpty()) { GL11.glPushMatrix(); adjustBodyWearablePosition(player); MC.getItemRenderer().renderItem(player, backpackStack, null); GL11.glPopMatrix(); } ItemStack beltStack = equipmentInventory.getStackInSlot(BELT_SLOT); - if(beltStack != null) { + if(!beltStack.isEmpty()) { GL11.glPushMatrix(); adjustBodyWearablePosition(player); MC.getItemRenderer().renderItem(player, beltStack, null); GL11.glPopMatrix(); } ItemStack vestStack = equipmentInventory.getStackInSlot(VEST_SLOT); - if(vestStack != null) { + if(!vestStack.isEmpty()) { GL11.glPushMatrix(); adjustBodyWearablePosition(player); MC.getItemRenderer().renderItem(player, vestStack, null); diff --git a/src/main/java/com/paneedah/mwc/renderer/StaticModelSourceRenderer.java b/src/main/java/com/paneedah/mwc/renderer/StaticModelSourceRenderer.java index 4a096e1fc..7747175af 100644 --- a/src/main/java/com/paneedah/mwc/renderer/StaticModelSourceRenderer.java +++ b/src/main/java/com/paneedah/mwc/renderer/StaticModelSourceRenderer.java @@ -221,7 +221,7 @@ protected void renderModelSource(RenderContext renderContext, I for (Tuple texturedModel : modelSource.getTexturedModels()) { if (texturedModel.getV().startsWith("customskin_")) { - MC.renderEngine.bindTexture(CustomSkin.getCustomSkinResource(texturedModel.getV().toLowerCase().replace("customskin_", "").replace(".png", ""))); + MC.renderEngine.bindTexture(CustomSkin.getCustomSkinResource(texturedModel.getV().replace("customskin_", ""))); } else { MC.renderEngine.bindTexture(new ResourceLocation(ID + ":textures/models/" + texturedModel.getV())); } diff --git a/src/main/java/com/paneedah/mwc/skins/CustomSkin.java b/src/main/java/com/paneedah/mwc/skins/CustomSkin.java index 57fb23152..c85be8fab 100644 --- a/src/main/java/com/paneedah/mwc/skins/CustomSkin.java +++ b/src/main/java/com/paneedah/mwc/skins/CustomSkin.java @@ -8,28 +8,25 @@ import static com.paneedah.mwc.proxies.ClientProxy.MC; import static com.paneedah.mwc.utils.ModReference.ID; +import static com.paneedah.mwc.utils.ModReference.RED_LOG; public class CustomSkin { - protected ResourceLocation resourceLocation; + private ResourceLocation resourceLocation; - public CustomSkin(String name, File file) { + public CustomSkin(final String name, final File file) { try { resourceLocation = new ResourceLocation(ID, "customskin_" + name.toLowerCase()); MC.getTextureManager().loadTexture(resourceLocation, new DynamicTexture(ImageIO.read(file))); MC.getTextureManager().bindTexture(resourceLocation); } catch (Exception e) { - e.printStackTrace(); + RED_LOG.printFramedError("Load Custom Skin", "Failed to load custom skin: " + name + " from file: " + file.getAbsolutePath(), "Skin will not be loaded."); } } - public static ResourceLocation getCustomSkinResource(String skinName) { - File image = new File("./config/mwc/skins/" + skinName + ".png"); - if (!image.exists()) - return new ResourceLocation(ID + ":textures/models/" + GunSkins.WoodlandCamo.getTextureName() + ".png"); - + public static ResourceLocation getCustomSkinResource(final String skinName) { if (!GunSkins.customSkins.containsKey(skinName)) - GunSkins.customSkins.put(skinName, new CustomSkin(skinName, new File("./config/mwc/skins/" + skinName.replace("customskin_", "")))); + GunSkins.customSkins.put(skinName, new CustomSkin(skinName, new File("./config/mwc/skins/" + skinName))); return GunSkins.customSkins.get(skinName).resourceLocation; } diff --git a/src/main/java/com/paneedah/mwc/skins/GunSkins.java b/src/main/java/com/paneedah/mwc/skins/GunSkins.java index 1c98c086e..f7489ab14 100644 --- a/src/main/java/com/paneedah/mwc/skins/GunSkins.java +++ b/src/main/java/com/paneedah/mwc/skins/GunSkins.java @@ -35,56 +35,56 @@ public class GunSkins { public static void init(Object mod) { GunSkins.WoodlandCamo = new ItemSkin.Builder() - .withTextureVariant("woodlandcamo") + .withTextureVariant("woodlandcamo") .withCreativeTab(MWC.ATTACHMENTS_TAB) .withName("WoodlandCamo") .build(MWC.modContext, ItemSkin.class); CommonRegistry.gunSkins.add(GunSkins.WoodlandCamo); - + GunSkins.PinkCamo = new ItemSkin.Builder() - .withTextureVariant("pinkcamo") + .withTextureVariant("pinkcamo") .withCreativeTab(MWC.ATTACHMENTS_TAB) .withName("PinkCamo") .build(MWC.modContext, ItemSkin.class); CommonRegistry.gunSkins.add(GunSkins.PinkCamo); - + GunSkins.ArcticCamo = new ItemSkin.Builder() - .withTextureVariant("arcticcamo") + .withTextureVariant("arcticcamo") .withCreativeTab(MWC.ATTACHMENTS_TAB) .withName("ArcticCamo") .build(MWC.modContext, ItemSkin.class); CommonRegistry.gunSkins.add(GunSkins.ArcticCamo); - + GunSkins.BlueCamo = new ItemSkin.Builder() - .withTextureVariant("bluecamo") + .withTextureVariant("bluecamo") .withCreativeTab(MWC.ATTACHMENTS_TAB) .withName("BlueCamo") .build(MWC.modContext, ItemSkin.class); CommonRegistry.gunSkins.add(GunSkins.BlueCamo); - + GunSkins.Unit01Camo = new ItemSkin.Builder() - .withTextureVariant("unit01camo") + .withTextureVariant("unit01camo") .withCreativeTab(MWC.ATTACHMENTS_TAB) .withName("Unit01Camo") .build(MWC.modContext, ItemSkin.class); CommonRegistry.gunSkins.add(GunSkins.Unit01Camo); - + GunSkins.BloodForestCamo = new ItemSkin.Builder() - .withTextureVariant("bloodforestcamo") + .withTextureVariant("bloodforestcamo") .withCreativeTab(MWC.ATTACHMENTS_TAB) .withName("BloodForestCamo") .build(MWC.modContext, ItemSkin.class); CommonRegistry.gunSkins.add(GunSkins.BloodForestCamo); - + GunSkins.DiamondCamo = new ItemSkin.Builder() - .withTextureVariant("diamondcamo") + .withTextureVariant("diamondcamo") .withCreativeTab(MWC.ATTACHMENTS_TAB) .withName("DiamondCamo") .build(MWC.modContext, ItemSkin.class); CommonRegistry.gunSkins.add(GunSkins.DiamondCamo); - + GunSkins.GoldCamo = new ItemSkin.Builder() - .withTextureVariant("goldcamo") + .withTextureVariant("goldcamo") .withCreativeTab(MWC.ATTACHMENTS_TAB) .withName("GoldCamo") .build(MWC.modContext, ItemSkin.class); @@ -109,9 +109,9 @@ public static void init(Object mod) { JsonObject jsonObject = new JsonParser().parse(new JsonReader(new FileReader(skinsConfiguration))).getAsJsonObject(); for (JsonElement element : jsonObject.getAsJsonArray("skins")) { - String skinName = element.getAsString(); + String skinName = element.getAsString().toLowerCase(); ItemSkin skin = new ItemSkin.Builder() - .withTextureVariant("customskin_" + skinName.toLowerCase()) + .withTextureVariant("customskin_" + skinName) .withCreativeTab(MWC.ATTACHMENTS_TAB) .withName(skinName) .build(MWC.modContext, ItemSkin.class); @@ -131,20 +131,23 @@ public static void init(Object mod) { if (imageUrl == null) throw new RuntimeException("Failed to find default custom skin (oldiepinkcamo.png)."); - try { FileUtils.copyURLToFile(imageUrl, new File(customSkinsDir, "oldiepinkcamo.png")); } - catch (IOException e) { e.printStackTrace(); } + try { + FileUtils.copyURLToFile(imageUrl, new File(customSkinsDir, "oldiepinkcamo.png")); + } catch (IOException e) { + e.printStackTrace(); + } File[] files = customSkinsDir.listFiles(); if (files == null) return; for (File f : files) { - String name = f.getName(); + String name = f.getName().toLowerCase(); if (!name.endsWith(".png")) continue; ItemSkin skin = new ItemSkin.Builder() - .withTextureVariant("customskin_" + name.toLowerCase().replace(".png", "")) + .withTextureVariant("customskin_" + name.replace(".png", "")) .withCreativeTab(MWC.ATTACHMENTS_TAB) .withName(name.replace(".png", "")) .build(MWC.modContext, ItemSkin.class); diff --git a/src/main/java/com/paneedah/weaponlib/WeaponReloadAspect.java b/src/main/java/com/paneedah/weaponlib/WeaponReloadAspect.java index 1e1e65dfd..bbc27fc34 100644 --- a/src/main/java/com/paneedah/weaponlib/WeaponReloadAspect.java +++ b/src/main/java/com/paneedah/weaponlib/WeaponReloadAspect.java @@ -513,7 +513,7 @@ private ItemAttachment getNextMagazine(PlayerWeaponInstance weaponInstan EquipmentInventory equipmentInventory = EquipmentCapability.getInventory(player); if(equipmentInventory != null) { ItemStack beltStack = equipmentInventory.getStackInSlot(BELT_SLOT); - if(beltStack != null) { + if(!beltStack.isEmpty()) { BackpackInventory beltInventory = new BackpackInventory(beltStack); for (int i = 0; i < beltInventory.getSizeInventory(); ++i) { if (beltInventory.getStackInSlot(i) != null && compatibleMagazines.contains(beltInventory.getStackInSlot(i).getItem()) && (maxStack == null || comparator.compare(beltInventory.getStackInSlot(i), maxStack) > 0)) { @@ -567,7 +567,7 @@ private ItemStack getNextBestMagazineStack(PlayerWeaponInstance weaponInstance) EquipmentInventory equipmentInventory = EquipmentCapability.getInventory(player); if(equipmentInventory != null) { ItemStack beltStack = equipmentInventory.getStackInSlot(BELT_SLOT); - if(beltStack != null) { + if(!beltStack.isEmpty()) { BackpackInventory beltInventory = new BackpackInventory(beltStack); for (int i = 0; i < beltInventory.getSizeInventory(); ++i) { if (beltInventory.getStackInSlot(i) != null && compatibleMagazines.contains(beltInventory.getStackInSlot(i).getItem()) && (maxStack == null || comparator.compare(beltInventory.getStackInSlot(i), maxStack) > 0)) { diff --git a/src/main/java/com/paneedah/weaponlib/WeaponRenderer.java b/src/main/java/com/paneedah/weaponlib/WeaponRenderer.java index b3688e039..0f10cf7a9 100644 --- a/src/main/java/com/paneedah/weaponlib/WeaponRenderer.java +++ b/src/main/java/com/paneedah/weaponlib/WeaponRenderer.java @@ -3313,7 +3313,7 @@ public void renderItem(ItemStack weaponItemStack, RenderContext GlStateManager.setActiveTexture(GL13.GL_TEXTURE0 + 3); if (itemSkin.getTextureName().startsWith("customskin_")) { - MC.getTextureManager().bindTexture(CustomSkin.getCustomSkinResource(itemSkin.getTextureName().toLowerCase().replace("customskin_", ""))); + MC.getTextureManager().bindTexture(CustomSkin.getCustomSkinResource(itemSkin.getTextureName().replace("customskin_", "") + ".png")); } else { MC.getTextureManager().bindTexture(new ResourceLocation(ID +":textures/models/"+itemSkin.getTextureName()+".png")); }