Update
This commit is contained in:
parent
8b0a15413c
commit
96fd964539
@ -2,6 +2,8 @@ package alterwain.offlineskin;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.options.components.BooleanOptionComponent;
|
||||
import net.minecraft.client.option.BooleanOption;
|
||||
import net.minecraft.core.lang.I18n;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
@ -17,6 +19,8 @@ public class GuiSkinChanger extends GuiScreen {
|
||||
private GuiButton buttonLoadSkin;
|
||||
private GuiButton buttonLoadCape;
|
||||
private GuiButton buttonClose;
|
||||
private GuiButton modelType;
|
||||
private GuiButton hasCape;
|
||||
|
||||
|
||||
public GuiSkinChanger(GuiScreen parent) {
|
||||
@ -27,6 +31,8 @@ public class GuiSkinChanger extends GuiScreen {
|
||||
public void init() {
|
||||
I18n stringtranslate = I18n.getInstance();
|
||||
this.controlList.clear();
|
||||
this.controlList.add(this.modelType = new GuiButton(3, this.width / 2 - 100, this.height / 4 + 2, 200, 20, stringtranslate.translateKey("gui.options.page.edit_skin.button.model_slim")));
|
||||
this.controlList.add(this.hasCape = new GuiButton(4, this.width / 2 - 100, this.height / 4 - 10 + 30 + 4, 200, 20, stringtranslate.translateKey("gui.options.page.edit_skin.button.has_cape_yes")));
|
||||
this.controlList.add(this.buttonLoadSkin = new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, stringtranslate.translateKey("gui.options.page.edit_skin.button.load_skin")));
|
||||
this.controlList.add(this.buttonLoadCape = new GuiButton(1, this.width / 2 - 100, this.height / 4 - 10 + 50 + 18 + 20 + 4, 200, 20, stringtranslate.translateKey("gui.options.page.edit_skin.button.load_cape")));
|
||||
this.controlList.add(this.buttonClose = new GuiButton(2, this.width / 2 - 100, this.height / 4 + 120 + 12, stringtranslate.translateKey("gui.options.page.edit_skin.button.close")));
|
||||
@ -50,6 +56,10 @@ public class GuiSkinChanger extends GuiScreen {
|
||||
OfflineSkinMod.capeImage = ImageIO.read(cape);
|
||||
Files.copy(cape.toPath(), new File(configPath, "cape.png").toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
} else if(button.id == 3) { // model type
|
||||
|
||||
} else if(button.id == 4) { // hasCape
|
||||
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
@ -19,6 +19,7 @@ import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public class OfflineSkinMod implements ModInitializer, GameStartEntrypoint, RecipeEntrypoint {
|
||||
@ -39,9 +40,11 @@ public class OfflineSkinMod implements ModInitializer, GameStartEntrypoint, Reci
|
||||
public void beforeGameStart() {
|
||||
configPath.mkdirs();
|
||||
try {
|
||||
if (new File(configPath, "skin.png").exists()) {
|
||||
skinImage = ImageIO.read(new File(configPath, "skin.png"));
|
||||
if(!new File(configPath, "skin.png").exists()) {
|
||||
BufferedImage i = ImageIO.read(Objects.requireNonNull(OfflineSkinMod.class.getClassLoader().getResourceAsStream("char.png")));
|
||||
ImageIO.write(i, "png", new File(configPath, "skin.png"));
|
||||
}
|
||||
skinImage = ImageIO.read(new File(configPath, "skin.png"));
|
||||
if (new File(configPath, "cape.png").exists()) {
|
||||
capeImage = ImageIO.read(new File(configPath, "cape.png"));
|
||||
}
|
||||
@ -81,7 +84,7 @@ public class OfflineSkinMod implements ModInitializer, GameStartEntrypoint, Reci
|
||||
ByteArrayInputStream is = new ByteArrayInputStream(b);
|
||||
return ImageIO.read(is);
|
||||
} catch (IOException e) {
|
||||
return null; // TODO: read default skin from resources.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,8 @@ public class SendSet extends Thread {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int i = 0;
|
||||
while(i < 10) {
|
||||
try {
|
||||
Thread.sleep(2500);
|
||||
if (isCape) {
|
||||
@ -22,8 +24,11 @@ public class SendSet extends Thread {
|
||||
return;
|
||||
}
|
||||
((ForceDownloadHandler) EntityRenderDispatcher.instance.renderEngine).offlineSkinChanger$forceLoadDownloadableTexture("offlineSkinLocal:" + this.username, null, PlayerSkinParser.instance);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,9 +20,17 @@ public abstract class NetClientHandlerMixin extends NetHandler implements SkinRe
|
||||
|
||||
@Override
|
||||
public void offlineSkinChanger$handleSkinRequest(Packet244SkinRequest request) {
|
||||
byte[] skin = new byte[0];
|
||||
byte[] cape = new byte[0];
|
||||
if( request.isRequestSkin() && OfflineSkinMod.skinImage != null ) {
|
||||
skin = OfflineSkinMod.imageToBytes(OfflineSkinMod.skinImage);
|
||||
}
|
||||
if( request.isRequestCape() && OfflineSkinMod.capeImage != null ) {
|
||||
cape = OfflineSkinMod.imageToBytes(OfflineSkinMod.capeImage);
|
||||
}
|
||||
this.netManager.addToSendQueue(new Packet245SkinResponse(mc.thePlayer.username,
|
||||
OfflineSkinMod.imageToBytes(OfflineSkinMod.skinImage),
|
||||
OfflineSkinMod.imageToBytes(OfflineSkinMod.capeImage),
|
||||
skin,
|
||||
cape,
|
||||
false));
|
||||
}
|
||||
}
|
||||
|
@ -45,4 +45,16 @@ public class Packet244SkinRequest extends Packet {
|
||||
public int getPacketSize() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
public boolean isRequestSkin() {
|
||||
return requestSkin;
|
||||
}
|
||||
|
||||
public boolean isRequestCape() {
|
||||
return requestCape;
|
||||
}
|
||||
|
||||
public boolean isRequestModelType() {
|
||||
return requestModelType;
|
||||
}
|
||||
}
|
||||
|
BIN
src/main/resources/char.png
Normal file
BIN
src/main/resources/char.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
@ -3,3 +3,7 @@ gui.options.page.edit_skin.button.load_skin=Load skin
|
||||
gui.options.page.edit_skin.button.load_cape=Load cape
|
||||
gui.options.page.edit_skin.button.close=Close
|
||||
gui.options.page.edit_skin.label.title=Change skin/cape
|
||||
gui.options.page.edit_skin.button.model_fat=Model type: Steve
|
||||
gui.options.page.edit_skin.button.model_slim=Model type: Alex
|
||||
gui.options.page.edit_skin.button.has_cape_yes=Has cape (yes)
|
||||
gui.options.page.edit_skin.button.has_cape_no=Has cape (no)
|
||||
|
Loading…
x
Reference in New Issue
Block a user