Skip to content

Commit

Permalink
Hotfixes right from the oven
Browse files Browse the repository at this point in the history
  • Loading branch information
Desoroxxx committed Mar 13, 2024
1 parent 0f42e4f commit e2de48c
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 39 deletions.
19 changes: 17 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/paneedah/mwc/asm/Interceptors.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ protected void renderModelSource(RenderContext<RenderableState> renderContext, I

for (Tuple<ModelBase, String> 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()));
}
Expand Down
15 changes: 6 additions & 9 deletions src/main/java/com/paneedah/mwc/skins/CustomSkin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
45 changes: 24 additions & 21 deletions src/main/java/com/paneedah/mwc/skins/GunSkins.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/paneedah/weaponlib/WeaponReloadAspect.java
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ private ItemAttachment<Weapon> 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)) {
Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/paneedah/weaponlib/WeaponRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3313,7 +3313,7 @@ public void renderItem(ItemStack weaponItemStack, RenderContext<RenderableState>
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"));
}
Expand Down

0 comments on commit e2de48c

Please sign in to comment.