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.GuiButton;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
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 net.minecraft.core.lang.I18n;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
@ -17,6 +19,8 @@ public class GuiSkinChanger extends GuiScreen {
|
|||||||
private GuiButton buttonLoadSkin;
|
private GuiButton buttonLoadSkin;
|
||||||
private GuiButton buttonLoadCape;
|
private GuiButton buttonLoadCape;
|
||||||
private GuiButton buttonClose;
|
private GuiButton buttonClose;
|
||||||
|
private GuiButton modelType;
|
||||||
|
private GuiButton hasCape;
|
||||||
|
|
||||||
|
|
||||||
public GuiSkinChanger(GuiScreen parent) {
|
public GuiSkinChanger(GuiScreen parent) {
|
||||||
@ -27,6 +31,8 @@ public class GuiSkinChanger extends GuiScreen {
|
|||||||
public void init() {
|
public void init() {
|
||||||
I18n stringtranslate = I18n.getInstance();
|
I18n stringtranslate = I18n.getInstance();
|
||||||
this.controlList.clear();
|
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.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.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")));
|
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);
|
OfflineSkinMod.capeImage = ImageIO.read(cape);
|
||||||
Files.copy(cape.toPath(), new File(configPath, "cape.png").toPath(), StandardCopyOption.REPLACE_EXISTING);
|
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) {
|
} catch (IOException e) {
|
||||||
|
@ -19,6 +19,7 @@ import java.io.IOException;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
||||||
public class OfflineSkinMod implements ModInitializer, GameStartEntrypoint, RecipeEntrypoint {
|
public class OfflineSkinMod implements ModInitializer, GameStartEntrypoint, RecipeEntrypoint {
|
||||||
@ -39,9 +40,11 @@ public class OfflineSkinMod implements ModInitializer, GameStartEntrypoint, Reci
|
|||||||
public void beforeGameStart() {
|
public void beforeGameStart() {
|
||||||
configPath.mkdirs();
|
configPath.mkdirs();
|
||||||
try {
|
try {
|
||||||
if (new File(configPath, "skin.png").exists()) {
|
if(!new File(configPath, "skin.png").exists()) {
|
||||||
skinImage = ImageIO.read(new File(configPath, "skin.png"));
|
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()) {
|
if (new File(configPath, "cape.png").exists()) {
|
||||||
capeImage = ImageIO.read(new File(configPath, "cape.png"));
|
capeImage = ImageIO.read(new File(configPath, "cape.png"));
|
||||||
}
|
}
|
||||||
@ -81,7 +84,7 @@ public class OfflineSkinMod implements ModInitializer, GameStartEntrypoint, Reci
|
|||||||
ByteArrayInputStream is = new ByteArrayInputStream(b);
|
ByteArrayInputStream is = new ByteArrayInputStream(b);
|
||||||
return ImageIO.read(is);
|
return ImageIO.read(is);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return null; // TODO: read default skin from resources.
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,15 +15,20 @@ public class SendSet extends Thread {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
int i = 0;
|
||||||
Thread.sleep(2500);
|
while(i < 10) {
|
||||||
if( isCape ) {
|
try {
|
||||||
((ForceDownloadHandler) EntityRenderDispatcher.instance.renderEngine).offlineSkinChanger$forceLoadDownloadableTexture("offlineCapeLocal:" + this.username, null, null);
|
Thread.sleep(2500);
|
||||||
return;
|
if (isCape) {
|
||||||
|
((ForceDownloadHandler) EntityRenderDispatcher.instance.renderEngine).offlineSkinChanger$forceLoadDownloadableTexture("offlineCapeLocal:" + this.username, null, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
((ForceDownloadHandler) EntityRenderDispatcher.instance.renderEngine).offlineSkinChanger$forceLoadDownloadableTexture("offlineSkinLocal:" + this.username, null, PlayerSkinParser.instance);
|
||||||
|
return;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
((ForceDownloadHandler) EntityRenderDispatcher.instance.renderEngine).offlineSkinChanger$forceLoadDownloadableTexture("offlineSkinLocal:"+this.username, null, PlayerSkinParser.instance);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,17 @@ public abstract class NetClientHandlerMixin extends NetHandler implements SkinRe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void offlineSkinChanger$handleSkinRequest(Packet244SkinRequest request) {
|
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,
|
this.netManager.addToSendQueue(new Packet245SkinResponse(mc.thePlayer.username,
|
||||||
OfflineSkinMod.imageToBytes(OfflineSkinMod.skinImage),
|
skin,
|
||||||
OfflineSkinMod.imageToBytes(OfflineSkinMod.capeImage),
|
cape,
|
||||||
false));
|
false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,4 +45,16 @@ public class Packet244SkinRequest extends Packet {
|
|||||||
public int getPacketSize() {
|
public int getPacketSize() {
|
||||||
return 3;
|
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.load_cape=Load cape
|
||||||
gui.options.page.edit_skin.button.close=Close
|
gui.options.page.edit_skin.button.close=Close
|
||||||
gui.options.page.edit_skin.label.title=Change skin/cape
|
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